Pluf_Text Class Reference

List of all members.

Static Public Member Functions

static wrapHtml ($string, $length=45, $wrapString="\n")
static tokenize ($string, $remove_accents=True)
static cleanString ($string)
static removeAccents ($string)
static stringToChars ($string)
static preventUpperCase ($string, $mode=MB_CASE_TITLE)
static simplePreventUpperCase ($string, $mode=MB_CASE_TITLE)


Detailed Description

Utility class to clean/manipulate strings.

Member Function Documentation

static Pluf_Text::wrapHtml ( string,
length = 45,
wrapString = "\n" 
) [static]

Wrap a string containing HTML code.

The HTML is not broken, words are broken only if very long.

Improved from a version available on php.net

See also:
http://www.php.net/manual/en/function.wordwrap.php#89782
Parameters:
string The string to wrap
int The maximal length of a string (45)
string Wrap string ("\n")
Returns:
string Wrapped string

HTML Begins

HTML ends

If this is inside HTML -> append to the wrapped string

Whitespace characted / new line

Check chars

static Pluf_Text::tokenize ( string,
remove_accents = True 
) [static]

Given a string, cleaned from the not interesting characters, returns an array with the words as index and the number of times it was in the text as the value.

Tokenizer of DokuWiki to handle Thai and CJK words. http://www.splitbrain.org/projects/dokuwiki

Parameters:
string Cleaned, lowercased and utf-8 encoded string.
bool Remove the accents (True)
Returns:
array Word and number of occurences.

static Pluf_Text::cleanString ( string  )  [static]

Clean a string from the HTML and the unnecessary punctuation. Convert the string to lowercase.

Require mbstring extension.

Parameters:
string String.
Returns:
string Cleaned lowercase string.

static Pluf_Text::removeAccents ( string  )  [static]

Remove the accentuated characters.

Requires a string in lowercase, the removal is not perfect but is better than nothing.

Parameters:
string Lowercased string in utf-8.
Returns:
string String with some of the accents removed.

static Pluf_Text::stringToChars ( string  )  [static]

Convert a string to a list of characters.

Parameters:
string utf-8 encoded string.
Returns:
array Characters.

static Pluf_Text::preventUpperCase ( string,
mode = MB_CASE_TITLE 
) [static]

Prevent a string to be all uppercase.

If more than 50% of the words in the string are uppercases and if the string contains more than one word, the string is converted using the mb_convert_case.

See also:
http://www.php.net/mb_convert_case
Parameters:
string String to test.
int Mode to convert the string (MB_CASE_TITLE)
Returns:
string Cleaned string.

static Pluf_Text::simplePreventUpperCase ( string,
mode = MB_CASE_TITLE 
) [static]

Simple uppercase prevention.

Contrary to self::preventUpperCase, this method will also prevent a single word to be uppercase.

Parameters:
string String possibly in uppercase.
int Mode to convert the string (MB_CASE_TITLE)
Returns:
string Mode cased if all uppercase in input.


The documentation for this class was generated from the following file:

Generated on Wed Feb 3 15:44:52 2010 for Pluf by  doxygen