You are here

function calendar_node_stripe in Calendar 7

Same name and namespace in other branches
  1. 5.2 calendar.module \calendar_node_stripe()
  2. 5 calendar.module \calendar_node_stripe()
  3. 6.2 calendar.module \calendar_node_stripe()
  4. 7.2 calendar.module \calendar_node_stripe()

Create a stripe.

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_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 205
Adds calendar filtering and displays to Views.

Code

function calendar_node_stripe($view, &$node, $query_name, $delta, $stripe = NULL, $label = '') {
  $colors = isset($view->date_info->calendar_colors) ? $view->date_info->calendar_colors : array();
  if (empty($colors)) {
    return;
  }
  $type_names = node_type_get_names();
  $type = $node->raw->node_type;
  if (!isset($node->stripe)) {
    $node->stripe = array();
    $node->stripe_label = array();
  }
  if (!$label && array_key_exists($type, $type_names)) {
    $label = $type_names[$type];
  }
  if (!$stripe) {
    if (array_key_exists($type, $colors)) {
      $stripe = $colors[$type];
    }
    else {
      $stripe = '';
    }
  }
  $node->stripe[] = $stripe;
  $node->stripe_label[] = $label;
  $GLOBALS['calendar_stripe_labels'][][$type] = array(
    'stripe' => $stripe,
    'label' => $label,
  );
  return $stripe;
}