Code Duplication    Length = 18-20 lines in 2 locations

class/Utility.php 1 location

@@ 585-604 (lines=20) @@
582
     * @param $hlE
583
     * @return string
584
     */
585
public static function getHTMLHighlight($needle, $haystack, $hlS, $hlE)
586
{
587
    $parts = explode('>', $haystack);
588
    foreach ($parts as $key => $part) {
589
        $pL = '';
590
        $pR = '';
591
592
        if (($pos = strpos($part, '<')) === false) {
593
            $pL = $part;
594
        } elseif ($pos > 0) {
595
            $pL = mb_substr($part, 0, $pos);
596
            $pR = mb_substr($part, $pos, strlen($part));
597
        }
598
        if ($pL != '') {
599
            $parts[$key] = preg_replace('|(' . quotemeta($needle) . ')|iU', $hlS . '\\1' . $hlE, $pL) . $pR;
600
        }
601
    }
602
603
    return implode('>', $parts);
604
}
605
606
    /* *******************************************************************************
607
     * Most of the following functions are modified functions from Herve's News Module

include/functions.php 1 location

@@ 339-356 (lines=18) @@
336
    return $searchform;
337
}
338
339
function lx_getHTMLHighlight($needle, $haystack, $hlS, $hlE) {
340
    $parts = explode(">", $haystack);
341
    foreach($parts as $key=>$part) {
342
        $pL = "";
343
        $pR = "";
344
345
        if (($pos = strpos($part, "<")) === false)
346
            $pL = $part;
347
        elseif($pos > 0) {
348
            $pL = substr($part, 0, $pos);
349
            $pR = substr($part, $pos, strlen($part));
350
        }
351
        if ($pL != "")
352
            $parts[$key] = preg_replace('|('.quotemeta($needle).')|iU', $hlS.'\\1'.$hlE, $pL) . $pR;
353
    }
354
355
    return(implode(">", $parts));
356
}
357
358
/* *******************************************************************************
359
 * Most of the following functions are modified functions from Herve's News Module