From c079e3fc575fa311154945b8f313275532c2e22d Mon Sep 17 00:00:00 2001 From: Manuel Cillero Date: Wed, 26 Jul 2017 20:08:33 +0200 Subject: [PATCH] Solved a display problem with events --- .../calendar_multiday/theme/theme.inc | 63 +++++++++++-------- 1 file changed, 37 insertions(+), 26 deletions(-) diff --git a/sites/all/modules/calendar/calendar_multiday/theme/theme.inc b/sites/all/modules/calendar/calendar_multiday/theme/theme.inc index b776d9f..16db441 100644 --- a/sites/all/modules/calendar/calendar_multiday/theme/theme.inc +++ b/sites/all/modules/calendar/calendar_multiday/theme/theme.inc @@ -36,6 +36,9 @@ function template_preprocess_calendar_main(&$vars) { else { $current_date = date_make_date($view->date_info->year .'-01-01 00:00:00'); } + $ww = date_day_of_week($vars['min_date_formatted'], DATE_ISO); + $ww = variable_get('date_first_day', 1) ? ($ww == 0 ? 6 : $ww - 1) : $ww; + $week_date = date('Y-m-d', strtotime("-$ww days", strtotime($vars['min_date_formatted']))); if (empty($view->date_info->month) || $view->date_info->month == $view->argument['date_argument']->options['wildcard']) { $view->date_info->month = date_format($current_date, 'm'); } @@ -43,7 +46,8 @@ function template_preprocess_calendar_main(&$vars) { $view->date_info->day = date_format($current_date, 'd'); } if (empty($view->date_info->week) || $view->date_info->week == $view->argument['date_argument']->options['wildcard']) { - $view->date_info->week = date_week($view->date_info->year .'-'. date_pad($view->date_info->month) .'-'. date_pad($view->date_info->day)); + $view->date_info->week = date_week(date_pad(date_part_extract($week_date, 'year'), 4) .'-'. date_part_extract($week_date, 'month') .'-'. date_part_extract($week_date, 'day')); +# $view->date_info->week = date_week($view->date_info->year .'-'. date_pad($view->date_info->month) .'-'. date_pad($view->date_info->day)); } $calendar_links = array(); @@ -55,7 +59,10 @@ function template_preprocess_calendar_main(&$vars) { $calendar_links[] = $base + array('title' => date_t('Month', 'datetime'), 'href' => date_real_url($view, 'month')); } if (!empty($displays['week'])) { + $wy = $view->date_info->year; + $view->date_info->year = date_pad(date_part_extract($week_date, 'year'), 4); $calendar_links[] = $base + array('title' => date_t('Week', 'datetime'), 'href' => date_real_url($view, 'week')); + $view->date_info->year = $wy; } if (!empty($displays['day'])) { $calendar_links[] = $base + array('title' => date_t('Day', 'datetime'), 'href' => date_real_url($view, 'day')); @@ -196,31 +203,34 @@ function template_preprocess_calendar_month(&$vars) { $month_rows = $rows; foreach ($rows as $weekno => $row) { - foreach ($row as $day => $data) { - $cell = $data['data']; - - // If this cell is already rendered, like the weekno column, - // move to the next item. - if (!is_array($cell)) { - $month_rows[$weekno][$day]['data'] = $cell; - continue; - } - $data = $cell['datebox']; - if ($cell['empty']) { - $data .= $cell['empty']; - } - else { - $data .= implode($cell['all_day']); - foreach ($cell['items'] as $hour => $item) { - $data .= implode($item); + // If this row is already rendered, don't do anything. + if (!isset($row['data'])) { + foreach ($row as $day => $data) { + $cell = $data['data']; + + // If this cell is already rendered, like the weekno column, + // move to the next item. + if (!is_array($cell)) { + $month_rows[$weekno][$day]['data'] = $cell; + continue; + } + $data = $cell['datebox']; + if ($cell['empty']) { + $data .= $cell['empty']; + } + else { + $data .= implode($cell['all_day']); + foreach ($cell['items'] as $hour => $item) { + $data .= implode($item); + } + $data .= $cell['link']; + } + if ($view->date_info->mini) { + $month_rows[$weekno][$day]['data'] = $data; + } + else { + $month_rows[$weekno][$day]['data'] = '
' . $data . '
'; } - $data .= $cell['link']; - } - if ($view->date_info->mini) { - $month_rows[$weekno][$day]['data'] = $data; - } - else { - $month_rows[$weekno][$day]['data'] = '
'. $data .'
'; } } } @@ -904,7 +914,8 @@ function _calc_indents(&$overlapped_items, $start, $end, &$item, $depth = 0) { } // No, child overlap, so check if we overlap this item - if ($start >= $entry['start'] && $start <= $entry['end']) { +# if ($start >= $entry['start'] && $start <= $entry['end']) { + if ($start >= $entry['start'] && $start < $entry['end']) { // We overlap, create an overlapping entry $entry['children'][] = array('item' => &$item, 'depth' => $depth + 1, 'start' => $start, 'end' => $end, 'children' => array());