/**
  * Method to auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  * @param   string  $ordering   The field to order on.
  * @param   string  $direction  The direction to order on.
  *
  * @return  void.
  *
  * @since   1.6
  */
 protected function populateState($ordering = null, $direction = null)
 {
     parent::populateState();
     $app = JFactory::getApplication();
     // Add archive properties
     $params = $this->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);
     // Set the archive ordering
     $articleOrderby = $params->get('orderby_sec', 'rdate');
     $articleOrderDate = $params->get('order_date');
     // No category ordering
     $secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate);
     $this->setState('list.ordering', $secondary . ', a.created DESC');
     $this->setState('list.direction', '');
 }
示例#2
0
 /**
  * @return	JDatabaseQuery
  */
 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
     $query->select(' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug');
     $query->select(' CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(":", c.id, c.alias) ELSE c.id END as catslug');
     // 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 auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  * @param   string  $ordering   The field to order on.
  * @param   string  $direction  The direction to order on.
  *
  * @return  void.
  *
  * @since   1.6
  */
 protected function populateState($ordering = null, $direction = null)
 {
     parent::populateState($ordering, $direction);
     $input = JFactory::getApplication()->input;
     $user = JFactory::getUser();
     // List state information
     $limitstart = $input->getUInt('limitstart', 0);
     $this->setState('list.start', $limitstart);
     $params = $this->state->params;
     $limit = $params->get('num_leading_articles') + $params->get('num_intro_articles') + $params->get('num_links');
     $this->setState('list.limit', $limit);
     $this->setState('list.links', $params->get('num_links'));
     $this->setState('filter.frontpage', true);
     if (!$user->authorise('core.edit.state', 'com_content') && !$user->authorise('core.edit', 'com_content')) {
         // Filter on published for those who do not have edit or edit.state rights.
         $this->setState('filter.published', 1);
     } else {
         $this->setState('filter.published', array(0, 1, 2));
     }
     // Check for category selection
     if ($params->get('featured_categories') && implode(',', $params->get('featured_categories')) == true) {
         $featuredCategories = $params->get('featured_categories');
         $this->setState('filter.frontpage.categories', $featuredCategories);
     }
     $articleOrderby = $params->get('orderby_sec', 'rdate');
     $articleOrderDate = $params->get('order_date');
     $categoryOrderby = $params->def('orderby_pri', '');
     $secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate);
     $primary = ContentHelperQuery::orderbyPrimary($categoryOrderby);
     $this->setState('list.ordering', $primary . $secondary . ', a.created DESC');
     $this->setState('list.direction', '');
 }
 /**
  * @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;
 }
示例#5
0
 function _buildContentOrderBy()
 {
     $filter_order = JRequest::getCmd('filter_order');
     $filter_order_Dir = JRequest::getWord('filter_order_Dir');
     $orderby = ' ORDER BY ';
     if ($filter_order && $filter_order_Dir) {
         $orderby .= $filter_order . ' ' . $filter_order_Dir . ', ';
     }
     // Get the page/component configuration
     $params = $this->getState('parameters.menu');
     if (!is_object($params)) {
         $params =& JComponentHelper::getParams('com_content');
     }
     // Special ordering for archive articles
     $orderby_sec = $params->def('orderby', 'rdate');
     $primary = ContentHelperQuery::orderbySecondary($orderby_sec);
     $orderby .= $primary;
     return $orderby;
 }
 /**
  * Generates the order by part of the query according to the
  * menu/component/user settings. It checks if the current user
  * has already changed the article's ordering column in the frontend
  *
  * @param JRegistry $params
  * @param int $parentId
  * @param int $itemid
  * @return string
  */
 static function buildContentOrderBy(&$params, $parentId, $itemid)
 {
     $app = JFactory::getApplication('site');
     // Case when the child gets a different menu itemid than it's parent
     if ($parentId != $itemid) {
         $menu = $app->getMenu();
         $item = $menu->getItem($itemid);
         $menuParams = clone $params;
         $itemParams = new JRegistry($item->params);
         $menuParams->merge($itemParams);
     } else {
         $menuParams =& $params;
     }
     $filter_order = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order', 'filter_order', '', 'string');
     $filter_order_Dir = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order_Dir', 'filter_order_Dir', '', 'cmd');
     $orderby = ' ';
     if ($filter_order && $filter_order_Dir) {
         $orderby .= $filter_order . ' ' . $filter_order_Dir . ', ';
     }
     $articleOrderby = $menuParams->get('orderby_sec', 'rdate');
     $articleOrderDate = $menuParams->get('order_date');
     //$categoryOrderby  = $menuParams->def('orderby_pri', '');
     $secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate) . ', ';
     //$primary      = ContentHelperQuery::orderbyPrimary($categoryOrderby);
     //$orderby .= $primary . ' ' . $secondary . ' a.created ';
     $orderby .= $secondary . ' a.created ';
     return $orderby;
 }
