public function getRequest() { $request = parent::getRequest(); if (!$this->getUser()->isAuthentic()) { $request->query->access = 0; } $view = $request->query->get('view', 'cmd', null); if ($view && Library\StringInflector::isPlural($view)) { if ($request->getFormat() != 'json') { $sort_by_map = array('newest' => array('ordering_date' => 'DESC'), 'oldest' => array('ordering_date' => 'ASC'), 'order' => array('ordering' => 'ASC')); // Get the parameters $params = $this->getObject('application')->getParams(); // Force some request vars based on setting parameters. $request->query->limit = (int) $params->get('articles_per_page', 3); $sort_by = $sort_by_map[$params->get('sort_by', 'newest')]; $request->query->sort = key($sort_by); $request->query->direction = current($sort_by); } // Allow editors (and above) to view unpublished items on lists. if (!$this->canEdit()) { $request->query->published = 1; } //Always show child category articles $request->query->category_recurse = false; } return $request; }
public function render() { $model = $this->getModel(); if (Library\StringInflector::isPlural($this->getName())) { $data = array('settings' => $model->getRowset()->toArray()); } else { $data = $model->getRow()->toArray(); } $this->setContent($data); return parent::render(); }