search.inc 908 Bytes
Newer Older
Dries's avatar
   
Dries committed
1
<?php
Dries's avatar
 
Dries committed
2
3
4
5
6
7
8
9
10
11
12
13

function search_form($keys) {
  global $REQUEST_URI;
  $output .= "<FORM ACTION=\"$REQUEST_URI\" METHOD=\"POST\">\n";
  $output .= " <INPUT SIZE=\"50\" VALUE=\"". check_textfield($keys) ."\" NAME=\"keys\">";
  $output .= " <INPUT TYPE=\"submit\" VALUE=\"Search\">\n";
  $output .= "</FORM>\n";
  return $output;
}

function search_data($keys, $type) {
  if ($keys && $type) {
Dries's avatar
   
Dries committed
14
    $result = module_invoke($type, "find", check_input($keys));
Dries's avatar
 
Dries committed
15
16
    foreach ($result as $entry) {
      $output .= "<P>\n";
Dries's avatar
   
Dries committed
17
      $output .= " <B><U><A HREF=\"$entry[link]\">$entry[title]</A></U></B><BR>";
Dries's avatar
   
Dries committed
18
      $output .= " <SMALL>$entry[link]". ($entry[user] ? " - ". format_username($entry[user]) : "") ."". ($entry[date] ? " - ". format_date($entry[date], "small") : "") ."</SMALL>";
Dries's avatar
 
Dries committed
19
20
21
22
23
      $output .= "</P>\n";
    }
  }

  if (!$output) {
Dries's avatar
   
Dries committed
24
    $output .= t("Your search yielded no results.");
Dries's avatar
 
Dries committed
25
26
27
28
29
30
  }

  return $output;
}

?>