X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=actions%2Fnoticesearch.php;h=c257ecec56ebf23b4b9dda4c357824a2f192790a;hb=63438008e021638004a61e76a7d6627fc2f49199;hp=ab383fab436152cdb42f3f37a40275f9b0ede2d3;hpb=8b32942658b179010315450a62b473631a501399;p=quix0rs-gnu-social.git
diff --git a/actions/noticesearch.php b/actions/noticesearch.php
index ab383fab43..c257ecec56 100644
--- a/actions/noticesearch.php
+++ b/actions/noticesearch.php
@@ -20,15 +20,14 @@
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?
class NoticesearchAction extends SearchAction {
function get_instructions() {
- return _('Search for notices on %%site.name%% by their contents. ' .
- 'Separate search terms by spaces; they must be 3 characters or more.');
+ return _('Search for notices on %%site.name%% by their contents. Separate search terms by spaces; they must be 3 characters or more.');
}
function get_title() {
@@ -86,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));
@@ -140,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;
}
}