From 49a0c4d358930e84d9dcc40c82e73cf19d661334 Mon Sep 17 00:00:00 2001 From: Krivchikov Dmitry Date: Fri, 1 Apr 2016 21:02:12 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D1=82=D0=B4=D0=B5=D0=BB=D1=8C=D0=BD?= =?UTF-8?q?=D0=B0=D1=8F=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D0=B0?= =?UTF-8?q?=20=D0=B4=D0=BB=D1=8F=20=D0=BB=D0=B5=D0=BD=D1=82=D1=8B=20=D1=81?= =?UTF-8?q?=D1=82=D0=B0=D1=82=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/PageController.php | 95 +++++++++++++++++- public/img/no-background.png | Bin 0 -> 1181 bytes views/feed/index.php | 2 + views/page/articles.php | 74 ++++++++++++++ views/{pointsTemplate.php => page/points.php} | 2 +- 5 files changed, 171 insertions(+), 2 deletions(-) create mode 100644 public/img/no-background.png create mode 100644 views/page/articles.php rename views/{pointsTemplate.php => page/points.php} (97%) 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 0000000000000000000000000000000000000000..09a449af565d9ecab5c4f969a6b9bcf33febf0d4 GIT binary patch literal 1181 zcmeAS@N?(olHy`uVBq!ia0y~yVAKJ!mvOKG$ppns^+1ZH*vT`50|;t3QaXTq&H|6f zVxaH?5M~UNEMf%;N|v}rlmzFem6RtIr81P4m+NKbWfvzW7NqLs7p2dBXCnnvE#>Lr z7*a9k?H%ttX+r_mK=>+NJ;{QOyY z>&}__)t}B?v^;;UIGt60w|v61FNYPFY|H!3mGWMx-gwZ*`rJ9;T<)-6i5~YYtiwjI(7K7X zv*%uY#_}rL8)VYEPhgYgZkX(O(CVSV68q@sa~Bt@zj?BFcT?%1#0{Un?bHJr$MUMm z86}T@JEHso*|{S8?a`<=}sb0*&*)DrNNJ|30^F_wj)Ngub-s?@pCF@QDwKrPb{sI!%T>SqIr?utb?fZr16$HH9Q~R!E?wptN<2kkE z53B;Z;7yFRJHK;%$@;1Q)>Y5_entJ-*mkqH?A?4}jj~w?w${&2RWrXh>oa{n%PBHd z_orUsa`ULG>8tk$zcYQhyJhNqnb>)2Kl#l_y?I=Z6@3SH-sw@-M|4yBzp{XCv^J>h=N!X@{(>q%=d6KnBKrJXO% zML%1>9j?;;w&h&R#F!fO5AE8M^k)fcRLlVy1$51s=Uq>_%bC6xyMB5!_khhh4>667 zhh0zDpEtbTq4e{ZWrBRT3bSF%M4lrVwXQ}JmR=P->9B3_dJnd9MOQ>m9=N#($gJwz zr6l=c?HAFL4E5Tju0{vSx5Z85Dd_eF%2gb>^j?VRjLFyCEezUs|88V!Sj}6%hB0Bg z{BC)MgeeJ(hAiA2iV+Sx2bq#M!~~o-G)OeD9ud${Xd9IxGc+EHyF~JDewMOn1+XY# N@O1TaS?83{1OQOk>e>JR literal 0 HcmV?d00001 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?>.