discuz-x32-php7 icon indicating copy to clipboard operation
discuz-x32-php7 copied to clipboard

搜索无法高亮,function_search.php中两行代码写反

Open KKRainbow opened this issue 10 years ago • 0 comments

55,56行代码应该互换位置。

function bat_highlight($message, $words, $color = '#ff0000') {
    if(!empty($words)) {
        $highlightarray = explode(' ', $words);
        $sppos = strrpos($message, chr(0).chr(0).chr(0));
        if($sppos !== FALSE) {
            $specialextra = substr($message, $sppos + 3);
            $message = substr($message, 0, $sppos);
        }
        $message = preg_replace("/<highlight>(.*)<\/highlight>/siU", "<strong><font color=\"$color\">\\1</font></strong>", $message);
        $message = preg_replace_callback("/(^|>)([^<]+)(?=<|$)/sU", function($matches) use($highlightarray) { return highlight($matches[2], $highlightarray, $matches[1]); }, $message);
        if($sppos !== FALSE) {
            $message = $message.chr(0).chr(0).chr(0).$specialextra;
        }
    }
    return $message;
}
$message = preg_replace("/<highlight>(.*)<\/highlight>/siU", "<strong><font color=\"$color\">\\1</font></strong>", $message);
$message = preg_replace_callback("/(^|>)([^<]+)(?=<|$)/sU", function($matches) use($highlightarray) { return highlight($matches[2], $highlightarray, $matches[1]); }, $message);

改为

$message = preg_replace_callback("/(^|>)([^<]+)(?=<|$)/sU", function($matches) use($highlightarray) { return highlight($matches[2], $highlightarray, $matches[1]); }, $message);
$message = preg_replace("/<highlight>(.*)<\/highlight>/siU", "<strong><font color=\"$color\">\\1</font></strong>", $message);

KKRainbow avatar Jan 12 '16 07:01 KKRainbow