| @@ 589-608 (lines=20) @@ | ||
| 586 | * @param $hlE |
|
| 587 | * @return string |
|
| 588 | */ |
|
| 589 | public static function getHTMLHighlight($needle, $haystack, $hlS, $hlE) |
|
| 590 | { |
|
| 591 | $parts = explode('>', $haystack); |
|
| 592 | foreach ($parts as $key => $part) { |
|
| 593 | $pL = ''; |
|
| 594 | $pR = ''; |
|
| 595 | ||
| 596 | if (($pos = strpos($part, '<')) === false) { |
|
| 597 | $pL = $part; |
|
| 598 | } elseif ($pos > 0) { |
|
| 599 | $pL = substr($part, 0, $pos); |
|
| 600 | $pR = substr($part, $pos, strlen($part)); |
|
| 601 | } |
|
| 602 | if ($pL != '') { |
|
| 603 | $parts[$key] = preg_replace('|(' . quotemeta($needle) . ')|iU', $hlS . '\\1' . $hlE, $pL) . $pR; |
|
| 604 | } |
|
| 605 | } |
|
| 606 | ||
| 607 | return implode('>', $parts); |
|
| 608 | } |
|
| 609 | ||
| 610 | /* ******************************************************************************* |
|
| 611 | * Most of the following functions are modified functions from Herve's News Module |
|
| @@ 271-288 (lines=18) @@ | ||
| 268 | return $searchform; |
|
| 269 | } |
|
| 270 | ||
| 271 | function lx_getHTMLHighlight($needle, $haystack, $hlS, $hlE) { |
|
| 272 | $parts = explode(">", $haystack); |
|
| 273 | foreach($parts as $key=>$part) { |
|
| 274 | $pL = ""; |
|
| 275 | $pR = ""; |
|
| 276 | ||
| 277 | if (($pos = strpos($part, "<")) === false) |
|
| 278 | $pL = $part; |
|
| 279 | elseif($pos > 0) { |
|
| 280 | $pL = substr($part, 0, $pos); |
|
| 281 | $pR = substr($part, $pos, strlen($part)); |
|
| 282 | } |
|
| 283 | if ($pL != "") |
|
| 284 | $parts[$key] = preg_replace('|('.quotemeta($needle).')|iU', $hlS.'\\1'.$hlE, $pL) . $pR; |
|
| 285 | } |
|
| 286 | ||
| 287 | return(implode(">", $parts)); |
|
| 288 | } |
|
| 289 | ||
| 290 | /* ******************************************************************************* |
|
| 291 | * Most of the following functions are modified functions from Herve's News Module |
|