]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Don't highlight search terms inside url
authorMike Cochrane <mikec@mikenz.geek.nz>
Sun, 20 Jul 2008 03:34:01 +0000 (23:34 -0400)
committerMike Cochrane <mikec@mikenz.geek.nz>
Sun, 20 Jul 2008 03:34:01 +0000 (23:34 -0400)
darcs-hash:20080720033401-533db-05bf2c9ebe988ebda6a295447a958af66571a088.gz

actions/noticesearch.php

index eb3382779975659b50c65c2585f1bd65cdabae59..29527c56725c721486b2d234bf2b4c108fac2826 100644 (file)
@@ -139,8 +139,15 @@ class NoticesearchAction extends SearchAction {
        }
 
        function highlight($text, $terms) {
+               /* Highligh serach terms */
                $pattern = '/('.implode('|',array_map('htmlspecialchars', $terms)).')/i';
                $result = preg_replace($pattern, '<strong>\\1</strong>', $text);
+
+               /* Remove highlighting from inside links, loop incase multiple highlights in links */
+               $pattern = '/(href="[^"]*)<strong>('.implode('|',array_map('htmlspecialchars', $terms)).')<\/strong>([^"]*")/iU';
+               do {
+                       $result = preg_replace($pattern, '\\1\\2\\3', $result, -1, $count);
+               } while ($count);
                return $result;
        }
 }