Loading includes/pager.incdeleted 100644 → 0 +0 −276 Original line number Diff line number Diff line <?php /** * @file * Contains pager theme and related functions. */ /** * Implements theme_pager(). * * Renders a pager with next format: * On page 1: [1] 2 ... 15 -> * On page 2: <- 1 [2] 3 ... 15 -> * On page 3: <- 1 2 [3] 4 ... 15 -> * On page 4: <- 1 ... 3 [4] 5 ... 15 -> * On page 15: <- 1 ... 14 [15] */ function semanticui_pager($variables) { global $pager_page_array, $pager_total; $output = ''; $items = array(); $tags = $variables['tags']; $element = $variables['element']; $parameters = $variables['parameters']; // Current is the page we are currently paged to. $pager_current = $pager_page_array[$element] + 1; // Max is the maximum page number. $pager_max = $pager_total[$element]; $interval = 1; $page_new_previous = pager_load_array($pager_page_array[$element] - $interval, $element, $pager_page_array); $page_new_next = pager_load_array($pager_page_array[$element] + $interval, $element, $pager_page_array); // Prepare previous item. $left_arrow = '<i class="icon left arrow"></i>'; $previous = array( '#theme' => 'pager_link', '#text' => !empty($tags[1]) ? $tags[1] : $left_arrow, '#page_new' => $page_new_previous, '#element' => $element, '#parameters' => $parameters, '#attributes' => array( 'class' => array( 'icon', 'previous', ), ), ); // Prepare next item. $right_arrow = '<i class="icon right arrow"></i>'; $next = array( '#theme' => 'pager_link', '#text' => !empty($tags[3]) ? $tags[3] : $right_arrow, '#page_new' => $page_new_next, '#element' => $element, '#parameters' => $parameters, '#attributes' => array( 'class' => array( 'icon', 'next', ), ), ); $ellipsis = array( '#type' => 'container', '#attributes' => array( 'class' => array( 'disabled', 'item', ), ), ); $ellipsis['markup'] = array( '#markup' => '…', ); if ($pager_max > 1) { if ($pager_current > 1) { $items[] = $previous; } if ($pager_current > 2) { $items[] = array( '#theme' => 'pager_link', '#text' => 1, '#page_new' => array($element => 0), '#element' => $element, '#parameters' => $parameters, ); } if ($pager_current > 3) { $items[] = $ellipsis; } $from = ($pager_current - 1) < 1 ? 1 : ($pager_current - 1); $to = ($pager_current + 1) > $pager_max ? $pager_max : ($pager_current + 1); for ($i = $from; $i <= $to; $i++) { $item = array( '#theme' => 'pager_link', '#text' => $i, '#page_new' => array($element => $i - 1), '#element' => $element, '#parameters' => $parameters, ); // Highlight current page item with active class. if ($i == $pager_current) { $item['#attributes'] = array( 'class' => array( 'active', ), ); } $items[] = $item; } if ($pager_current < $pager_max - 2) { $items[] = $ellipsis; } if ($pager_current < $pager_max - 1) { $items[] = array( '#theme' => 'pager_link', '#text' => $pager_max, '#page_new' => array($element => $pager_max - 1), '#element' => $element, '#parameters' => $parameters, ); } if ($pager_current < $pager_max) { $items[] = $next; } return theme('pager_item_list', array('items' => $items)); } return $output; } /** * Implements theme_pager_link(). * * Allows rendering pager item with <i> tag (used to render an icon, e.g. left * or right arrow). */ function semanticui_pager_link($variables) { $text = $variables['text']; $page_new = $variables['page_new']; $element = $variables['element']; $parameters = $variables['parameters']; $attributes = $variables['attributes']; $page = isset($_GET['page']) ? $_GET['page'] : ''; if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) { $parameters['page'] = $new_page; } $query = array(); if (count($parameters)) { $query = drupal_get_query_parameters($parameters, array()); } if ($query_pager = pager_get_query_parameters()) { $query = array_merge($query, $query_pager); } // Set each pager link title. if (!isset($attributes['title'])) { static $titles = NULL; if (!isset($titles)) { $titles = array( t('‹ previous') => t('Go to previous page'), t('next ›') => t('Go to next page'), ); } if (isset($titles[$text])) { $attributes['title'] = $titles[$text]; } elseif (is_numeric($text)) { $attributes['title'] = t('Go to page @number', array('@number' => $text)); } } $attributes['href'] = url($_GET['q'], array('query' => $query)); return '<a' . drupal_attributes($attributes) . '>' . filter_xss($text, array('i')) . '</a>'; } /** * Implements theme_preprocess_pager_link(). */ function semanticui_preprocess_pager_link(&$variables) { $variables['attributes']['class'][] = 'item'; } /** * Implements theme_views_mini_pager(). */ function semanticui_views_mini_pager($vars) { global $pager_page_array, $pager_total; $tags = $vars['tags']; $element = $vars['element']; $parameters = $vars['parameters']; // Current is the page we are currently paged to. $pager_current = $pager_page_array[$element] + 1; // Max is the maximum page number. $pager_max = $pager_total[$element]; $interval = 1; $page_new_previous = pager_load_array($pager_page_array[$element] - $interval, $element, $pager_page_array); $page_new_next = pager_load_array($pager_page_array[$element] + $interval, $element, $pager_page_array); // Prepare previous item. $left_arrow = '<i class="icon left arrow"></i>'; $previous = array( '#theme' => 'pager_link', '#text' => !empty($tags[1]) ? $tags[1] : $left_arrow, '#page_new' => $page_new_previous, '#element' => $element, '#parameters' => $parameters, '#attributes' => array( 'class' => array( 'icon', 'previous', ), ), ); // Prepare next item. $right_arrow = '<i class="icon right arrow"></i>'; $next = array( '#theme' => 'pager_link', '#text' => !empty($tags[3]) ? $tags[3] : $right_arrow, '#page_new' => $page_new_next, '#element' => $element, '#parameters' => $parameters, '#attributes' => array( 'class' => array( 'icon', 'next', ), ), ); if ($pager_total[$element] > 1) { if ($pager_current > 1) { $items[] = $previous; } $current = array( '#type' => 'container', '#attributes' => array( 'class' => array( 'current', 'item', ), ), ); $current['text'] = array( '#markup' => t('@current of @max', array('@current' => $pager_current, '@max' => $pager_max)), ); $items[] = $current; if ($pager_current < $pager_max) { $items[] = $next; } return theme('pager_item_list', array('items' => $items)); } } templates/navigation/pager.html.twig 0 → 100644 +87 −0 Original line number Diff line number Diff line {# /** * @file * Theme override to display a pager. * * Available variables: * - heading_id: Pagination heading ID. * - items: List of pager items. * The list is keyed by the following elements: * - first: Item for the first page; not present on the first page of results. * - previous: Item for the previous page; not present on the first page * of results. * - next: Item for the next page; not present on the last page of results. * - last: Item for the last page; not present on the last page of results. * - pages: List of pages, keyed by page number. * Sub-sub elements: * items.first, items.previous, items.next, items.last, and each item inside * items.pages contain the following elements: * - href: URL with appropriate query parameters for the item. * - attributes: A keyed list of HTML attributes for the item. * - text: The visible text used for the item link, such as "‹ Previous" * or "Next ›". * - current: The page number of the current page. * - ellipses: If there are more pages than the quantity allows, then an * ellipsis before or after the listed pages may be present. * - previous: Present if the currently visible list of pages does not start * at the first page. * - next: Present if the visible list of pages ends before the last page. * * @see template_preprocess_pager() */ #} {% if items %} <div class="pager pagination ui menu" role="navigation" aria-labelledby="{{ heading_id }}"> <h4 id="{{ heading_id }}" class="visually-hidden">{{ 'Pagination'|t }}</h4> {# Print first item if we are not on the first page. #} {% if items.first %} <a href="{{ items.first.href }}" title="{{ 'Go to first page'|t }}"{{ items.first.attributes|without('href', 'title') }} class="item"> <span class="visually-hidden">{{ 'First page'|t }}</span> <span aria-hidden="true">{{ items.first.text|default('« First'|t) }}</span> </a> {% endif %} {# Print previous item if we are not on the first page. #} {% if items.previous %} <a href="{{ items.previous.href }}" title="{{ 'Go to previous page'|t }}" rel="prev"{{ items.previous.attributes|without('href', 'title', 'rel') }} class="item"> <span class="visually-hidden">{{ 'Previous page'|t }}</span> <span aria-hidden="true">{{ items.previous.text|default('‹ Previous'|t) }}</span> </a> {% endif %} {# Add an ellipsis if there are further previous pages. #} {% if ellipses.previous %} <div class="pager__item pager__item--ellipsis disabled item" role="presentation">…</div> {% endif %} {# Now generate the actual pager piece. #} {% for key, item in items.pages %} {% if current == key %} {% set title = 'Current page'|t %} {% else %} {% set title = 'Go to page @key'|t({'@key': key}) %} {% endif %} <a href="{{ item.href }}" title="{{ title }}"{{ item.attributes|without('href', 'title') }} class="item {{ current == key ? ' is-active' : '' }}" class="item"> <span class="visually-hidden"> {{ current == key ? 'Current page'|t : 'Page'|t }} </span> {{- key -}} </a> {% endfor %} {# Add an ellipsis if there are further next pages. #} {% if ellipses.next %} <div class="pager__item pager__item--ellipsis disabled item" role="presentation">…</div> {% endif %} {# Print next item if we are not on the last page. #} {% if items.next %} <a href="{{ items.next.href }}" title="{{ 'Go to next page'|t }}" rel="next"{{ items.next.attributes|without('href', 'title', 'rel') }} class="item"> <span class="visually-hidden">{{ 'Next page'|t }}</span> <span aria-hidden="true">{{ items.next.text|default('Next ›'|t) }}</span> </a> {% endif %} {# Print last item if we are not on the last page. #} {% if items.last %} <a href="{{ items.last.href }}" title="{{ 'Go to last page'|t }}"{{ items.last.attributes|without('href', 'title') }} class="item"> <span class="visually-hidden">{{ 'Last page'|t }}</span> <span aria-hidden="true">{{ items.last.text|default('Last »'|t) }}</span> </a> {% endif %} </div> {% endif %} Loading
includes/pager.incdeleted 100644 → 0 +0 −276 Original line number Diff line number Diff line <?php /** * @file * Contains pager theme and related functions. */ /** * Implements theme_pager(). * * Renders a pager with next format: * On page 1: [1] 2 ... 15 -> * On page 2: <- 1 [2] 3 ... 15 -> * On page 3: <- 1 2 [3] 4 ... 15 -> * On page 4: <- 1 ... 3 [4] 5 ... 15 -> * On page 15: <- 1 ... 14 [15] */ function semanticui_pager($variables) { global $pager_page_array, $pager_total; $output = ''; $items = array(); $tags = $variables['tags']; $element = $variables['element']; $parameters = $variables['parameters']; // Current is the page we are currently paged to. $pager_current = $pager_page_array[$element] + 1; // Max is the maximum page number. $pager_max = $pager_total[$element]; $interval = 1; $page_new_previous = pager_load_array($pager_page_array[$element] - $interval, $element, $pager_page_array); $page_new_next = pager_load_array($pager_page_array[$element] + $interval, $element, $pager_page_array); // Prepare previous item. $left_arrow = '<i class="icon left arrow"></i>'; $previous = array( '#theme' => 'pager_link', '#text' => !empty($tags[1]) ? $tags[1] : $left_arrow, '#page_new' => $page_new_previous, '#element' => $element, '#parameters' => $parameters, '#attributes' => array( 'class' => array( 'icon', 'previous', ), ), ); // Prepare next item. $right_arrow = '<i class="icon right arrow"></i>'; $next = array( '#theme' => 'pager_link', '#text' => !empty($tags[3]) ? $tags[3] : $right_arrow, '#page_new' => $page_new_next, '#element' => $element, '#parameters' => $parameters, '#attributes' => array( 'class' => array( 'icon', 'next', ), ), ); $ellipsis = array( '#type' => 'container', '#attributes' => array( 'class' => array( 'disabled', 'item', ), ), ); $ellipsis['markup'] = array( '#markup' => '…', ); if ($pager_max > 1) { if ($pager_current > 1) { $items[] = $previous; } if ($pager_current > 2) { $items[] = array( '#theme' => 'pager_link', '#text' => 1, '#page_new' => array($element => 0), '#element' => $element, '#parameters' => $parameters, ); } if ($pager_current > 3) { $items[] = $ellipsis; } $from = ($pager_current - 1) < 1 ? 1 : ($pager_current - 1); $to = ($pager_current + 1) > $pager_max ? $pager_max : ($pager_current + 1); for ($i = $from; $i <= $to; $i++) { $item = array( '#theme' => 'pager_link', '#text' => $i, '#page_new' => array($element => $i - 1), '#element' => $element, '#parameters' => $parameters, ); // Highlight current page item with active class. if ($i == $pager_current) { $item['#attributes'] = array( 'class' => array( 'active', ), ); } $items[] = $item; } if ($pager_current < $pager_max - 2) { $items[] = $ellipsis; } if ($pager_current < $pager_max - 1) { $items[] = array( '#theme' => 'pager_link', '#text' => $pager_max, '#page_new' => array($element => $pager_max - 1), '#element' => $element, '#parameters' => $parameters, ); } if ($pager_current < $pager_max) { $items[] = $next; } return theme('pager_item_list', array('items' => $items)); } return $output; } /** * Implements theme_pager_link(). * * Allows rendering pager item with <i> tag (used to render an icon, e.g. left * or right arrow). */ function semanticui_pager_link($variables) { $text = $variables['text']; $page_new = $variables['page_new']; $element = $variables['element']; $parameters = $variables['parameters']; $attributes = $variables['attributes']; $page = isset($_GET['page']) ? $_GET['page'] : ''; if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) { $parameters['page'] = $new_page; } $query = array(); if (count($parameters)) { $query = drupal_get_query_parameters($parameters, array()); } if ($query_pager = pager_get_query_parameters()) { $query = array_merge($query, $query_pager); } // Set each pager link title. if (!isset($attributes['title'])) { static $titles = NULL; if (!isset($titles)) { $titles = array( t('‹ previous') => t('Go to previous page'), t('next ›') => t('Go to next page'), ); } if (isset($titles[$text])) { $attributes['title'] = $titles[$text]; } elseif (is_numeric($text)) { $attributes['title'] = t('Go to page @number', array('@number' => $text)); } } $attributes['href'] = url($_GET['q'], array('query' => $query)); return '<a' . drupal_attributes($attributes) . '>' . filter_xss($text, array('i')) . '</a>'; } /** * Implements theme_preprocess_pager_link(). */ function semanticui_preprocess_pager_link(&$variables) { $variables['attributes']['class'][] = 'item'; } /** * Implements theme_views_mini_pager(). */ function semanticui_views_mini_pager($vars) { global $pager_page_array, $pager_total; $tags = $vars['tags']; $element = $vars['element']; $parameters = $vars['parameters']; // Current is the page we are currently paged to. $pager_current = $pager_page_array[$element] + 1; // Max is the maximum page number. $pager_max = $pager_total[$element]; $interval = 1; $page_new_previous = pager_load_array($pager_page_array[$element] - $interval, $element, $pager_page_array); $page_new_next = pager_load_array($pager_page_array[$element] + $interval, $element, $pager_page_array); // Prepare previous item. $left_arrow = '<i class="icon left arrow"></i>'; $previous = array( '#theme' => 'pager_link', '#text' => !empty($tags[1]) ? $tags[1] : $left_arrow, '#page_new' => $page_new_previous, '#element' => $element, '#parameters' => $parameters, '#attributes' => array( 'class' => array( 'icon', 'previous', ), ), ); // Prepare next item. $right_arrow = '<i class="icon right arrow"></i>'; $next = array( '#theme' => 'pager_link', '#text' => !empty($tags[3]) ? $tags[3] : $right_arrow, '#page_new' => $page_new_next, '#element' => $element, '#parameters' => $parameters, '#attributes' => array( 'class' => array( 'icon', 'next', ), ), ); if ($pager_total[$element] > 1) { if ($pager_current > 1) { $items[] = $previous; } $current = array( '#type' => 'container', '#attributes' => array( 'class' => array( 'current', 'item', ), ), ); $current['text'] = array( '#markup' => t('@current of @max', array('@current' => $pager_current, '@max' => $pager_max)), ); $items[] = $current; if ($pager_current < $pager_max) { $items[] = $next; } return theme('pager_item_list', array('items' => $items)); } }
templates/navigation/pager.html.twig 0 → 100644 +87 −0 Original line number Diff line number Diff line {# /** * @file * Theme override to display a pager. * * Available variables: * - heading_id: Pagination heading ID. * - items: List of pager items. * The list is keyed by the following elements: * - first: Item for the first page; not present on the first page of results. * - previous: Item for the previous page; not present on the first page * of results. * - next: Item for the next page; not present on the last page of results. * - last: Item for the last page; not present on the last page of results. * - pages: List of pages, keyed by page number. * Sub-sub elements: * items.first, items.previous, items.next, items.last, and each item inside * items.pages contain the following elements: * - href: URL with appropriate query parameters for the item. * - attributes: A keyed list of HTML attributes for the item. * - text: The visible text used for the item link, such as "‹ Previous" * or "Next ›". * - current: The page number of the current page. * - ellipses: If there are more pages than the quantity allows, then an * ellipsis before or after the listed pages may be present. * - previous: Present if the currently visible list of pages does not start * at the first page. * - next: Present if the visible list of pages ends before the last page. * * @see template_preprocess_pager() */ #} {% if items %} <div class="pager pagination ui menu" role="navigation" aria-labelledby="{{ heading_id }}"> <h4 id="{{ heading_id }}" class="visually-hidden">{{ 'Pagination'|t }}</h4> {# Print first item if we are not on the first page. #} {% if items.first %} <a href="{{ items.first.href }}" title="{{ 'Go to first page'|t }}"{{ items.first.attributes|without('href', 'title') }} class="item"> <span class="visually-hidden">{{ 'First page'|t }}</span> <span aria-hidden="true">{{ items.first.text|default('« First'|t) }}</span> </a> {% endif %} {# Print previous item if we are not on the first page. #} {% if items.previous %} <a href="{{ items.previous.href }}" title="{{ 'Go to previous page'|t }}" rel="prev"{{ items.previous.attributes|without('href', 'title', 'rel') }} class="item"> <span class="visually-hidden">{{ 'Previous page'|t }}</span> <span aria-hidden="true">{{ items.previous.text|default('‹ Previous'|t) }}</span> </a> {% endif %} {# Add an ellipsis if there are further previous pages. #} {% if ellipses.previous %} <div class="pager__item pager__item--ellipsis disabled item" role="presentation">…</div> {% endif %} {# Now generate the actual pager piece. #} {% for key, item in items.pages %} {% if current == key %} {% set title = 'Current page'|t %} {% else %} {% set title = 'Go to page @key'|t({'@key': key}) %} {% endif %} <a href="{{ item.href }}" title="{{ title }}"{{ item.attributes|without('href', 'title') }} class="item {{ current == key ? ' is-active' : '' }}" class="item"> <span class="visually-hidden"> {{ current == key ? 'Current page'|t : 'Page'|t }} </span> {{- key -}} </a> {% endfor %} {# Add an ellipsis if there are further next pages. #} {% if ellipses.next %} <div class="pager__item pager__item--ellipsis disabled item" role="presentation">…</div> {% endif %} {# Print next item if we are not on the last page. #} {% if items.next %} <a href="{{ items.next.href }}" title="{{ 'Go to next page'|t }}" rel="next"{{ items.next.attributes|without('href', 'title', 'rel') }} class="item"> <span class="visually-hidden">{{ 'Next page'|t }}</span> <span aria-hidden="true">{{ items.next.text|default('Next ›'|t) }}</span> </a> {% endif %} {# Print last item if we are not on the last page. #} {% if items.last %} <a href="{{ items.last.href }}" title="{{ 'Go to last page'|t }}"{{ items.last.attributes|without('href', 'title') }} class="item"> <span class="visually-hidden">{{ 'Last page'|t }}</span> <span aria-hidden="true">{{ items.last.text|default('Last »'|t) }}</span> </a> {% endif %} </div> {% endif %}