示例#7
0
 /**
  * Get the list of items.
  *
  * @return  JDatabaseQuery
  */
 protected function getListQuery()
 {
     // Set the blog ordering
     $params = $this->state->params;
     $articleOrderby = $params->get('orderby_sec', 'rdate');
     $articleOrderDate = $params->get('order_date');
     $categoryOrderby = $params->def('orderby_pri', '');
     $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();
     // Filter by frontpage.
     if ($this->getState('filter.frontpage')) {
         $query->join('INNER', '#__content_frontpage AS fp ON fp.content_id = a.id');
     }
     // Filter by categories
     $featuredCategories = $this->getState('filter.frontpage.categories');
     if (is_array($featuredCategories) && !in_array('', $featuredCategories)) {
         $query->where('a.catid IN (' . implode(',', $featuredCategories) . ')');
     }
     return $query;
 }
 function _buildContentOrderBy($state = 1)
 {
     $filter_order = JRequest::getCmd('filter_order');
     $filter_order_Dir = JRequest::getWord('filter_order_Dir');
     $orderby = ' ORDER BY ';
     if ($filter_order && $filter_order_Dir) {
         $orderby .= $filter_order . ' ' . $filter_order_Dir . ', ';
     }
     // Get the page/component configuration
     $app =& JFactory::getApplication();
     $params =& $app->getParams();
     switch ($state) {
         case -1:
             // Special ordering for archive articles
             $orderby_sec = $params->def('orderby', 'rdate');
             $secondary = ContentHelperQuery::orderbySecondary($orderby_sec);
             $primary = '';
             break;
         case 1:
         default:
             $orderby_sec = $params->def('orderby_sec', 'rdate');
             $orderby_sec = $orderby_sec == 'front' ? '' : $orderby_sec;
             $orderby_pri = $params->def('orderby_pri', '');
             $secondary = ContentHelperQuery::orderbySecondary($orderby_sec);
             $primary = ContentHelperQuery::orderbyPrimary($orderby_pri);
             break;
     }
     $orderby .= "{$primary} {$secondary}";
     return $orderby;
 }
示例#9
0
 /**
  * Build the orderby for the query
  *
  * @return	string	$orderby portion of query
  */
 protected function _buildContentOrderBy()
 {
     $app =& JFactory::getApplication('site');
     $params = $this->_state->params;
     $itemid = JRequest::getInt('id', 0) . ':' . JRequest::getInt('Itemid', 0);
     $filter_order = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order', 'filter_order', '', 'string');
     $filter_order_Dir = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order_Dir', 'filter_order_Dir', '', 'cmd');
     $orderby = ' ';
     if ($filter_order && $filter_order_Dir) {
         $orderby .= $filter_order . ' ' . $filter_order_Dir . ', ';
     }
     $articleOrderby = $params->get('article_orderby', 'rdate');
     $articleOrderDate = $params->get('order_date');
     $categoryOrderby = $params->def('category_orderby', '');
     $secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate) . ', ';
     $primary = ContentHelperQuery::orderbyPrimary($categoryOrderby);
     $orderby .= $primary . ' ' . $secondary . ' a.created DESC ';
     return $orderby;
 }
示例#10
0
 /**
  * Build the orderby for the query
  *
  * @return  string	$orderby portion of query
  * @since   1.5
  */
 protected function _buildContentOrderBy()
 {
     $app = JFactory::getApplication('site');
     $db = $this->getDbo();
     $params = $this->state->params;
     $itemid = $app->input->get('id', 0, 'int') . ':' . $app->input->get('Itemid', 0, 'int');
     $orderCol = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order', 'filter_order', '', 'string');
     $orderDirn = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order_Dir', 'filter_order_Dir', '', 'cmd');
     $orderby = ' ';
     if (!in_array($orderCol, $this->filter_fields)) {
         $orderCol = null;
     }
     if (!in_array(strtoupper($orderDirn), array('ASC', 'DESC', ''))) {
         $orderDirn = 'ASC';
     }
     if ($orderCol && $orderDirn) {
         $orderby .= $db->escape($orderCol) . ' ' . $db->escape($orderDirn) . ', ';
     }
     $articleOrderby = $params->get('orderby_sec', 'rdate');
     $articleOrderDate = $params->get('order_date');
     $categoryOrderby = $params->def('orderby_pri', '');
     $secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate) . ', ';
     $primary = ContentHelperQuery::orderbyPrimary($categoryOrderby);
     $orderby .= $primary . ' ' . $secondary . ' a.created ';
     return $orderby;
 }
