function _pagerer_resolve_markers in Pagerer 7
Helper to calculate some markers needed by all themes.
Parameters
array $variables: theme's variables
Return value
array associative array of integer values representing the markers
1 call to _pagerer_resolve_markers()
- _pagerer_theme_handler in ./
pagerer.module - Pagerer's theme handler.
File
- ./
pagerer.module, line 1141 - Pagerer
Code
function _pagerer_resolve_markers($variables) {
global $pager_page_array, $pager_total, $pager_total_items, $pager_limits;
$markers = array();
// Pages.
// Middle is used to "center" pages around the current page.
$markers['pager_middle'] = ceil($variables['quantity'] / 2);
// Current is the page we are currently paged to.
$markers['pager_current'] = $pager_page_array[$variables['element']] + 1;
// First is the first page listed by this pager piece (re quantity).
$markers['pager_first'] = $markers['pager_current'] - $markers['pager_middle'] + 1;
// Last is the last page listed by this pager piece (re quantity).
$markers['pager_last'] = $markers['pager_current'] + $variables['quantity'] - $markers['pager_middle'];
// Max is the maximum page number.
$markers['pager_max'] = $pager_total[$variables['element']];
// Items.
// 'pager_current_first_item' is the first item listed on the current page.
$markers['pager_current_first_item'] = $pager_limits[$variables['element']] * $pager_page_array[$variables['element']] + 1;
// 'pager_current_last_item' is the last item listed on the current page.
$markers['pager_current_last_item'] = $pager_limits[$variables['element']] * $markers['pager_current'] > $pager_total_items[$variables['element']] ? $pager_total_items[$variables['element']] : $pager_limits[$variables['element']] * $markers['pager_current'];
// 'pager_item_max' is the maximum item number.
$markers['pager_item_max'] = $pager_total_items[$variables['element']];
// 'pager_items_next' is the number of items expected on next page.
if ($markers['pager_current'] * $pager_limits[$variables['element']] > $markers['pager_item_max']) {
$markers['pager_items_next'] = NULL;
}
else {
$markers['pager_items_next'] = $pager_total_items[$variables['element']] - $markers['pager_current'] * $pager_limits[$variables['element']] > $pager_limits[$variables['element']] ? $pager_limits[$variables['element']] : $pager_total_items[$variables['element']] - $markers['pager_current'] * $pager_limits[$variables['element']];
}
// 'pager_item_previous' is the number of items expected on previous page.
if ($markers['pager_current'] == 1) {
$markers['pager_items_previous'] = NULL;
}
else {
$markers['pager_items_previous'] = $pager_limits[$variables['element']];
}
return $markers;
}