Beispiel #1
0
 /**
  * Get options order by
  *
  * @param   string         $view   View mode '' or 'filter'
  * @param   JDatabasQuery  $query  Set to false to return a string
  *
  * @return  string  order by statement
  */
 protected function getOrderBy($view = '', $query = false)
 {
     if ($view == 'filter') {
         $params = $this->getParams();
         $joinKey = $this->getJoinValueColumn();
         $joinLabel = $this->getJoinLabelColumn();
         $order = '';
         switch ($params->get('filter_groupby', 'text')) {
             case 'text':
                 $order = $joinLabel . 'ASC ';
                 break;
             case 'value':
                 $order = $joinKey . 'ASC ';
                 break;
             case '-1':
             default:
                 // Check if the 'Joins where and/or order by statement' has an order by
                 $joinWhere = $params->get('database_join_where_sql');
                 if (JString::stristr($joinWhere, 'ORDER BY')) {
                     $joinWhere = str_replace('order by', 'ORDER BY', $joinWhere);
                     $joinWhere = explode('ORDER BY', $joinWhere);
                     if (count($joinWhere) > 1) {
                         $order = $joinWhere[count($joinWhere) - 1];
                     }
                 }
                 break;
         }
         if (!$query) {
             return $order === '' ? '' : ' ORDER BY ' . $order;
         } else {
             if ($order !== '') {
                 $query->order($order);
             }
             return $query;
         }
     } else {
         if (isset($this->orderBy)) {
             if (!$query) {
                 return $this->orderBy;
             } else {
                 $order = JString::str_ireplace('ORDER BY', '', $this->orderBy);
                 $query->order($order);
                 return $query;
             }
         } else {
             if (!$query) {
                 return "ORDER BY text ASC ";
             } else {
                 $query->order('text ASC');
                 return $query;
             }
         }
     }
 }
Beispiel #2
0
 /**
  * Get options order by
  *
  * @param   string         $view   view mode '' or 'filter'
  * @param   JDatabasQuery  $query  set to false to return a string
  *
  * @return  string  order by statement
  */
 protected function getOrderBy($view = '', $query = false)
 {
     if ($view == 'filter') {
         $params = $this->getParams();
         $joinKey = $this->getJoinValueColumn();
         $joinLabel = $this->getJoinLabelColumn();
         $groupByCol = $params->get('filter_groupby', 'text');
         if ($groupByCol != -1) {
             $groupByCol = $groupByCol == 'text' ? $joinLabel : $joinKey;
             $order = 'ORDER BY ' . $groupByCol . ' ASC';
         } else {
             $order = $this->orderBy;
         }
         $order = $params->get('filter_groupby', 'text') == 'text' ? $joinLabel : $joinKey;
         if (!$query) {
             return " ORDER BY {$order} ASC ";
         } else {
             $query->order($order . ' ASC');
             return $query;
         }
     } else {
         if (isset($this->orderBy)) {
             if (!$query) {
                 return $this->orderBy;
             } else {
                 $order = JString::str_ireplace('ORDER BY', '', $this->orderBy);
                 $query->order($order);
                 return $query;
             }
         } else {
             if (!$query) {
                 return "ORDER BY text ASC ";
             } else {
                 $query->order('text ASC');
                 return $query;
             }
         }
     }
 }