示例#11
0
 function _buildContentOrderBy($state = 1)
 {
     global $mainframe;
     // Get the page/component configuration
     $params =& $mainframe->getParams();
     $filter_order = JRequest::getCmd('filter_order');
     $filter_order_Dir = JRequest::getWord('filter_order_Dir');
     $orderby = ' ORDER BY ';
     if ($filter_order && $filter_order_Dir) {
         $orderby .= $filter_order . ' ' . $filter_order_Dir . ', ';
     }
     if ($filter_order == 'author') {
         $orderby .= 'created_by_alias ' . $filter_order_Dir . ', ';
     }
     switch ($state) {
         case -1:
             // Special ordering for archive articles
             $orderby_sec = $params->def('orderby', 'rdate');
             $secondary = ContentHelperQuery::orderbySecondary($orderby_sec) . ', ';
             $primary = '';
             break;
         case 1:
         default:
             $orderby_sec = $params->def('orderby_sec', 'rdate');
             $orderby_sec = $orderby_sec == 'front' ? '' : $orderby_sec;
             $orderby_pri = $params->def('orderby_pri', '');
             $secondary = ContentHelperQuery::orderbySecondary($orderby_sec) . ', ';
             $primary = ContentHelperQuery::orderbyPrimary($orderby_pri);
             break;
     }
     $orderby .= $primary . ' ' . $secondary . ' a.created DESC';
     return $orderby;
 }
示例#12
0
 function _buildContentOrderBy()
 {
     $filter_order = JRequest::getCmd('filter_order');
     $filter_order_Dir = JRequest::getWord('filter_order_Dir');
     if (!in_array($filter_order, array('a.id', 'a.title', 'a.alias', 'a.title_alias', 'a.introtext', 'a.sectionid', 'a.state', 'a.catid', 'a.created', 'a.created_by', 'a.created_by_alias', 'a.modified', 'a.modified_by', 'a.hits', 'a.ordering', 'cc.title', 's.title'))) {
         $filter_order = '';
     }
     if (!in_array(strtoupper($filter_order_Dir), array('ASC', 'DESC'))) {
         $filter_order_Dir = '';
     }
     $orderby = ' ORDER BY ';
     if ($filter_order) {
         $orderby .= $filter_order . ' ' . $filter_order_Dir . ', ';
     }
     // Get the page/component configuration
     $params = $this->getState('parameters.menu');
     if (!is_object($params)) {
         $params =& JComponentHelper::getParams('com_content');
     }
     // Special ordering for archive articles
     $orderby_sec = $params->def('orderby', 'rdate');
     $primary = ContentHelperQuery::orderbySecondary($orderby_sec);
     $orderby .= $primary;
     return $orderby;
 }
示例#13
0
 function _buildContentOrderBy($state = 1)
 {
     $filter_order = JRequest::getCmd('filter_order');
     $filter_order_Dir = JRequest::getWord('filter_order_Dir');
     $orderby = ' ORDER BY ';
     if ($filter_order && $filter_order_Dir) {
         $orderby .= $filter_order . ' ' . $filter_order_Dir . ', ';
     }
     // Get the parameters of the active menu item
     $menu =& JSite::getMenu();
     $item = $menu->getActive();
     $params =& $menu->getParams($item->id);
     switch ($state) {
         case -1:
             // Special ordering for archive articles
             $orderby_sec = $params->def('orderby', 'rdate');
             $secondary = ContentHelperQuery::orderbySecondary($orderby_sec);
             $primary = '';
             break;
         case 1:
         default:
             $orderby_sec = $params->def('orderby_sec', 'rdate');
             $orderby_sec = $orderby_sec == 'front' ? '' : $orderby_sec;
             $orderby_pri = $params->def('orderby_pri', '');
             $secondary = ContentHelperQuery::orderbySecondary($orderby_sec);
             $primary = ContentHelperQuery::orderbyPrimary($orderby_pri);
             break;
     }
     $orderby .= "{$primary} {$secondary}";
     return $orderby;
 }
