Esempio n. 1
0
 /**
  * Список новостей
  */
 public function index()
 {
     $total = News::count();
     $page = App::paginate(Setting::get('news_per_page'), $total);
     $news_list = News::all(['offset' => $page['offset'], 'limit' => $page['limit'], 'order' => 'created_at desc', 'include' => ['user']]);
     App::view('news.index', compact('news_list', 'page'));
 }
Esempio n. 2
0
 public function taggedAction($tag)
 {
     $tag = $this->filter->sanitize($tag, "alphanum");
     Phalcon_Tag::setTitle('Tagged ' . $tag);
     $category = Categories::findFirst("name='{$tag}'");
     if ($category == false) {
         return $this->_forward('index/index');
     }
     $news = array();
     $newsCategories = NewsCategories::find(array("categories_id='" . $category->id . "'"));
     foreach ($newsCategories as $newCategory) {
         $news[] = $newCategory->getNews();
     }
     $this->view->setVar("activeYear", 0);
     $this->view->setVar("tag", $tag);
     $this->view->setVar("news", $news);
     $this->view->setVar("years", News::count(array('group' => 'year')));
 }
Esempio n. 3
0
 public function taggedAction($tag)
 {
     $tag = $this->filter->sanitize($tag, "alphanum");
     $exists = $this->view->getCache()->exists($tag);
     if (!$exists) {
         Phalcon\Tag::setTitle('Tagged ' . $tag);
         $category = Categories::findFirst("name='{$tag}'");
         if ($category == false) {
             return $this->dispatcher->forward(array('controller' => 'index', 'action' => 'index'));
         }
         $news = array();
         $newsCategories = NewsCategories::find(array("categories_id='" . $category->id . "'"));
         foreach ($newsCategories as $newCategory) {
             $news[] = $newCategory->getNews();
         }
         $this->view->setVar("activeYear", 0);
         $this->view->setVar("tag", $tag);
         $this->view->setVar("news", $news);
         $this->view->setVar("years", News::count(array('group' => 'year')));
     }
     $this->view->cache(array("lifetime" => 86400, "key" => $tag));
 }
Esempio n. 4
0
/**
 *  Количество новостей
 * @return integer количество новостей
 */
function newsCount()
{
    return News::count();
}