diff --git a/core/includes/pager.inc b/core/includes/pager.inc index e25c328..dd731f8 100644 --- a/core/includes/pager.inc +++ b/core/includes/pager.inc @@ -219,95 +219,74 @@ function template_preprocess_pager(&$variables) { } // End of generation loop preparation. - $li_first = ''; - $li_previous = ''; - $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(); + $items['first'] = array(); $options = array( 'query' => pager_query_add_page($parameters, $element, 0), ); - $li_first['href'] = url($current_path, $options); - $li_first['text'] = $tags[0]; - $li_first['attributes'] = new Attribute(array('title' => t('Go to first page'))); + $items['first']['href'] = url($current_path, $options); + $items['first']['text'] = $tags[0]; + $items['first']['attributes'] = new Attribute(array('title' => t('Go to first page'))); - $li_previous = array(); + $items['previous'] = array(); $options = array( 'query' => pager_query_add_page($parameters, $element, $pager_page_array[$element] - 1), ); - $li_previous['href'] = url($current_path, $options); - $li_previous['text'] = $tags[1]; - $li_previous['attributes'] = new Attribute(array( + $items['previous']['href'] = url($current_path, $options); + $items['previous']['text'] = $tags[1]; + $items['previous']['attributes'] = new Attribute(array( 'title' => t('Go to previous page'), 'rel' => 'prev', )); } - // 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(); + if ($i != $pager_max) { + // Add an ellipsis if there are further previous pages. + if ($i > 1) { + $items['ellipsis']['previous'] = TRUE; + } + // Now generate the actual pager piece. + for (; $i <= $pager_last && $i <= $pager_max; $i++) { + $options = array( + 'query' => pager_query_add_page($parameters, $element, $i - 1), + ); + $items['pages'][$i]['href'] = url($current_path, $options); + if ($i == $pager_current) { + $items['current'] = $i; + } + } + // Add an ellipsis if there are further next pages. + if ($i < $pager_max) { + $items['ellipsis']['next'] = TRUE; + } + } + + // Create the "next" and "last" links if we are not on the last page. + if ($pager_page_array[$element] < ($pager_max - 1)) { + $items['next'] = array(); $options = array( 'query' => pager_query_add_page($parameters, $element, $pager_page_array[$element] + 1), ); - $li_next['href'] = url($current_path, $options); - $li_next['text'] = $tags[3]; - $li_next['attributes'] = new Attribute(array( + $items['next']['href'] = url($current_path, $options); + $items['next']['text'] = $tags[3]; + $items['next']['attributes'] = new Attribute(array( 'title' => t('Go to next page'), 'rel' => 'next', )); - $li_last = array(); + $items['last'] = array(); $options = array( - 'query' => pager_query_add_page($parameters, $element, $pager_total[$element] - 1), + 'query' => pager_query_add_page($parameters, $element, $pager_max - 1), ); - $li_last['href'] = url($current_path, $options); - $li_last['text'] = $tags[4]; - $li_last['attributes'] = new Attribute(array('title' => t('Go to last page'))); + $items['last']['href'] = url($current_path, $options); + $items['last']['text'] = $tags[4]; + $items['last']['attributes'] = new Attribute(array('title' => t('Go to last page'))); } - if ($pager_total[$element] > 1) { - if ($li_first) { - $items['first'] = $li_first; - } - if ($li_previous) { - $items['previous'] = $li_previous; - } - - // 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['ellipsis']['previous'] = TRUE; - } - // Now generate the actual pager piece. - for (; $i <= $pager_last && $i <= $pager_max; $i++) { - $options = array( - 'query' => pager_query_add_page($parameters, $element, $i - 1), - ); - $items['pages'][$i]['href'] = url($current_path, $options); - if ($i == $pager_current) { - $items['current'] = $i; - } - } - // Check whether there are further next pages. - if ($i < $pager_max) { - $items['ellipsis']['next'] = TRUE; - } - } - // End generation. - if ($li_next) { - $items['next'] = $li_next; - } - if ($li_last) { - $items['last'] = $li_last; - } - - $variables['items'] = $items; - } + $variables['items'] = $items; } /**