TextHelper Class Reference

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 48 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 151 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 132 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 110 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 265 of file text.php.
References $pos, ife(), and truncate().
| TextHelper::flay | ( | $ | text, | |
| $ | allowHtml = false | |||
| ) |
| 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
| TextHelper::stripLinks | ( | $ | text | ) |
| TextHelper::toList | ( | $ | list, | |
| $ | and = 'and' | |||
| ) |
| TextHelper::trim | ( | ) |
Alias for truncate().
- See also:
- TextHelper::truncate() public
Definition at line 251 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.
The documentation for this class was generated from the following file:
- 1.2.x.x/cake/libs/view/helpers/text.php