Index: branches/5.2.x/core/kernel/db/db_event_handler.php =================================================================== diff -u -N -r15425 -r15427 --- branches/5.2.x/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 15425) +++ branches/5.2.x/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 15427) @@ -1,6 +1,6 @@ Array ('self' => 'view|advanced:export'), 'OnExportProgress' => Array ('self' => 'view|advanced:export'), - 'OnSetAutoRefreshInterval' => Array ('self' => true, 'subitem' => true), 'OnAutoRefreshToggle' => Array ('self' => true, 'subitem' => true), @@ -224,7 +222,7 @@ $list_helper = $this->Application->recallObject('ListHelper'); /* @var $list_helper ListHelper */ - $select_clause = $this->Application->getUnitOption($object->Prefix, 'NavigationSelectClause', null); + $select_clause = $this->Application->getUnitOption($object->Prefix, 'NavigationSelectClause', NULL); return $list_helper->getNavigationResource($object, $event->getEventParam('list'), $event->Special == 'next', $select_clause); } @@ -281,7 +279,7 @@ * @return Array * @access protected */ - protected function StoreSelectedIDs(kEvent $event, $direct_ids = null) + protected function StoreSelectedIDs(kEvent $event, $direct_ids = NULL) { $wid = $this->Application->GetTopmostWid($event->Prefix); $session_name = rtrim($event->getPrefixSpecial() . '_selected_ids_' . $wid, '_'); @@ -1059,7 +1057,12 @@ $cur_sort1 = $cur_sort1_dir = $cur_sort2 = $cur_sort2_dir = false; if ( $sort_by ) { - list ($cur_sort1, $cur_sort1_dir) = explode(',', $sort_by); + $sortings = explode('|', $sort_by); + list ($cur_sort1, $cur_sort1_dir) = explode(',', $sortings[0]); + + if ( isset($sortings[1]) ) { + list ($cur_sort2, $cur_sort2_dir) = explode(',', $sortings[1]); + } } } else { @@ -1088,24 +1091,11 @@ } } - $list_sortings = $this->Application->getUnitOption($event->Prefix, 'ListSortings', Array ()); - $sorting_prefix = array_key_exists($event->Special, $list_sortings) ? $event->Special : ''; - $sorting_configs = $this->Application->getUnitOption($event->Prefix, 'ConfigMapping'); + $list_sortings = $this->_getDefaultSorting($event); - if ( $sorting_configs && array_key_exists('DefaultSorting1Field', $sorting_configs) ) { - // sorting defined in configuration variables overrides one from unit config - $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']), - ); - - // TODO: lowercase configuration variable values in db, instead of here - $list_sortings[$sorting_prefix]['Sorting'] = array_map('strtolower', $list_sortings[$sorting_prefix]['Sorting']); - } - // use default if not specified in session if ( !$cur_sort1 || !$cur_sort1_dir ) { - $sorting = getArrayValue($list_sortings, $sorting_prefix, 'Sorting'); + $sorting = getArrayValue($list_sortings, 'Sorting'); if ( $sorting ) { reset($sorting); @@ -1120,7 +1110,7 @@ } // always add forced sorting before any user sorting fields - $forced_sorting = getArrayValue($list_sortings, $sorting_prefix, 'ForcedSorting'); + $forced_sorting = getArrayValue($list_sortings, 'ForcedSorting'); /* @var $forced_sorting Array */ if ( $forced_sorting ) { @@ -1140,6 +1130,33 @@ } /** + * Returns default list sortings + * + * @param kEvent $event + * @return Array + * @access protected + */ + protected function _getDefaultSorting(kEvent $event) + { + $list_sortings = $this->Application->getUnitOption($event->Prefix, 'ListSortings', Array ()); + $sorting_prefix = array_key_exists($event->Special, $list_sortings) ? $event->Special : ''; + $sorting_configs = $this->Application->getUnitOption($event->Prefix, 'ConfigMapping'); + + if ( $sorting_configs && array_key_exists('DefaultSorting1Field', $sorting_configs) ) { + // sorting defined in configuration variables overrides one from unit config + $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']), + ); + + // TODO: lowercase configuration variable values in db, instead of here + $list_sortings[$sorting_prefix]['Sorting'] = array_map('strtolower', $list_sortings[$sorting_prefix]['Sorting']); + } + + return isset($list_sortings[$sorting_prefix]) ? $list_sortings[$sorting_prefix] : Array (); + } + + /** * Gets list setting by name (persistent or real session) * * @param kEvent $event @@ -1177,7 +1194,7 @@ * @return void * @access protected */ - protected function setListSetting(kEvent $event, $variable_name, $variable_value = null) + protected function setListSetting(kEvent $event, $variable_name, $variable_value = NULL) { $view_name = $this->Application->RecallVar($event->getPrefixSpecial() . '_current_view'); // $this->Application->StoreVar($event->getPrefixSpecial() . '_' . $variable_name, $variable_value, true); //true for optional @@ -2330,7 +2347,6 @@ $event->SetRedirectParam('opener', 'u'); } - /* End of Edit events */ // III. Events that allow to put some code before and after Update,Load,Create and Delete methods of item @@ -2804,7 +2820,7 @@ if ( $resource_id ) { $t_prefixes = explode(',', $this->Application->GetVar('translator_prefixes')); - $cdata = $this->Application->recallObject($t_prefixes[1], null, Array ('skip_autoload' => true)); + $cdata = $this->Application->recallObject($t_prefixes[1], NULL, Array ('skip_autoload' => true)); /* @var $cdata kDBItem */ $cdata->Load($resource_id, 'ResourceId'); @@ -2899,7 +2915,6 @@ $event->SetRedirectParam('opener', 'u'); } - /** EXPORT RELATED **/ /**