示例#1
0
 public function get_index($page = 1)
 {
     $articles = Model_Articles::getLast($page, self::ARTICLES_BY_PAGE);
     if ($articles->isEmpty()) {
         $this->response->set(\Eliya\Tpl::get('index/no_articles'));
         return;
     }
     $tpl_articles = Eliya\Tpl::get('common/articles/list', ['articles' => $articles]);
     $nbrPages = ceil(Model_Articles::count('is_published = ?', [1]) / self::ARTICLES_BY_PAGE);
     if ($page == 1) {
         \Eliya\Tpl::set('canonical_url', BASE_URL);
     }
     $this->response->set(\Eliya\Tpl::get('index/index', ['tpl_articles' => $tpl_articles, 'nbr_pages' => $nbrPages, 'current_page' => $page]));
 }
 private function displayDetails(Model_Categories $category, $page)
 {
     if (empty($category)) {
         $this->response->error('La catégorie demandée est introuvable.', 404);
         return;
     }
     \Eliya\Tpl::set('page_title', $category->prop('name'));
     $articles = Model_Articles::getLast($page, self::ARTICLES_BY_PAGE, $category);
     if ($articles->isEmpty()) {
         $this->response->set(\Eliya\Tpl::get('categories/no_articles', ['category' => $category]));
         return;
     }
     $tpl_articles = Eliya\Tpl::get('common/articles/list', ['articles' => $articles]);
     $nbrPages = ceil(Model_Articles::countByCategory($category) / self::ARTICLES_BY_PAGE);
     if ($page == 1) {
         \Eliya\Tpl::set('canonical_url', $category->getUrl());
     }
     $this->response->set(\Eliya\Tpl::get('categories/details', ['category' => $category, 'tpl_articles' => $tpl_articles, 'nbr_pages' => $nbrPages, 'current_page' => $page]));
 }
示例#3
0
 public function get_index($unused_param = 0)
 {
     $this->response->type(\Eliya\Mime::XML)->isRaw(true);
     $categories = Model_Categories::getAll();
     $categoriesIdsToNames = [];
     foreach ($categories as $category) {
         $categoriesIdsToNames[$category->getId()] = $category->prop('name');
     }
     $authors = Model_Users::getAll();
     $authorsIdsToNames = [];
     foreach ($authors as $author) {
         $authorsIdsToNames[$author->getId()] = $author->prop('username');
     }
     $tpl_items = null;
     $articles = Model_Articles::getLast(1, self::ARTICLES_BY_PAGE);
     foreach ($articles as $article) {
         $tpl_items .= \Eliya\Tpl::get('rss/item_article', ['article' => $article, 'author' => $authorsIdsToNames[$article->id_author] ?: null, 'category' => $categoriesIdsToNames[$article->id_category] ?: null]);
     }
     $this->response->set(\Eliya\Tpl::get('rss/index', ['tpl_items' => $tpl_items]));
 }