diff --git a/ground/controllers/FeedController.php b/ground/controllers/FeedController.php new file mode 100644 index 0000000..8afd6a0 --- /dev/null +++ b/ground/controllers/FeedController.php @@ -0,0 +1,71 @@ +getAll(array( + 'order' => '`pubDate` DESC', + 'limit' => 5, + )); + foreach ($news as $new) { + $feed[$new->date] = array( + 'title' => $new->name, + 'text' => $new->description, + 'img' => '', + 'type' => 'news', + ); + } + + // --------- POINTS + $points = Point::model()->getAll(array( + 'order' => '`date` DESC', + 'limit' => 5, + )); + foreach ($points as $point) { + $feed[$point->date] = array( + 'title' => $point->name, + 'text' => $point->description, + 'img' => $point->getImg(), + 'type' => 'point', + ); + } + + // --------- ARTICLES + $articles = Article::model()->getAll(array( + 'order' => '`id` DESC', + 'limit' => 5, + )); + foreach ($articles as $article) { + $feed[$article->pubDate] = array( + 'title' => $article->title, + 'text' => $article->text, + 'img' => $article->getImg(), + 'type' => 'article', + ); + } + + // --------- SORT + + krsort($feed); + + self::$layout = 'layouts/page.php'; + 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/jquery.cookie.js'); + self::addStyle('/css/style.css?ver=' . App::getConfig('version')); + self::addStyle('/css/pageStyle.css?ver=' . App::getConfig('version')); + self::addStyle('/css/bootstrap.min.css'); + self::addStyle('/css/bootstrap-theme.min.css'); + + self::render('feed/index.php', array( + 'news' => $news, + 'articles' => $articles, + 'points' => $points, + )); + } +} diff --git a/ground/models/News.php b/ground/models/News.php new file mode 100644 index 0000000..8282a02 --- /dev/null +++ b/ground/models/News.php @@ -0,0 +1,18 @@ +_tableName_ = 'news'; + parent::__construct($fromArray); + $this->setRelation('RefUser', 'userId', 'User', 'id', self::TO_ONE); + } + + static function model() + { + return new self(); + } + +} diff --git a/ground/views/feed/index.php b/ground/views/feed/index.php new file mode 100644 index 0000000..05722ff --- /dev/null +++ b/ground/views/feed/index.php @@ -0,0 +1,43 @@ +
+