Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
This is a hotfix for TextHelper which seems to have gone wrong in a m…
…erge. tail() is missing completly and the docs for truncate() are the ones for tail(). This fixes it.
  • Loading branch information
euromark committed May 2, 2014
1 parent 6c6a650 commit fecf321
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/Cake/Test/Case/View/Helper/TextHelperTest.php
Expand Up @@ -79,7 +79,7 @@ public function tearDown() {
*/
public function testTextHelperProxyMethodCalls() {
$methods = array(
'highlight', 'stripLinks', 'truncate', 'excerpt', 'toList',
'highlight', 'stripLinks', 'truncate', 'tail', 'excerpt', 'toList',
);
$String = $this->getMock('StringMock', $methods);
$Text = new TextHelperTestObject($this->View, array('engine' => 'StringMock'));
Expand Down
30 changes: 27 additions & 3 deletions lib/Cake/View/Helper/TextHelper.php
Expand Up @@ -267,15 +267,16 @@ public function stripLinks($text) {
}

/**
* Truncates text starting from the end.
* Truncates text.
*
* Cuts a string to the length of $length and replaces the first characters
* Cuts a string to the length of $length and replaces the last characters
* with the ellipsis if the text is longer than length.
*
* ### Options:
*
* - `ellipsis` Will be used as Beginning and prepended to the trimmed string
* - `ellipsis` Will be used as Ending and appended to the trimmed string (`ending` is deprecated)
* - `exact` If false, $text will not be cut mid-word
* - `html` If true, HTML tags would be handled correctly
*
* @see String::truncate()
*
Expand All @@ -289,6 +290,29 @@ public function truncate($text, $length = 100, $options = array()) {
return $this->_engine->truncate($text, $length, $options);
}

/**
* 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.
*
* ### Options:
*
* - `ellipsis` Will be used as Beginning and prepended to the trimmed string
* - `exact` If false, $text will not be cut mid-word
*
* @see String::truncate()
*
* @param string $text String to truncate.
* @param integer $length Length of returned string, including ellipsis.
* @param array $options An array of html attributes and options.
* @return string Trimmed string.
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/text.html#TextHelper::tail
*/
public function tail($text, $length = 100, $options = array()) {
return $this->_engine->tail($text, $length, $options);
}

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

0 comments on commit fecf321

Please sign in to comment.