public function truncateText($text = null, $length = 0) {
		$result = '';
		if (empty($text)) {
			return $result;
		}

		$text = (string)$text;
		$length = (int)$length;
		if ($length <= 0) {
			$length = 50;
		}

		if (($text === h($text)) && (mb_strlen($text) <= $length)) {
			return $text;
		}

		$truncateOpt = $this->_getOptionsForElem('truncateText.truncateOpt');
		$tuncatedText = $this->Text->truncate($text, $length, $truncateOpt);
		if ($tuncatedText === $text) {
			return $tuncatedText;
		}

		$result = $this->Html->div('collapse-text-truncated', $tuncatedText);
		$result .= $this->Html->div(
			'collapse-text-original',
			$text . $this->_getOptionsForElem('truncateText.collapseLink')
		);
		$result = $this->Html->div('collapse-text-expanded', $result);

		return $result;
	}
public function truncateText($text = null, $length = 0) {
		$result = '';
		if (empty($text)) {
			return $result;
		}

		$text = (string)$text;
		$length = (int)$length;
		if ($length <= 0) {
			$length = 50;
		}

		if (($text === h($text)) && (mb_strlen($text) <= $length)) {
			return $text;
		}

		$truncateOpt = $this->_getOptionsForElem('truncateText.truncateOpt');
		$tuncatedText = $this->Text->truncate($text, $length, $truncateOpt);
		if ($tuncatedText === $text) {
			return $tuncatedText;
		}

		$result = $this->Html->div('collapse-text-truncated', $tuncatedText);
		$result .= $this->Html->div(
			'collapse-text-original',
			$text . $this->_getOptionsForElem('truncateText.collapseLink')
		);
		$result = $this->Html->div('collapse-text-expanded', $result);

		return $result;
	}
public function truncateText ( $ text = null , $ length = 0 ) { $ result = '' ; if ( empty ( $ text ) ) { return $ result ; } $ text = ( string ) $ text ; $ length = ( int ) $ length ; if ( $ length <= 0 ) { $ length = 50 ; } if ( ( $ text === h ( $ text ) ) && ( mb_strlen ( $ text ) <= $ length ) ) { return $ text ; } $ truncateOpt = $ this -> _getOptionsForElem ( 'truncateText.truncateOpt' ) ; $ tuncatedText = $ this -> Text -> truncate ( $ text , $ length , $ truncateOpt ) ; if ( $ tuncatedText === $ text ) { return $ tuncatedText ; } $ result = $ this -> Html -> div ( 'collapse-text-truncated' , $ tuncatedText ) ; $ result .= $ this -> Html -> div ( 'collapse-text-original' , $ text . $ this -> _getOptionsForElem ( 'truncateText.collapseLink' ) ) ; $ result = $ this -> Html -> div ( 'collapse-text-expanded' , $ result ) ; return $ result ; }
Return truncated text with button `expand` and `roll up`.

@param string $text Text to truncate.
@param int $length Length of returned string.
@return string Truncated text.
Return truncated text with button expand and roll up .