summaryrefslogtreecommitdiff
path: root/modules/node/node.module
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2004-12-31 09:30:12 +0000
committerDries Buytaert <dries@buytaert.net>2004-12-31 09:30:12 +0000
commit1dbe0dc2ee80fc8d67e42785b12203513dc11820 (patch)
treeff4db2592bb43981e685a92dbf075a7095d63793 /modules/node/node.module
parent828be2ad6198538def4eb3da0ce03a34961a38e9 (diff)
downloadbrdo-1dbe0dc2ee80fc8d67e42785b12203513dc11820.tar.gz
brdo-1dbe0dc2ee80fc8d67e42785b12203513dc11820.tar.bz2
- 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.
Diffstat (limited to 'modules/node/node.module')
-rw-r--r--modules/node/node.module14
1 files changed, 6 insertions, 8 deletions
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 = '<h1>'. drupal_specialchars($node->title) .'</h1>'. $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 .= '<h2>'. $comment->subject .'</h2>'. 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