From 6c4a89faa99063c90e586b580cd6fd516e58d9fb Mon Sep 17 00:00:00 2001 From: Krivchikov Dmitry Date: Sat, 17 Oct 2015 19:51:01 +0300 Subject: [PATCH] FIX --- ground/controllers/FeedController.php | 2 ++ ground/models/Article.php | 13 +++++++++++++ ground/views/feed/index.php | 27 ++++++++++++++++----------- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/ground/controllers/FeedController.php b/ground/controllers/FeedController.php index 8afd6a0..264fb63 100644 --- a/ground/controllers/FeedController.php +++ b/ground/controllers/FeedController.php @@ -22,6 +22,7 @@ class FeedController extends Controller // --------- POINTS $points = Point::model()->getAll(array( + 'where' => '`moderate` = 1', 'order' => '`date` DESC', 'limit' => 5, )); @@ -36,6 +37,7 @@ class FeedController extends Controller // --------- ARTICLES $articles = Article::model()->getAll(array( + 'where' => '`status` = "published"', 'order' => '`id` DESC', 'limit' => 5, )); diff --git a/ground/models/Article.php b/ground/models/Article.php index e27e71a..ccd3915 100644 --- a/ground/models/Article.php +++ b/ground/models/Article.php @@ -31,4 +31,17 @@ class Article extends Model return $size == 'small' ? '/img/noPhoto200150.png' : '/img/logo.png'; } + public function hasImg() + { + $imgId = (int)$this->photoId; + + if ($imgId) { + $img = ArticlePhotos::model()->getByPK($imgId); + if ($img) { + return TRUE; + } + } + return FALSE; + } + } diff --git a/ground/views/feed/index.php b/ground/views/feed/index.php index 05722ff..e11ce05 100644 --- a/ground/views/feed/index.php +++ b/ground/views/feed/index.php @@ -7,31 +7,36 @@
-

Новости

-
+

title ?>

text, 0, 400, 'UTF-8') ?>…
-

Точки

-
-

name ?>

-
- description, 0, 400, 'UTF-8') ?>… +
+ +

name ?>

+
+ + description, 0, 400, 'UTF-8') ?> … + >>>
-

Статьи

-
-

title ?>

+
+ +

title ?>

+
+ hasImg()): ?> - text, 0, 400, 'UTF-8') ?>… + + text), 0, 400, 'UTF-8') ?> … + >>>