View source
<?php
function _date_views_filters($field) {
switch ($field['type']) {
case 'date':
$handler = 'date_views_filter_handler';
$ymd_handler = 'date_views_handler_filter_ymd';
break;
case 'datestamp':
$handler = 'date_views_timestamp_filter_handler';
$ymd_handler = 'date_views_timestamp_handler_filter_ymd';
break;
}
include_once drupal_get_path('module', 'date_api') . '/date.inc';
$formats = date_get_formats($field);
$format = $formats['input']['desc'];
$current = array(
'' => t('<all>'),
'now' => t('now'),
);
$months = $current + drupal_map_assoc(range(1, 12), 'map_month');
$days = $current + drupal_map_assoc(range(1, 31));
$operator = array(
'=' => t('is equal to'),
'<>' => t('is not equal to'),
'>' => t('greater than'),
'>=' => t('greater than or equal to'),
'<' => t('less than'),
'<=' => t('less than or equal to'),
);
$filters = array(
'default' => array(
'name' => t('Date'),
'operator' => $operator,
'value' => date_views_handler_filter_date_value_form($field),
'option' => 'string',
'handler' => $handler,
'type' => 'DATE',
'extra' => array(
'column' => 'value',
'field' => $field,
),
'help' => t('This filter allows events to be filtered by their date. Enter dates in the format: %format. Enter \'now\' to use the current time. You may enter a delta (in seconds) to the option that will be added to the time; this is most useful when combined with now. If you have the jscalendar module from jstools installed, you can use a popup date picker here.', array(
'%format' => $format,
)),
),
'year' => array(
'name' => t('Year'),
'operator' => $operator,
'handler' => $handler,
'option' => 'string',
'type' => 'YEAR',
'extra' => array(
'column' => 'value',
'field' => $field,
),
'help' => t('Filter by year. Enter \'now\' to use the current year. You may enter a delta (in seconds) to the option that will be added to the time; this is most useful when combined with now. '),
),
'month' => array(
'name' => t('Month'),
'operator' => $operator,
'list' => $months,
'list-type' => 'select',
'handler' => $handler,
'option' => 'string',
'type' => 'MONTH',
'extra' => array(
'column' => 'value',
'field' => $field,
),
'help' => t('Filter by month. Enter \'now\' to use the current month. You may enter a delta (in seconds) to the option that will be added to the time; this is most useful when combined with now. '),
),
'day' => array(
'name' => t('Day'),
'operator' => $operator,
'list' => $days,
'list-type' => 'select',
'handler' => $handler,
'option' => 'string',
'type' => 'DAY',
'extra' => array(
'column' => 'value',
'field' => $field,
),
'help' => t('Filter by day. Enter \'now\' to use the current day. You may enter a delta (in seconds) to the option that will be added to the time; this is most useful when combined with now. '),
),
);
if ($field['todate']) {
$filters2 = array(
'to|default' => array(
'name' => t('To Date'),
'operator' => $operator,
'value' => date_views_handler_filter_date_value_form($field),
'option' => 'string',
'handler' => $handler,
'type' => 'DATE',
'extra' => array(
'column' => 'value2',
'field' => $field,
),
'help' => t('This filter allows events to be filtered by their date. Enter dates in the format: %format. Enter \'now\' to use the current time. You may enter a delta (in seconds) to the option that will be added to the time; this is most useful when combined with now. If you have the jscalendar module from jstools installed, you can use a popup date picker here.', array(
'%format' => $format,
)),
),
'to|year' => array(
'name' => t('To Year'),
'operator' => $operator,
'handler' => $handler,
'option' => 'string',
'type' => 'YEAR',
'extra' => array(
'column' => 'value2',
'field' => $field,
),
'help' => t('Filter by year. Enter \'now\' to use the current year. You may enter a delta (in seconds) to the option that will be added to the time; this is most useful when combined with now. '),
),
'to|month' => array(
'name' => t('To Month'),
'operator' => $operator,
'list' => $months,
'list-type' => 'select',
'handler' => $handler,
'option' => 'string',
'type' => 'MONTH',
'extra' => array(
'column' => 'value2',
'field' => $field,
),
'help' => t('Filter by month. Enter \'now\' to use the current month. You may enter a delta (in seconds) to the option that will be added to the time; this is most useful when combined with now. '),
),
'to|day' => array(
'name' => t('To Day'),
'operator' => $operator,
'list' => $days,
'list-type' => 'select',
'handler' => $handler,
'option' => 'string',
'type' => 'DAY',
'extra' => array(
'column' => 'value2',
'field' => $field,
),
'help' => t('Filter by day. Enter \'now\' to use the current day. You may enter a delta (in seconds) to the option that will be added to the time; this is most useful when combined with now. '),
),
);
$filters += $filters2;
}
return $filters;
}
function _date_views_timestamp_filter_handler($op, $filter, $filterinfo, &$query) {
return _date_views_filter_handler($op, $filter, $filterinfo, $query, 'int');
}
function _date_views_filter_handler($op, $filter, $filterinfo, &$query, $field_type = 'iso') {
include_once drupal_get_path('module', 'date_api') . '/date.inc';
$value = $filter['value'];
$type = $filterinfo['type'];
switch ($type) {
case 'YEAR':
case 'MONTH':
case 'DAY':
if (empty($value) || !($value == 'now' || is_numeric($value))) {
return;
}
break;
default:
if ($field_type == 'int' && (empty($value) || !($value == 'now' || date_is_valid($value, DATE_UNIX)))) {
return;
}
elseif (empty($value) || !($value == 'now' || date_is_valid($value, DATE_ISO))) {
return;
}
break;
}
$field = $filterinfo['extra']['field'];
$column = $filterinfo['extra']['column'];
$formats = date_get_formats($field);
$db_info = $filterinfo['content_db_info'];
$table = 'node_data_' . $field['field_name'];
$table_field = $db_info['columns'][$column]['column'];
switch ($type) {
case 'DATE':
$date = $value == 'now' ? date_sql('NOW', 'NOW()', $field_type, intval(date_views_offset($field) + $filter['options'])) : "'" . str_replace('T', ' ', date_custom2iso($value, $formats['input']['text'])) . "'";
break;
default:
$date = $value == 'now' ? date_sql($type, "NOW()", $field_type, intval(date_views_offset($field) + $filter['options'])) : $value;
break;
}
$query
->ensure_table($table);
$query
->add_where(date_sql($type, $table . "." . $table_field, $field_type, date_views_offset($field)) . ' ' . $filter['operator'] . ' ' . $date);
}
function _date_views_handler_filter_date_value_form($field) {
include_once drupal_get_path('module', 'date_api') . '/date.inc';
$formats = date_get_formats($field);
$format = $formats['input']['jscal'] ? $formats['input']['jscal'] : '';
$form = array(
'#type' => 'textfield',
'#attributes' => array(
'class' => 'jscalendar',
),
'#jscalendar_ifFormat' => $format,
'#jscalendar_showsTime' => date_has_time($field['granularity']) ? 'true' : 'false',
'#jscalendar_timeFormat' => $formats['input']['am_pm'] ? '12' : '24',
);
return $form;
}
function date_views_offset($field) {
switch ($field['tz_handling']) {
case 'date':
$offset = 'node_data_' . $field['field_name'] . '.' . $field['field_name'] . '_offset';
break;
case 'site':
$offset = variable_get('date_default_timezone', 0);
break;
default:
$offset = '';
break;
}
return $offset;
}
function _date_views_arguments($field) {
$field_types = _content_field_types();
$arguments = array();
$argument = array();
$argument['name'] = $field_types[$field['type']]['label'] . ($field['todate'] ? t(': From ') : ': ') . t($field['widget']['label']) . ' (' . $field['field_name'] . ')';
$argument['handler'] = $field['type'] == 'date' ? 'date_views_argument_range_handler' : 'date_views_timestamp_argument_range_handler';
$argument['help'] = t("Defines an argument to filter for dates within a range, in the format 'YYYY-MM-DD--YYYY-MM-DD'. Many other options can be used in arguments. See !link for other examples.", array(
'!link' => l(t('help'), 'admin/help/date'),
));
$argument['option'] = 'date_range_arg_options';
$arguments['content: ' . $field['field_name']] = $argument;
if ($field['todate']) {
$argument['name'] = $field_types[$field['type']]['label'] . t(': To ') . t($field['widget']['label']) . ' (' . $field['field_name'] . ')';
$arguments['content: to|' . $field['field_name']] = $argument;
}
return $arguments;
}
function _date_views_timestamp_argument_range_handler($op, &$query, $argtype, $arg = '') {
return _date_views_argument_range_handler($op, $query, $argtype, $arg, 'int');
}
function _date_views_argument_range_handler($op, &$query, $argtype, $arg = '', $field_type = 'iso') {
static $format;
include_once drupal_get_path('module', 'date_api') . '/date.inc';
$name = explode(':', is_array($argtype) ? $argtype['type'] : $argtype);
$tofield_name = trim($name[1]);
$field_name = substr($tofield_name, 0, 3) == 'to|' ? substr($tofield_name, 3) : $tofield_name;
if ($field_name == $tofield_name) {
$value = 'value';
}
else {
$value = 'value2';
}
$field = content_fields($field_name);
$db_info = content_database_info($field);
$value = $db_info['columns'][$value]['column'];
$timezone = $db_info['columns']['timezone']['column'];
$table = 'node_data_' . $field['field_name'];
$offset = date_views_offset($field);
switch ($op) {
case 'summary':
$groupby = $arg;
switch ($groupby) {
case 'year':
$format = 'Y';
$fieldinfo['field'] = date_sql_concat(array(
date_sql('YEAR', $table . '.' . $value, $field_type, $offset),
));
break;
case 'month':
$format = 'F Y';
$fieldinfo['field'] = date_sql_concat(array(
date_sql('YEAR', $table . '.' . $value, $field_type),
"'-'",
date_sql_pad(date_sql('MONTH', $table . '.' . $value, $field_type, $offset)),
));
break;
case 'day':
$format = 'F j Y';
$fieldinfo['field'] = date_sql_concat(array(
date_sql('YEAR', $table . '.' . $value, $field_type),
"'-'",
date_sql_pad(date_sql('MONTH', $table . '.' . $value, $field_type, $offset)),
"'-'",
date_sql_pad(date_sql('DAY', $table . '.' . $value, $field_type, $offset)),
));
break;
case 'hour':
$format = 'F j Y - H';
$fieldinfo['field'] = date_sql_concat(array(
date_sql('YEAR', $table . '.' . $value, $field_type),
"'-'",
date_sql_pad(date_sql('MONTH', $table . '.' . $value, $field_type, $offset)),
"'-'",
date_sql_pad(date_sql('DAY', $table . '.' . $value, $field_type, $offset)),
"'T'",
date_sql_pad(date_sql('HOUR', $table . '.' . $value, $field_type, $offset)),
));
break;
case 'week':
$format = 'F j Y (W)';
$fieldinfo['field'] = date_sql_concat(array(
date_sql('YEAR', $table . '.' . $value, $field_type, $offset),
"'-W'",
date_sql('WEEK', $table . '.' . $value, $field_type, $offset),
));
break;
}
$fieldinfo['fieldname'] = 'range';
$query
->ensure_table($table);
$query
->add_field($value, $table);
return $fieldinfo;
break;
case 'link':
$time = $query->{$value} > '' ? $field_type == 'iso' ? date_iso2unix($query->{$value}) : $query->{$value} : '';
return l(date_format_date($format, $time), $arg . '/' . $query->range);
case 'sort':
break;
case 'filter':
$range = date_views_date_range($arg, $field);
$query
->ensure_table($table);
$query
->add_field($value, $table);
$query
->add_where(date_sql('DATE', $table . '.' . $value, $field_type, $offset) . ">='" . str_replace('T', ' ', $range[0]) . "'");
$query
->add_where(date_sql('DATE', $table . '.' . $value, $field_type, $offset) . "<='" . str_replace('T', ' ', $range[1]) . "'");
break;
case 'title':
$item = array(
key($db_info['columns']) => $query,
);
return content_format($field, $item, 'default');
}
}
function date_views_date_range($arg, $field = NULL) {
if (stristr($arg, 'P')) {
$range = date_plus_period($arg);
$min_date = $range[0];
$max_date = $range[1];
}
elseif (stristr($arg, '-W') && !stristr($arg, '--')) {
$range = date_week_value($arg);
$min_date = $range[0];
$max_date = $range[1];
}
else {
$range = (array) explode('--', $arg);
$min_date = date_range_value($range[0], 'min');
$max_date = date_range_value($range[1] ? $range[1] : $range[0], 'max');
}
if (isset($field)) {
$min_date = date_unset_granularity($min_date, date_granularity_array($field), $field['type']);
$max_date = date_unset_granularity($max_date, date_granularity_array($field), $field['type']);
}
return array(
$min_date,
$max_date,
);
}
function date_range_value($value, $value_type = 'min') {
include_once drupal_get_path('module', 'date_api') . '/date.inc';
$now = date_date(DATE_STRING_ISO, time());
if (trim($value) == '@' || trim($value) == '') {
return $now;
}
switch (strlen($value)) {
case 4:
$return = $value_type == 'min' ? $value . '-01-01T00:00:00' : $value . '-12-31T23:59:59';
break;
case 7:
$return = $value_type == 'min' ? $value . '-01T00:00:00' : $value . '-31T23:59:59';
break;
case 10:
$return = $value_type == 'min' ? $value . 'T00:00:00' : $value . 'T23:59:59';
break;
case 13:
$return = $value_type == 'min' ? $value . ':00:00' : $value . ':59:59';
break;
case 16:
$return = $value_type == 'min' ? $value . ':00' : $value . ':59';
break;
case 19:
$return = $value;
break;
default:
$return = $now;
}
return date_preg($return) ? $return : $now;
}
function date_week_value($value) {
include_once drupal_get_path('module', 'date_api') . '/date.inc';
$parts = explode('-W', $value);
$year = $parts[0];
$weeks = intval($parts[1] - 1);
$first_day_of_year = date_iso2unix($year . '-01-01T00:00:00');
$dow = date_gmdate('w', $first_day_of_year);
if ($dow > 2) {
$weeks += 1;
}
$shift = intval((1 - $dow) * 86400);
$first_day_of_week = $first_day_of_year + $weeks * 604800 + $shift;
$last_day_of_week = $first_day_of_week + 604800 - 1;
return array(
date_unix2iso($first_day_of_week),
date_unix2iso($last_day_of_week),
);
}
function date_plus_period($value) {
include_once drupal_get_path('module', 'date_api') . '/date.inc';
$value = str_replace('--P', 'P', $value);
$range = explode('P', $value);
$min_date = date_range_value($range[0], 'min');
$max_date = date_make_date($min_date, 'GMT', 'db', DATE_ISO);
$remaining = $range[1];
if ($years = strpos($remaining, 'Y')) {
$sub = explode('Y', $remaining);
$remaining = $sub[1];
$count = intval($sub[0]);
$max_iso = intval(substr($max_date->db->iso, 0, 4) + $count) . substr($max_date->db->iso, 4, 15);
date_set_date($max_date, $max_iso, 'GMT', 'db', DATE_ISO, TRUE);
}
if ($months = strpos($remaining, 'M')) {
$sub = explode('M', $remaining);
$remaining = $sub[1];
$count = intval($sub[0]);
$cur_mon = intval(substr($max_date->db->iso, 5, 2));
$cur_year = intval(substr($max_date->db->iso, 0, 4));
$max_iso = (intval($cur_mon + $count) < 13 ? $cur_year : intval($cur_year + 1)) . '-' . sprintf('%02d', intval($cur_mon + $count) < 13 ? intval($cur_mon + $count) : 1) . substr($min_date, 7, 12);
date_set_date($max_date, $max_iso, 'GMT', 'db', DATE_ISO, TRUE);
}
if (stristr($range[1], 'W')) {
$sub = explode('W', $remaining);
$remaining = $sub[1];
$count = intval($sub[0]);
$max_unix = intval($max_date->db->timestamp + 604800 * $count);
date_set_date($max_date, $max_unix, 'GMT', 'db', DATE_UNIX, TRUE);
}
if ($days = strpos($remaining, 'D')) {
$sub = explode('D', $remaining);
$remaining = $sub[1];
$count = intval($sub[0]);
$max_unix = intval($max_date->db->timestamp + 86400 * $count);
date_set_date($max_date, $max_unix, 'GMT', 'db', DATE_UNIX, TRUE);
}
if ($hours = strpos($remaining, 'H')) {
$sub = explode('H', $remaining);
$remaining = $sub[1];
$count = intval($sub[0]);
$max_unix = intval($max_date->db->timestamp + 3600 * $count);
date_set_date($max_date, $max_unix, 'GMT', 'db', DATE_UNIX, TRUE);
}
$date->db->unix = intval($max_date->db->timestamp - 1);
date_set_date($max_date, $date->db->unix, 'GMT', 'db', DATE_UNIX, TRUE);
return array(
$min_date,
$max_date->db->iso,
);
}
function date_range_arg_options() {
return array(
'year' => t('summarize by year'),
'month' => t('summarize by month'),
'day' => t('summarize by day'),
'week' => t('summarize by week'),
'hour' => t('summarize by hour'),
);
}
function _date_views_style_plugins() {
$items = array();
$items['date_views_browser'] = array(
'name' => t('Date: Date Browser'),
'theme' => 'date_views_browser_full_view',
'summary_theme' => 'date_views_browser_summary_view',
'needs_fields' => true,
'needs_table_header' => true,
'even_empty' => true,
'validate' => 'date_browser_validate',
);
return $items;
}
function date_browser_validate($type, $view, $form) {
if (is_array($view['field'])) {
$fields = array_filter(array_keys($view['field']), 'is_numeric');
}
if (!$fields) {
form_error($form["{$type}-info"][$type . '_type'], t('The Date Browser requires at least one field.'));
}
foreach ($view['argument'] as $delta => $argument) {
if (is_numeric($delta) && $argument['argdefault'] != 2) {
form_error($form['argument'][$delta]['argdefault'], t('Date Browser arguments must be set to \'Display All Values\'.'));
}
}
}
function _date_views_query_alter(&$query, &$view) {
$date_views_browser_views = date_views_browser_get_views();
if (in_array($view->name, array_keys($date_views_browser_views))) {
$path = explode('/', $view->url);
$pos = sizeof($path);
if ($view->build_type == 'block' || arg($pos) == '') {
$arg = NULL;
}
else {
$arg = arg($pos);
}
if ($arg == NULL) {
$arg = date_views_browser_period_arg($arg, $view->argument[0]['options']);
$name = explode(':', $view->argument[0]['type']);
$field_name = trim($name[1]);
$field = content_fields($field_name);
$field_type = $field['type'] == 'datestamp' ? 'int' : 'iso';
$db_info = content_database_info($field);
$value = $db_info['columns']['value']['column'];
$table = 'node_data_' . $field['field_name'];
$offset = date_views_offset($field);
if ($range = date_views_date_range($arg, $field)) {
$query
->ensure_table($table);
$query
->add_field('nid', 'node');
$query
->add_field($value, $table);
$query
->add_where(date_sql('DATE', $table . '.' . $value, $field_type, $offset) . ">='" . str_replace('T', ' ', $range[0]) . "'");
$query
->add_where(date_sql('DATE', $table . '.' . $value, $field_type, $offset) . "<='" . str_replace('T', ' ', $range[1]) . "'");
}
}
}
}
function date_views_browser_get_views($reset = FALSE) {
static $date_views_browser_views;
if (empty($date_views_browser_views) || $reset) {
$cid = 'date_browser_views';
if (!$reset && ($cached = cache_get($cid, 'cache_views'))) {
$date_views_browser_views = unserialize($cached->data);
}
else {
$date_views_browser_views = array();
$arguments = array();
$fields = content_fields();
foreach ($fields as $field) {
if ($field['type'] == DATE_UNIX || $field['type'] == DATE_ISO) {
$arguments = array_merge($arguments, _date_views_arguments($field));
}
}
$argument_list = "'" . implode("','", array_keys($arguments)) . "'";
if (!$argument_list) {
return array();
}
$result = db_query("SELECT arg.*, view.name FROM {view_argument} arg INNER JOIN {view_view} view ON arg.vid=view.vid WHERE arg.type IN ({$argument_list}) AND view.page_type='date_views_browser'");
while ($view = db_fetch_object($result)) {
$date_views_browser_views[$view->name] = $view;
}
cache_set($cid, 'cache_views', serialize($date_views_browser_views));
}
}
return $date_views_browser_views;
}
function date_views_browser_period($period = 'month') {
switch ($period) {
case 'year':
return 'P1Y';
case 'week':
return 'P1W';
case 'day':
return 'P1D';
case 'hour':
return 'P1H';
default:
return 'P1M';
}
}
function date_views_browser_period_arg($arg = NULL, $period = 'month') {
include_once drupal_get_path('module', 'date_api') . '/date.inc';
switch ($period) {
case 'week':
return date_gmdate('Y-m-d', date_views_browser_period_start_stamp($arg, $period)) . date_views_browser_period($period);
case 'year':
return date_gmdate('Y', date_views_browser_period_start_stamp($arg, $period)) . date_views_browser_period($period);
case 'day':
return date_gmdate('Y-m-d', date_views_browser_period_start_stamp($arg, $period)) . date_views_browser_period($period);
case 'hour':
return date_gmdate('Y-m-d\\TH', date_views_browser_period_start_stamp($arg, $period)) . date_views_browser_period($period);
default:
return date_gmdate('Y-m', date_views_browser_period_start_stamp($arg, $period)) . date_views_browser_period($period);
}
}
function date_views_browser_period_label($arg = NULL, $period = 'month') {
return theme('date_views_browser_period_label', $period, date_views_browser_period_start_stamp($arg, $period));
}
function date_views_browser_period_start_stamp($arg = NULL, $period = 'month') {
include_once drupal_get_path('module', 'date_api') . '/date.inc';
$range = date_views_date_range($arg);
$stamp = date_iso2unix($range[0]);
if ($arg) {
return $stamp;
}
switch ($period) {
case 'week':
$dow = date_gmdate('w', $stamp);
if ($dow >= 6) {
$adj = 86400 * 7;
}
$start = intval($stamp - intval($dow * 86400) + $adj);
if (variable_get('date_first_day', 0)) {
$start += intval(variable_get('date_first_day', 0) * 86400);
}
break;
case 'year':
$year = date_gmdate('Y', $stamp);
$start = date_gmmktime(array(
'year' => $year,
'mon' => 1,
'mday' => 1,
));
break;
case 'day':
$year = date_gmdate('Y', $stamp);
$month = date_gmdate('n', $stamp);
$day = date_gmdate('j', $stamp);
$start = date_gmmktime(array(
'year' => $year,
'mon' => $month,
'mday' => $day,
'hours' => 1,
));
break;
case 'hour':
$year = date_gmdate('Y', $stamp);
$month = date_gmdate('n', $stamp);
$day = date_gmdate('j', $stamp);
$hour = date_gmdate('H', $stamp);
$start = date_gmmktime(array(
'year' => $year,
'mon' => $month,
'mday' => $day,
'hours' => $hour,
'minutes' => 1,
));
break;
default:
$year = date_gmdate('Y', $stamp);
$month = date_gmdate('n', $stamp);
$start = date_gmmktime(array(
'year' => $year,
'mon' => $month,
'mday' => 1,
));
break;
}
return $start;
}
function date_views_browser_navigation($view, $period) {
include_once drupal_get_path('module', 'date_api') . '/date.inc';
$path = explode('/', $view->url);
$pos = sizeof($path);
if (arg($pos) == '') {
$arg = NULL;
}
else {
$arg = arg($pos);
}
$range = date_views_date_range($arg);
$stamp = date_views_browser_period_start_stamp($arg, $period);
switch ($period) {
case 'week':
$prev_date = date_gmdate('Y-m-d', intval($stamp - 604799));
$next_date = date_gmdate('Y-m-d', intval($stamp + 604801));
break;
case 'year':
$year = intval(substr($range[0], 0, 4));
$month = intval(substr($range[0], 5, 2));
$prev_date = $month < 2 ? intval($year - 1) : $year;
$next_date = $month > 11 ? intval($year + 1) : $year;
break;
case 'day':
$prev_date = date_gmdate('Y-m-d', intval($stamp - 86399));
$next_date = date_gmdate('Y-m-d', intval($stamp + 86401));
break;
case 'hour':
$prev_date = date_gmdate('Y-m-d\\TH', intval($stamp - 3599));
$next_date = date_gmdate('Y-m-d\\TH', intval($stamp + 3601));
break;
default:
$year = intval(substr($range[0], 0, 4));
$month = intval(substr($range[0], 5, 2));
$prev_date = ($month > 1 ? $year : intval($year - 1)) . '-' . ($month > 1 ? sprintf('%02d', intval($month - 1)) : '12');
$next_date = ($month < 12 ? $year : intval($year + 1)) . '-' . ($month < 12 ? sprintf('%02d', intval($month + 1)) : '01');
break;
}
$prev = $view->url . '/' . $prev_date . date_views_browser_period($period);
$next = $view->url . '/' . $next_date . date_views_browser_period($period);
$label = date_views_browser_period_label($arg, $period);
return theme('date_views_browser_navigation', $label, $period, $prev, $next, $view);
}
function theme_date_views_browser_period_label($period, $date) {
include_once drupal_get_path('module', 'date_api') . '/date.inc';
if ($period != 'hour') {
$format = array_shift(explode(' ', variable_get('date_format_short', 'm/d/Y - H:i')));
}
else {
$format = str_replace(':i', '', variable_get('date_format_short', 'm/d/Y - H:i'));
}
return t('%period of %date', array(
'%period' => ucwords($period),
'%date' => date_gmdate($format, $date),
));
}
function theme_date_views_browser_navigation($label, $period, $prev, $next, $view) {
drupal_add_css(drupal_get_path('module', 'date_api') . '/date.css');
$output = '<div class="book-navigation date-browser-navigation">';
$output .= '<div class="page-links">';
$output .= l(t('‹ prev !period ', array(
'!period' => $period,
)), $prev, array(
'class' => 'page-previous',
));
$output .= '<h3 class="date-browser-label"><span class="page-up">' . $label . '</span></h3>';
$output .= l(t(' next !period ›', array(
'!period' => $period,
)), $next, array(
'class' => 'page-next',
));
$output .= '</div></div>';
return $output;
return $output;
}
function theme_date_views_browser_summary_view($view, $type, $level, $nodes, $args) {
return theme('date_views_browser_full_view', $view, $nodes, $type);
}
function theme_date_views_browser_full_view($view, $nodes, $type) {
$teasers = true;
$links = true;
drupal_add_css(drupal_get_path('module', 'date_api') . '/date.css');
$date_views_browser_views = date_views_browser_get_views();
$period = $date_views_browser_views[$view->name]->options;
switch ($type) {
case 'block':
$arg = date_views_browser_period_arg(NULL, $view->argument[0]['options']);
if ($view->url) {
$url = $view->url . '/' . $arg;
}
$output .= '<h5 class="date-browser-block-label">' . l(date_views_browser_period_label(NULL, $period), $url) . '</h5>';
$display = 'views_view_list';
break;
default:
$output .= date_views_browser_navigation($view, $period);
$display = 'views_view_teasers';
break;
}
$output .= theme($display, $view, $nodes, $type, $teasers, $links);
return $output;
}