diff --git a/ground/controllers/PageController.php b/ground/controllers/PageController.php index 71e85e6..e976d70 100644 --- a/ground/controllers/PageController.php +++ b/ground/controllers/PageController.php @@ -2,7 +2,7 @@ class PageController extends Controller { - const elementsByPage = 50; + const elementsByPage = 30; static function actionPoints() { @@ -46,9 +46,34 @@ class PageController extends Controller $param = array(); $param['where'] = '`moderate` = 1'; $pointsCount = Point::model()->getCount($param); - $pagesCount = ceil($pointsCount/self::elementsByPage); + $pagesCount = intval(ceil($pointsCount/self::elementsByPage)); $page = isset($_GET['page']) ? abs((int)$_GET['page']) : $pagesCount; + $pages = array(); + + for ($index = $pagesCount; $index > $pagesCount-3; $index--) { + $pages[$index] = 1; + } + + for ($index = 3; $index > 0; $index--) { + $pages[$index] = 1; + } + + if ($page > $pagesCount) { + $page = $pagesCount; + } else if ($page < 1) { + $page = 1; + } + + $topIndex = ($page+2 > $pagesCount) ? $pagesCount : $page+2; + $bottomIndex = ($page-3 < 1) ? 1 : $page-3; + + for ($index = $topIndex; $index > $bottomIndex; $index--) { + $pages[$index] = 1; + } + + krsort($pages); + $param = array(); $param['order'] = 'id DESC'; if (App::getParam('category')) { @@ -88,6 +113,7 @@ class PageController extends Controller 'pointsCount' => $pointsCount, 'page' => $page, 'pagesCount' => $pagesCount, + 'pages' => $pages, 'notModeratedPoints' => $notModeratedPoints, 'randomPoint' => Point::model()->getRandom(), )); diff --git a/ground/views/pointsTemplate.php b/ground/views/pointsTemplate.php index 6d432cd..5fb0e97 100644 --- a/ground/views/pointsTemplate.php +++ b/ground/views/pointsTemplate.php @@ -5,6 +5,7 @@ if (App::getParam('user')) { App::redirect('/page/points/'); } } +$oldIndex = $pagesCount+1; ?>
@@ -74,9 +75,13 @@ if (App::getParam('user')) { - 0; $index--): ?> + $val): ?> + +
  • ...
  • +
  • - + +