示例#14
0
 public static function _buildContentOrderBy($atribmenu)
 {
     $app = JFactory::getApplication('site');
     $db = JFactory::getDbo();
     $params = $atribmenu;
     $itemid = $app->input->get('id', 0, 'int') . ':' . $app->input->get('Itemid', 0, 'int');
     $orderCol = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order', 'filter_order', '', 'string');
     $orderDirn = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order_Dir', 'filter_order_Dir', '', 'cmd');
     $orderby = ' ';
     /*if (!in_array($orderCol, $this->filter_fields))
     		{
     			$orderCol = null;
     		}*/
     if (!in_array(strtoupper($orderDirn), array('ASC', 'DESC', ''))) {
         $orderDirn = 'ASC';
     }
     if ($orderCol && $orderDirn) {
         $orderby .= $db->escape($orderCol) . ' ' . $db->escape($orderDirn) . ', ';
     }
     $articleOrderby = $atribmenu['orderby_sec'] ? $atribmenu['orderby_sec'] : 'rdate';
     $articleOrderDate = $atribmenu['order_date'];
     $categoryOrderby = $atribmenu['orderby_pri'];
     require_once JPATH_SITE . '/components/com_content/helpers/query.php';
     $secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate) . ', ';
     $primary = ContentHelperQuery::orderbyPrimary($categoryOrderby);
     $orderby .= $primary . ' ' . $secondary . ' a.created ';
     return $orderby;
 }
示例#15
0
 function _buildContentOrderBy($state = 1)
 {
     global $mainframe;
     // Get the page/component configuration
     $params =& $mainframe->getParams();
     $itemid = JRequest::getInt('id', 0) . ':' . JRequest::getInt('Itemid', 0);
     $filter_order = $mainframe->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order', 'filter_order', '', 'cmd');
     $filter_order_Dir = $mainframe->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order_Dir', 'filter_order_Dir', '', 'cmd');
     if (!in_array($filter_order, array('a.title', 'author', 'a.hits', 'a.created', 'a.publish_up', 'a.publish_down', 'a.modified'))) {
         $filter_order = '';
     }
     if (!in_array(strtoupper($filter_order_Dir), array('ASC', 'DESC'))) {
         $filter_order_Dir = 'ASC';
     }
     $orderby = ' ORDER BY ';
     if ($filter_order && $filter_order_Dir) {
         $orderby .= $filter_order . ' ' . $filter_order_Dir . ', ';
     }
     if ($filter_order == 'author') {
         $orderby .= 'created_by_alias ' . $filter_order_Dir . ', ';
     }
     switch ($state) {
         case -1:
             // Special ordering for archive articles
             $orderby_sec = $params->def('orderby', 'rdate');
             $secondary = ContentHelperQuery::orderbySecondary($orderby_sec) . ', ';
             $primary = '';
             break;
         case 1:
         default:
             $orderby_sec = $params->def('orderby_sec', 'rdate');
             $orderby_sec = $orderby_sec == 'front' ? '' : $orderby_sec;
             $orderby_pri = $params->def('orderby_pri', '');
             $secondary = ContentHelperQuery::orderbySecondary($orderby_sec) . ', ';
             $primary = ContentHelperQuery::orderbyPrimary($orderby_pri);
             break;
     }
     $orderby .= $primary . ' ' . $secondary . ' a.created DESC';
     return $orderby;
 }
示例#16
0
 function buildContentOrderBy()
 {
     $orderby = array();
     $orderby_sec = $this->params->def('orderby_sec', 'rdate');
     if ($orderby_sec == 'random') {
         return ' ORDER BY RAND() ';
     } else {
         $orderby_sec = $orderby_sec == 'front' ? '' : $orderby_sec;
         $orderby_pri = $this->params->def('orderby_pri', '');
         $orderby[] = ContentHelperQuery::orderbySecondary($orderby_sec);
         $orderby[] = ContentHelperQuery::orderbyPrimary($orderby_pri);
         $orderby = array_filter($orderby);
         if (!count($orderby)) {
             $orderby[] = 'a.created DESC';
         }
         return ' ORDER BY ' . implode(',', $orderby);
     }
 }
