1 date.views.inc | date_pager_url($view, $date_type = NULL, $date_arg = NULL, $force_view_url = FALSE, $absolute = TRUE) |
Format links correctly for the new Date pager.
File
- core/
modules/ date/ views/ date.views.inc, line 250 - Defines date-related Views data and plugins:
Code
function date_pager_url($view, $date_type = NULL, $date_arg = NULL, $force_view_url = FALSE, $absolute = TRUE) {
// If someone adds a pager without a matching argument,
// there is no date information to work with.
if (empty($view->date_info) || !isset($view->date_info->date_arg_pos)) {
return '';
}
$args = $view->args;
$pos = $view->date_info->date_arg_pos;
// The View arguments array is indexed numerically but is not necessarily
// in numerical order. Sort the arguments to ensure the correct order.
ksort($args);
// If there are empty arguments before the date argument,
// pad them with the wildcard so the date argument will be in
// the right position.
if (count($args) < $pos) {
foreach ($view->argument as $name => $argument) {
if ($argument->position == $pos) {
break;
}
$args[] = $argument->options['exception']['value'];
}
}
if (!empty($date_type)) {
switch ($date_type) {
case 'year':
$args[$pos] = date_pad($view->date_info->year, 4);
break;
case 'week':
$args[$pos] = date_pad($view->date_info->year, 4) . '-W' . date_pad($view->date_info->week);
break;
case 'day':
$args[$pos] = date_pad($view->date_info->year, 4) . '-' . date_pad($view->date_info->month) . '-' . date_pad($view->date_info->day);
break;
default:
$args[$pos] = date_pad($view->date_info->year, 4) . '-' . date_pad($view->date_info->month);
break;
}
}
elseif (!empty($date_arg)) {
$args[$pos] = $date_arg;
}
else {
$args = $view->args;
}
// Is this an embedded or a block view?
// Return the pager query value.
if (!$force_view_url &&
(!empty($view->preview) || !empty($view->date_info->block_identifier))) {
$url = $args[$pos];
$key = date_block_identifier($view);
if (!empty($key)) {
return url($_GET['q'], array(
'query' => date_views_querystring($view, array($key => $url)),
'absolute' => $absolute));
}
}
// Normal views may need query strings appended to them if they use exposed
// filters.
return url($view->get_url($args), array(
'query' => date_views_querystring($view),
'absolute' => $absolute,
)
);
}