From 314adde2b170edf218b1eccc51ae1da4e14eeef2 Mon Sep 17 00:00:00 2001 From: ilyautkin Date: Thu, 1 Aug 2013 02:41:14 +0400 Subject: [PATCH] Update include.getpage.php Change the algoritm of shows links to any page in [[+page.nav]] --- core/components/getpage/include.getpage.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/components/getpage/include.getpage.php b/core/components/getpage/include.getpage.php index 7280a48..cba3b96 100644 --- a/core/components/getpage/include.getpage.php +++ b/core/components/getpage/include.getpage.php @@ -17,7 +17,15 @@ function getpage_buildControls(& $modx, $properties) { $nav['prev'] = getpage_makeUrl($modx, $properties, $page - 1, $pagePrevTpl); } } - if (empty($pageLimit) || ($i >= $page - $pageLimit && $i <= $page + $pageLimit)) { + $halfPageLimit = $secondHalfPageLimit = ($pageLimit - ($pageLimit%2)) / 2; + if ($halfPageLimit == $pageLimit / 2) $halfPageLimit = $halfPageLimit - 1; + if ($pageLimit > $page + $secondHalfPageLimit) { + $secondHalfPageLimit = $secondHalfPageLimit - ($page - $halfPageLimit - 1); + } + if ($pageCount < $page + $secondHalfPageLimit) { + $halfPageLimit = $halfPageLimit + ($page + $secondHalfPageLimit - $pageCount); + } + if (empty($pageLimit) || ($i >= $page - $halfPageLimit && $i <= $page + $secondHalfPageLimit)) { if (!array_key_exists('pages', $nav)) $nav['pages'] = array(); if ($i == $page) { $nav['pages'][$i] = getpage_makeUrl($modx, $properties, $i, $pageActiveTpl);