Index: branches/RC/core/kernel/db/db_tag_processor.php =================================================================== diff -u -N -r11368 -r11395 --- branches/RC/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 11368) +++ branches/RC/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 11395) @@ -1283,6 +1283,63 @@ } /** + * Detects, that current sorting is not default + * + * @param Array $params + * @return bool + */ + function OrderChanged($params) + { + $list =& $this->GetList($params); + $user_sorting_start = $this->getUserSortIndex(); + + $sorting_configs = $this->Application->getUnitOption($this->Prefix, 'ConfigMapping', Array ()); + $list_sortings = $this->Application->getUnitOption($this->Prefix, 'ListSortings', Array ()); + $sorting_prefix = getArrayValue($list_sortings, $this->Special) ? $this->Special : ''; + + if (array_key_exists('DefaultSorting1Field', $sorting_configs)) { + $list_sortings[$sorting_prefix]['Sorting'] = Array ( + $this->Application->ConfigValue($sorting_configs['DefaultSorting1Field']) => $this->Application->ConfigValue($sorting_configs['DefaultSorting1Dir']), + $this->Application->ConfigValue($sorting_configs['DefaultSorting2Field']) => $this->Application->ConfigValue($sorting_configs['DefaultSorting2Dir']), + ); + } + + $sorting = getArrayValue($list_sortings, $sorting_prefix, 'Sorting'); + $sort_fields = is_array($sorting) ? array_keys($sorting) : Array (); + + for ($order_number = 0; $order_number < 2; $order_number++) { + // currect sorting in list + $sorting_pos = $user_sorting_start + $order_number; + $current_order_field = $list->GetOrderField($sorting_pos, true); + $current_order_direction = $list->GetOrderDirection($sorting_pos, true); + + if (!$current_order_field || !$current_order_direction) { + // no sorting defined for this sorting position + continue; + } + + // user sorting found + if (array_key_exists($order_number, $sort_fields)) { + // default sorting found + $default_order_field = $sort_fields[$order_number]; + $default_order_direction = $sorting[$default_order_field]; + + if ($current_order_field != $default_order_field || $current_order_direction != $default_order_direction) { + // #1. user sorting differs from default sorting -> changed + return true; + } + } + else { + // #2. user sorting + no default sorting -> changed + return true; + } + } + + // #3. user sorting match default or not defined -> not changed + return false; + } + + /** * Get's information of sorting field at "pos" position, * like sorting field name (type="field") or sorting direction (type="direction") *