Exemplo n.º 1
0
 /**
  * Render the cropped text
  *
  * @param integer $maxCharacters Place where to truncate the string
  * @param string $append What to append, if truncation happened
  * @param boolean $respectWordBoundaries If TRUE and division is in the middle of a word, the remains of that word is removed.
  * @param boolean $respectHtml If TRUE the cropped string will respect HTML tags and entities. Technically that means, that cropHTML() is called rather than crop()
  * @return string cropped text
  */
 public function render($maxCharacters, $append = '...', $respectWordBoundaries = TRUE, $respectHtml = TRUE)
 {
     $stringToTruncate = $this->renderChildren();
     if (TYPO3_MODE === 'BE') {
         $this->simulateFrontendEnvironment();
     }
     if ($respectHtml) {
         $content = $this->contentObject->cropHTML($stringToTruncate, $maxCharacters . '|' . $append . '|' . $respectWordBoundaries);
     } else {
         $content = $this->contentObject->crop($stringToTruncate, $maxCharacters . '|' . $append . '|' . $respectWordBoundaries);
     }
     if (TYPO3_MODE === 'BE') {
         $this->resetFrontendEnvironment();
     }
     return $content;
 }
 /**
  * @test
  */
 public function cropIsMultibyteSafe()
 {
     $this->assertEquals('бла', $this->cObj->crop('бла', '3|...'));
 }