From 1dbe0dc2ee80fc8d67e42785b12203513dc11820 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Fri, 31 Dec 2004 09:30:12 +0000 Subject: - Patch #14917 by UnConeD/Steven: 1) The different types of search, which used to be radio button options in the search form, are now subtabs of "search" (default "search/node"). This seems better from a UI point of view, but also has another advantage: modules which implement a custom search form (flexinode, project) can add it as a subtab of search. This means that all search forms will be located in the same place, and also without needing an extra api call to search.module. 2) The current code was a bit hackish, as the indexing of comments along with nodes was hardcoded in node.module. Instead, I created a nodeapi operation "update index" which allows modules to add more data for a node that is being indexed. Comments are now indexed using this mechanism and from comment.module, which is a lot cleaner. 3) The search results format was also hardcoded to include "N comments". I replaced this with a nodeapi operation "search result" and moved the comment code to comment.module where it belongs. This op is quite useful, as for example I also modified upload.module to add "N attachments" to a search result if any are present. --- modules/node/node.module | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'modules/node/node.module') diff --git a/modules/node/node.module b/modules/node/node.module index 224c4c9a1..21655e1ef 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -582,13 +582,13 @@ function node_search($op = 'search', $keys = null) { $results = array(); foreach ($find as $item) { $node = node_load(array('nid' => $item)); - $comments = db_result(db_query('SELECT comment_count FROM {node_comment_statistics} WHERE nid = %d', $item)); + $extra = node_invoke_nodeapi($node, 'search result'); $results[] = array('link' => url('node/'. $item), 'type' => node_invoke($node, 'node_name'), 'title' => $node->title, 'user' => format_name($node), 'date' => $node->changed, - 'extra' => format_plural($comments, '1 comment', '%count comments'), + 'extra' => $extra, 'snippet' => search_excerpt($keys, check_output($node->body, $node->format))); } return $results; @@ -1588,12 +1588,10 @@ function node_update_index() { $text = '

'. drupal_specialchars($node->title) .'

'. $node->body; - // Fetch comments - if (module_exist('comment')) { - $comments = db_query('SELECT subject, comment, format FROM {comments} WHERE nid = %d AND status = 0', $node->nid); - while ($comment = db_fetch_object($comments)) { - $text .= '

'. $comment->subject .'

'. check_output($comment->comment, $comment->format); - } + // Fetch extra data normally not visible + $extra = node_invoke_nodeapi($node, 'update index'); + foreach ($extra as $t) { + $text .= $t; } // Update index -- cgit v1.2.3