Solved a display problem with events

This commit is contained in:
Manuel Cillero 2017-07-26 20:08:33 +02:00
parent c9c9965367
commit c079e3fc57

View file

@ -36,6 +36,9 @@ function template_preprocess_calendar_main(&$vars) {
else { else {
$current_date = date_make_date($view->date_info->year .'-01-01 00:00:00'); $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']) { 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'); $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'); $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']) { 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(); $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')); $calendar_links[] = $base + array('title' => date_t('Month', 'datetime'), 'href' => date_real_url($view, 'month'));
} }
if (!empty($displays['week'])) { 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')); $calendar_links[] = $base + array('title' => date_t('Week', 'datetime'), 'href' => date_real_url($view, 'week'));
$view->date_info->year = $wy;
} }
if (!empty($displays['day'])) { if (!empty($displays['day'])) {
$calendar_links[] = $base + array('title' => date_t('Day', 'datetime'), 'href' => date_real_url($view, '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; $month_rows = $rows;
foreach ($rows as $weekno => $row) { foreach ($rows as $weekno => $row) {
foreach ($row as $day => $data) { // If this row is already rendered, don't do anything.
$cell = $data['data']; if (!isset($row['data'])) {
foreach ($row as $day => $data) {
$cell = $data['data'];
// If this cell is already rendered, like the weekno column, // If this cell is already rendered, like the weekno column,
// move to the next item. // move to the next item.
if (!is_array($cell)) { if (!is_array($cell)) {
$month_rows[$weekno][$day]['data'] = $cell; $month_rows[$weekno][$day]['data'] = $cell;
continue; continue;
} }
$data = $cell['datebox']; $data = $cell['datebox'];
if ($cell['empty']) { if ($cell['empty']) {
$data .= $cell['empty']; $data .= $cell['empty'];
} }
else { else {
$data .= implode($cell['all_day']); $data .= implode($cell['all_day']);
foreach ($cell['items'] as $hour => $item) { foreach ($cell['items'] as $hour => $item) {
$data .= implode($item); $data .= implode($item);
}
$data .= $cell['link'];
}
if ($view->date_info->mini) {
$month_rows[$weekno][$day]['data'] = $data;
}
else {
$month_rows[$weekno][$day]['data'] = '<div class="inner">' . $data . '</div>';
} }
$data .= $cell['link'];
}
if ($view->date_info->mini) {
$month_rows[$weekno][$day]['data'] = $data;
}
else {
$month_rows[$weekno][$day]['data'] = '<div class="inner">'. $data .'</div>';
} }
} }
} }
@ -904,7 +914,8 @@ function _calc_indents(&$overlapped_items, $start, $end, &$item, $depth = 0) {
} }
// No, child overlap, so check if we overlap this item // 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 // We overlap, create an overlapping entry
$entry['children'][] = array('item' => &$item, 'depth' => $depth + 1, 'start' => $start, 'end' => $end, 'children' => array()); $entry['children'][] = array('item' => &$item, 'depth' => $depth + 1, 'start' => $start, 'end' => $end, 'children' => array());