diff --git a/core/includes/pager.inc b/core/includes/pager.inc index f4aae0a..126fb52 100644 --- a/core/includes/pager.inc +++ b/core/includes/pager.inc @@ -188,27 +188,29 @@ function template_preprocess_pager(&$variables) { $tags = $variables['pager']['#tags']; - // Calculate various markers within this pager list: + // Calculate various markers within this pager piece: // Middle is used to "center" pages around the current page. - $list_middle = ceil($quantity / 2); - // Current is the page we are currently paged to. - $list_current = $pager->getCurrentPage() + 1; - // First is the first page listed by this pager list (re quantity). - $list_first = $list_current - $list_middle + 1; - // Last is the last page listed by this pager list (re quantity). - $list_last = $list_current + $quantity - $list_middle; + $pager_middle = ceil($quantity / 2); + // current is the page we are currently paged to. + $pager_current = $pager_page_array[$element] + 1; + // first is the first page listed by this pager piece (re quantity). + $pager_first = $pager_current - $pager_middle + 1; + // last is the last page listed by this pager piece (re quantity). + $pager_last = $pager_current + $quantity - $pager_middle; + // max is the maximum page number. + $pager_max = $pager_total[$element]; // End of marker calculations. // Prepare for generation loop. - $i = $list_first; - if ($list_last > $pager->getTotalPages()) { + $i = $pager_first; + if ($pager_last > $pager_max) { // Adjust "center" if at end of query. - $i = $i + ($pager->getTotalPages() - $list_last); - $list_last = $pager->getTotalPages(); + $i = $i + ($pager_max - $pager_last); + $pager_last = $pager_max; } if ($i <= 0) { // Adjust "center" if at start of query. - $list_last = $list_last + (1 - $i); + $pager_last = $pager_last + (1 - $i); $i = 1; } // End of generation loop preparation.