Commit 77947830 authored by catch's avatar catch

Issue #1898474 by mondrake, Cottser, azinoman: pager.inc - Convert theme_ functions to Twig.

parent 0f7247e9
This diff is collapsed.
......@@ -3154,21 +3154,7 @@ function drupal_common_theme() {
// From pager.inc.
'pager' => array(
'variables' => array('tags' => array(), 'element' => 0, 'parameters' => array(), 'quantity' => 9),
),
'pager_first' => array(
'variables' => array('text' => NULL, 'element' => 0, 'parameters' => array()),
),
'pager_previous' => array(
'variables' => array('text' => NULL, 'element' => 0, 'interval' => 1, 'parameters' => array()),
),
'pager_next' => array(
'variables' => array('text' => NULL, 'element' => 0, 'interval' => 1, 'parameters' => array()),
),
'pager_last' => array(
'variables' => array('text' => NULL, 'element' => 0, 'parameters' => array()),
),
'pager_link' => array(
'variables' => array('text' => NULL, 'page_new' => NULL, 'element' => NULL, 'parameters' => array(), 'attributes' => array()),
'template' => 'pager',
),
// From menu.inc.
'menu_link' => array(
......
......@@ -97,10 +97,7 @@ function template_preprocess_search_results(&$variables) {
'#module' => $variables['module'],
);
}
$variables['pager'] = array(
'#theme' => 'pager',
'#tags' => NULL,
);
$variables['pager'] = array('#theme' => 'pager');
// @todo Revisit where this help text is added, see also
// http://drupal.org/node/1918856.
$variables['help'] = search_help('search#noresults', drupal_help_arg());
......
......@@ -198,7 +198,7 @@ abbr.form-required, abbr.tabledrag-changed, abbr.ajax-changed {
}
/**
* Markup generated by theme_pager().
* Markup generated by pager.html.twig.
*/
.item-list .pager {
clear: both;
......
{#
/**
* @file
* Default theme implementation to display a pager.
*
* Available variables:
* - items: List of pager items.
*
* @see template_preprocess_pager()
*
* @ingroup themeable
*/
#}
{% if items %}
<h2 class="visually-hidden">{{ 'Pages'|t }}</h2>
{{ items }}
{% endif %}
......@@ -82,7 +82,8 @@ public function summaryTitle() {
*/
function render($input) {
$pager_theme = $this->view->buildThemeFunctions('pager');
// The 0, 1, 3, 4 index are correct. See theme_pager documentation.
// The 0, 1, 3, 4 indexes are correct. See the template_preprocess_pager()
// documentation.
$tags = array(
0 => $this->options['tags']['first'],
1 => $this->options['tags']['previous'],
......
......@@ -96,7 +96,7 @@ public function postExecute(&$result) {
* Overrides \Drupal\views\Plugin\views\pager\PagerPluginBase::render().
*/
function render($input) {
// The 1, 3 index are correct, see theme_pager().
// The 1, 3 indexes are correct, see template_preprocess_pager().
$tags = array(
1 => $this->options['tags']['previous'],
3 => $this->options['tags']['next'],
......
......@@ -1116,40 +1116,69 @@ function theme_views_form_views_form($variables) {
return drupal_render_children($form);
}
/**
* Theme function for the Mini pager.
*/
function theme_views_mini_pager($vars) {
global $pager_page_array, $pager_total;
$tags = $vars['tags'];
$tags = &$vars['tags'];
$element = $vars['element'];
$parameters = $vars['parameters'];
// Fill in default link labels.
$tags += array(
1 => t('‹‹'),
3 => t('››'),
);
// Current is the page we are currently paged to.
$pager_current = $pager_page_array[$element] + 1;
// End of marker calculations.
$current_path = current_path();
$li_previous = array();
if ($pager_total[$element] > 1 && $pager_page_array[$element] > 0) {
$li_previous = array(
'#theme' => 'pager_link__previous',
'#text' => (isset($tags[1]) ? $tags[1] : t('‹‹')),
'#attributes' => array('title' => t('Go to previous page')),
'#page_new' => pager_load_array($pager_page_array[$element] - 1, $element, $pager_page_array),
'#element' => $element,
'#interval' => 1,
'#parameters' => $parameters,
'#type' => 'link',
'#title' => $tags[1],
'#href' => $current_path,
'#options' => array(
'query' => pager_query_add_page($parameters, $element, $pager_page_array[$element] - 1),
'attributes' => array(
'title' => t('Go to previous page'),
'rel' => 'prev',
),
// Below is ignored by default, supplied to support hook_link_alter
// implementations.
'pager_context' => array(
'link_type' => 'previous',
'element' => $element,
'interval' => -1,
),
),
);
}
$li_next = array();
if ($pager_page_array[$element] < ($pager_total[$element] - 1)) {
$li_next = array(
'#theme' => 'pager_link__next',
'#text' => (isset($tags[3]) ? $tags[3] : t('››')),
'#attributes' => array('title' => t('Go to next page')),
'#page_new' => pager_load_array($pager_page_array[$element] + 1, $element, $pager_page_array),
'#element' => $element,
'#interval' => 1,
'#parameters' => $parameters,
'#type' => 'link',
'#title' => $tags[3],
'#href' => $current_path,
'#options' => array(
'query' => pager_query_add_page($parameters, $element, $pager_page_array[$element] + 1),
'attributes' => array(
'title' => t('Go to next page'),
'rel' => 'next',
),
// Below is ignored by default, supplied to support hook_link_alter
// implementations.
'pager_context' => array(
'link_type' => 'previous',
'element' => $element,
'interval' => 1,
),
),
);
}
......@@ -1167,7 +1196,7 @@ function theme_views_mini_pager($vars) {
) + $li_next;
$item_list = array(
'#theme' => 'item_list',
'#theme' => 'item_list__pager',
'#items' => $items,
'#title' => NULL,
'#list_type' => 'ul',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment