Code Duplication    Length = 18-20 lines in 2 locations

class/Utility.php 1 location

@@ 601-620 (lines=20) @@
598
     * @param $hlE
599
     * @return string
600
     */
601
public static function getHTMLHighlight($needle, $haystack, $hlS, $hlE)
602
{
603
    $parts = explode('>', $haystack);
604
    foreach ($parts as $key => $part) {
605
        $pL = '';
606
        $pR = '';
607
608
        if (($pos = strpos($part, '<')) === false) {
609
            $pL = $part;
610
        } elseif ($pos > 0) {
611
            $pL = substr($part, 0, $pos);
612
            $pR = substr($part, $pos, strlen($part));
613
        }
614
        if ($pL != '') {
615
            $parts[$key] = preg_replace('|(' . quotemeta($needle) . ')|iU', $hlS . '\\1' . $hlE, $pL) . $pR;
616
        }
617
    }
618
619
    return implode('>', $parts);
620
}
621
622
    /* *******************************************************************************
623
     * 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