diff options
Diffstat (limited to 'modules/search.module')
-rw-r--r-- | modules/search.module | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/modules/search.module b/modules/search.module new file mode 100644 index 000000000..7beb1e74c --- /dev/null +++ b/modules/search.module @@ -0,0 +1,57 @@ +<?php + +function search_perm() { + return array("search content"); +} + +function search_link($type) { + if ($type == "page" && user_access("search content")) { + $links[] = "<a href=\"module.php?mod=search\">search</a>"; + } + + return $links ? $links : array(); +} + +function search_page() { + global $theme, $type, $keys, $REQUEST_URI; + + if (user_access("search content")) { + // 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"; + } + } + + // build form: + $form .= "<form action=\"$REQUEST_URI\" 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"; + + // visualize form: + $theme->header(); + + if ($form) { + $theme->box(t("Search"), $form); + } + + if ($keys) { + $theme->box(t("Result"), search_data($keys, $type)); + } + + $theme->footer(); + } + else { + $theme->header(); + $theme->box("Access denied", message_access()); + $theme->footer(); + } +} + +?>
\ No newline at end of file |