Text helper library.
Text manipulations: Highlight, excerpt, truncate, strip of links, convert email addresses to mailto: links...
String
$_engine
protected stdClass
$_placeholders
protected array
An array of md5sums and their contents. Used when inserting links into text.
$helpers
public array
$Html
public Saves the placeholder for a string, for later use. This gets around double escaping content in URL's.
Adds links (<a href=....) to a given text, by finding text that begins with strings like http:// and ftp://.
Formats paragraphs around given text for all line breaks
added for single line return
<
p> added for double line return
Extracts an excerpt from the text surrounding the phrase with a number of characters on each side determined by radius.
Highlights a given phrase in a text. You can specify any expression in highlighter that may include the \1 expression to include the $phrase found.
__call( string $method , array $params )
Call methods from CakeText utility class
$method
$params
__construct( View $View , array $settings array() )
Constructor
engine
Class name to use to replace CakeText functionality. The class needs to be placed in the Utility
directory.View
$View
$settings
optional array() CakeException
_insertPlaceHolder( array $matches )
Saves the placeholder for a string, for later use. This gets around double escaping content in URL's.
$matches
_linkEmails( string $text , array $options )
Links email addresses
$text
$options
_linkUrls( string $text , array $htmlOptions )
Replace placeholders with links.
$text
$htmlOptions
autoLink( string $text , array $options array() )
Convert all links and email addresses to HTML links.
escape
Control HTML escaping of input. Defaults to true.$text
$options
optional array() autoLinkEmails( string $text , array $options array() )
Adds email links (<a href="mailto:....) to a given text.
escape
Control HTML escaping of input. Defaults to true.$text
$options
optional array() autoLinkUrls( string $text , array $options array() )
Adds links (<a href=....) to a given text, by finding text that begins with strings like http:// and ftp://.
escape
Control HTML escaping of input. Defaults to true.$text
$options
optional array() autoParagraph( string $text )
Formats paragraphs around given text for all line breaks
added for single line return
<
p> added for double line return
$text
The text with proper
<
p> and
tags
excerpt( string $text , string $phrase , integer $radius 100 , string $ending '...' )
Extracts an excerpt from the text surrounding the phrase with a number of characters on each side determined by radius.
$text
$phrase
$radius
optional 100 $ending
optional '...' highlight( string $text , string $phrase , array $options array() )
Highlights a given phrase in a text. You can specify any expression in highlighter that may include the \1 expression to include the $phrase found.
$text
$phrase
$options
optional array() stripLinks( string $text )
Strips given text of all links (<a href=....)
$text
tail( string $text , integer $length 100 , array $options array() )
Truncates text starting from the end.
Cuts a string to the length of $length and replaces the first characters with the ellipsis if the text is longer than length.
ellipsis
Will be used as Beginning and prepended to the trimmed stringexact
If false, $text will not be cut mid-word$text
$length
optional 100 $options
optional array() toList( array $list , string $and null , string $separator ', ' )
Creates a comma separated list where the last two items are joined with 'and', forming natural language.
$list
$and
optional null $separator
optional ', ' truncate( string $text , integer $length 100 , array $options array() )
Truncates text.
Cuts a string to the length of $length and replaces the last characters with the ellipsis if the text is longer than length.
ellipsis
Will be used as Ending and appended to the trimmed string (ending
is deprecated)exact
If false, $text will not be cut mid-wordhtml
If true, HTML tags would be handled correctly$text
$length
optional 100 $options
optional array() protected array
An array of md5sums and their contents. Used when inserting links into text.
array()
public HtmlHelper
© 2005–2016 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/2.9/class-TextHelper.html