You are here

function calendar_node_group_stripe in Calendar 7

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

Create a stripe based on group.

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

Code

function calendar_node_group_stripe($view, &$node, $query_name, $delta, $stripe = NULL, $label = '') {
  $colors_group = isset($view->date_info->calendar_colors_group) ? $view->date_info->calendar_colors_group : array();
  if (empty($colors_group)) {
    return;
  }
  if (!function_exists('og_get_node_groups')) {
    return;
  }
  $groups_for_node = og_get_node_groups($node);
  if (!isset($node->stripe)) {
    $node->stripe = array();
    $node->stripe_label = array();
  }
  if (count($groups_for_node)) {
    foreach ($groups_for_node as $gid => $group_name) {
      if (!array_key_exists($gid, $colors_group)) {
        continue;
      }
      $stripe = $colors_group[$gid];
      $stripe_label = $group_name;
      $node->stripe[] = $stripe;
      $node->stripe_label[] = $stripe_label;
      $GLOBALS['calendar_stripe_labels'][][$gid] = array(
        'stripe' => $stripe,
        'label' => $stripe_label,
      );
    }
  }
  else {
    $node->stripe[] = '';
    $node->stripe_label[] = '';
  }
  return $stripe;
}