summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--search.php37
1 files changed, 24 insertions, 13 deletions
diff --git a/search.php b/search.php
index bfd5e60c3..cc1dfd4b8 100644
--- a/search.php
+++ b/search.php
@@ -4,24 +4,35 @@ include_once "includes/common.inc";
page_header();
-function find_module($name) {
- global $options, $type;
- if (module_hook($name, "search")) $options .= "<OPTION VALUE=\"$name\"". ($name == $type ? " SELECTED" : "") .">$name</OPTION>\n";
+// verify input:
+$type = check_input($type);
+$keys = check_input($keys);
+
+// build options list:
+foreach (module_list() as $name) {
+ if (module_hook($name, "search")) {
+ $options .= "<OPTION VALUE=\"$name\"". ($name == $type ? " SELECTED" : "") .">$name</OPTION>\n";
+ }
}
-module_iterate("find_module");
+// build form:
+$form .= "<FORM ACTION=\"search.php\" METHOD=\"POST\">\n";
+$form .= " <INPUT SIZE=\"50\" VALUE=\"". check_form($keys) ."\" NAME=\"keys\" TYPE=\"text\">\n";
+$form .= " <SELECT NAME=\"type\">$options</SELECT>\n";
+$form .= " <INPUT TYPE=\"submit\" VALUE=\"". t("Search") ."\">\n";
+$form .= "</FORM>\n";
-$search .= "<FORM ACTION=\"search.php\" METHOD=\"POST\">\n";
-$search .= " <INPUT SIZE=\"50\" VALUE=\"". check_form($keys) ."\" NAME=\"keys\" TYPE=\"text\">\n";
-$search .= " <SELECT NAME=\"type\">$options</SELECT>\n";
-$search .= " <INPUT TYPE=\"submit\" VALUE=\"". t("Search") ."\">\n";
-$search .= "</FORM>\n";
+// visualize form:
+$theme->header();
-$output = search_data($keys, $type);
+if ($form) {
+ $theme->box(t("Search"), $form);
+}
+
+if ($keys) {
+ $theme->box(t("Result"), search_data($keys, $type));
+}
-$theme->header();
-$theme->box(t("Search"), $search);
-$theme->box(t("Result"), $output);
$theme->footer();
page_footer();