/[drupal]/contributions/modules/field_indexer/node_field_indexer.module
ViewVC logotype

Contents of /contributions/modules/field_indexer/node_field_indexer.module

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


Revision 1.2 - (show annotations) (download) (as text)
Sun Jun 22 17:22:08 2008 UTC (17 months ago) by davidlesieur
Branch: MAIN
CVS Tags: DRUPAL-6--1-0, DRUPAL-5--1-0, HEAD
Branch point for: DRUPAL-5
Changes since 1.1: +2 -2 lines
File MIME type: text/x-php
Show namespace in field help.
1 <?php
2 // $Id: node_field_indexer.module,v 1.1 2008/06/19 20:29:49 davidlesieur Exp $
3
4 /**
5 * @file
6 * Exposes core node data for indexing into the search index.
7 */
8
9 /**
10 * Implementation of hook_field_indexer_list().
11 *
12 * @return
13 * An array describing the fields, each field being represented by an array
14 * with the following attributes:
15 * - name: Machine name or id of the field.
16 * - extra_name: Extra field name or id information.
17 * - label: Printable name of the field.
18 * - help: Optional info that may help in identifying the field.
19 */
20 function node_field_indexer_field_indexer_list() {
21 // Node title.
22 $fields[] = array(
23 'namespace' => 'node',
24 'name' => 'title',
25 'extra_name' => '',
26 'label' => t('Title'),
27 'help' => '',
28 );
29 // TODO: Node author.
30 return $fields;
31 }
32
33 /**
34 * Implementation of hook_nodeapi().
35 *
36 * This is used to add our own entries to the search index. Using nodeapi's
37 * update index operation is convenient, since the node module already handles
38 * the logic for determining which nodes need indexing.
39 */
40 function node_field_indexer_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
41 static $fields = NULL;
42 if ($op == 'update index') {
43 if (!isset($fields)) {
44 $fields = field_indexer_load_fields(TRUE, 'node');
45 }
46 foreach ($fields as $field) {
47 $value = '';
48 switch ($field['name']) {
49 case 'title':
50 if (isset($node->title)) {
51 $value = check_plain($node->title);
52 }
53 break;
54 }
55 if (trim($value) != '') {
56 field_indexer_index($node->nid, $field['fiid'], $value);
57 }
58 }
59 }
60 }
61

  ViewVC Help
Powered by ViewVC 1.1.2