TextHelper Class Reference

Inheritance diagram for TextHelper:

AppHelper Helper Helper Overloadable Overloadable Object Object Object Object List of all members.

Public Member Functions

 autoLink ($text, $htmlOptions=array())
 autoLinkEmails ($text, $htmlOptions=array())
 autoLinkUrls ($text, $htmlOptions=array())
 excerpt ($text, $phrase, $radius=100, $ending="...")
 flay ($text, $allowHtml=false)
 highlight ($text, $phrase, $highlighter= '< span class="highlight">\1</span >', $considerHtml=false)
 stripLinks ($text)
 toList ($list, $and= 'and')
 trim ()
 truncate ($text, $length=100, $ending= '...', $exact=true, $considerHtml=false)

Detailed Description

Definition at line 45 of file text.php.


Member Function Documentation

TextHelper::autoLink ( text,
htmlOptions = array() 
)

Convert all links and email adresses to HTML links.

Parameters:
string $text Text
array $htmlOptions Array of HTML options.
Returns:
string The text with links public

Definition at line 147 of file text.php.

References autoLinkEmails(), and autoLinkUrls().

TextHelper::autoLinkEmails ( text,
htmlOptions = array() 
)

Adds email links (<a href="mailto:....) to a given text.

Parameters:
string $text Text
array $htmlOptions Array of HTML options.
Returns:
string The text with links public

Definition at line 128 of file text.php.

Referenced by autoLink().

TextHelper::autoLinkUrls ( text,
htmlOptions = array() 
)

Adds links (<a href=....) to a given text, by finding text that begins with strings like http:// and ftp://.

Parameters:
string $text Text to add links to
array $htmlOptions Array of HTML options.
Returns:
string The text with links public

Definition at line 106 of file text.php.

Referenced by autoLink().

TextHelper::excerpt ( text,
phrase,
radius = 100,
ending = "..." 
)

Extracts an excerpt from the text surrounding the phrase with a number of characters on each side determined by radius.

Parameters:
string $text String to search the phrase in
string $phrase Phrase that will be searched for
integer $radius The amount of characters that will be returned on each side of the founded phrase
string $ending Ending that will be appended
Returns:
string Modified string public

Definition at line 269 of file text.php.

References truncate().

TextHelper::flay ( text,
allowHtml = false 
)

Text-to-html parser, similar to Textile or RedCloth, only with a little different syntax.

Parameters:
string $text String to "flay"
boolean $allowHtml Set to true if if html is allowed
Returns:
string "Flayed" text public
Todo:
Change this. We need a real Textile parser.

Definition at line 333 of file text.php.

References __(), a(), Flay::toHtml(), and uses().

TextHelper::highlight ( text,
phrase,
highlighter = '<span class="highlight">\1</span>',
considerHtml = false 
)

Highlights a given phrase in a text. You can specify any expression in highlighter that may include the expression to include the $phrase found.

Parameters:
string $text Text to search the phrase in
string $phrase The phrase that will be searched
string $highlighter The piece of html with that the phrase will be highlighted
boolean $considerHtml If true, will ignore any HTML tags, ensuring that only the correct text is highlighted
Returns:
string The highlighted text public

Definition at line 57 of file text.php.

TextHelper::stripLinks ( text  ) 

Strips given text of all links (<a href=....)

Parameters:
string $text Text
Returns:
string The text without links public

Definition at line 94 of file text.php.

References a().

TextHelper::toList ( list,
and = 'and' 
)

Creates a comma separated list where the last two items are joined with 'and', forming natural English

Parameters:
array $list The list to be joined
Returns:
string public

Definition at line 311 of file text.php.

TextHelper::trim (  ) 

Alias for truncate().

See also:
TextHelper::truncate() public

Definition at line 255 of file text.php.

References truncate().

TextHelper::truncate ( text,
length = 100,
ending = '...',
exact = true,
considerHtml = false 
)

Truncates text.

Cuts a string to the length of $length and replaces the last characters with the ending if the text is longer than length.

Parameters:
string $text String to truncate.
integer $length Length of returned string, including ellipsis.
mixed $ending If string, will be used as Ending and appended to the trimmed string. Can also be an associative array that can contain the last three params of this method.
boolean $exact If false, $text will not be cut mid-word
boolean $considerHtml If true, HTML tags would be handled correctly
Returns:
string Trimmed string.

Definition at line 163 of file text.php.

References Helper::$tags, and a().

Referenced by excerpt(), and trim().


The documentation for this class was generated from the following file:
Generated on Sun Nov 22 00:30:57 2009 for CakePHP 1.2.x.x (v1.2.4.8284) by doxygen 1.4.7