Exemplo n.º 1
0
 public function action_index()
 {
     $category_uri = $this->request->param('category_uri');
     $news_category = new News_Category();
     $category_list = $news_category->get_list($this->page_id);
     if (empty($category_list)) {
         throw new HTTP_Exception_404();
     }
     $category_orm = $news_category->by_uri($category_list, $category_uri);
     $orm = ORM::factory('news')->where('category_id', 'IN', array_keys($category_list));
     if ($category_orm) {
         $orm->where('category_id', '=', $category_orm->id);
         $properties = $news_category->get_properties(array($category_orm));
         $properties = reset($properties);
         $this->title = $category_orm->title;
         $this->breadcrumbs[] = array('title' => $category_orm->title);
     } else {
         $orm_helper = ORM_Helper::factory('page', $this->page_id);
         $properties = $orm_helper->property_list();
     }
     $paginator_orm = clone $orm;
     $paginator = new Paginator('layout/paginator');
     $paginator->per_page($this->limit)->count($paginator_orm->count_all());
     unset($paginator_orm);
     $list = $orm->paginator($paginator)->find_all()->as_array();
     $titlebar_title = Arr::path($properties, 'Title.value');
     if (empty($titlebar_title)) {
         $titlebar_title = __('Blog');
     }
     $this->template->set_filename('modules/news/list')->set('list', $list)->set('paginator', $paginator)->set('categories', $category_list)->set('properties', $properties)->set('titlebar_title', $titlebar_title);
 }