diff --git a/controllers/PageController.php b/controllers/PageController.php index f65225b..539fe48 100644 --- a/controllers/PageController.php +++ b/controllers/PageController.php @@ -121,7 +121,7 @@ class PageController extends Controller App::setConfig('title', App::$defaultTitle); - self::render('pointsTemplate.php', array( + self::render('page/points.php', array( 'categories' => $categories, 'points' => $result, 'pointsCount' => $pointsCount, @@ -133,6 +133,99 @@ class PageController extends Controller )); } + static function actionArticles() + { + self::$layout = 'layouts/page.php'; + self::addStyle('/css/style.css?ver=' . App::getConfig('version')); + self::addStyle('/css/pageStyle.css?ver=' . App::getConfig('version')); + self::addScript('/js/jquery-2.1.0.min.js'); + self::addScript('/js/jquery-ui-1.10.4.custom.min.js'); + self::addScript('/js/bootstrap.min.js'); + self::addScript('/js/app.js'); + self::addStyle('/css/bootstrap.min.css'); + self::addStyle('/css/bootstrap-theme.min.css'); + + $param = array(); + $param['order'] = '`pubDate` ASC'; + $param['where'] = '`status` = "published"'; + + $articlesCount = Article::model()->getCount($param); + $pagesCount = intval(ceil($articlesCount/self::elementsByPage)); + $fullPagesCount = intval(floor($articlesCount/self::elementsByPage)); + $residue = $articlesCount - ($fullPagesCount * self::elementsByPage); + + if ($residue < self::minElementsByPage) { + $pagesCount = $fullPagesCount; + } + + $page = isset($_GET['page']) ? abs((int)$_GET['page']) : $pagesCount; + + $pages = array(); + + // Заполняем страницы от большей к меньшей - добавляем 3 штуки + for ($index = $pagesCount; (($index > $pagesCount-3) && ($index > 0)); $index--) { + $pages[$index] = 1; + } + + // Заполняем страницы от 3 к 1 - добавляем 3 штуки + if ($pagesCount >= 3) { + for ($index = 3; $index > 0; $index--) { + $pages[$index] = 1; + } + } + + if ($page > $pagesCount) { + $page = $pagesCount; + } else if ($page < 1) { + $page = 1; + } + + // Заполняем страницы вокруг текущей. +/- 2 штуки. + $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); + + if ($page == $pagesCount && $residue < self::minElementsByPage) { + $param['limit'] = self::elementsByPage + $residue; + } else { + $param['limit'] = self::elementsByPage; + } + + if($page) { + $param['offset'] = self::elementsByPage * ($page - 1); + } + + $articles = Article::model()->getAll($param); + $articles = array_reverse($articles); + + $result = array(); + + foreach ($articles as $article) { + $id = $article->id; + $result[$id]['id'] = $article->id; + $result[$id]['title'] = $article->title; + $result[$id]['text'] = mb_substr(Markdown::getClear($article->text), 0, 400, 'UTF-8'); + $result[$id]['photoId'] = $article->photoId; + $result[$id]['img'] = $article->getImg('middle'); + $result[$id]['author'] = $article->authorUser->nick; + } + + App::setConfig('title', App::$defaultTitle); + + self::render('page/articles.php', array( + 'articles' => $result, + 'articlesCount' => $articlesCount, + 'page' => $page, + 'pagesCount' => $pagesCount, + 'pages' => $pages, + 'randomPoint' => Point::model()->getRandom(), + )); + } + static function actionPoint() { $pointId = (int) App::getParam('id'); diff --git a/public/img/no-background.png b/public/img/no-background.png new file mode 100644 index 0000000..09a449a Binary files /dev/null and b/public/img/no-background.png differ diff --git a/views/feed/index.php b/views/feed/index.php index 37b1532..ff97faa 100644 --- a/views/feed/index.php +++ b/views/feed/index.php @@ -40,6 +40,8 @@ authorUser->nick ?> +
+

Тут целая лента статей!


diff --git a/views/page/articles.php b/views/page/articles.php new file mode 100644 index 0000000..1673933 --- /dev/null +++ b/views/page/articles.php @@ -0,0 +1,74 @@ + +
+ +
+
+
+

Лента статей

+
+ Перейти: на карту или к точкам +
+
+ +
+
+
+ 1):?> + + +
+ +
+
+ + + + +
+
+
+ $randomPoint), true)?> +
diff --git a/views/pointsTemplate.php b/views/page/points.php similarity index 97% rename from views/pointsTemplate.php rename to views/page/points.php index c8fd62b..521d0ba 100644 --- a/views/pointsTemplate.php +++ b/views/page/points.php @@ -14,7 +14,7 @@ $oldIndex = $pagesCount+1;

Списки точек по категориям

- Перейти: на карту + Перейти: на карту или к статьям / страница nick?>.