function calendar_build_week in Calendar 5.2
Same name and namespace in other branches
- 6.2 includes/calendar.inc \calendar_build_week()
- 6.2 calendar_multiday/includes/calendar.inc \calendar_build_week()
- 7 includes/calendar.inc \calendar_build_week()
- 7 calendar_multiday/includes/calendar.inc \calendar_build_week()
- 7.2 includes/calendar.inc \calendar_build_week()
- 7.2 calendar_multiday/includes/calendar.inc \calendar_build_week()
Build one week row.
2 calls to calendar_build_week()
- calendar_build_calendar in ./
calendar.inc - Build calendar
- calendar_build_month in ./
calendar.inc - Build one month.
File
- ./
calendar.inc, line 280 - All the code used while processing a calendar is stored in this file and is included only when needed.
Code
function calendar_build_week(&$curday, $view, $items, $params, $check_month = FALSE) {
$curday_date = date_format($curday, DATE_FORMAT_DATE);
$weekdays = calendar_untranslated_days($results, $view);
$today = date_format(date_now(date_default_timezone_name()), DATE_FORMAT_DATE);
$month = date_format($curday, 'n');
$week = date_week($curday_date);
$first_day = variable_get('date_first_day', 0);
// move backwards to the first day of the week
$day_wday = date_format($curday, 'w');
date_modify($curday, '-' . strval((7 + $day_wday - $first_day) % 7) . ' days');
$curday_date = date_format($curday, DATE_FORMAT_DATE);
// If we're displaying the week number, add it as the
// first cell in the week.
$display_formats = calendar_get_formats($view);
if ($params['with_weekno'] && $view->calendar_type != 'day') {
if (!empty($display_formats['week'])) {
if ($view->build_type == 'embed') {
$url = $view->page_url . '/' . $view->year . '/W' . $week;
$block_identifier = isset($view->block_identifier) ? $view->block_identifier : 'mini';
$query_string = (!empty($params['append']) ? $params['append'] . '&' : '') . $block_identifier . '=' . $view->real_path . '/' . $view->year . '/W' . $week;
}
else {
$url = $view->real_url . '/' . $view->year . '/W' . $week;
$query_string = $params['append'];
}
$weekno = l($week, $url, NULL, $query_string);
}
else {
// Do not link week numbers, if Week views are disabled.
$weekno = $week;
}
$rows[$week][] = array(
'data' => $weekno,
'class' => 'week',
);
}
for ($i = 0; $i < 7; $i++) {
$curday_date = date_format($curday, DATE_FORMAT_DATE);
$class = strtolower($weekdays[$i] . ($view->mini ? ' mini' : ''));
if ($check_month && ($curday_date < $view->min_date_date || $curday_date > $view->max_date_date || date_format($curday, 'n') != $month)) {
$class .= ' empty';
$content = theme('calendar_empty_day');
}
else {
$content = calendar_build_day($curday, $view, $items, $params);
$class .= ($curday_date == $today ? ' today' : '') . ($curday_date < $today ? ' past' : '') . ($curday_date > $today ? ' future' : '');
}
$rows[$week][] = array(
'data' => $view->mini ? $content : '<div class="inner">' . $content . '</div>',
'class' => $class,
'id' => $view->name . '-' . $curday_date,
);
date_modify($curday, '+1 day');
}
return $rows;
}