예제 #1
0
파일: libTest.php 프로젝트: viyancs/bolt
 /**
  * @dataProvider trimTextDataProvider
  */
 public function testTrimToHTML($html, $length, $nbsp, $hellip, $striptags, $expected)
 {
     if ($hellip) {
         $ellipseStr = '…';
     } else {
         $ellipseStr = '';
     }
     $actual = trimToHTML($html, $length, $ellipseStr, $striptags, $nbsp);
     $this->assertEquals($expected, $actual);
 }
예제 #2
0
파일: lib.php 프로젝트: LeonB/site
/**
 * Wrapper around trimToHTML for backwards-compatibility
 *
 * @param string $str String to trim
 * @param int $desiredLength Target string length
 * @param bool $nbsp Transform spaces to their html entity
 * @param bool $hellip Add dots when the string is too long
 * @param bool $striptags Strip html tags
 * @return string Trimmed string
 */
function trimText($str, $desiredLength, $nbsp = false, $hellip = true, $striptags = true)
{
    if ($hellip) {
        $ellipseStr = '…';
    } else {
        $ellipseStr = '';
    }
    return trimToHTML($str, $desiredLength, $ellipseStr, $striptags, $nbsp);
}