- Patch #5393 by Goba: changes the search hook return value, and requires an array

containing two elements, the first being the requested title, and the second being
  the result list. Advantages:
    * Cleaner search code in common.inc
    * Po extraction is possible and works fine
    * No hardcoded exceptions for node and comment modules, since any module can
      return results in order of relevance (or another order)
4.4.x
Dries Buytaert 2004-01-26 19:22:22 +00:00
parent 667022830e
commit 66190b1787
7 changed files with 8 additions and 13 deletions

View File

@ -664,13 +664,8 @@ function search_data($keys = NULL) {
if (isset($keys)) {
foreach (module_list() as $name) {
if (module_hook($name, "search") && (!$edit["type"] || $edit["type"][$name]) && ($result = module_invoke($name, "search", $keys))) {
if ($name == "node" || $name == "comment") {
$output .= "<p><strong>". t("Matching %names ranked in order of relevance:", array("%name" => $name)) ."</strong></p>";
}
else {
$output .= "<p><strong>". t("Matching {$name}s") .":</strong></p>";
}
foreach ($result as $entry) {
$output .= "<h2>$result[0]</h2>";
foreach ($result[1] as $entry) {
$output .= search_item($entry, $name);
}
}

View File

@ -1622,7 +1622,7 @@ function comment_search($keys) {
$find = do_search(array("keys" => $keys, "type" => "comment", "select" => "select s.lno as lno, c.nid as nid, c.subject as title, c.timestamp as created, u.uid as uid, u.name as name, s.count as count FROM {search_index} s, {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE s.lno = c.cid AND s.type = 'comment' AND c.status = 0 AND s.word like '%'"));
return $find;
return array(t("Matching comments ranked in order of relevance"), $find);
}
function comment_update_index() {

View File

@ -1622,7 +1622,7 @@ function comment_search($keys) {
$find = do_search(array("keys" => $keys, "type" => "comment", "select" => "select s.lno as lno, c.nid as nid, c.subject as title, c.timestamp as created, u.uid as uid, u.name as name, s.count as count FROM {search_index} s, {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE s.lno = c.cid AND s.type = 'comment' AND c.status = 0 AND s.word like '%'"));
return $find;
return array(t("Matching comments ranked in order of relevance"), $find);
}
function comment_update_index() {

View File

@ -566,7 +566,7 @@ function node_search($keys) {
//
$find = do_search(array("keys" => $keys, "type" => "node", "select" => "select s.lno as lno, n.title as title, n.created as created, u.uid as uid, u.name as name, s.count as count FROM {search_index} s, {node} n INNER JOIN {users} u ON n.uid = u.uid WHERE s.lno = n.nid AND s.type = 'node' AND s.word like '%' AND n.status = 1"));
return $find;
return array(t("Matching nodes ranked in order of relevance"), $find);
}
function node_settings() {

View File

@ -566,7 +566,7 @@ function node_search($keys) {
//
$find = do_search(array("keys" => $keys, "type" => "node", "select" => "select s.lno as lno, n.title as title, n.created as created, u.uid as uid, u.name as name, s.count as count FROM {search_index} s, {node} n INNER JOIN {users} u ON n.uid = u.uid WHERE s.lno = n.nid AND s.type = 'node' AND s.word like '%' AND n.status = 1"));
return $find;
return array(t("Matching nodes ranked in order of relevance"), $find);
}
function node_settings() {

View File

@ -300,7 +300,7 @@ function user_search($keys) {
while ($account = db_fetch_object($result)) {
$find[] = array("title" => $account->name, "link" => (strstr(request_uri(), "admin") ? url("admin/user/edit/$account->uid") : url("user/view/$account->uid")), "user" => $account->name);
}
return $find;
return array(t("Matching users"), $find);
}
function user_block($op = "list", $delta = 0) {

View File

@ -300,7 +300,7 @@ function user_search($keys) {
while ($account = db_fetch_object($result)) {
$find[] = array("title" => $account->name, "link" => (strstr(request_uri(), "admin") ? url("admin/user/edit/$account->uid") : url("user/view/$account->uid")), "user" => $account->name);
}
return $find;
return array(t("Matching users"), $find);
}
function user_block($op = "list", $delta = 0) {