From e95aa56e02215ae211942b4e3192a17f115e99c7 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Wed, 25 Jun 2003 22:10:54 +0000 Subject: - Bugfix: fixed bug in the search module that prevented the title module from working properly. Patch by Moshe. Fixes bug #1852. --- modules/search.module | 26 ++++++++++++++++---------- modules/search/search.module | 26 ++++++++++++++++---------- 2 files changed, 32 insertions(+), 20 deletions(-) (limited to 'modules') diff --git a/modules/search.module b/modules/search.module index a34754134..8a332263b 100644 --- a/modules/search.module +++ b/modules/search.module @@ -5,7 +5,7 @@ function search_help() { $output = "". t("Search guidelines") .""; $output .= "

". t("The search page allows you to search the web site's content. You can specify multiple words, and they will all be searched for. You can also use wildcards, so 'walk*' will match 'walk', 'walking', 'walker', 'walkable' and so on. Furthermore, searches are not case sensitive so searching for 'walk', 'Walk' or 'WALK' will yield exactly the same results.") ."

"; $output .= "". t("Words excluded from the search") .""; - $output .= "

". t("Words that frequently occur, typically called 'noise words', are ignored. Example words are 'a', 'at', 'and', 'are', 'as', 'how', 'where', etc. Words shorter than %number letters are also being filtered.", array("%number" => variable_get("minimum_word_size", 2))) ."

"; + $output .= "

". t("Words that frequently occur, typically called 'noise words', are ignored. Example words are 'a', 'at', 'and', 'are', 'as', 'how', 'where', etc. Words shorter than %number letters are also ignored.", array("%number" => variable_get("minimum_word_size", 2))) ."

"; return $output; } @@ -327,17 +327,15 @@ function search_save($edit) { variable_set("remove_short", $edit["remove_short"]); } -function search_view($keys = NULL) { +function search_view($keys) { global $type; - $edit = $_POST["edit"]; - if (user_access("search content")) { // Construct the search form: - $form = search_form(NULL, NULL, TRUE); + $form = search_form(NULL, $keys, TRUE); // Collect the search results: - $output = search_data(); + $output = search_data($keys); // Display form and search results: $help_link = l(t("search help"), "search/help"); @@ -349,10 +347,10 @@ function search_view($keys = NULL) { $form .= search_help(); break; case "3": - $form = $help_link. $form; + $form = $help_link. "
". $form; break; case "4": - $form .= $help_link; + $form .= "
". $help_link; } theme("header"); @@ -363,10 +361,18 @@ function search_view($keys = NULL) { if ($keys) { if ($output) { - theme("box", t("Result"), $output); + theme("box", t("Search Results"), $output); } else { - theme("box", t("Result"), t("Your search yielded no results.")); + // no results. try a substring search + $output = search_data("*". $keys. "*"); + + if ($output) { + theme("box", t("Search Results"), $output); + } + else { + theme("box", t("Search Results"), t("Your search yielded no results.")); + } } } diff --git a/modules/search/search.module b/modules/search/search.module index a34754134..8a332263b 100644 --- a/modules/search/search.module +++ b/modules/search/search.module @@ -5,7 +5,7 @@ function search_help() { $output = "". t("Search guidelines") .""; $output .= "

". t("The search page allows you to search the web site's content. You can specify multiple words, and they will all be searched for. You can also use wildcards, so 'walk*' will match 'walk', 'walking', 'walker', 'walkable' and so on. Furthermore, searches are not case sensitive so searching for 'walk', 'Walk' or 'WALK' will yield exactly the same results.") ."

"; $output .= "". t("Words excluded from the search") .""; - $output .= "

". t("Words that frequently occur, typically called 'noise words', are ignored. Example words are 'a', 'at', 'and', 'are', 'as', 'how', 'where', etc. Words shorter than %number letters are also being filtered.", array("%number" => variable_get("minimum_word_size", 2))) ."

"; + $output .= "

". t("Words that frequently occur, typically called 'noise words', are ignored. Example words are 'a', 'at', 'and', 'are', 'as', 'how', 'where', etc. Words shorter than %number letters are also ignored.", array("%number" => variable_get("minimum_word_size", 2))) ."

"; return $output; } @@ -327,17 +327,15 @@ function search_save($edit) { variable_set("remove_short", $edit["remove_short"]); } -function search_view($keys = NULL) { +function search_view($keys) { global $type; - $edit = $_POST["edit"]; - if (user_access("search content")) { // Construct the search form: - $form = search_form(NULL, NULL, TRUE); + $form = search_form(NULL, $keys, TRUE); // Collect the search results: - $output = search_data(); + $output = search_data($keys); // Display form and search results: $help_link = l(t("search help"), "search/help"); @@ -349,10 +347,10 @@ function search_view($keys = NULL) { $form .= search_help(); break; case "3": - $form = $help_link. $form; + $form = $help_link. "
". $form; break; case "4": - $form .= $help_link; + $form .= "
". $help_link; } theme("header"); @@ -363,10 +361,18 @@ function search_view($keys = NULL) { if ($keys) { if ($output) { - theme("box", t("Result"), $output); + theme("box", t("Search Results"), $output); } else { - theme("box", t("Result"), t("Your search yielded no results.")); + // no results. try a substring search + $output = search_data("*". $keys. "*"); + + if ($output) { + theme("box", t("Search Results"), $output); + } + else { + theme("box", t("Search Results"), t("Your search yielded no results.")); + } } } -- cgit v1.2.3