Index: branches/5.2.x/core/kernel/db/dblist.php =================================================================== diff -u -N -r14602 -r14646 --- branches/5.2.x/core/kernel/db/dblist.php (.../dblist.php) (revision 14602) +++ branches/5.2.x/core/kernel/db/dblist.php (.../dblist.php) (revision 14646) @@ -1,6 +1,6 @@ 'HavingFilter', self::AGGREGATE_FILTER => 'AggregateFilter' ); - + $filter_name = $filter_source[$filter_type]; $filter =& $this->$filter_name; @@ -346,7 +346,7 @@ $filter =& $this->$filter_name; $filter =& $filter[$filter_scope]; /* @var $filter kMultipleFilter */ - + return $filter->getFilter($name); } @@ -371,7 +371,7 @@ $filter =& $this->$filter_name; $filter =& $filter[$filter_scope]; /* @var $filter kMultipleFilter */ - + $filter->removeFilter($name); } @@ -702,14 +702,14 @@ } /** - * Replaces all calculated field occurences with their associated expressions + * Replaces all calculated field occurrences with their associated expressions * * @param string $clause where clause to extract calculated fields from * @param int $aggregated 0 - having + aggregated, 1 - having only, 2 - aggregated only * @return string - * @access private + * @access public */ - private function extractCalculatedFields($clause, $aggregated = 1) + public function extractCalculatedFields($clause, $aggregated = 1) { $fields = $this->getCalculatedFields($aggregated); if (is_array($fields) && count($fields) > 0) { @@ -733,7 +733,7 @@ { $where =& $this->Application->makeClass('kMultipleFilter'); /* @var $where kMultipleFilter */ - + $where->addFilter('system_where', $this->WhereFilter[self::FLT_SYSTEM] ); if (!$system_filters_only) { @@ -748,7 +748,7 @@ // CUSTOM $search_w = $this->WhereFilter[self::FLT_CUSTOM]->getSQL(); - + if ($search_w || $for_counting) { // move search_having to search_where in case search_where isset or we are counting $search_h = $this->extractCalculatedFields( $this->HavingFilter[self::FLT_CUSTOM]->getSQL() ); $search_w = ($search_w && $search_h) ? $search_w.' AND '.$search_h : $search_w.$search_h; @@ -845,13 +845,14 @@ } /** - * Adds order field to ORDER BY clause - * - * @param string $field Field name - * @param string $direction Direction of ordering (asc|desc) - * @param bool $is_expression this is expression, that should not be escapted by "`" symbols - * @access public - */ + * Adds order field to ORDER BY clause + * + * @param string $field Field name + * @param string $direction Direction of ordering (asc|desc) + * @param bool $is_expression this is expression, that should not be escapted by "`" symbols + * @return int + * @access public + */ public function AddOrderField($field, $direction = 'asc', $is_expression = false) { // original multilanguage field - convert to current lang field @@ -868,9 +869,40 @@ } $this->OrderFields[] = Array($field, $direction, $is_expression); + + return count($this->OrderFields) - 1; } /** + * Sets new order fields, replacing existing ones + * + * @param Array $order_fields + * @return void + * @access public + */ + public function setOrderFields($order_fields) + { + $this->OrderFields = $order_fields; + } + + /** + * Changes sorting direction for a given sorting field index + * + * @param int $field_index + * @param string $direction + * @return void + * @access public + */ + public function changeOrderDirection($field_index, $direction) + { + if ( !isset($this->OrderFields[$field_index]) ) { + return; + } + + $this->OrderFields[$field_index][1] = $direction; + } + + /** * Returns expression, used to sort given multilingual field * * @param string $field @@ -954,6 +986,17 @@ } /** + * Returns list order fields + * + * @return Array + * @access public + */ + public function getOrderFields() + { + return $this->OrderFields; + } + + /** * Returns order field direction in given position * * @param int $pos @@ -1504,7 +1547,7 @@ /** * Detects relations between LEFT JOINs - * + * * @return void * @access private */ @@ -1527,7 +1570,7 @@ /** * Removes scheduled LEFT JOINs, but only if they are not protected - * + * * @return void * @access private */ @@ -1544,7 +1587,7 @@ /** * Schedules unused LEFT JOINs to for removal - * + * * @return void * @access private */