Exemple #1
0
 /**
  * Build the orderby for the query
  *
  * @return	string	$orderby portion of query
  * @since	1.5
  */
 protected function _buildContentOrderBy()
 {
     global $jlistConfig;
     $app = JFactory::getApplication('site');
     $db = $this->getDbo();
     $params = $this->state->params;
     $itemid = JRequest::getInt('catid', 0) . ':' . JRequest::getInt('Itemid', 0);
     $orderCol = $app->getUserStateFromRequest('com_jdownloads.category.' . $itemid . '.filter_order', 'filter_order', '', 'string');
     if ($orderCol == '') {
         $orderCol = $this->state->get('list.ordering');
     }
     $orderDirn = $app->getUserStateFromRequest('com_jdownloads.category.' . $itemid . '.filter_order_Dir', 'filter_order_Dir', '', 'cmd');
     if ($orderDirn == '') {
         $orderDirn = $this->state->get('list.direction');
     }
     $orderby = ' ';
     if (!in_array($orderCol, $this->filter_fields)) {
         $orderCol = null;
     }
     if (!in_array(strtoupper($orderDirn), array('ASC', 'DESC', ''))) {
         $orderDirn = '';
     }
     /* if ($orderCol && $orderDirn) {
     			$orderby .= $db->escape($orderCol) . ' ' . $db->escape($orderDirn) . ' ';
     		} else {
                 $orderby .= $db->escape($orderCol) .' ';
                 
             } */
     $filesOrderby = $params->get('orderby_sec', '');
     // we have uses in the jD configuration the old numerical values (to be compatible) so we must correct it here at first
     $config_cats_order = JDHelper::getCorrectedOrderbyValues('primary', $jlistConfig['cats.order']);
     $categoryOrderby = $params->def('orderby_pri', $config_cats_order);
     if ($filesOrderby) {
         $secondary = JDContentHelperQuery::orderbySecondary($filesOrderby) . ' ';
     } else {
         $secondary = JDContentHelperQuery::orderbySecondary($orderCol) . ' ';
     }
     $primary = JDContentHelperQuery::orderbyPrimary($categoryOrderby);
     $orderby .= $db->escape($primary) . ' ' . $db->escape($secondary) . ' ';
     // a.created ';
     return $orderby;
 }