From b343df8690097e4443d8ce63824b3822fc36dd7e Mon Sep 17 00:00:00 2001 From: vyshane Date: Sun, 24 Sep 2006 15:28:16 +0000 Subject: [PATCH] Merged fix for MDL-6615. --- mod/forum/search.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/mod/forum/search.php b/mod/forum/search.php index 7ea5dcff72..ce5c282dff 100644 --- a/mod/forum/search.php +++ b/mod/forum/search.php @@ -199,6 +199,17 @@ //Use highlight() with nonsense tags to spot search terms in the //actual text content first. fiedorow - 9/2/2005 $missing_terms = ""; + + // Hack for posts of format FORMAT_PLAIN. Otherwise html tags added by + // the highlight() call bellow get stripped out by forum_print_post(). + if ($post->format == FORMAT_PLAIN) { + $post->message = s($post->message); + $post->message = rebuildnolinktag($post->message); + $post->message = str_replace(' ', '  ', $post->message); + $post->message = nl2br($post->message); + $post->format = FORMAT_HTML; + } + $options = new object(); $options->trusttext = true; // detect TRUSTTEXT marker before first call to format_text @@ -207,8 +218,9 @@ } else { $ttpresent = false; } - $message = highlight($strippedsearch,format_text($post->message, $post->format, $options, $course->id), - 0,'',''); + $message = highlight($strippedsearch, + format_text($post->message, $post->format, $options, $course->id), + 0, '', ''); foreach ($searchterms as $searchterm) { if (preg_match("/$searchterm/i",$message) && !preg_match('/'.$searchterm.'<\/fgw9sdpq4>/i',$message)) { -- 2.39.5