Path

ez projects / gwf_textutils


gwf_TextUtils

UNIX name Owner Status Version Compatible with
gwf_textutils Georg Franz planning N/A N/A

A small collection of utilities belonging to "text conversion". The
class gwf_TextUtils can be used e.g. for own template operators.

A small collection of utilities belonging to "text conversion".
The class gwf_TextUtils can be used e.g. for own template
operators.
Feedback / Bug reports: Georg Franz
uses the php-extensions mbstring and iconv, if they are installed
Attention: The class is not using the textcodec-methods of ez3!!
Use it only if you are using UTF-8 in combination with ISO-8859-1
charsets
or if you are using only ISO-8859-1
Otherwise you may have to rewrite some methods!
Installation:
You need
[MailSettings]
MailHost=www.yourdomain.com
in your site.ini.append if you are using gwf_TextUtils::add_host
Look there for further infos.
If you are using the "email conversion" you need the javascript code
too.
look at gwf_TextUtils::change_email for further details
javascript code:
--------------------
function buildtext(friday,monday,tuesday,sunday,thirsday)
{
window.open(tuesday+sunday+monday,'','');
}
function writeMessage(friday,monday,tuesday,sunday,thirsday,christmas)
{
document.write(christmas+thirsday+monday+sunday);
}
function displayEmailStatusMsg(sunday,friday,monday,tuesday,thirsday) {
status=friday+thirsday+tuesday;
document.MM_returnValue = true;
}
function MM_displayStatusMsg(msgStr)
{
status=msgStr;
document.MM_returnValue = true;
}
---------------------------------
Overview:
---------------------------------
gwf_TextUtils::convertToAlias ($text)
---------------------------------
Converts $text to a correct url alias
Tries to replace specials characters like
ä => ae
ö => oe
Tries to convert "Word-Characters" like “
make a url like:
/this-is-a/test-url
or for german-speaking users:
Heute ist ein schöner Tag mit ss =>
heute-ist-ein-schoener-tag-mit-ss
gwf_TextUtils::isUtf8 ($text)
---------------------------------
returns true, if $text is ut8-encoded
gwf_TextUtils::textWash ($text)
---------------------------------
converts a text for output
usefull for e.g. forum messages
gwf_TextUtils::gwfutf8decode ($text)
---------------------------------
checks if the text is utf8-encoded and
converts it back to ISO-8859-1
gwf_TextUtils::gwfutf8encode ($text)
---------------------------------
checks if the text is utf8-encoded and
- if not - converts it to utf8
gwf_TextUtils::convert_plain ($text, $break_word = false, $break_width = 60)
---------------------------------
Converts a html-text to plain text.
e.g. Usefull for getting a html-mail input and make a
"plain text" copy
text: The input text
break_word: if using word_wrap()
break_width: the cutting position of word_wrap()
gwf_TextUtils::make_keywords ( $text )
---------------------------------
Tries to return a "keyword"-string of the given html-text.
Example: If you have html-code of your article-intro this method is
stripping out the html-code, strips out word-duplicates and
returns
the comma-separated string.
e.g. input:
-----------

Das geht auf keine Kuhhaut! Im Kuhrier kannst Du bunte und
verrückte
Nachrichten aus aller Welt lesen. Wenn Du auch eine für uns hast,
dann
schick sie doch an unsere Redaktion!


----------
output:
----------
keine, Kuhhaut, Kuhrier, kannst, bunte, verrückte, Nachrichten,
aller, lesen, schick, unsere, Redaktion
Usefull for the

part.
gwf_TextUtils::strip_search_chars ($contents)
---------------------------------
Strips out special characters.
Used for keywords.
gwf_TextUtils::convert_mail_line($text)
---------------------------------
Helper function to get a clean mail name
e.g. input:
“John Doe„
becomes to
„John Doe“
gwf_TextUtils::add_host($text, $host = '', $include_images = false)
---------------------------------
If you have html-text and want to send it in an email
this method add the host to links and images.
example:
Test-URL

becomes to

Attention:
$include_images have to be FALSE if you want to add the
host to image-tags too!!
gwf_TextUtils::change_email($email, $link_text='', $first_character='', $last_character = '')
---------------------------------
Helper function to convert a email-address for not beeing accessed by
spammers
It uses a javascript.
Example: will be converted e.g. to



Advantages:
Real visitors are able to click on e-mail links and the mail program
opens.
and E-Mail crawlers are totally lost :-)
The js works with all browsers except Opera.
gwf_TextUtils::remove_img($text)
---------------------------------
removes all img-tags from html-input
gwf_TextUtils::convert_url ($text)
---------------------------------
replace
a href="
to
kuh.at (
Usefull for plain text emails
gwf_TextUtils::strip_multiple_lines ($text, $line_search = 3, $line_replace = 2)
---------------------------------
strips out multiple, empty lines
used by html to plain text conversion for emails
gwf_TextUtils::strip_whitespaces ($text, $break = false)
---------------------------------
strips out whitespaces
gwf_TextUtils::html_normal_chars ($text)
---------------------------------
the opposite of htmlspecialchars()
gwf_TextUtils::cleanUpHTML ($text)
---------------------------------
strips out html-code of $text
gwf_TextUtils::replaceHtmlEntities ($text)
---------------------------------
replaces HTML Entities
gwf_TextUtils::replaceWordChars ($contents, $stripUnkowns = true)
---------------------------------
replaces characters which come mostly from ms word
by copy & paste
e.g. “ becomes "
gwf_TextUtils::convertSpecialChars($text, $toLower = true)
---------------------------------
strtolower() and strtoupper()
don't work for "special characters"
So use mb_strtoupper() or mb_strtolower instead - if installed or
do it manually ...
gwf_TextUtils::stripUrl($text)
---------------------------------
Strip out all urls
Kind regards,
Emil alias
Georg Franz.

 

Screenshot

No news yet.

This project has no reviews yet. Be the first one to review it!

No forum messages yet.