views_natural_sort.node.inc 1.07 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
<?php
/**
 * @file
 *
 * Node specific views_natural_sort code.
 */

/**
 * Helper function for writing node data to our sort index.
 *
 * @param $node
 *   A drupal node object containing at least a nid and title.
 */
function _views_natural_sort_store_node($node) {
  views_natural_sort_store(_views_natural_sort_node_to_vns($node));
}

/**
 * Helper function for getting an index_entry from a node object.
 *
 * @param stdClass $node
 *   Node Entity
 *
 * @return array
 *   index_entry array
 */
function _views_natural_sort_node_to_vns($node) {
  return array(
    'eid' => $node->nid,
    'entity_type' => 'node',
    'field' => 'title',
    'delta' => 0,
    'content' => $node->title,
  );
}

/**
 * Helper function for removing node data from our sort index.
 *
 * @param $node
 *   A drupal node object containing at least a nid.
 *
 * @return int
 *   The number of rows deleted.
 */
function _views_natural_sort_remove_node($node) {
  return views_natural_sort_remove(array(
    'eid' => $node->nid,
    'entity_type' => 'node',
    'field' => 'title',
    'delta' => 0,
  ));
}