X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fnoticesearch.php;h=c257ecec56ebf23b4b9dda4c357824a2f192790a;hb=f7865b1d410e303bb5dc2549d12823f37149b8e5;hp=29de0ad7cae17f3c0588f642d3f254981dee9beb;hpb=834c21b2aaf78da1081416d05098286e9bf17c2a;p=quix0rs-gnu-social.git diff --git a/actions/noticesearch.php b/actions/noticesearch.php index 29de0ad7ca..c257ecec56 100644 --- a/actions/noticesearch.php +++ b/actions/noticesearch.php @@ -20,7 +20,7 @@ if (!defined('LACONICA')) { exit(1); } require_once(INSTALLDIR.'/lib/searchaction.php'); -define(NOTICES_PER_PAGE, 20); +define('NOTICES_PER_PAGE', 20); # XXX common parent for people and content search? @@ -85,6 +85,10 @@ class NoticesearchAction extends SearchAction { function show_notice($notice, $terms) { $profile = $notice->getProfile(); + if (!$profile) { + common_log_db_error($notice, 'SELECT', __FILE__); + return; + } # XXX: RDFa common_element_start('li', array('class' => 'notice_single', 'id' => 'notice-' . $notice->id)); @@ -139,8 +143,15 @@ class NoticesearchAction extends SearchAction { } function highlight($text, $terms) { + /* Highligh serach terms */ $pattern = '/('.implode('|',array_map('htmlspecialchars', $terms)).')/i'; $result = preg_replace($pattern, '\\1', $text); + + /* Remove highlighting from inside links, loop incase multiple highlights in links */ + $pattern = '/(href="[^"]*)('.implode('|',array_map('htmlspecialchars', $terms)).')<\/strong>([^"]*")/iU'; + do { + $result = preg_replace($pattern, '\\1\\2\\3', $result, -1, $count); + } while ($count); return $result; } }