コード例 #1
0
 /**
  * @covers ../../../src/Library/Helper/Text::cut()
  */
 public function testCut()
 {
     $this->checkNoArg('cut');
     $this->assertEquals('Lorem ...', \Library\Helper\Text::cut($this->lorem_ipsum, 6));
     $this->assertEquals('Lo ...', \Library\Helper\Text::cut($this->lorem_ipsum, 2));
     $this->assertEquals('Lo', \Library\Helper\Text::cut($this->lorem_ipsum, 2, ''));
     $this->assertEquals($this->lorem_ipsum, \Library\Helper\Text::cut($this->lorem_ipsum, strlen($this->lorem_ipsum) + 1));
 }
コード例 #2
0
ファイル: Helper.php プロジェクト: atelierspierrot/docbook
 public static function rssEncode($str, $cut = 800)
 {
     $str = preg_replace(',<h1(.*)</h1>,i', '', $str);
     $str = TextHelper::cut($str, $cut);
     return $str;
 }
コード例 #3
0
 /**
  * Cut a string at a certain characters count adding it a suffix string
  *
  * @param string $str The original string to cut
  * @param int $length The length to use before cutting the string
  * @param string $end_str A suffix string added if the original string is cutted
  * @param bool $return Return/Echo flag (default is to echo result)
  * @return mixed The result of the `_echo` function (string or bool)
  * @see _echo()
  * @see Library\Helper\Text::cut()
  */
 function _cut($str, $length = 120, $end_str = ' ...', $return = false)
 {
     return _echo(Helper\Text::cut($str, $length, $end_str), $return);
 }
コード例 #4
0
 /**
  * @param int $str_len
  * @param bool $strip_tags
  * @return string
  */
 public function viewIntroduction($str_len = 600, $strip_tags = true, $end_str = '')
 {
     if (!isset($this->cache['docbook_introduction'])) {
         $intro = $this->getFile()->getIntroduction();
         $this->cache['docbook_introduction'] = TextHelper::cut($strip_tags ? strip_tags($intro) : $intro, $str_len, $end_str);
     }
     return $this->cache['docbook_introduction'];
 }