57 lines
1.3 KiB
Plaintext
57 lines
1.3 KiB
Plaintext
<?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();
|
|
}
|
|
}
|
|
|
|
?> |