You are here

function _auto_index_index_node in Auto Index 7

Same name and namespace in other branches
  1. 6 auto_index.module \_auto_index_index_node()
7 calls to _auto_index_index_node()
auto_index_comment_delete in ./auto_index.module
Implementation of hook_comment_delete
auto_index_comment_insert in ./auto_index.module
Implementation of hook_comment_insert
auto_index_comment_publish in ./auto_index.module
Implementation of hook_comment_publish
auto_index_comment_unpublish in ./auto_index.module
Implementation of hook_comment_unpublish
auto_index_comment_update in ./auto_index.module
Implementation of hook_comment_update

... See full list

File

./auto_index.module, line 74
Auto-index: Automatically indexes node content on update.

Code

function _auto_index_index_node(&$node) {

  // Static variable to keep track of any node ids already indexed.
  static $indexed_nodes = array();

  // Extract the node ID
  $node_id = is_array($node) ? $node['nid'] : $node->nid;

  // Check if the node ID has already been indexed.
  if (array_search($node_id, $indexed_nodes) === false) {

    // Ensure we force the cache to be updated so latest content is indexed.
    $node_obj = node_load($node_id, NULL, TRUE);

    // Do the indexing of this node only.
    _node_index_node($node_obj);

    // Update search totals.
    search_update_totals();

    // Append to array to ensure node only indexed once per action.
    $indexed_nodes[] = $node_id;
  }
}