function event_page in Event 5.2
Same name and namespace in other branches
- 5 event.module \event_page()
Displays a page containing event information. The page layout defaults to a graphical calendar.
Return value
the content for the event page.
Related topics
1 string reference to 'event_page'
- event_menu in ./
event.module - Implementation of hook_menu()
File
- ./
event.module, line 298
Code
function event_page($year = NULL, $month = NULL, $day = NULL, $view = NULL, $types = NULL, $tids = NULL, $duration = NULL) {
event_include_files();
// get local date value
$now = _event_user_date();
// date values
$year = isset($year) && is_numeric($year) ? $year : $now['year'];
$month = isset($month) && is_numeric($month) ? $month : $now['month'];
$day = isset($day) && is_numeric($day) ? $day : $now['day'];
$date = $now;
$date['year'] = $year;
$date['month'] = $month;
$date['day'] = $day;
$view = $view ? $view : variable_get('event_overview', 'month');
if (isset($_POST['event_type_select'])) {
drupal_goto('event/' . $year . '/' . $month . '/' . $day . '/' . $view . '/' . check_plain($_POST['event_type_select']) . '/' . $tids . '/' . check_plain($duration));
}
if (isset($_POST['event_term_select'])) {
drupal_goto('event/' . $year . '/' . $month . '/' . $day . '/' . $view . '/' . ($types ? $types : 'all') . '/' . check_plain($_POST['event_term_select']) . '/' . check_plain($duration));
}
$breadcrumbs[] = l(t('Home'), NULL);
$breadcrumbs[] = l(t('Events'), 'event');
$links = array();
if ($types) {
// The '+' character in a query string may be parsed as ' '.
$types = preg_split('/[+ ]/', $types);
foreach ($types as $type) {
if ($name = node_get_types('name', $type)) {
$x = module_invoke($type, 'node_name', $node);
$temp[$x] = $type;
$filter[] = module_invoke($type, 'node_name', $node);
}
}
if (is_array($filter)) {
$links['event_all'] = array(
'title' => t('View all'),
'href' => 'event/' . $year . '/' . $month . '/' . $day . '/' . $view . '/',
);
$title = t('Filter') . ': ' . implode(', ', $filter);
$types = $temp;
}
else {
$types = null;
}
}
$terms = null;
if ($tids && $tids != 'all') {
$links['event_all'] = array(
'title' => t('View all'),
'href' => 'event/' . $year . '/' . $month . '/' . $day . '/day',
);
if (preg_match('/^([0-9]+[+ ])+[0-9]+$/', $tids)) {
// The '+' character in a query string may be parsed as ' '.
$terms = preg_split('/[+ ]/', $tids);
}
else {
if (preg_match('/^([0-9]+,)*[0-9]+$/', $tids)) {
$terms = explode(',', $tids);
}
}
}
// add taxonomy filter controls to top of calendar
if (variable_get('event_taxonomy_control', 'all') == 'all' || variable_get('event_taxonomy_control', 'all') == 'request' && isset($terms)) {
$output .= _event_get_taxonomy_control($terms);
}
// add content type filter controls to top of calendar
if (variable_get('event_type_control', 'all') == 'all' || variable_get('event_type_control', 'all') == 'request' && isset($types)) {
$output .= _event_get_type_control($types);
}
switch ($view) {
case 'day':
// day view
$caption = event_format_date($date, 'custom', t('l F d, Y'));
list($thead, $tbody) = event_calendar_day('page', $date, $types, $terms);
break;
case 'week':
// week view
// setup calendar table header
$dow = _event_day_of_week($date);
$temp = event_format_date(event_date_later($date, -1 * $dow), 'custom', 'F-j-Y');
$temp = explode('-', $temp);
$caption = t('Week of !month !day, !year', array(
'!month' => $temp[0],
'!day' => $temp[1],
'!year' => $temp[2],
));
$colspan = 5;
list($thead, $tbody) = event_calendar_week('page', $date, $types, $terms);
break;
case 'month':
// month view
$caption = event_format_date($date, 'custom', t('F Y'));
$colspan = 5;
list($thead, $tbody) = event_calendar_month('page', $date, $types, $terms);
break;
case 'table':
// table view
// next 30 day view, $duration can be set for different ranges
// but set a maximum $duration of 1 year.
$duration = $duration && $duration <= 366 ? $duration : variable_get('event_table_duration', '30');
$end_date = event_date_later($date, $duration);
$caption = event_format_date($date, 'custom', 'F d Y') . ' - ' . event_format_date($end_date, 'custom', 'F d Y');
list($thead, $tbody) = event_calendar_table('page', $date, $end_date, $types, $terms);
break;
case 'list':
// list view
// next 30 day view, $duration can be set for different ranges
// but set a maximum $duration of 1 year.
$duration = $duration && $duration <= 366 ? $duration : variable_get('event_table_duration', '30');
$end_date = event_date_later($date, $duration);
$caption = event_format_date($date, 'custom', 'F d Y') . ' - ' . event_format_date($end_date, 'custom', 'F d Y');
$tbody = event_calendar_list('page', $date, $end_date, $types, $terms);
break;
case 'feed':
// rss feed
drupal_set_header('Content-Type: text/xml; charset=utf-8');
$duration = $duration ? $duration : variable_get('event_table_duration', '30');
print event_calendar_rss($date, $duration, $types, $terms, $title);
break;
case 'ical':
// ical feed
drupal_set_header('Content-Type: text/calendar; charset=utf-8');
drupal_set_header('Content-Disposition: attachment; filename="calendar.ics"; ');
$duration = $duration ? $duration : variable_get('event_table_duration', '30');
print event_calendar_ical($date, $duration, $types, $terms, $title);
break;
case 'block':
// block update
$date = _event_user_date();
if (arg(0) == 'event' && is_numeric(arg(1))) {
// follow event calendar
$date['year'] = arg(1) ? arg(1) : $time['year'];
$date['month'] = arg(2) ? arg(2) : $time['month'];
$date['day'] = arg(3) ? arg(3) : $time['day'];
}
print event_calendar_month('block', $date);
break;
}
if ($view != 'feed' && $view != 'ical' && $view != 'block') {
// build header navigation
$prev = _event_nav($date, 'prev', $view, $types, $terms, $duration);
$next = _event_nav($date, 'next', $view, $types, $terms, $duration);
// setup calendar table header
$caption = $prev . ' ' . $caption . ' ' . $next;
$node->event = array();
$node->event['start_exploded'] = array(
'year' => $year,
'month' => $month,
'day' => $day,
);
$node->event['filter'] = ($types ? implode('+', $types) : 'all') . '/' . ($terms ? implode('+', $terms) : 'all');
$output .= theme('event_links', array_merge(module_invoke_all('link', 'event_' . $view, $node, FALSE), $links), $view);
$output .= theme('event_calendar_' . $view, 'page', $thead, $tbody, array(), $caption);
$output .= theme('event_ical_link', 'event/ical/' . $node->filter);
// Add RSS feed and icon to events page
drupal_add_feed(url('event/feed', NULL, NULL, TRUE), t('Events at %site', array(
'%site' => variable_get('site_name', 'drupal'),
)));
drupal_set_title(t('Events') . ($title ? ' - ' . $title : ''));
drupal_set_breadcrumb($breadcrumbs);
return $output;
}
}