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() { ...@@ -3154,21 +3154,7 @@ function drupal_common_theme() {
// From pager.inc. // From pager.inc.
'pager' => array( 'pager' => array(
'variables' => array('tags' => array(), 'element' => 0, 'parameters' => array(), 'quantity' => 9), 'variables' => array('tags' => array(), 'element' => 0, 'parameters' => array(), 'quantity' => 9),
), 'template' => 'pager',
'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()),
), ),
// From menu.inc. // From menu.inc.
'menu_link' => array( 'menu_link' => array(
......
...@@ -97,10 +97,7 @@ function template_preprocess_search_results(&$variables) { ...@@ -97,10 +97,7 @@ function template_preprocess_search_results(&$variables) {
'#module' => $variables['module'], '#module' => $variables['module'],
); );
} }
$variables['pager'] = array( $variables['pager'] = array('#theme' => 'pager');
'#theme' => 'pager',
'#tags' => NULL,
);
// @todo Revisit where this help text is added, see also // @todo Revisit where this help text is added, see also
// http://drupal.org/node/1918856. // http://drupal.org/node/1918856.
$variables['help'] = search_help('search#noresults', drupal_help_arg()); $variables['help'] = search_help('search#noresults', drupal_help_arg());
......
...@@ -198,7 +198,7 @@ abbr.form-required, abbr.tabledrag-changed, abbr.ajax-changed { ...@@ -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 { .item-list .pager {
clear: both; 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() { ...@@ -82,7 +82,8 @@ public function summaryTitle() {
*/ */
function render($input) { function render($input) {
$pager_theme = $this->view->buildThemeFunctions('pager'); $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( $tags = array(
0 => $this->options['tags']['first'], 0 => $this->options['tags']['first'],
1 => $this->options['tags']['previous'], 1 => $this->options['tags']['previous'],
......
...@@ -96,7 +96,7 @@ public function postExecute(&$result) { ...@@ -96,7 +96,7 @@ public function postExecute(&$result) {
* Overrides \Drupal\views\Plugin\views\pager\PagerPluginBase::render(). * Overrides \Drupal\views\Plugin\views\pager\PagerPluginBase::render().
*/ */
function render($input) { function render($input) {
// The 1, 3 index are correct, see theme_pager(). // The 1, 3 indexes are correct, see template_preprocess_pager().
$tags = array( $tags = array(
1 => $this->options['tags']['previous'], 1 => $this->options['tags']['previous'],
3 => $this->options['tags']['next'], 3 => $this->options['tags']['next'],
......
...@@ -1116,40 +1116,69 @@ function theme_views_form_views_form($variables) { ...@@ -1116,40 +1116,69 @@ function theme_views_form_views_form($variables) {
return drupal_render_children($form); return drupal_render_children($form);
} }
/**
* Theme function for the Mini pager.
*/
function theme_views_mini_pager($vars) { function theme_views_mini_pager($vars) {
global $pager_page_array, $pager_total; global $pager_page_array, $pager_total;
$tags = $vars['tags']; $tags = &$vars['tags'];
$element = $vars['element']; $element = $vars['element'];
$parameters = $vars['parameters']; $parameters = $vars['parameters'];
// Fill in default link labels.
$tags += array(
1 => t('‹‹'),
3 => t('››'),
);
// Current is the page we are currently paged to. // Current is the page we are currently paged to.
$pager_current = $pager_page_array[$element] + 1; $pager_current = $pager_page_array[$element] + 1;
// End of marker calculations. $current_path = current_path();
$li_previous = array(); $li_previous = array();
if ($pager_total[$element] > 1 && $pager_page_array[$element] > 0) { if ($pager_total[$element] > 1 && $pager_page_array[$element] > 0) {
$li_previous = array( $li_previous = array(
'#theme' => 'pager_link__previous', '#type' => 'link',
'#text' => (isset($tags[1]) ? $tags[1] : t('‹‹')), '#title' => $tags[1],
'#attributes' => array('title' => t('Go to previous page')), '#href' => $current_path,
'#page_new' => pager_load_array($pager_page_array[$element] - 1, $element, $pager_page_array), '#options' => array(
'#element' => $element, 'query' => pager_query_add_page($parameters, $element, $pager_page_array[$element] - 1),
'#interval' => 1, 'attributes' => array(
'#parameters' => $parameters, '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(); $li_next = array();
if ($pager_page_array[$element] < ($pager_total[$element] - 1)) { if ($pager_page_array[$element] < ($pager_total[$element] - 1)) {
$li_next = array( $li_next = array(
'#theme' => 'pager_link__next', '#type' => 'link',
'#text' => (isset($tags[3]) ? $tags[3] : t('››')), '#title' => $tags[3],
'#attributes' => array('title' => t('Go to next page')), '#href' => $current_path,
'#page_new' => pager_load_array($pager_page_array[$element] + 1, $element, $pager_page_array), '#options' => array(
'#element' => $element, 'query' => pager_query_add_page($parameters, $element, $pager_page_array[$element] + 1),
'#interval' => 1, 'attributes' => array(
'#parameters' => $parameters, '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) { ...@@ -1167,7 +1196,7 @@ function theme_views_mini_pager($vars) {
) + $li_next; ) + $li_next;
$item_list = array( $item_list = array(
'#theme' => 'item_list', '#theme' => 'item_list__pager',
'#items' => $items, '#items' => $items,
'#title' => NULL, '#title' => NULL,
'#list_type' => 'ul', '#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