You are here

function calendar_node_taxonomy_stripe in Calendar 7

Same name and namespace in other branches
  1. 6.2 calendar.module \calendar_node_taxonomy_stripe()
  2. 7.2 calendar.module \calendar_node_taxonomy_stripe()

Create a stripe based on a taxonomy term.

Parameters

$node - the node object:

$query_name - the views queryname for this date field:

$delta - the delta for this field, used to distinguish fields that appear more than once in the calendar:

$stripe - the hex code for this stripe.:

$label - the label to give this stripe.:

TODO Reconsider use of $GLOBALS as a method of triggering the legend, there may be a better way.

1 call to calendar_node_taxonomy_stripe()
calendar_build_nodes in ./calendar.module
Take the array of items and alter it to an array of calendar nodes that the theme can handle.

File

./calendar.module, line 248
Adds calendar filtering and displays to Views.

Code

function calendar_node_taxonomy_stripe($view, &$node, $query_name, $delta, $stripe = NULL, $label = '') {
  $colors_taxonomy = isset($view->date_info->calendar_colors_taxonomy) ? $view->date_info->calendar_colors_taxonomy : array();
  if (empty($colors_taxonomy)) {
    return;
  }
  if (empty($node->raw->taxonomy_term_data_tid)) {
    return;
  }

  // Rename the vid added by Views to the normal name that
  // taxonomy will expect, it's in the raw results.
  $node->vid = $node->raw->node_vid;
  $terms_for_node = (array) $node->raw->taxonomy_term_data_tid;
  if (!isset($node->stripe)) {
    $node->stripe = array();
    $node->stripe_label = array();
  }
  if (count($terms_for_node)) {
    foreach ($terms_for_node as $tid) {
      $term_for_node = taxonomy_term_load($tid);
      if (!array_key_exists($term_for_node->tid, $colors_taxonomy)) {
        continue;
      }
      $stripe = $colors_taxonomy[$term_for_node->tid];
      $stripe_label = $term_for_node->name;
      $node->stripe[] = $stripe;
      $node->stripe_label[] = $stripe_label;
      $GLOBALS['calendar_stripe_labels'][][$term_for_node->tid] = array(
        'stripe' => $stripe,
        'label' => $stripe_label,
      );
    }
  }
  else {
    $node->stripe[] = '';
    $node->stripe_label[] = '';
  }
  return;
}