diff --git a/core/includes/pager.inc b/core/includes/pager.inc index 780ff6f..a711823 100644 --- a/core/includes/pager.inc +++ b/core/includes/pager.inc @@ -175,23 +175,13 @@ function template_preprocess_pager(&$variables) { $element = $variables['element']; $parameters = $variables['parameters']; $quantity = $variables['quantity']; - global $pager_page_array, $pager_total; + global $pager_page_array, $pager_total, $base_url; // Nothing to do if there is only one page. if ($pager_total[$element] <= 1) { return; } - // Fill in default link labels. - $tags = &$variables['tags']; - $tags += array( - t('« first'), - t('‹ previous'), - '', - t('next ›'), - t('last »'), - ); - // Calculate various markers within this pager piece: // Middle is used to "center" pages around the current page. $pager_middle = ceil($quantity / 2); @@ -224,192 +214,63 @@ function template_preprocess_pager(&$variables) { $li_next = ''; $li_last = ''; $current_path = current_path(); - - // Create the "first" and "previous" links if we are not on the first page. - if ($pager_page_array[$element] > 0) { - $li_first = array( - '#type' => 'link', - '#title' => $tags[0], - '#href' => $current_path, - '#options' => array( - 'query' => pager_query_add_page($parameters, $element, 0), - 'attributes' => array( - 'title' => t('Go to first page'), - 'rel' => 'first', - ), - // Below is ignored by default, supplied to support hook_link_alter - // implementations. - 'pager_context' => array( - 'link_type' => 'first', - 'element' => $element, - ), - ), - ); - $li_previous = array( - '#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, - ), - ), - ); - } - - // Create the "last" and "next" links if we are not on the last page. - if ($pager_page_array[$element] < ($pager_total[$element] - 1)) { - $li_next = array( - '#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' => 'next', - 'element' => $element, - ), - ), - ); - $li_last = array( - '#type' => 'link', - '#title' => $tags[4], - '#href' => $current_path, - '#options' => array( - 'query' => pager_query_add_page($parameters, $element, $pager_total[$element] - 1), - 'attributes' => array( - 'title' => t('Go to last page'), - 'rel' => 'last', - ), - // Below is ignored by default, supplied to support hook_link_alter - // implementations. - 'pager_context' => array( - 'link_type' => 'last', - 'element' => $element, - ), - ), - ); - } + $ellipsis = array(); if ($pager_total[$element] > 1) { - if ($li_first) { - $items[] = array( - '#wrapper_attributes' => array('class' => array('pager-first')), - 'link' => $li_first, - ); - } - if ($li_previous) { - $items[] = array( - '#wrapper_attributes' => array('class' => array('pager-previous')), - 'link' => $li_previous, - ); + // Create the "first" and "previous" links if we are not on the first page. + if ($pager_page_array[$element] > 0) { + $li_first = pager_query_add_page($parameters, $element, 0); + $li_previous = pager_query_add_page($parameters, $element, $pager_page_array[$element] - 1); + + if ($li_first) { + $items['first'] = true; + } + + if ($li_previous && isset($li_previous['page'])) { + $items['previous'] = $li_previous['page']; + } } // When there is more than one page, create the pager list. if ($i != $pager_max) { // Check whether there are further previous pages. if ($i > 1) { - $items[] = array( - '#wrapper_attributes' => array('class' => array('pager-ellipsis')), - '#markup' => '…', - ); + $ellipsis['prev'] = true; } + // Now generate the actual pager piece. for (; $i <= $pager_last && $i <= $pager_max; $i++) { - if ($i < $pager_current) { - $items[] = array( - '#wrapper_attributes' => array('class' => array('pager-item')), - 'link' => array( - '#type' => 'link', - '#title' => $i, - '#href' => $current_path, - '#options' => array( - 'query' => pager_query_add_page($parameters, $element, $i - 1), - 'attributes' => array( - 'title' => t('Go to page @number', array('@number' => $i)), - ), - // Below is ignored by default, supplied to support hook_link_alter - // implementations. - 'pager_context' => array( - 'link_type' => 'item', - 'element' => $element, - 'interval' => ($pager_current - $i), - ), - ), - ), - ); - } - if ($i == $pager_current) { - $items[] = array( - '#wrapper_attributes' => array('class' => array('pager-current')), - '#markup' => $i, - ); - } - if ($i > $pager_current) { - $items[] = array( - '#wrapper_attributes' => array('class' => array('pager-item')), - 'link' => array( - '#type' => 'link', - '#title' => $i, - '#href' => $current_path, - '#options' => array( - 'query' => pager_query_add_page($parameters, $element, $i - 1), - 'attributes' => array( - 'title' => t('Go to page @number', array('@number' => $i)), - ), - // Below is ignored by default, supplied to support hook_link_alter - // implementations. - 'pager_context' => array( - 'link_type' => 'item', - 'element' => $element, - 'interval' => ($i - $pager_current), - ), - ), - ), - ); + $query = pager_query_add_page($parameters, $element, $i); + if (isset($query['page'])) { + $items['pages'][$i-1] = $query['page']; } } + // Check whether there are further next pages. if ($i < $pager_max) { - $items[] = array( - '#wrapper_attributes' => array('class' => array('pager-ellipsis')), - '#markup' => '…', - ); + $ellipsis['next'] = true; } } - // End generation. - if ($li_next) { - $items[] = array( - '#wrapper_attributes' => array('class' => array('pager-next')), - 'link' => $li_next, - ); - } - if ($li_last) { - $items[] = array( - '#wrapper_attributes' => array('class' => array('pager-last')), - 'link' => $li_last, - ); + + // Create the "last" and "next" links if we are not on the last page. + if ($pager_page_array[$element] < ($pager_total[$element] - 1)) { + $li_next = pager_query_add_page($parameters, $element, $pager_page_array[$element] + 1); + $li_last = pager_query_add_page($parameters, $element, $pager_total[$element] - 1); + + // End generation. + if ($li_next) { + $items['next'] = $li_next['page']; + } + if ($li_last) { + $items['last'] = $li_last['page']; + } } - - $variables['items'] = array( - '#theme' => 'item_list__pager', - '#items' => $items, - '#attributes' => array('class' => array('pager')), - ); + + // If there is a better way to generate the URL, by all means go for it! + $variables['current_path'] = $base_url . '/' . $current_path; + $variables['pager_current'] = $pager_current; + $variables['items'] = $items; + $variables['ellipsis'] = $ellipsis; } } diff --git a/core/modules/system/templates/pager.html.twig b/core/modules/system/templates/pager.html.twig index 47b20a7..127e21c 100644 --- a/core/modules/system/templates/pager.html.twig +++ b/core/modules/system/templates/pager.html.twig @@ -12,6 +12,37 @@ */ #} {% if items %} -

{{ 'Pages'|t }}

- {{ items }} + {% endif %} diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc index d01235d..eaf3d86 100644 --- a/core/modules/views/views.theme.inc +++ b/core/modules/views/views.theme.inc @@ -62,7 +62,7 @@ function template_preprocess_views_view(&$variables) { // @todo: Figure out whether this belongs into views_ui_preprocess_views_view. // Render title for the admin preview. - $variables['title'] = !empty($view->views_ui_context) ? Xss::filterAdmin($view->getTitle()) : ''; + $variables['title'] = !empty($view->views_ui_context) ? filter_xss_admin($view->getTitle()) : ''; if ($view->display_handler->renderPager()) { $exposed_input = isset($view->exposed_raw_input) ? $view->exposed_raw_input : NULL; @@ -203,7 +203,7 @@ function template_preprocess_views_view_fields(&$variables) { } if (!empty($variables['options']['separator']) && $previous_inline && $object->inline && $object->content) { - $object->separator = Xss::filterAdmin($variables['options']['separator']); + $object->separator = filter_xss_admin($variables['options']['separator']); } $object->class = drupal_clean_css_identifier($id); @@ -453,7 +453,7 @@ function template_preprocess_views_view_summary_unformatted(&$variables) { foreach ($variables['rows'] as $id => $row) { // Only false on first time. if ($count++) { - $variables['rows'][$id]->separator = Xss::filterAdmin($variables['options']['separator']); + $variables['rows'][$id]->separator = filter_xss_admin($variables['options']['separator']); } $variables['rows'][$id]->attributes = array(); $variables['rows'][$id]->link = $argument->summaryName($row); @@ -643,7 +643,7 @@ function template_preprocess_views_view_table(&$variables) { // Place the field into the column, along with an optional separator. if (!empty($column_reference['content'])) { if (!empty($options['info'][$column]['separator'])) { - $column_reference['content'] .= Xss::filterAdmin($options['info'][$column]['separator']); + $column_reference['content'] .= filter_xss_admin($options['info'][$column]['separator']); } } else { diff --git a/core/themes/bartik/css/style.css b/core/themes/bartik/css/style.css index 663d60c..32c62d7 100644 --- a/core/themes/bartik/css/style.css +++ b/core/themes/bartik/css/style.css @@ -119,7 +119,7 @@ body, ul.contextual-links, ul.links, ul.primary, -.item-list .pager, +.pager__items, div.field-type-taxonomy-term-reference, div.messages, div.meta, @@ -266,28 +266,49 @@ table ul.links li { font-size: 0.923em; text-shadow: 0 0 0 !important; } -.item-list .pager { +nav.pager { + text-align: center; +} +.pager__items { + display: inline-block; font-size: 0.929em; + list-style: none; } -.item-list .pager li { +.pager__items li { + display: inline-block; padding: 0; } -.item-list .pager a { +.pager__items a { display: inline-block; padding: 10px 15px; } -.item-list .pager .pager-first a { - padding: 10px 10px 10px 0; +.pager__items .is-active { + font-weight: 700; + padding: 10px 15px; +} +.pager__items .is-active a { + padding: 0; +} +.pager__items .icon { + border-bottom-width: 0; + color: #2a678c; + font-weight: 600; + font-style: normal; +} +.pager__items .icon--go-first:before { + content: "\00AB\00A0 first"; +} +.pager__items .icon--go-previous:before { + content: "\003C\00A0 previous"; } -.item-list .pager .pager-previous a { - padding: 10px 0; +.pager__items .icon--ellipsis:before { + content: "..."; } -.item-list .pager .pager-current { - padding: 0 10px; +.pager__items .icon--go-next:after { + content: "next \00A0\003E"; } -.item-list .pager .pager-next a, -.item-list .pager .pager-last a { - padding: 10px 0 10px 10px; +.pager__items .icon--go-last:after { + content: "last \00A0\00BB"; } ul.menu li { margin: 0; diff --git a/core/themes/seven/style.css b/core/themes/seven/style.css index 33b3eee..bf84af5 100644 --- a/core/themes/seven/style.css +++ b/core/themes/seven/style.css @@ -521,18 +521,21 @@ div.submitted { /** * Pagination. - * The item-list CSS uses quite strong selectors, we have to match them here to - * override. */ -.item-list .pager li { +nav.pager { + text-align: center; +} +.pager__items { + display: inline-block; +} +.pager__items li { display: inline-block; color: #8c8c8c; font-size: 1.08em; padding: 0 0.6em; margin: 0; } -.item-list .pager a, -.item-list .pager .pager-current { +.pager__items a { border-bottom: 2px solid transparent; line-height: 1.55em; padding: 0 5px; @@ -543,28 +546,41 @@ div.submitted { font-weight: 600; -webkit-font-smoothing: antialiased; } -.item-list .pager a { +.pager__items a { padding-bottom: 3px; } -.item-list .pager .pager-current { +.pager__items .is-active { border-bottom-width: 3px; border-bottom-color: #2a678c; color: #2a678c; margin: 0 5px; font-weight: 700; } -.item-list .pager a:focus, -.item-list .pager a:hover { +.pager__items a:focus, +.pager__items a:hover { border-bottom-color: #3395d2; color: #3395d2; } -.item-list .pager-next a, -.item-list .pager-last a, -.item-list .pager-first a, -.item-list .pager-previous a { +.pager__items .icon { border-bottom-width: 0; color: #2a678c; font-weight: 600; + font-style: normal; +} +.pager__items .icon--go-first:before { + content: "\00AB\00A0 first"; +} +.pager__items .icon--go-previous:before { + content: "\003C\00A0 previous"; +} +.pager__items .icon--ellipsis:before { + content: "..."; +} +.pager__items .icon--go-next:after { + content: "next \00A0\003E"; +} +.pager__items .icon--go-last:after { + content: "last \00A0\00BB"; } /**