state->params; // Filter on archived articles $this->setState('filter.published', 2); // Filter on month, year $this->setState('filter.month', $app->input->getInt('month')); $this->setState('filter.year', $app->input->getInt('year')); // Optional filter text $this->setState('list.filter', $app->input->getString('filter-search')); // Get list limit $itemid = $app->input->get('Itemid', 0, 'int'); $limit = $app->getUserStateFromRequest('com_content.archive.list' . $itemid . '.limit', 'limit', $params->get('display_num'), 'uint'); $this->setState('list.limit', $limit); } /** * @return JDatabaseQuery */ protected function getListQuery() { // Set the archive ordering $params = $this->state->params; $articleOrderby = $params->get('orderby_sec', 'rdate'); $articleOrderDate = $params->get('order_date'); // No category ordering $categoryOrderby = ''; $secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate) . ', '; $primary = ContentHelperQuery::orderbyPrimary($categoryOrderby); $orderby = $primary . ' ' . $secondary . ' a.created DESC '; $this->setState('list.ordering', $orderby); $this->setState('list.direction', ''); // Create a new query object. $query = parent::getListQuery(); // Add routing for archive //sqlsrv changes $case_when = ' CASE WHEN '; $case_when .= $query->charLength('a.alias', '!=', '0'); $case_when .= ' THEN '; $a_id = $query->castAsChar('a.id'); $case_when .= $query->concatenate(array($a_id, 'a.alias'), ':'); $case_when .= ' ELSE '; $case_when .= $a_id.' END as slug'; $query->select($case_when); $case_when = ' CASE WHEN '; $case_when .= $query->charLength('c.alias', '!=', '0'); $case_when .= ' THEN '; $c_id = $query->castAsChar('c.id'); $case_when .= $query->concatenate(array($c_id, 'c.alias'), ':'); $case_when .= ' ELSE '; $case_when .= $c_id.' END as catslug'; $query->select($case_when); // Filter on month, year // First, get the date field $queryDate = ContentHelperQuery::getQueryDate($articleOrderDate); if ($month = $this->getState('filter.month')) { $query->where('MONTH('. $queryDate . ') = ' . $month); } if ($year = $this->getState('filter.year')) { $query->where('YEAR('. $queryDate . ') = ' . $year); } //echo nl2br(str_replace('#__','jos_',$query)); return $query; } /** * Method to get the archived article list * * @access public * @return array */ public function getData() { $app = JFactory::getApplication(); // Lets load the content if it doesn't already exist if (empty($this->_data)) { // Get the page/component configuration $params = $app->getParams(); // Get the pagination request variables $limit = $app->input->get('limit', $params->get('display_num', 20), 'uint'); $limitstart = $app->input->get('limitstart', 0, 'uint'); $query = $this->_buildQuery(); $this->_data = $this->_getList($query, $limitstart, $limit); } return $this->_data; } // JModelLegacy override to add alternating value for $odd protected function _getList($query, $limitstart=0, $limit=0) { $result = parent::_getList($query, $limitstart, $limit); $odd = 1; foreach ($result as $k => $row) { $result[$k]->odd = $odd; $odd = 1 - $odd; } return $result; } }