function event_calendar_month in Event 5.2
Same name and namespace in other branches
- 5 event.module \event_calendar_month()
Displays a monthly event calendar.
Return value
a themed monthly event calendar.
Related topics
2 calls to event_calendar_month()
- event_block in ./
event.module - Provides the blocks that this module is capable of displaying.
- event_page in ./
event.module - Displays a page containing event information. The page layout defaults to a graphical calendar.
File
- ./
event.module, line 513
Code
function event_calendar_month($op, $date, $types = NULL, $terms = NULL, $rewrite_parameter = array()) {
$year = $date['year'];
$month = $date['month'];
$day = $date['day'];
switch ($op) {
case 'page':
// setup callback for data population
$callback = 'event_render_day';
$view = 'month';
break;
case 'block':
// create caption and navigation links
$caption = _event_nav($date, 'prev', 'block', $types, $terms) . ' ' . l(event_format_date($date, 'custom', t('F Y')), 'event/' . _event_format_url($date) . '/month') . ' ' . _event_nav($date, 'next', 'block', $types, $terms);
$callback = 'event_render_day_single';
$view = 'block';
break;
}
event_calendar_data($date, $view, $types, $terms, 'prepopulate', array(), $rewrite_parameter);
// get weekdays array and header information
$weekdays = event_week_days();
$thead = event_week_header();
$tbody = array();
// get GMT current date value
$today = _event_user_date();
// name of the month
$month_name = event_format_date($date, 'custom', 'F');
// date of first day of month
$cur_date = $date;
$cur_date['day'] = '01';
// last day in month
$last_date = $date;
$last_date['day'] = date('t', mktime(0, 0, 0, $date['month'], 1, $date['year']));
// pad the first week row array to fill up days in the previous month we don't build
$row = array_fill(0, 6, array(
'class' => 'pad',
));
// get the day of week offset value for the first day of the month
$start = $offset = _event_day_of_week($cur_date);
// render the month calendar
while (event_is_later($last_date, $cur_date)) {
$week = 0;
for ($x = $start; $x < 7 && event_is_later($last_date, $cur_date); $x++) {
$cur_day = $week * 7 + ($x + 1) - $offset;
$row[$x] = array(
'class' => strtolower($weekdays[$x]['day']) . ' day-' . $cur_date['day'] . ($cur_date == $today ? ' today' : '') . ($cur_date['day'] == $day ? ' selected' : ''),
'data' => $callback($cur_date, $view, $types, $terms, $rewrite_parameter),
);
$cur_date = event_date_later($cur_date, 1);
}
$week++;
$start = 0;
$tbody[] = array_pad($row, 7, array(
'class' => 'pad',
));
$row = array();
}
switch ($op) {
case 'page':
return array(
$thead,
$tbody,
);
break;
case 'block':
return theme('event_calendar_month', $op, $thead, $tbody, $attributes = array(
'class' => 'event-block ' . strtolower($month_name),
), $caption);
break;
}
}