mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
Cleaned up some bodgy search code and formatted according to guidelines ..
This commit is contained in:
parent
c93f852dbc
commit
9044a3874e
1 changed files with 15 additions and 13 deletions
|
@ -34,6 +34,7 @@
|
|||
$strsearch = get_string("search", "forum");
|
||||
$strsearchresults = get_string("searchresults", "forum");
|
||||
$strpage = get_string("page");
|
||||
$strmissingsearchterms = get_string('missingsearchterms','forum');
|
||||
|
||||
$searchform = forum_print_search_form($course, $search, true, "plain");
|
||||
|
||||
|
@ -57,8 +58,8 @@
|
|||
$strippedsearch = str_replace("user:","",$search);
|
||||
$strippedsearch = str_replace("subject:","",$strippedsearch);
|
||||
$strippedsearch = str_replace(""","",$strippedsearch);
|
||||
if (!$posts = forum_search_posts($searchterms, $course->id, $page*$perpage, $perpage, $totalcount)) {
|
||||
|
||||
if (!$posts = forum_search_posts($searchterms, $course->id, $page*$perpage, $perpage, $totalcount)) {
|
||||
|
||||
print_header_simple("$strsearchresults", "",
|
||||
"<a href=\"index.php?id=$course->id\">$strforums</a> ->
|
||||
|
@ -131,18 +132,19 @@
|
|||
//actual text content first.
|
||||
//fiedorow - 9/2/2005
|
||||
$missing_terms = "";
|
||||
$message = highlight($strippedsearch,format_text($post->message, $post->format, NULL, $courseid),0,"<fgw9sdpq4>","</fgw9sdpq4>");
|
||||
$message = highlight($strippedsearch,format_text($post->message, $post->format, NULL, $course->id),
|
||||
0,'<fgw9sdpq4>','</fgw9sdpq4>');
|
||||
foreach ($searchterms as $searchterm) {
|
||||
if (preg_match("/$searchterm/i",$message) && !preg_match('/<fgw9sdpq4>'.$searchterm.'<\/fgw9sdpq4>/i',$message)) {
|
||||
$missing_terms .= " $searchterm";}
|
||||
$missing_terms .= " $searchterm";
|
||||
}
|
||||
$message = preg_replace('/<fgw9sdpq4>/','<span class="highlight">',$message);
|
||||
$message = preg_replace('/<\/fgw9sdpq4>/','</span class="highlight">',$message);
|
||||
}
|
||||
$message = str_replace('<fgw9sdpq4>','<span class="highlight">',$message);
|
||||
$message = str_replace('</fgw9sdpq4>','</span>',$message);
|
||||
|
||||
if ($missing_terms) {
|
||||
$missing_terms_message = get_string('missingsearchterms','forum');
|
||||
$message = "<div><p><span class=\"highlight2\">$missing_terms_message $missing_terms</span class=\"higlight2\"></p></div>" . $message;
|
||||
$post->message = '<p class="highlight2">'.$strmissingsearchterms.' '.$missing_terms.'</p>'.$message;
|
||||
}
|
||||
$post->message = $message;
|
||||
|
||||
$fulllink = "<a href=\"discuss.php?d=$post->discussion#$post->id\">".get_string("postincontext", "forum")."</a>";
|
||||
//search terms already highlighted - fiedorow - 9/2/2005
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue