You are here

function library_get_table_row in Library 7

Same name and namespace in other branches
  1. 5.2 library.module \library_get_table_row()
  2. 6.2 library.module \library_get_table_row()
  3. 6 library.module \library_get_table_row()

Returns one table for an item table.

Parameters

object $node: The node object to evaluate.

array $var: Controls via display_categories, display_quantity and display_status which data is collated.

Return value

array Array containing all rows for an item.

1 call to library_get_table_row()
library_display_items in ./library.pages.inc
Display all library items.

File

./library.module, line 1322

Code

function library_get_table_row($node, $var) {
  $row = array();
  $row[] = l($node->title, 'node/' . $node->nid);
  if ($var['display_categories']) {
    $defined_vocabularies = variable_get('library_taxonomy_display', array());
    $vid = array();
    foreach ($defined_vocabularies as $key => $vocabulary) {
      if ($vocabulary) {
        $vid[] = $key;
      }
    }
    $query = db_select('taxonomy_index', 'r');
    $query
      ->join('taxonomy_term_data', 't', 'r.tid = t.tid');
    $query
      ->fields('t', array(
      'tid',
      'name',
    ))
      ->condition('r.nid', $node->nid)
      ->condition('t.vid', $vid, 'IN')
      ->orderBy('t.vid', 'ASC')
      ->orderBy('t.name', 'ASC');
    $result = $query
      ->execute();
    $terms = array();
    foreach ($result as $term) {
      $categories[] = l($term->name, 'taxonomy/term/' . $term->tid);
    }
    $row[] = implode(" | ", $categories);
  }
  if ($var['display_quantity']) {
    $row[] = library_get_quantity($node);
  }

  // Replace with a function to find out if there is one available item.
  $item = library_get_status_items($node);
  if ($item && $var['display_status']) {
    $row[] = library_get_status_text($item);
  }
  return $row;
}