Révision 62e0cc08
Ajouté par Assos Assos il y a plus de 3 ans
drupal7/sites/all/modules/calendar/theme/theme.inc | ||
---|---|---|
6 | 6 |
*/ |
7 | 7 |
|
8 | 8 |
/** |
9 |
* Preprocess an RSS feed |
|
9 |
* Preprocess an RSS feed.
|
|
10 | 10 |
*/ |
11 | 11 |
function template_preprocess_calendar_style(&$vars) { |
12 | 12 |
global $base_url; |
13 | 13 |
global $language; |
14 |
|
|
15 | 14 |
} |
16 | 15 |
|
17 | 16 |
/** |
... | ... | |
24 | 23 |
$rows = array(); |
25 | 24 |
$day_names = array(); |
26 | 25 |
} |
27 |
elseif (sizeof($rows) > 1) {
|
|
26 |
elseif (count($rows) > 1) {
|
|
28 | 27 |
$day_names = array_shift($rows); |
29 | 28 |
} |
30 | 29 |
else { |
... | ... | |
85 | 84 |
|
86 | 85 |
// Make sure that the calendar title links go to the month view, |
87 | 86 |
// not the year view (if this is embedded in a year display). |
88 |
$view->override_path = calendar_granularity_path($view, 'month');
|
|
87 |
$view->override_path = calendar_granularity_path($view, 'month'); |
|
89 | 88 |
|
90 | 89 |
$view->date_info->show_title = !empty($view->date_info->show_title) ? $view->date_info->show_title : FALSE; |
91 | 90 |
$vars['show_title'] = $view->date_info->show_title; |
... | ... | |
152 | 151 |
$display_overlap = !empty($view->date_info->style_theme_style) && !empty($view->date_info->style_groupby_times); |
153 | 152 |
$vars['scroll_content'] = !empty($view->date_info->style_theme_style) && $view->date_info->style_theme_style == 1; |
154 | 153 |
|
155 |
// Add optional css |
|
154 |
// Add optional css.
|
|
156 | 155 |
if ($display_overlap) { |
157 | 156 |
$overlapped_items = array(); |
158 | 157 |
drupal_add_css(drupal_get_path('module', 'calendar') . '/css/calendar-overlap.css'); |
... | ... | |
269 | 268 |
$group_time = NULL; |
270 | 269 |
$divisor = NULL; |
271 | 270 |
if ($display_overlap) { |
272 |
if ($view->style_options['groupby_times'] == 'half') { |
|
271 |
if ($view->style_plugin->options['groupby_times'] == 'half') {
|
|
273 | 272 |
$group_time = 30; |
274 | 273 |
$divisor = 7.5; |
275 | 274 |
} |
276 |
elseif ($view->style_options['groupby_times'] == 'hour') { |
|
275 |
elseif ($view->style_plugin->options['groupby_times'] == 'hour') {
|
|
277 | 276 |
$group_time = 60; |
278 | 277 |
$divisor = 15; |
279 | 278 |
} |
... | ... | |
310 | 309 |
|
311 | 310 |
$vars['first_column_width'] = $first_column_width; |
312 | 311 |
if (count($columns)) { |
313 |
$vars['column_width'] = round((100 - $first_column_width)/count($columns));
|
|
312 |
$vars['column_width'] = round((100 - $first_column_width) / count($columns));
|
|
314 | 313 |
} |
315 | 314 |
else { |
316 | 315 |
$vars['column_width'] = (100 - $first_column_width); |
... | ... | |
341 | 340 |
$start_time = NULL; |
342 | 341 |
$columns = array(); |
343 | 342 |
|
344 |
if (sizeof($rows) > 1) {
|
|
343 |
if (count($rows) > 1) {
|
|
345 | 344 |
$day_names = array_shift($rows); |
346 | 345 |
} |
347 | 346 |
else { |
... | ... | |
355 | 354 |
|
356 | 355 |
$grouped_items = array(); |
357 | 356 |
|
358 |
// pass the multiday buckets
|
|
357 |
// Pass the multiday buckets.
|
|
359 | 358 |
$vars['all_day'] = $rows['multiday_buckets']; |
360 | 359 |
|
361 |
// Remove the count for singleday |
|
360 |
// Remove the count for singleday.
|
|
362 | 361 |
$vars['multiday_rows'] = max(0, $rows['total_rows'] - 1); |
363 | 362 |
$display_overlap = ($view->date_info->style_multiday_theme == '1' && !empty($view->date_info->style_theme_style)); |
364 | 363 |
$vars['display_overlap'] = $display_overlap; |
365 | 364 |
$vars['scroll_content'] = !empty($view->date_info->style_theme_style) && $view->date_info->style_theme_style == 1; |
366 | 365 |
|
367 |
// Add optional css |
|
366 |
// Add optional css.
|
|
368 | 367 |
if ($display_overlap) { |
369 | 368 |
drupal_add_css(drupal_get_path('module', 'calendar') . '/css/calendar-overlap.css'); |
370 | 369 |
if (empty($view->live_preview) && !empty($vars['scroll_content'])) { |
... | ... | |
373 | 372 |
if (empty($vars['scroll_content'])) { |
374 | 373 |
drupal_add_css(drupal_get_path('module', 'calendar') . '/css/calendar-overlap-no-scroll.css'); |
375 | 374 |
} |
376 |
$overlapped_items = array( array(), array(), array(), array(), array(), array(), array());
|
|
375 |
$overlapped_items = array(array(), array(), array(), array(), array(), array(), array()); |
|
377 | 376 |
|
378 |
// Locate the first item |
|
377 |
// Locate the first item.
|
|
379 | 378 |
$first_time = '23:59:59'; |
380 | 379 |
$first_time_index = -1; |
381 | 380 |
for ($i = 0; $i < 7; $i++) { |
... | ... | |
396 | 395 |
// If we're not grouping by time, move all items into the 'all day' array. |
397 | 396 |
if (empty($view->date_info->style_groupby_times)) { |
398 | 397 |
$add_row = FALSE; |
399 |
foreach ($vars['all_day'] as $index => &$day ) {
|
|
398 |
foreach ($vars['all_day'] as $index => &$day) { |
|
400 | 399 |
foreach ($rows['singleday_buckets'][$index] as $item) { |
401 | 400 |
foreach ($item as $event) { |
402 | 401 |
$day[] = $event; |
... | ... | |
404 | 403 |
} |
405 | 404 |
} |
406 | 405 |
} |
407 |
if ( $add_row ) {
|
|
406 |
if ($add_row) {
|
|
408 | 407 |
$vars['multiday_rows']++; |
409 | 408 |
} |
410 | 409 |
} |
... | ... | |
482 | 481 |
if ($display_overlap) { |
483 | 482 |
$group_time = NULL; |
484 | 483 |
$divisor = NULL; |
485 |
if ($view->style_options['groupby_times'] == 'half'){
|
|
484 |
if ($view->style_plugin->options['groupby_times'] == 'half') {
|
|
486 | 485 |
$group_time = 30; |
487 | 486 |
$divisor = 7.5; |
488 | 487 |
} |
489 |
elseif ($view->style_options['groupby_times'] == 'hour'){
|
|
488 |
elseif ($view->style_plugin->options['groupby_times'] == 'hour') {
|
|
490 | 489 |
$group_time = 60; |
491 | 490 |
$divisor = 15; |
492 | 491 |
} |
... | ... | |
540 | 539 |
else { |
541 | 540 |
foreach ($vars['view']->field as $id => $field) { |
542 | 541 |
if ($field->options['exclude'] || (!empty($item->is_multi_day) && in_array($id, $multiday_hidden))) { |
543 |
unset($vars['rendered_fields'][$field->field]);
|
|
542 |
unset($vars['rendered_fields'][$id]);
|
|
544 | 543 |
} |
545 | 544 |
} |
546 | 545 |
} |
... | ... | |
583 | 582 |
$count = $vars['count']; |
584 | 583 |
$ids = $vars['ids']; |
585 | 584 |
|
586 |
// get the year month and date
|
|
585 |
// Get the year month and date.
|
|
587 | 586 |
$parts = explode('-', substr($curday, 0, 10)); |
588 | 587 |
$year = $parts[0]; |
589 | 588 |
$month = intval($parts[1]); |
590 | 589 |
$day = intval($parts[2]); |
591 | 590 |
|
592 |
// create the link to the day
|
|
591 |
// Create the link to the day.
|
|
593 | 592 |
$month_path = calendar_granularity_path($view, 'month'); |
594 | 593 |
$day_path = calendar_granularity_path($view, 'day'); |
595 | 594 |
$vars['link'] = str_replace($month_path, $day_path, date_pager_url($view, NULL, date_pad($year, 4) . '-' . date_pad($month) . '-' . date_pad($day))); |
... | ... | |
646 | 645 |
} |
647 | 646 |
|
648 | 647 |
/** |
649 |
* Format a node stripe legend |
|
648 |
* Format a node stripe legend.
|
|
650 | 649 |
*/ |
651 | 650 |
function theme_calendar_stripe_legend($vars) { |
652 | 651 |
if (empty($vars) || !$view = $vars['view']) { |
... | ... | |
670 | 669 |
|
671 | 670 |
case 'taxonomy': |
672 | 671 |
$vocabularies = (array) $row_options['colors']['calendar_colors_vocabulary']; |
673 |
$term_colors = $row_options['colors']['calendar_colors_taxonomy']; |
|
674 | 672 |
foreach ($vocabularies as $field_name => $vid) { |
675 | 673 |
$vocab = taxonomy_get_tree($vid); |
676 | 674 |
foreach ($vocab as $key => $term) { |
... | ... | |
704 | 702 |
} |
705 | 703 |
|
706 | 704 |
$header = array( |
707 |
array('class' => 'calendar-legend', 'data' => t('Item')),
|
|
708 |
array('class' => 'calendar-legend', 'data' => t('Key'))
|
|
709 |
);
|
|
705 |
array('class' => 'calendar-legend', 'data' => t('Item')), |
|
706 |
array('class' => 'calendar-legend', 'data' => t('Key')),
|
|
707 |
); |
|
710 | 708 |
|
711 | 709 |
$rows = array(); |
712 | 710 |
$output = ''; |
... | ... | |
730 | 728 |
} |
731 | 729 |
|
732 | 730 |
/** |
733 |
* Format item stripes |
|
731 |
* Format item stripes.
|
|
734 | 732 |
*/ |
735 | 733 |
function theme_calendar_stripe_stripe($vars) { |
736 | 734 |
$item = $vars['item']; |
... | ... | |
749 | 747 |
} |
750 | 748 |
|
751 | 749 |
/** |
752 |
* Format an empty day on a calendar |
|
750 |
* Format an empty day on a calendar.
|
|
753 | 751 |
* |
754 | 752 |
* @param day |
755 | 753 |
* The day to display. |
... | ... | |
767 | 765 |
} |
768 | 766 |
|
769 | 767 |
/** |
770 |
* Indent items based off a nested tree structure of overlapping items |
|
768 |
* Indent items based off a nested tree structure of overlapping items.
|
|
771 | 769 |
* |
772 | 770 |
* @param array $overlapped_items |
773 |
* Tree of overlapped items |
|
771 |
* Tree of overlapped items.
|
|
774 | 772 |
* @param date $start |
775 |
* Start time of the event |
|
773 |
* Start time of the event.
|
|
776 | 774 |
* @param date $end |
777 |
* End tiem of the event
|
|
775 |
* End time of the event.
|
|
778 | 776 |
* @param array $item |
779 |
* The event to add to the tree |
|
777 |
* The event to add to the tree.
|
|
780 | 778 |
* @param int $depth |
781 |
* Current depth of the tree |
|
779 |
* Current depth of the tree. |
|
780 |
* |
|
782 | 781 |
* @return rc |
783 | 782 |
* Returns an array with the max depth of the branch and whether an overlap occurred |
784 | 783 |
*/ |
... | ... | |
787 | 786 |
// Are there any items at this depth? |
788 | 787 |
if (!empty($overlapped_items)) { |
789 | 788 |
|
790 |
// Iterate for each item as this depth and see if we overlap |
|
789 |
// Iterate for each item as this depth and see if we overlap.
|
|
791 | 790 |
foreach ($overlapped_items as $index => &$entry) { |
792 | 791 |
|
793 | 792 |
// We search depth-first, so if there are children for this item, recurse into |
794 |
// each child tree looking for an overlap |
|
793 |
// each child tree looking for an overlap.
|
|
795 | 794 |
if (!empty($entry['children'])) { |
796 | 795 |
$rc = _calc_indents($entry['children'], $start, $end, $item, $depth + 1); |
797 | 796 |
|
... | ... | |
806 | 805 |
$entry['item']['max_depth'] = $rc['max_depth']; |
807 | 806 |
} |
808 | 807 |
|
809 |
// There was an overlap, pop out of this depth |
|
808 |
// There was an overlap, pop out of this depth.
|
|
810 | 809 |
return $rc; |
811 | 810 |
} |
812 | 811 |
} |
813 |
// No, child overlap, so check if we overlap this item |
|
814 |
if ($start >= $entry['start'] && $start < $entry['end']) { |
|
812 |
// No, child overlap, so check if we overlap this item.
|
|
813 |
if ($start >= $entry['start'] && $start <= $entry['end']) {
|
|
815 | 814 |
|
816 |
// We overlap, create an overlapping entry |
|
815 |
// We overlap, create an overlapping entry.
|
|
817 | 816 |
$entry['children'][] = array('item' => &$item, 'depth' => $depth + 1, 'start' => $start, 'end' => $end, 'children' => array()); |
818 | 817 |
if (is_object($entry['item'])) { |
819 | 818 |
$max_depth = max($entry['item']->max_depth, $depth + 1); |
... | ... | |
834 | 833 |
$item['max_depth'] = $max_depth; |
835 | 834 |
} |
836 | 835 |
|
837 |
// We overlap, so pop out of this depth |
|
836 |
// We overlap, so pop out of this depth.
|
|
838 | 837 |
return array('overlap' => TRUE, 'max_depth' => $max_depth); |
839 | 838 |
} |
840 | 839 |
} |
841 | 840 |
|
842 | 841 |
// If there are items at this depth, but no overlap, then return no overlap and pop |
843 |
// out of this depth |
|
842 |
// out of this depth.
|
|
844 | 843 |
if ($depth > 0) { |
845 | 844 |
return array('overlap' => FALSE, 'max_depth' => 0); |
846 | 845 |
} |
847 |
}
|
|
846 |
} |
|
848 | 847 |
|
849 |
// No overlap at any depth, reset the array of overlaps |
|
848 |
// No overlap at any depth, reset the array of overlaps.
|
|
850 | 849 |
if ($depth == 0) { |
851 |
reset($overlapped_items); |
|
852 |
$overlapped_items[0] = array('item' => &$item, 'depth' => $depth, 'start' => $start, 'end' => $end, 'children' => array()); |
|
850 |
reset($overlapped_items);
|
|
851 |
$overlapped_items[0] = array('item' => &$item, 'depth' => $depth, 'start' => $start, 'end' => $end, 'children' => array());
|
|
853 | 852 |
} |
854 | 853 |
else { |
855 | 854 |
$overlapped_items[] = array('item' => &$item, 'depth' => $depth, 'start' => $start, 'end' => $end, 'children' => array()); |
... | ... | |
867 | 866 |
} |
868 | 867 |
|
869 | 868 |
/** |
870 |
* Calculates the indent based of the current depth and the depth of this branch in the tree |
|
869 |
* Calculates the indent based of the current depth and the depth of this branch in the tree.
|
|
871 | 870 |
* |
872 | 871 |
* @param int $cur_depth |
873 | 872 |
* @param int $depth |
874 |
* @return number |
|
873 |
* |
|
874 |
* @return int |
|
875 | 875 |
*/ |
876 |
function _calc_indent( $cur_depth, $depth ) {
|
|
876 |
function _calc_indent($cur_depth, $depth) {
|
|
877 | 877 |
return round(10 * $cur_depth / ($depth + 1)); |
878 | 878 |
} |
879 | 879 |
|
880 |
/** @} End of addtogroup themeable */ |
|
880 |
/** |
|
881 |
* @} End of addtogroup themeable */ |
Formats disponibles : Unified diff
Weekly update of contrib modules