function calendar_node_taxonomy_stripe in Calendar 6.2
Same name and namespace in other branches
- 7 calendar.module \calendar_node_taxonomy_stripe()
- 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 242 - 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;
}
// 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 = taxonomy_node_get_terms($node);
if (!isset($node->stripe)) {
$node->stripe = array();
$node->stripe_label = array();
}
if (count($terms_for_node)) {
foreach ($terms_for_node as $term_for_node) {
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;
}