diff options
author | Dries Buytaert <dries@buytaert.net> | 2003-06-25 22:10:54 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2003-06-25 22:10:54 +0000 |
commit | e95aa56e02215ae211942b4e3192a17f115e99c7 (patch) | |
tree | d327b571eccdb02a0ee91f24257f0ed59bda12b7 | |
parent | 2689d6aa1ea3f8af7f405da3a25bea75d433b686 (diff) | |
download | brdo-e95aa56e02215ae211942b4e3192a17f115e99c7.tar.gz brdo-e95aa56e02215ae211942b4e3192a17f115e99c7.tar.bz2 |
- Bugfix: fixed bug in the search module that prevented the title module
from working properly. Patch by Moshe. Fixes bug #1852.
-rw-r--r-- | includes/common.inc | 21 | ||||
-rw-r--r-- | modules/search.module | 26 | ||||
-rw-r--r-- | modules/search/search.module | 26 |
3 files changed, 38 insertions, 35 deletions
diff --git a/includes/common.inc b/includes/common.inc index d00c04f2f..12a71bbda 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -317,7 +317,7 @@ function search_item($item, $type) { $output = module_invoke($type, "search_item", $item); } else { - $output .= " <b>". $item["count"] ." <u><a href=\"". $item["link"] ."\">". $item["title"] ."</a></u></b><br />"; + $output .= " <b><u><a href=\"". $item["link"] ."\">". $item["title"] ."</a></u></b><br />"; $output .= " <small>$type ". ($item["user"] ? " - ". $item["user"] : "") ."". ($item["date"] ? " - ". format_date($item["date"], "small") : "") ."</small>"; $output .= "<br /><br />"; } @@ -335,21 +335,16 @@ function search_item($item, $type) { * parts of this form. * * @param $action Form action. Defaults to 'site.com/search'. - * @param $query Query string. Defaults to global $keys. + * @param $keys string containing keywords for the search. * @param $options != 0: Render additional form fields/text * ("Restrict search to", help text, etc). */ -function search_form($action = 0, $query = 0, $options = 0) { - $keys = $_POST["keys"]; +function search_form($action = 0, $keys = 0, $options = 0) { if (!$action) { $action = url("search"); } - if (!$query) { - $query = $keys; - } - $output .= " <br /><input type=\"text\" size=\"50\" value=\"". check_form($keys) ."\" name=\"keys\" />"; $output .= " <input type=\"submit\" value=\"". t("Search") ."\" />\n"; @@ -372,9 +367,8 @@ function search_form($action = 0, $query = 0, $options = 0) { /* * Collect the search results: */ -function search_data() { +function search_data($keys = NULL) { - $keys = $_POST["keys"]; $edit = $_POST["edit"]; if (isset($keys)) { @@ -391,9 +385,6 @@ function search_data() { } } } - if (!$output) { - $output .= t("Your search yielded no results."); - } } return $output; @@ -409,13 +400,13 @@ function search_data() { * @param $options != 0: Render additional form fields/text * ("Restrict search to", help text, etc). */ -function search_type($type = 0, $action = 0, $query = 0, $options = 0) { +function search_type($type = 0, $action = 0, $keys = 0, $options = 0) { if (isset($type)) { $_POST["edit"]["type"][$type] = "on"; } - return search_form($action, $query, $options) . search_data(); + return search_form($action, $keys, $options) . "<br />". search_data($keys); } 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 = "<b>". t("Search guidelines") ."</b>"; $output .= "<p>". 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.") ."</p>"; $output .= "<b>". t("Words excluded from the search") ."</b>"; - $output .= "<p>". 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))) ."</p>"; + $output .= "<p>". 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))) ."</p>"; 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. "<br />". $form; break; case "4": - $form .= $help_link; + $form .= "<br />". $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 = "<b>". t("Search guidelines") ."</b>"; $output .= "<p>". 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.") ."</p>"; $output .= "<b>". t("Words excluded from the search") ."</b>"; - $output .= "<p>". 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))) ."</p>"; + $output .= "<p>". 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))) ."</p>"; 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. "<br />". $form; break; case "4": - $form .= $help_link; + $form .= "<br />". $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.")); + } } } |