function _pagerer_itemize_page_links in Pagerer 7
Return rendered items representing the links to 'page' elements in the pager.
Parameters
array $variables: theme's variables
array $markers: precalculated markers for the pager
array $pages: the pages that are to be displayed in the pager
Return value
array pre-rendered items
1 call to _pagerer_itemize_page_links()
- _pagerer_theme_handler in ./
pagerer.module - Pagerer's theme handler.
File
- ./
pagerer.module, line 1272 - Pagerer
Code
function _pagerer_itemize_page_links($variables, $markers, $pages) {
global $pager_page_array, $_pagerer_ak_array;
$element = $variables['element'];
$c = $markers['pager_current'] - 1;
$m = $markers['pager_max'] - 1;
$items = array();
if (!empty($pages)) {
$i = 0;
$previous_page = NULL;
foreach ($pages as $page => $page_data) {
// If not on first link, then introduce a separator or a breaker between
// the links.
if (isset($previous_page)) {
if ($page == $previous_page + 1) {
if ($variables['pager_separator'] != 'none') {
$items[] = array(
'class' => array(
'pager-item',
'separator',
),
'data' => $variables['pager_separator'],
);
}
}
else {
$items[] = array(
'class' => array(
'pager-item',
'breaker',
),
'data' => $variables['pager_breaker'],
);
}
}
elseif ($page != 0 and $variables['fl_breakers']) {
// If on first link, but current page is not first, introduce a
// breaker before the new link.
$items[] = array(
'class' => array(
'pager-item',
'breaker',
),
'data' => $variables['pager_breaker'],
);
}
// Sets previous page.
$previous_page = $page;
$text = isset($page_data['text']) ? $page_data['text'] : NULL;
$text_title = isset($page_data['text_title']) ? $page_data['text_title'] : NULL;
if ($page_data['interval'] < 0) {
// Link to page before the current.
// Target page.
$page_new = pager_load_array($page, $element, $pager_page_array);
// Adaptive keys.
if (isset($page_data['page_pl'])) {
if (isset($page_data['page_px'])) {
$aks = implode('.', array(
$page_data['page_pl'],
$page_data['page_pr'],
$page_data['page_px'],
));
}
else {
$aks = implode('.', array(
$page_data['page_pl'],
$page_data['page_pr'],
));
}
$variables['parameters']['page_ak'] = implode(',', _pagerer_load_ak_array($aks, $element, $_pagerer_ak_array));
}
// Get link data from theme_pagerer_link().
$link_data = theme('pagerer_link', array(
'text' => $text,
'page_new' => $page_new,
'element' => $variables['element'],
'interval' => -$page_data['interval'],
'parameters' => $variables['parameters'],
'attributes' => array(
'title' => $text_title,
),
));
$items[] = array(
'class' => array(
'pager-item',
'active',
),
'data' => _pagerer_resolve_link_data($link_data),
);
}
elseif ($page_data['interval'] == 0) {
// Link to current page.
if ($variables['label_display'] == 'before_current') {
$items[] = array(
'class' => array(
'pager-item',
),
'data' => _pagerer_get_page_tag($variables),
);
}
switch ($variables['current_display']) {
case 'none':
break;
case 'widget':
case 'slider':
case 'scrollpane':
$items = array_merge($items, _pagerer_itemize_js_element($variables['current_display'], $variables, $markers));
break;
case 'normal':
default:
$items[] = array(
'class' => array(
'pager-current',
),
'data' => $text,
);
}
if ($variables['total_display'] == 'after_current') {
$items[] = array(
'class' => array(
'pager-item',
),
'data' => format_string($variables['tags']['total'], array(
'@total' => _pagerer_get_total($variables, $markers),
)),
);
}
}
elseif ($page_data['interval'] > 0) {
// Link to page after the current.
// Target page.
$page_new = pager_load_array($page, $element, $pager_page_array);
// Adaptive keys.
if (isset($page_data['page_pl'])) {
if (isset($page_data['page_px'])) {
$aks = implode('.', array(
$page_data['page_pl'],
$page_data['page_pr'],
$page_data['page_px'],
));
}
else {
$aks = implode('.', array(
$page_data['page_pl'],
$page_data['page_pr'],
));
}
$variables['parameters']['page_ak'] = implode(',', _pagerer_load_ak_array($aks, $element, $_pagerer_ak_array));
}
// Get link data from theme_pagerer_link().
$link_data = theme('pagerer_link', array(
'text' => $text,
'page_new' => $page_new,
'element' => $variables['element'],
'interval' => $page_data['interval'],
'parameters' => $variables['parameters'],
'attributes' => array(
'title' => $text_title,
),
));
$items[] = array(
'class' => array(
'pager-item',
'active',
),
'data' => _pagerer_resolve_link_data($link_data),
);
}
$i++;
}
if ($page != $m and $variables['fl_breakers']) {
$items[] = array(
'class' => array(
'pager-item',
'breaker',
),
'data' => $variables['pager_breaker'],
);
}
}
return $items;
}