Source for file archive.php
Documentation is available at archive.php
* @subpackage com_content
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
require_once __DIR__ .
'/articles.php';
* Content Component Archive Model
* @subpackage com_content
* Method to auto-populate the model state.
* Note. Calling getState in this method will result in recursion.
protected function populateState($ordering =
null, $direction =
null)
// Add archive properties
$params =
$this->state->params;
// Filter on archived articles
$this->setState('filter.month', $app->input->getInt('month'));
$this->setState('filter.year', $app->input->getInt('year'));
$this->setState('list.filter', $app->input->getString('filter-search'));
$itemid =
$app->input->get('Itemid', 0, 'int');
$limit =
$app->getUserStateFromRequest('com_content.archive.list' .
$itemid .
'.limit', 'limit', $params->get('display_num'), 'uint');
// Set the archive ordering
$params =
$this->state->params;
$articleOrderby =
$params->get('orderby_sec', 'rdate');
$articleOrderDate =
$params->get('order_date');
$orderby =
$primary .
' ' .
$secondary .
' a.created DESC ';
$this->setState('list.ordering', $orderby);
// Create a new query object.
// Add routing for archive
$case_when =
' CASE WHEN ';
$case_when .=
$query->charLength('a.alias', '!=', '0');
$a_id =
$query->castAsChar('a.id');
$case_when .=
$query->concatenate(array($a_id, 'a.alias'), ':');
$case_when .=
$a_id.
' END as slug';
$query->select($case_when);
$case_when =
' CASE WHEN ';
$case_when .=
$query->charLength('c.alias', '!=', '0');
$c_id =
$query->castAsChar('c.id');
$case_when .=
$query->concatenate(array($c_id, 'c.alias'), ':');
$case_when .=
$c_id.
' END as catslug';
$query->select($case_when);
// First, get the date field
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));
* Method to get the archived article list
// Lets load the content if it doesn't already exist
// 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);
// JModelLegacy override to add alternating value for $odd
protected function _getList($query, $limitstart=
0, $limit=
0)
$result =
parent::_getList($query, $limitstart, $limit);
foreach ($result as $k =>
$row)
Documentation generated on Tue, 19 Nov 2013 14:53:49 +0100 by phpDocumentor 1.4.3