calendar_plugin_row_node.inc 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. <?php
  2. /**
  3. * @file
  4. * Contains the Calendar row style plugin.
  5. *
  6. * This plugin takes the view results, finds the date value for each,
  7. * then compares that date to the date range for the current view.
  8. * Items that started before or ended after the current date range
  9. * are shortened to the current range. Items that extend over more
  10. * than one day are cloned to create a calendar item for each day.
  11. * The resulting array of results (which may have a different number
  12. * of items than the original view result) are then passed back
  13. * to the style plugin so they can be displayed in a calendar.
  14. *
  15. * Row plugins are specific to entity types. To create a row plugin
  16. * for other types of entities, this class can be extended or copied,
  17. * adjusting the parts that are specific to nodes.
  18. */
  19. /**
  20. * Plugin which creates a view on the resulting object
  21. * and formats it as a Calendar node.
  22. */
  23. class calendar_plugin_row_node extends views_plugin_row {
  24. // Basic properties that let the row style follow relationships.
  25. var $base_table = 'node';
  26. var $base_field = 'nid';
  27. // Stores the nodes loaded with pre_render.
  28. var $nodes = array();
  29. /**
  30. * Helper function to find the date argument handler for this view.
  31. */
  32. function date_argument_handler() {
  33. foreach ($this->view->argument as $name => $handler) {
  34. if (date_views_handler_is_date($handler, 'argument')) {
  35. return $handler;
  36. }
  37. }
  38. }
  39. function option_definition() {
  40. $options = parent::option_definition();
  41. $options['date_fields'] = array('default' => array());
  42. $options['calendar_date_link'] = array('default' => '');
  43. $options['colors'] = array(
  44. 'contains' => array(
  45. 'legend' => array('default' => ''),
  46. 'calendar_colors_type' => array('default' => array()),
  47. 'taxonomy_field' => array('default' => ''),
  48. 'calendar_colors_vocabulary' => array('default' => array()),
  49. 'calendar_colors_taxonomy' => array('default' => array()),
  50. 'calendar_colors_group' => array('default' => array()),
  51. ));
  52. return $options;
  53. }
  54. /**
  55. * Provide a form for setting options.
  56. */
  57. function options_form(&$form, &$form_state) {
  58. parent::options_form($form, $form_state);
  59. $form['markup']['#markup'] = t("The calendar row plugin will format view results as calendar items. Make sure this display has a 'Calendar' format and uses a 'Date' contextual filter, or this plugin will not work correctly.");
  60. $form['calendar_date_link'] = array(
  61. '#title' => t('Add new date link'),
  62. '#type' => 'select',
  63. '#default_value' => $this->options['calendar_date_link'],
  64. '#options' => array('' => t('No link')) + node_type_get_names(),
  65. '#description' => t('Display a link to add a new date of the specified content type. Displayed only to users with appropriate permissions.'),
  66. );
  67. $form['colors'] = array(
  68. '#type' => 'fieldset',
  69. '#title' => t('Legend Colors'),
  70. '#description' => t('Set a hex color value (like #ffffff) to use in the calendar legend for each content type. Items with empty values will have no stripe in the calendar and will not be added to the legend.'),
  71. );
  72. $form['colors']['legend'] = array(
  73. '#title' => t('Stripes'),
  74. '#description' => t('Add stripes to calendar items.'),
  75. '#type' => 'select',
  76. '#options' => array('' => t('None'), 'type' => t('Based on Content Type'), 'taxonomy' => t('Based on Taxonomy'), 'group' => t('Based on Organic Group')),
  77. '#default_value' => $this->options['colors']['legend'],
  78. );
  79. if (!module_exists('og')) {
  80. unset($form['colors']['legend']['#options']['group']);
  81. }
  82. $colors = $this->options['colors']['calendar_colors_type'];
  83. $type_names = node_type_get_names();
  84. foreach ($type_names as $key => $name) {
  85. $form['colors']['calendar_colors_type'][$key] = array(
  86. '#title' => check_plain($name),
  87. '#type' => 'textfield',
  88. '#default_value' => isset($colors[$key]) ? $colors[$key] : '#ffffff',
  89. '#size' => 7,
  90. '#maxlength' => 7,
  91. '#element_validate' => array('calendar_validate_hex_color'),
  92. '#dependency' => array('edit-row-options-colors-legend' => array('type')),
  93. '#prefix' => '<div class="calendar-colorpicker-wrapper">',
  94. '#suffix' => '<div class="calendar-colorpicker"></div></div>',
  95. '#attributes' => array('class' => array('edit-calendar-colorpicker')),
  96. '#attached' => array(
  97. // Add Farbtastic color picker.
  98. 'library' => array(
  99. array('system', 'farbtastic'),
  100. ),
  101. // Add javascript to trigger the colorpicker.
  102. 'js' => array(drupal_get_path('module', 'calendar') . '/js/calendar_colorpicker.js'),
  103. ),
  104. );
  105. }
  106. if (module_exists('taxonomy')) {
  107. $vocab_field_options = array();
  108. $fields = $this->display->handler->get_option('fields');
  109. foreach ($fields as $name => $field) {
  110. if (!empty($field['type']) && $field['type'] == 'taxonomy_term_reference_link') {
  111. $vocab_field_options[$field['field']] = $field['field'];
  112. }
  113. }
  114. $form['colors']['taxonomy_field'] = array(
  115. '#title' => t('Term field'),
  116. '#type' => !empty($vocab_field_options) ? 'select' : 'hidden',
  117. '#default_value' => $this->options['colors']['taxonomy_field'],
  118. '#description' => t("Select the taxonomy term field to use when setting stripe colors. This works best for vocabularies with only a limited number of possible terms."),
  119. '#options' => $vocab_field_options,
  120. '#dependency' => array('edit-row-options-colors-legend' => array('taxonomy')),
  121. );
  122. if (empty($vocab_field_options)) {
  123. $form['colors']['taxonomy_field']['#options'] = array('' => '');
  124. $form['colors']['taxonomy_field']['#suffix'] = t('You must add a term field to this view to use taxonomy stripe values. This works best for vocabularies with only a limited number of possible terms.');
  125. }
  126. $taxonomy_field = field_info_field($this->options['colors']['taxonomy_field']);
  127. $vocab_names[] = array();
  128. foreach ((array) $taxonomy_field['settings']['allowed_values'] as $delta => $options) {
  129. $vocab_names[] = $options['vocabulary'];
  130. }
  131. $taxonomies = taxonomy_get_vocabularies();
  132. foreach ($taxonomies as $vid => $vocab) {
  133. if (in_array($vocab->name, $vocab_names)) {
  134. $this->options['colors']['calendar_colors_vocabulary'][] = $vid;
  135. }
  136. }
  137. $form['colors']['calendar_colors_vocabulary'] = array(
  138. '#title' => t('Vocabulary Legend Types'),
  139. '#type' => 'value',
  140. '#value' => $this->options['colors']['calendar_colors_vocabulary'],
  141. );
  142. $vocabularies = (array) $this->options['colors']['calendar_colors_vocabulary'];
  143. $term_colors = $this->options['colors']['calendar_colors_taxonomy'];
  144. foreach ($vocabularies as $vid) {
  145. $vocab = taxonomy_get_tree($vid);
  146. foreach ($vocab as $tid => $term) {
  147. $form['colors']['calendar_colors_taxonomy'][$term->tid] = array(
  148. '#title' => check_plain(t($term->name)),
  149. '#type' => 'textfield',
  150. '#default_value' => isset($term_colors[$term->tid]) ? $term_colors[$term->tid] : '#ffffff',
  151. '#size' => 7,
  152. '#maxlength' => 7,
  153. '#access' => !empty($vocab_field_options),
  154. '#dependency' => array('edit-row-options-colors-legend' => array('taxonomy')),
  155. '#element_validate' => array('calendar_validate_hex_color'),
  156. '#prefix' => '<div class="calendar-colorpicker-wrapper">',
  157. '#suffix' => '<div class="calendar-colorpicker"></div></div>',
  158. '#attributes' => array('class' => array('edit-calendar-colorpicker')),
  159. '#attached' => array(
  160. // Add Farbtastic color picker.
  161. 'library' => array(
  162. array('system', 'farbtastic'),
  163. ),
  164. // Add javascript to trigger the colorpicker.
  165. 'js' => array(drupal_get_path('module', 'calendar') . '/js/calendar_colorpicker.js'),
  166. ),
  167. );
  168. }
  169. }
  170. }
  171. if (module_exists('og')) {
  172. $colors_group = $this->options['colors']['calendar_colors_group'];
  173. $groups = og_get_all_group();
  174. foreach ($groups as $gid) {
  175. $form['colors']['calendar_colors_group'][$gid] = array(
  176. '#title' => check_plain(t(og_label($gid))),
  177. '#type' => 'textfield',
  178. '#default_value' => isset($colors_group[$gid]) ? $colors_group[$gid] : '#ffffff',
  179. '#dependency' => array('edit-row-options-colors-legend' => array('group')),
  180. '#element_validate' => array('calendar_validate_hex_color'),
  181. '#prefix' => '<div class="calendar-colorpicker-wrapper">',
  182. '#suffix' => '<div class="calendar-colorpicker"></div></div>',
  183. '#attributes' => array('class' => array('edit-calendar-colorpicker')),
  184. '#attached' => array(
  185. // Add Farbtastic color picker.
  186. 'library' => array(
  187. array('system', 'farbtastic'),
  188. ),
  189. // Add javascript to trigger the colorpicker.
  190. 'js' => array(drupal_get_path('module', 'calendar') . '/js/calendar_colorpicker.js'),
  191. ),
  192. );
  193. }
  194. }
  195. }
  196. function options_submit(&$form, &$form_state) {
  197. parent::options_submit($form, $form_state);
  198. $path = $this->view->display_handler->get_option('path');
  199. calendar_clear_link_path($path);
  200. if (!empty($form_state['values']['row_options']['calendar_date_link'])) {
  201. $node_type = $form_state['values']['row_options']['calendar_date_link'];
  202. calendar_set_link('node', $node_type, $path);
  203. }
  204. }
  205. function pre_render($values) {
  206. // @TODO When the date is coming in through a relationship, the nid
  207. // of the view is not the right node to use, then we need the related node.
  208. // Need to sort out how that should be handled.
  209. // Preload each node used in this view from the cache.
  210. // Provides all the node values relatively cheaply, and we don't
  211. // need to do it repeatedly for the same node if there are
  212. // multiple results for one node.
  213. $nids = array();
  214. foreach ($values as $row) {
  215. // Use the $nid as the key so we don't create more than one value per node.
  216. $nid = $row->{$this->field_alias};
  217. $nids[$nid] = $nid;
  218. }
  219. if (!empty($nids)) {
  220. $this->nodes = node_load_multiple($nids);
  221. }
  222. // Let the style know if a link to create a new date is required.
  223. $this->view->date_info->calendar_date_link = $this->options['calendar_date_link'];
  224. // Identify the date argument and fields that apply to this view.
  225. // Preload the Date Views field info for each field, keyed by the
  226. // field name, so we know how to retrieve field values from the cached node.
  227. $data = date_views_fields('node');
  228. $data = $data['name'];
  229. $date_fields = array();
  230. foreach ($this->view->argument as $handler) {
  231. if (date_views_handler_is_date($handler, 'argument')) {
  232. // If this is the complex Date argument, the date fields are stored in the handler options,
  233. // otherwise we are using the simple date field argument handler.
  234. if ($handler->definition['handler'] != 'date_views_argument_handler') {
  235. $alias = $handler->table_alias . '.' . $handler->field;
  236. $info = $data[$alias];
  237. $field_name = str_replace(array('_value2', '_value'), '', $info['real_field_name']);
  238. $date_fields[$field_name] = $info;
  239. }
  240. else {
  241. foreach ($handler->options['date_fields'] as $alias) {
  242. $info = $data[$alias];
  243. $field_name = str_replace(array('_value2', '_value'), '', $info['real_field_name']);
  244. $date_fields[$field_name] = $info;
  245. }
  246. }
  247. $this->date_argument = $handler;
  248. $this->date_fields = $date_fields;
  249. }
  250. }
  251. // Get the language for this view.
  252. $this->language = $this->display->handler->get_option('field_language');
  253. $substitutions = views_views_query_substitutions($this->view);
  254. if (array_key_exists($this->language, $substitutions)) {
  255. $this->language = $substitutions[$this->language];
  256. }
  257. }
  258. function render($row) {
  259. global $base_url;
  260. $rows = array();
  261. $date_info = $this->date_argument->view->date_info;
  262. $nid = $row->{$this->field_alias};
  263. if (!is_numeric($nid)) {
  264. return $rows;
  265. }
  266. // There could be more than one date field in a view
  267. // so iterate through all of them to find the right values
  268. // for this view result.
  269. foreach ($this->date_fields as $field_name => $info) {
  270. // Load the specified node:
  271. // We have to clone this or nodes on other views on this page,
  272. // like an Upcoming block on the same page as a calendar view,
  273. // will end up acquiring the values we set here.
  274. $node = clone($this->nodes[$nid]);
  275. if (empty($node)) {
  276. return $rows;
  277. }
  278. $table_name = $info['table_name'];
  279. $delta_field = $info['delta_field'];
  280. $tz_handling = $info['tz_handling'];
  281. $tz_field = $info['timezone_field'];
  282. $rrule_field = $info['rrule_field'];
  283. $is_field = $info['is_field'];
  284. // Retrieve the field value that matched our query from the cached node.
  285. // Find the date and set it to the right timezone.
  286. $node->date_id = array();
  287. $item_start_date = NULL;
  288. $item_end_date = NULL;
  289. $granularity = 'second';
  290. $increment = 1;
  291. if ($is_field) {
  292. $delta = isset($row->$delta_field) ? $row->$delta_field : 0;
  293. $items = field_get_items('node', $node, $field_name, $this->language);
  294. $item = $items[$delta];
  295. $db_tz = date_get_timezone_db($tz_handling, isset($item->$tz_field) ? $item->$tz_field : $date_info->display_timezone_name);
  296. $to_zone = date_get_timezone($tz_handling, isset($item->$tz_field) ? $item->$tz_field : $date_info->display_timezone_name);
  297. // Set the date_id for the node, used to identify which field value to display for
  298. // fields that have multiple values. The theme expects it to be an array.
  299. $node->date_id = array('calendar.' . $node->nid . '.' . $field_name . '.' . $delta);
  300. if (!empty($item['value'])) {
  301. $item_start_date = new dateObject($item['value'], $db_tz);
  302. $item_end_date = array_key_exists('value2', $item) ? new dateObject($item['value2'], $db_tz) : $item_start_date;
  303. }
  304. $cck_field = field_info_field($field_name);
  305. $instance = field_info_instance($this->view->base_table, $field_name, $node->type);
  306. $granularity = date_granularity_precision($cck_field['settings']['granularity']);
  307. $increment = $instance['widget']['settings']['increment'];
  308. }
  309. elseif (!empty($node->$field_name)) {
  310. $item = $node->$field_name;
  311. $db_tz = date_get_timezone_db($tz_handling, isset($item->$tz_field) ? $item->$tz_field : $date_info->display_timezone_name);
  312. $to_zone = date_get_timezone($tz_handling, isset($item->$tz_field) ? $item->$tz_field : $date_info->display_timezone_name);
  313. $item_start_date = new dateObject($item, $db_tz);
  314. $item_end_date = $item_start_date;
  315. $node->date_id = array('calendar.' . $node->nid . '.' . $field_name . '.0');
  316. }
  317. // If we don't have date value, go no further.
  318. if (empty($item_start_date)) {
  319. continue;
  320. }
  321. // Set the item date to the proper display timezone;
  322. $item_start_date->setTimezone(new dateTimezone($to_zone));
  323. $item_end_date->setTimezone(new dateTimezone($to_zone));
  324. $event = new stdClass();
  325. $event->nid = $node->nid;
  326. $event->title = $node->title;
  327. $event->type = $node->type;
  328. $event->date_start = $item_start_date;
  329. $event->date_end = $item_end_date;
  330. $event->db_tz = $db_tz;
  331. $event->to_zone = $to_zone;
  332. $event->granularity = $granularity;
  333. $event->increment = $increment;
  334. $event->field = $is_field ? $item : NULL;
  335. $event->row = $row;
  336. $event->node = $node;
  337. // All calendar row plugins should provide a date_id that the theme can use.
  338. $event->date_id = $node->date_id[0];
  339. $nodes = $this->explode_values($event);
  340. foreach ($nodes as $node) {
  341. switch ($this->options['colors']['legend']) {
  342. case 'type':
  343. $this->calendar_node_type_stripe($node);
  344. break;
  345. case 'taxonomy':
  346. $this->calendar_node_taxonomy_stripe($node);
  347. break;
  348. case 'group':
  349. $this->calendar_node_group_stripe($node);
  350. break;
  351. }
  352. $rows[] = $node;
  353. }
  354. }
  355. return $rows;
  356. }
  357. function explode_values($event) {
  358. $rows = array();
  359. $date_info = $this->date_argument->view->date_info;
  360. $item_start_date = $event->date_start;
  361. $item_end_date = $event->date_end;
  362. $to_zone = $event->to_zone;
  363. $db_tz = $event->db_tz;
  364. $granularity = $event->granularity;
  365. $increment = $event->increment;
  366. // Now that we have a 'node' for each view result, we need
  367. // to remove anything outside the view date range,
  368. // and possibly create additional nodes so that we have a 'node'
  369. // for each day that this item occupies in this view.
  370. $now = max($date_info->min_zone_string, $item_start_date->format(DATE_FORMAT_DATE));
  371. $to = min($date_info->max_zone_string, $item_end_date->format(DATE_FORMAT_DATE));
  372. $next = new DateObject($now . ' 00:00:00', $date_info->display_timezone);
  373. if ($date_info->display_timezone_name != $to_zone) {
  374. // Make $start and $end (derived from $node) use the timezone $to_zone, just as the original dates do.
  375. date_timezone_set($next, timezone_open($to_zone));
  376. }
  377. if (empty($to) || $now > $to) {
  378. $to = $now;
  379. }
  380. // $now and $next are midnight (in display timezone) on the first day where node will occur.
  381. // $to is midnight on the last day where node will occur.
  382. // All three were limited by the min-max date range of the view.
  383. $pos = 0;
  384. while (!empty($now) && $now <= $to) {
  385. $node = clone($event);
  386. $node->url = url('node/' . $node->nid, array('absolute' => TRUE));
  387. // Get start and end of current day.
  388. $start = $next->format(DATE_FORMAT_DATETIME);
  389. date_modify($next, '+1 day');
  390. date_modify($next, '-1 second');
  391. $end = $next->format(DATE_FORMAT_DATETIME);
  392. // Get start and end of item, formatted the same way.
  393. $item_start = $item_start_date->format(DATE_FORMAT_DATETIME);
  394. $item_end = $item_end_date->format(DATE_FORMAT_DATETIME);
  395. // Get intersection of current day and the node value's duration (as strings in $to_zone timezone).
  396. $node->calendar_start = $item_start < $start ? $start : $item_start;
  397. $node->calendar_end = !empty($item_end) ? ($item_end > $end ? $end : $item_end) : $node->calendar_start;
  398. // Make date objects
  399. $node->calendar_start_date = date_create($node->calendar_start, timezone_open($to_zone));
  400. $node->calendar_end_date = date_create($node->calendar_end, timezone_open($to_zone));
  401. // Change string timezones into
  402. // calendar_start and calendar_end are UTC dates as formatted strings
  403. $node->calendar_start = date_format($node->calendar_start_date, DATE_FORMAT_DATETIME);
  404. $node->calendar_end = date_format($node->calendar_end_date, DATE_FORMAT_DATETIME);
  405. $node->calendar_all_day = date_is_all_day($node->calendar_start, $node->calendar_end, $granularity, $increment);
  406. unset($node->calendar_fields);
  407. if (isset($node) && (empty($node->calendar_start))) {
  408. // if no date for the node and no date in the item
  409. // there is no way to display it on the calendar
  410. unset($node);
  411. }
  412. else {
  413. $node->date_id .= '.' . $pos;
  414. $rows[] = $node;
  415. unset($node);
  416. }
  417. date_modify($next, '+1 second');
  418. $now = date_format($next, DATE_FORMAT_DATE);
  419. $pos++;
  420. }
  421. return $rows;
  422. }
  423. /**
  424. * Create a stripe base on node type.
  425. */
  426. function calendar_node_type_stripe(&$node) {
  427. $colors = isset($this->options['colors']['calendar_colors_type']) ? $this->options['colors']['calendar_colors_type'] : array();
  428. if (empty($colors)) {
  429. return;
  430. }
  431. if (empty($node->type)) {
  432. return;
  433. }
  434. $type_names = node_type_get_names();
  435. $type = $node->type;
  436. if (!(isset($node->stripe))) {
  437. $node->stripe = array();
  438. $node->stripe_label = array();
  439. }
  440. if (array_key_exists($type, $type_names)) {
  441. $label = $type_names[$type];
  442. }
  443. if (array_key_exists($type, $colors)) {
  444. $stripe = $colors[$type];
  445. }
  446. else {
  447. $stripe = '';
  448. }
  449. $node->stripe[] = $stripe;
  450. $node->stripe_label[] = $label;
  451. return $stripe;
  452. }
  453. /**
  454. * Create a stripe based on a taxonomy term.
  455. */
  456. function calendar_node_taxonomy_stripe(&$event) {
  457. $term_colors = isset($this->options['colors']['calendar_colors_taxonomy']) ? $this->options['colors']['calendar_colors_taxonomy'] : array();
  458. if (empty($term_colors)) {
  459. return;
  460. }
  461. $node = $event->node;
  462. $terms = array();
  463. if ($this->options['colors']['legend'] == 'taxonomy') {
  464. $term_field_name = $this->options['colors']['taxonomy_field'];
  465. if ($term_field = field_get_items('node', $node, $term_field_name)) {
  466. foreach ($term_field as $delta => $items) {
  467. foreach ($items as $item) {
  468. $terms[] = $item['tid'];
  469. }
  470. }
  471. }
  472. }
  473. if (empty($terms)) {
  474. return;
  475. }
  476. if (!(isset($event->stripe))) {
  477. $event->stripe = array();
  478. $event->stripe_label = array();
  479. }
  480. if (count($terms)) {
  481. foreach ($terms as $tid) {
  482. $term_for_node = taxonomy_term_load($tid);
  483. if (!array_key_exists($term_for_node->tid, $term_colors)) {
  484. continue;
  485. }
  486. $stripe = $term_colors[$term_for_node->tid];
  487. $stripe_label = $term_for_node->name;
  488. $event->stripe[] = $stripe;
  489. $event->stripe_label[] = $stripe_label;
  490. }
  491. }
  492. else {
  493. $event->stripe[] = '';
  494. $event->stripe_label[] = '';
  495. }
  496. return;
  497. }
  498. /**
  499. * Create a stripe based on group.
  500. */
  501. function calendar_node_group_stripe(&$node) {
  502. $colors_group = isset($this->options['colors']['calendar_colors_group']) ? $this->options['colors']['calendar_colors_group'] : array();
  503. if (empty($colors_group)) {
  504. return;
  505. }
  506. if (!function_exists('og_get_entity_groups')) {
  507. return;
  508. }
  509. $groups_for_node = og_get_entity_groups('node', $node);
  510. if (!(isset($node->stripe))) {
  511. $node->stripe = array();
  512. $node->stripe_label = array();
  513. }
  514. if (count($groups_for_node)) {
  515. foreach ($groups_for_node as $gid => $group_name) {
  516. if (!array_key_exists($gid, $colors_group)) {
  517. continue;
  518. }
  519. $stripe = $colors_group[$gid];
  520. $stripe_label = $group_name;
  521. $node->stripe[] = $stripe;
  522. $node->stripe_label[] = $stripe_label;
  523. }
  524. }
  525. else {
  526. $node->stripe[] = '';
  527. $node->stripe_label[] = '';
  528. }
  529. return;
  530. }
  531. }