示例#17
0
 function _buildContentOrderBy($state = 1)
 {
     $filter_order = JRequest::getCmd('filter_order');
     $filter_order_Dir = JRequest::getWord('filter_order_Dir');
     if (!in_array($filter_order, array('a.id', 'a.title', 'a.alias', 'a.title_alias', 'a.introtext', 'a.fulltext', 'a.sectionid', 'a.state', 'a.catid', 'a.created', 'a.created_by', 'a.created_by_alias', 'a.modified', 'a.modified_by', 'a.checked_out', 'a.checked_out_time', 'a.hits', 'a.ordering', 'a.metakey', 'a.access'))) {
         $filter_order = 'a.ordering';
     }
     if (!in_array(trim(strtoupper($filter_order_Dir)), array('ASC', 'DESC'))) {
         $filter_order_Dir = 'ASC';
     }
     $orderby = ' ORDER BY ';
     if ($filter_order) {
         $orderby .= $filter_order . ' ' . $filter_order_Dir . ', ';
     }
     // Get the page/component configuration
     $app =& JFactory::getApplication();
     $params =& $app->getParams();
     switch ($state) {
         case -1:
             // Special ordering for archive articles
             $orderby_sec = $params->def('orderby', 'rdate');
             $secondary = ContentHelperQuery::orderbySecondary($orderby_sec);
             $primary = '';
             break;
         case 1:
         default:
             $orderby_sec = $params->def('orderby_sec', 'rdate');
             $orderby_sec = $orderby_sec == 'front' ? '' : $orderby_sec;
             $orderby_pri = $params->def('orderby_pri', '');
             $secondary = ContentHelperQuery::orderbySecondary($orderby_sec);
             $primary = ContentHelperQuery::orderbyPrimary($orderby_pri);
             break;
     }
     $orderby .= "{$primary} {$secondary}";
     return $orderby;
 }
示例#18
0
 function _buildContentOrderBy()
 {
     global $mainframe;
     // Get the page/component configuration
     $params =& $mainframe->getParams();
     if (!is_object($params)) {
         $params =& JComponentHelper::getParams('com_content');
     }
     $orderby_sec = $params->def('orderby_sec', '');
     $orderby_pri = $params->def('orderby_pri', '');
     $secondary = ContentHelperQuery::orderbySecondary($orderby_sec);
     $primary = ContentHelperQuery::orderbyPrimary($orderby_pri);
     $orderby = ' ORDER BY ' . $primary . ' ' . $secondary;
     return $orderby;
 }
 protected function _buildContentOrderBy()
 {
     $app = JFactory::getApplication();
     $db = JFactory::getDbo();
     $params = JComponentHelper::getParams('com_content');
     $itemid = $app->input->get('id', 0, 'int') . ':' . $app->input->get('Itemid', 0, 'int');
     $orderCol = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order', 'filter_order', '', 'string');
     $orderDirn = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order_Dir', 'filter_order_Dir', '', 'cmd');
     $orderby = ' ';
     $_filter_fields = array('id', 'a.id', 'title', 'a.title', 'alias', 'a.alias', 'checked_out', 'a.checked_out', 'checked_out_time', 'a.checked_out_time', 'catid', 'a.catid', 'category_title', 'state', 'a.state', 'access', 'a.access', 'access_level', 'created', 'a.created', 'created_by', 'a.created_by', 'modified', 'a.modified', 'ordering', 'a.ordering', 'featured', 'a.featured', 'language', 'a.language', 'hits', 'a.hits', 'publish_up', 'a.publish_up', 'publish_down', 'a.publish_down', 'author', 'a.author');
     if (!in_array($orderCol, $_filter_fields)) {
         $orderCol = null;
     }
     if (!in_array(strtoupper($orderDirn), array('ASC', 'DESC', ''))) {
         $orderDirn = 'ASC';
     }
     if ($orderCol && $orderDirn) {
         $orderby .= $db->escape($orderCol) . ' ' . $db->escape($orderDirn) . ', ';
     }
     $articleOrderby = $params->get('orderby_sec', 'rdate');
     $articleOrderDate = $params->get('order_date');
     $categoryOrderby = $params->def('orderby_pri', '');
     $secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate) . ', ';
     $primary = ContentHelperQuery::orderbyPrimary($categoryOrderby);
     $orderby .= $primary . ' ' . $secondary . ' a.created ';
     return $orderby;
 }