/[drupal]/contributions/modules/AutoUpdateSearch/autoupdatesearch.module
ViewVC logotype

Contents of /contributions/modules/AutoUpdateSearch/autoupdatesearch.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Thu Aug 14 12:51:16 2008 UTC (15 months, 1 week ago) by marcelbichon
Branch: MAIN
CVS Tags: DRUPAL-5--1-0, HEAD
Branch point for: DRUPAL-5
File MIME type: text/x-php
no message
1 <?php
2 // $Id: autoupdatesearch.module,v 1.1 2008/08/13 13:50:49 MXMorin Exp $
3 // Author: M. Morin
4 global $_opList;
5 $_opList = array("update","insert","delete","delete revision");
6
7 /**
8 * Implementation of hook_nodeapi().
9 */
10 function autoupdatesearch_nodeapi(&$node, $op, $teaser) {
11 global $_opList;
12 if (in_array($op,$_opList)) {
13 autoUpdate($node);
14 }
15 return array();
16
17 }
18
19 function autoupdatesearch_filter_tips($delta, $format, $long = false) {
20 // if ($long) {
21 return t('Enabling this module update search engine at each node save.');
22 }
23
24 function autoUpdate(&$node) {
25 global $last_change, $last_nid;
26 $last_change = $node->changed;
27 $last_nid = $node->nid;
28
29 // Build the node body.
30 $node = node_build_content($node, FALSE, FALSE);
31 $node->body = drupal_render($node->content);
32
33 // Allow modules to modify the fully-built node.
34 node_invoke_nodeapi($node, 'alter');
35
36 $text = '<h1>'. check_plain($node->title) .'</h1>'. $node->body;
37
38 // Fetch extra data normally not visible
39 $extra = node_invoke_nodeapi($node, 'update index');
40 foreach ($extra as $t) {
41 $text .= $t;
42 }
43
44 // Update index
45 search_index($node->nid, 'node', $text);
46 search_update_totals();
47 node_update_shutdown();
48 }
49
50
51
52
53 ?>

  ViewVC Help
Powered by ViewVC 1.1.2