Code Duplication    Length = 15-18 lines in 2 locations

class/Utility.php 1 location

@@ 1476-1493 (lines=18) @@
1473
     * @param  bool         $break_words
1474
     * @return mixed|string
1475
     */
1476
public static function truncateTagSafe($string, $length = 80, $etc = '...', $break_words = false)
1477
{
1478
    if ($length == 0) {
1479
        return '';
1480
    }
1481
    if (strlen($string) > $length) {
1482
        $length -= strlen($etc);
1483
        if (!$break_words) {
1484
            $string = preg_replace('/\s+?(\S+)?$/', '', mb_substr($string, 0, $length + 1));
1485
            $string = preg_replace('/<[^>]*$/', '', $string);
1486
            $string = LexikonUtility::closeTags($string);
1487
        }
1488
1489
        return $string . $etc;
1490
    } else {
1491
        return $string;
1492
    }
1493
}
1494
1495
    /**
1496
     * @return array

include/functions.php 1 location

@@ 1035-1049 (lines=15) @@
1032
 *           <amos dot robinson at gmail dot com>
1033
 * used in Block entries_scrolling.php
1034
 */
1035
function lx_truncate_tagsafe($string, $length = 80, $etc = '...', $break_words = false) {
1036
    if ($length == 0) return '';
1037
    if (strlen($string) > $length) {
1038
        $length -= strlen($etc);
1039
        if (!$break_words) {
1040
            $string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length+1));
1041
            $string = preg_replace('/<[^>]*$/', '', $string);
1042
            $string = lx_close_tags($string);
1043
        }
1044
1045
        return $string . $etc;
1046
    } else {
1047
        return $string;
1048
    }
1049
}
1050
1051
function lexikon_summary() {
1052
global $xoopsDB;