From 72eeb54d5641ae0ac62edc36f1981c1771f0ca90 Mon Sep 17 00:00:00 2001 From: Oleg Chemerys Date: Fri, 19 Jun 2015 14:52:08 +0300 Subject: [PATCH 1/2] Issue #1264520: Fixed displaying multi-day items as a single column on week view. --- theme/calendar-week.tpl.php | 31 ++++++++++++++++--------------- theme/theme.inc | 15 +++++++++------ 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/theme/calendar-week.tpl.php b/theme/calendar-week.tpl.php index e0ae61c..3f00756 100644 --- a/theme/calendar-week.tpl.php +++ b/theme/calendar-week.tpl.php @@ -2,12 +2,12 @@ /** * @file * Template to display a view as a calendar week. - * + * * @see template_preprocess_calendar_week. * * $day_names: An array of the day of week names for the table header. * $rows: The rendered data for this week. - * + * * For each day of the week, you have: * $rows['date'] - the date for this day, formatted as YYYY-MM-DD. * $rows['datebox'] - the formatted datebox for this day. @@ -17,11 +17,11 @@ * $rows['items'][$time_period]['hour'] - the formatted hour for a time period. * $rows['items'][$time_period]['ampm'] - the formatted ampm value, if any for a time period. * $rows['items'][$time_period]['values'] - An array of formatted items for a time period. - * + * * $view: The view. * $min_date_formatted: The minimum date for this calendar in the format YYYY-MM-DD HH:MM:SS. * $max_date_formatted: The maximum date for this calendar in the format YYYY-MM-DD HH:MM:SS. - * + * */ //dsm('Display: '. $display_type .': '. $min_date_formatted .' to '. $max_date_formatted); //dsm($rows); @@ -48,8 +48,8 @@ foreach ($day_names as $key => $value) { - $value) { 'datetime'))?> - + + is_multi_day) ? 'single-day' : 'multi-day' ?> -
 
+
 
- +
- +
 
- + @@ -97,7 +98,7 @@ foreach ($day_names as $key => $value) {
 
- +
@@ -110,16 +111,16 @@ foreach ($day_names as $key => $value) {
- +
 
- + - + diff --git a/theme/theme.inc b/theme/theme.inc index 82fb5fb..66d1af5 100644 --- a/theme/theme.inc +++ b/theme/theme.inc @@ -395,18 +395,21 @@ function template_preprocess_calendar_week(&$vars) { // If we're not grouping by time, move all items into the 'all day' array. if (empty($view->date_info->style_groupby_times)) { - $add_row = FALSE; - foreach ($vars['all_day'] as $index => &$day ) { + $rows_numbers = array(); + foreach ($vars['all_day'] as $index => &$day) { foreach ($rows['singleday_buckets'][$index] as $item) { + if (!isset($rows_numbers[$index])) { + $rows_numbers[$index] = count($item); + } + else { + $rows_numbers[$index] += count($item); + } foreach ($item as $event) { $day[] = $event; - $add_row = TRUE; } } } - if ( $add_row ) { - $vars['multiday_rows']++; - } + $vars['multiday_rows'] = max($rows_numbers); } else { foreach ($rows['singleday_buckets'] as $wday => $singleday_row) { -- 1.8.0.msysgit.0 From 90387a9be9a57147fd051a44f036315b94372aaf Mon Sep 17 00:00:00 2001 From: Oleg Chemerys Date: Mon, 22 Jun 2015 14:19:03 +0300 Subject: [PATCH 2/2] Added content empty check to prevent error on weeks with no events. --- theme/theme.inc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/theme/theme.inc b/theme/theme.inc index 66d1af5..ad21cba 100644 --- a/theme/theme.inc +++ b/theme/theme.inc @@ -409,7 +409,9 @@ function template_preprocess_calendar_week(&$vars) { } } } - $vars['multiday_rows'] = max($rows_numbers); + if (!empty($rows_numbers)) { + $vars['multiday_rows'] = max($rows_numbers); + } } else { foreach ($rows['singleday_buckets'] as $wday => $singleday_row) { -- 1.8.0.msysgit.0