/** * Display a list of articles * * @return void */ public function displayTask() { // Get filters $filters = array('search' => Request::getState($this->_option . '.' . $this->_controller . '.search', 'search', ''), 'category' => Request::getState($this->_option . '.' . $this->_controller . '.category', 'category', 0, 'int'), 'sort' => Request::getState($this->_option . '.' . $this->_controller . '.sort', 'filter_order', 'title'), 'sort_Dir' => Request::getState($this->_option . '.' . $this->_controller . '.sortdir', 'filter_order_Dir', 'ASC'), 'access' => Request::getState($this->_option . '.' . $this->_controller . '.access', 'access', 0, 'int')); $articles = Article::all(); if ($filters['search']) { $articles->whereLike('title', strtolower((string) $filters['search'])); } if ($filters['category']) { $articles->whereEquals('category', (int) $filters['category']); } if ($filters['access']) { $articles->whereEquals('access', (int) $filters['access']); } // Get records $rows = $articles->ordered('filter_order', 'filter_order_Dir')->paginated('limitstart', 'limit')->rows(); // Get the sections $categories = Category::all()->ordered()->rows(); // Output the HTML $this->view->set('filters', $filters)->set('rows', $rows)->set('categories', $categories)->display(); }
/** * Create an item entry * * @param integer $id Optional ID to use * @return boolean */ public function make($id = null) { if ($this->exists()) { return true; } $id = $id ?: Request::getInt('id', 0); include_once PATH_CORE . DS . 'components' . DS . 'com_kb' . DS . 'models' . DS . 'article.php'; $article = null; if (!$id) { $category = Category::all()->whereEquals('alias', Request::getVar('category'))->limit(1)->row(); if (!$category->get('id')) { return true; } $article = Article::all()->whereEquals('alias', Request::getVar('alias', ''))->whereEquals('category', $category->get('id'))->limit(1)->row(); $id = $article->get('id'); } $this->_tbl->loadType($id, $this->_type); if ($this->exists()) { return true; } if (!$article) { $article = Article::oneOrNew($id); } if ($article->isNew()) { $this->setError(Lang::txt('Knowledge base article not found.')); return false; } $this->set('type', $this->_type)->set('object_id', $article->get('id'))->set('created', $article->get('created'))->set('created_by', $article->get('created_by'))->set('title', $article->get('title'))->set('description', \Hubzero\Utility\String::truncate($article->fulltxt(), 200))->set('url', Route::url($article->link())); if (!$this->store()) { return false; } return true; }