Attached Files |
sorting_storage_1106.patch [^] (11,593 bytes) 2011-10-21 11:49
[Show Content]
Index: db_event_handler.php
===================================================================
--- db_event_handler.php (revision 14670)
+++ db_event_handler.php (working copy)
@@ -997,10 +997,11 @@
}
}
else {
- $cur_sort1 = $this->getListSetting($event, 'Sort1');
- $cur_sort1_dir = $this->getListSetting($event, 'Sort1_Dir');
- $cur_sort2 = $this->getListSetting($event, 'Sort2');
- $cur_sort2_dir = $this->getListSetting($event, 'Sort2_Dir');
+ $sort_settings = $this->getSortSettings($event);
+ $cur_sort1 = getArrayValue($sort_settings, 'Sort1');
+ $cur_sort1_dir = getArrayValue($sort_settings, 'Sort1_Dir');
+ $cur_sort2 = getArrayValue($sort_settings, 'Sort2');
+ $cur_sort2_dir = getArrayValue($sort_settings, 'Sort2_Dir');
}
$tag_sort_by = $event->getEventParam('sort_by');
@@ -1072,6 +1073,44 @@
}
/**
+ * Gets list sort settings (persistent or real session)
+ *
+ * @param kEvent $event
+ * @return array
+ */
+ function getSortSettings(&$event)
+ {
+ $view_name = $this->Application->RecallVar($event->getPrefixSpecial() . '_current_view');
+ $storage_prefix = $event->getEventParam('same_special') ? $event->Prefix : $event->getPrefixSpecial();
+
+ // get sorting from pesistent session
+ $settings = $this->Application->RecallPersistentVar($storage_prefix . '_Sort.' . $view_name, ALLOW_DEFAULT_SETTINGS);
+
+ return unserialize($settings);
+ }
+
+ /**
+ * Sets list sort settings (persistent and real session)
+ *
+ * @param kEvent $event
+ * @param array $settings
+ */
+ function setSortSettings(&$event, $settings)
+ {
+ $view_name = $this->Application->RecallVar($event->getPrefixSpecial() . '_current_view');
+
+ if ( isset($settings) ) {
+ $this->Application->StorePersistentVar($event->getPrefixSpecial() . '_Sort.' . $view_name, serialize($settings), true); //true for optional
+ }
+ else {
+ $this->Application->RemovePersistentVar($event->getPrefixSpecial() . '_Sort.' . $view_name);
+ }
+ }
+
+
+
+
+ /**
* Gets list setting by name (persistent or real session)
*
* @param kEvent $event
@@ -1201,14 +1240,15 @@
*/
function OnSetSorting(&$event)
{
- $cur_sort1 = $this->getListSetting($event, 'Sort1');
- $cur_sort1_dir = $this->getListSetting($event, 'Sort1_Dir');
+ $sort_settings = $this->getSortSettings($event);
+ $cur_sort1 = getArrayValue($sort_settings, 'Sort1');
+ $cur_sort1_dir = getArrayValue($sort_settings, 'Sort1_Dir');
$use_double_sorting = $this->Application->ConfigValue('UseDoubleSorting');
if ($use_double_sorting) {
- $cur_sort2 = $this->getListSetting($event, 'Sort2');
- $cur_sort2_dir = $this->getListSetting($event, 'Sort2_Dir');
+ $cur_sort2 = getArrayValue($sort_settings, 'Sort2');
+ $cur_sort2_dir = getArrayValue($sort_settings, 'Sort2_Dir');
}
$passed_sort1 = $this->Application->GetVar($event->getPrefixSpecial(true) . '_Sort1');
@@ -1224,13 +1264,17 @@
$cur_sort1_dir = 'asc';
}
- $this->setListSetting($event, 'Sort1', $cur_sort1);
- $this->setListSetting($event, 'Sort1_Dir', $cur_sort1_dir);
+ $sort_settings = Array(
+ 'Sort1' => $cur_sort1,
+ 'Sort1_Dir' => $cur_sort1_dir,
+ );
if ($use_double_sorting) {
- $this->setListSetting($event, 'Sort2', $cur_sort2);
- $this->setListSetting($event, 'Sort2_Dir', $cur_sort2_dir);
+ $sort_settings['Sort2'] = $cur_sort2;
+ $sort_settings['Sort2_Dir'] = $cur_sort2_dir;
}
+
+ $this->setSortSettings($event, $sort_settings);
}
/**
@@ -1248,8 +1292,10 @@
list ($field, $dir) = explode('|', $combined);
if ($this->Application->isAdmin || !$this->Application->GetVar('main_list')) {
- $this->setListSetting($event, 'Sort1', $field);
- $this->setListSetting($event, 'Sort1_Dir', $dir);
+ $this->setSortSettings($evwnt, Array(
+ 'Sort1' => $field,
+ 'Sort1_Dir' => $dir,
+ ));
}
else {
$event->setPseudoClass('_List');
@@ -1286,10 +1332,7 @@
*/
function OnResetSorting(&$event)
{
- $this->setListSetting($event, 'Sort1');
- $this->setListSetting($event, 'Sort1_Dir');
- $this->setListSetting($event, 'Sort2');
- $this->setListSetting($event, 'Sort2_Dir');
+ $this->setSortSettings($event);
}
/**
Index: install/upgrades.php
===================================================================
--- install/upgrades.php (revision 14670)
+++ install/upgrades.php (working copy)
@@ -1814,4 +1814,72 @@
$this->Conn->Query($sql);
}
}
+
+ /**
+ * Update to 5.2.0-B1; Transform list sortings storage
+ *
+ * @param string $mode when called mode {before, after)
+ */
+ public function Upgrade_5_2_0_B1($mode)
+ {
+ if ($mode == 'after') {
+
+ $sql = 'SELECT VariableName, PortalUserId FROM '.TABLE_PREFIX.'PersistantSessionData
+ WHERE
+ VariableName LIKE \'%_Sort1.%\'
+ ';
+
+ $sortings = $this->Conn->Query($sql);
+
+ foreach ($sortings AS $sorting) {
+ $user_id = $sorting['PortalUserId'];
+ $sort1_name = $sorting['VariableName'];
+ if (preg_match('#^(.*)_Sort1.(.*)$#', $sort1_name, $matches)) {
+ $prefix = $matches[1].'_';
+ $suffix = '.'.$matches[2];
+ $sql = 'SELECT VariableValue, VariableName FROM '.TABLE_PREFIX.'PersistantSessionData
+ WHERE
+ PortalUserId = '.$user_id.'
+ AND VariableName IN (
+ '.$this->Conn->qstr($prefix . 'Sort1' . $suffix).',
+ '.$this->Conn->qstr($prefix . 'Sort2' . $suffix).',
+ '.$this->Conn->qstr($prefix . 'Sort1_Dir' . $suffix).',
+ '.$this->Conn->qstr($prefix . 'Sort2_Dir' . $suffix).'
+ )';
+ $sort_data = $this->Conn->GetCol($sql, 'VariableName');
+
+ $new_sorting = Array(
+ 'Sort1' => $sort_data[$prefix . 'Sort1' . $suffix],
+ 'Sort1_Dir' => $sort_data[$prefix . 'Sort1_Dir' . $suffix],
+ );
+
+ if (isset($sort_data[$prefix . 'Sort2' . $suffix])) {
+ $new_sorting['Sort2'] = $sort_data[$prefix . 'Sort2' . $suffix];
+ $new_sorting['Sort2_Dir'] = $sort_data[$prefix . 'Sort2_Dir' . $suffix]; }
+
+ $sql = 'INSERT INTO '.TABLE_PREFIX.'PersistantSessionData (
+ PortalUserId,
+ VariableName,
+ VariableValue
+ ) VALUES (
+ '.$user_id.',
+ '.$this->Conn->qstr($prefix . 'Sort' . $suffix).',
+ '.$this->Conn->qstr(serialize($new_sorting)).'
+ )';
+ $this->Conn->Query($sql);
+ }
+ $sql = 'DELETE FROM '.TABLE_PREFIX.'PersistantSessionData
+ WHERE
+ PortalUserId = '.$user_id.'
+ AND VariableName IN (
+ '.$this->Conn->qstr($prefix . 'Sort1' . $suffix).',
+ '.$this->Conn->qstr($prefix . 'Sort2' . $suffix).',
+ '.$this->Conn->qstr($prefix . 'Sort1_Dir' . $suffix).',
+ '.$this->Conn->qstr($prefix . 'Sort2_Dir' . $suffix).'
+ )';
+ $this->Conn->Query($sql);
+ }
+
+ }
+ }
}
\ No newline at end of file
Index: kernel/db/db_event_handler.php
===================================================================
--- kernel/db/db_event_handler.php (revision 14670)
+++ kernel/db/db_event_handler.php (working copy)
@@ -997,10 +997,11 @@
}
}
else {
- $cur_sort1 = $this->getListSetting($event, 'Sort1');
- $cur_sort1_dir = $this->getListSetting($event, 'Sort1_Dir');
- $cur_sort2 = $this->getListSetting($event, 'Sort2');
- $cur_sort2_dir = $this->getListSetting($event, 'Sort2_Dir');
+ $sort_settings = $this->getListSetting($event, 'Sort');
+ $cur_sort1 = getArrayValue($sort_settings, 'Sort1');
+ $cur_sort1_dir = getArrayValue($sort_settings, 'Sort1_Dir');
+ $cur_sort2 = getArrayValue($sort_settings, 'Sort2');
+ $cur_sort2_dir = getArrayValue($sort_settings, 'Sort2_Dir');
}
$tag_sort_by = $event->getEventParam('sort_by');
@@ -1078,7 +1079,7 @@
* @param string $variable_name
* @return string
*/
- function getListSetting(&$event, $variable_name)
+ protected function getListSetting(&$event, $variable_name)
{
$view_name = $this->Application->RecallVar($event->getPrefixSpecial() . '_current_view');
$storage_prefix = $event->getEventParam('same_special') ? $event->Prefix : $event->getPrefixSpecial();
@@ -1091,6 +1092,10 @@
$variable_value = $this->Application->RecallVar($storage_prefix . '_' . $variable_name);
}*/
+ if ( kUtil::IsSerialized($variable_value) ) {
+ $variable_value = unserialize($variable_value);
+ }
+
return $variable_value;
}
@@ -1101,12 +1106,17 @@
* @param string $variable_name
* @param string $variable_value
*/
- function setListSetting(&$event, $variable_name, $variable_value = null)
+ protected function setListSetting(&$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
if ( isset($variable_value) ) {
+
+ if ( is_array($variable_value) ) {
+ $variable_value = serialize($variable_value);
+ }
+
$this->Application->StorePersistentVar($event->getPrefixSpecial() . '_' . $variable_name . '.' . $view_name, $variable_value, true); //true for optional
}
else {
@@ -1201,14 +1211,15 @@
*/
function OnSetSorting(&$event)
{
- $cur_sort1 = $this->getListSetting($event, 'Sort1');
- $cur_sort1_dir = $this->getListSetting($event, 'Sort1_Dir');
+ $sort_settings = $this->getListSetting($event, 'Sort');
+ $cur_sort1 = getArrayValue($sort_settings, 'Sort1');
+ $cur_sort1_dir = getArrayValue($sort_settings, 'Sort1_Dir');
$use_double_sorting = $this->Application->ConfigValue('UseDoubleSorting');
if ($use_double_sorting) {
- $cur_sort2 = $this->getListSetting($event, 'Sort2');
- $cur_sort2_dir = $this->getListSetting($event, 'Sort2_Dir');
+ $cur_sort2 = getArrayValue($sort_settings, 'Sort2');
+ $cur_sort2_dir = getArrayValue($sort_settings, 'Sort2_Dir');
}
$passed_sort1 = $this->Application->GetVar($event->getPrefixSpecial(true) . '_Sort1');
@@ -1224,13 +1235,17 @@
$cur_sort1_dir = 'asc';
}
- $this->setListSetting($event, 'Sort1', $cur_sort1);
- $this->setListSetting($event, 'Sort1_Dir', $cur_sort1_dir);
+ $sort_settings = Array(
+ 'Sort1' => $cur_sort1,
+ 'Sort1_Dir' => $cur_sort1_dir,
+ );
if ($use_double_sorting) {
- $this->setListSetting($event, 'Sort2', $cur_sort2);
- $this->setListSetting($event, 'Sort2_Dir', $cur_sort2_dir);
+ $sort_settings['Sort2'] = $cur_sort2;
+ $sort_settings['Sort2_Dir'] = $cur_sort2_dir;
}
+
+ $this->setListSetting($event, 'Sort', $sort_settings);
}
/**
@@ -1248,8 +1263,10 @@
list ($field, $dir) = explode('|', $combined);
if ($this->Application->isAdmin || !$this->Application->GetVar('main_list')) {
- $this->setListSetting($event, 'Sort1', $field);
- $this->setListSetting($event, 'Sort1_Dir', $dir);
+ $this->setListSetting($event, 'Sort', Array(
+ 'Sort1' => $field,
+ 'Sort1_Dir' => $dir,
+ ));
}
else {
$event->setPseudoClass('_List');
@@ -1286,10 +1303,7 @@
*/
function OnResetSorting(&$event)
{
- $this->setListSetting($event, 'Sort1');
- $this->setListSetting($event, 'Sort1_Dir');
- $this->setListSetting($event, 'Sort2');
- $this->setListSetting($event, 'Sort2_Dir');
+ $this->setListSetting($event, 'Sort');
}
/**
sorting_storage_v3.patch [^] (11,482 bytes) 2011-10-26 04:16
[Show Content]
Index: install/upgrades.php
===================================================================
--- install/upgrades.php (revision 14653)
+++ install/upgrades.php (working copy)
@@ -729,8 +729,8 @@
/**
* Group list records by header, saves internal order in group
*
- * @param Array $records
- * @param string $heading_field
+ * @param Array $variables
+ * @return Array
*/
function _groupRecords($variables)
{
@@ -754,6 +754,7 @@
* Returns module root category
*
* @param string $module_name
+ * @param string $module_prefix
* @return int
*/
function _getRootCategory($module_name, $module_prefix)
@@ -1814,4 +1815,74 @@
$this->Conn->Query($sql);
}
}
+
+ /**
+ * Update to 5.2.0-B1; Transform list sortings storage
+ *
+ * @param string $mode when called mode {before, after)
+ */
+ public function Upgrade_5_2_0_B1($mode)
+ {
+ if ($mode == 'after') {
+ $this->transformSortings();
+ }
+ }
+
+ /**
+ * Transforms a way, how list sortings are stored
+ *
+ * @return void
+ */
+ function transformSortings()
+ {
+ $sql = 'SELECT VariableName, PortalUserId
+ FROM ' . TABLE_PREFIX . 'PersistantSessionData
+ WHERE VariableName LIKE "%_Sort1.%"';
+ $sortings = $this->Conn->Query($sql);
+
+ foreach ($sortings AS $sorting) {
+ if ( !preg_match('/^(.*)_Sort1.(.*)$/', $sorting['VariableName'], $regs) ) {
+ continue;
+ }
+
+ $user_id = $sorting['PortalUserId'];
+ $prefix_special = $regs[1] . '_';
+ $view_name = '.' . $regs[2];
+
+ $old_variable_names = Array (
+ $prefix_special . 'Sort1' . $view_name, $prefix_special . 'Sort1_Dir' . $view_name,
+ $prefix_special . 'Sort2' . $view_name, $prefix_special . 'Sort2_Dir' . $view_name,
+ );
+ $old_variable_names = array_map(Array (&$this->Conn, 'qstr'), $old_variable_names);
+
+ $sql = 'SELECT VariableValue, VariableName
+ FROM ' . TABLE_PREFIX . 'PersistantSessionData
+ WHERE PortalUserId = ' . $user_id . ' AND VariableName IN (' . implode(',', $old_variable_names) . ')';
+ $sorting_data = $this->Conn->GetCol($sql, 'VariableName');
+
+ // prepare & save new sortings
+ $new_sorting = Array (
+ 'Sort1' => $sorting_data[$prefix_special . 'Sort1' . $view_name],
+ 'Sort1_Dir' => $sorting_data[$prefix_special . 'Sort1_Dir' . $view_name],
+ );
+
+ if ( isset($sorting_data[$prefix_special . 'Sort2' . $view_name]) ) {
+ $new_sorting['Sort2'] = $sorting_data[$prefix_special . 'Sort2' . $view_name];
+ $new_sorting['Sort2_Dir'] = $sorting_data[$prefix_special . 'Sort2_Dir' . $view_name];
+ }
+
+ $fields_hash = Array (
+ 'PortalUserId' => $user_id,
+ 'VariableName' => $prefix_special . 'Sortings' . $view_name,
+ 'VariableValue' => serialize($new_sorting),
+ );
+
+ $this->Conn->doInsert($fields_hash, TABLE_PREFIX . 'PersistantSessionData');
+
+ // delete sortings, that were already processed
+ $sql = 'DELETE FROM ' . TABLE_PREFIX . 'PersistantSessionData
+ WHERE PortalUserId = ' . $user_id . ' AND VariableName IN (' . implode(',', $old_variable_names) . ')';
+ $this->Conn->Query($sql);
+ }
+ }
}
\ No newline at end of file
Index: kernel/db/db_event_handler.php
===================================================================
--- kernel/db/db_event_handler.php (revision 14681)
+++ kernel/db/db_event_handler.php (working copy)
@@ -401,7 +401,7 @@
/**
* Common builder part for Item & List
*
- * @param kDBBase $object
+ * @param kDBBase|kDBItem|kDBList $object
* @param kEvent $event
* @access private
*/
@@ -988,19 +988,21 @@
$object =& $event->getObject();
/* @var $object kDBList */
- if ($object->isMainList()) {
+ if ( $object->isMainList() ) {
$sort_by = $this->Application->GetVar('sort_by');
$cur_sort1 = $cur_sort1_dir = $cur_sort2 = $cur_sort2_dir = false;
- if ($sort_by) {
+ if ( $sort_by ) {
list ($cur_sort1, $cur_sort1_dir) = explode(',', $sort_by);
}
}
else {
- $cur_sort1 = $this->getListSetting($event, 'Sort1');
- $cur_sort1_dir = $this->getListSetting($event, 'Sort1_Dir');
- $cur_sort2 = $this->getListSetting($event, 'Sort2');
- $cur_sort2_dir = $this->getListSetting($event, 'Sort2_Dir');
+ $sorting_settings = $this->getListSetting($event, 'Sortings');
+
+ $cur_sort1 = getArrayValue($sorting_settings, 'Sort1');
+ $cur_sort1_dir = getArrayValue($sorting_settings, 'Sort1_Dir');
+ $cur_sort2 = getArrayValue($sorting_settings, 'Sort2');
+ $cur_sort2_dir = getArrayValue($sorting_settings, 'Sort2_Dir');
}
$tag_sort_by = $event->getEventParam('sort_by');
@@ -1036,15 +1038,15 @@
}
// use default if not specified in session
- if (!$cur_sort1 || !$cur_sort1_dir) {
+ if ( !$cur_sort1 || !$cur_sort1_dir ) {
$sorting = getArrayValue($list_sortings, $sorting_prefix, 'Sorting');
- if ($sorting) {
+ if ( $sorting ) {
reset($sorting);
$cur_sort1 = key($sorting);
$cur_sort1_dir = current($sorting);
- if (next($sorting)) {
+ if ( next($sorting) ) {
$cur_sort2 = key($sorting);
$cur_sort2_dir = current($sorting);
}
@@ -1055,18 +1057,18 @@
$forced_sorting = getArrayValue($list_sortings, $sorting_prefix, 'ForcedSorting');
/* @var $forced_sorting Array */
- if ($forced_sorting) {
+ if ( $forced_sorting ) {
foreach ($forced_sorting as $field => $dir) {
$object->AddOrderField($field, $dir);
}
}
// add user sorting fields
- if ($cur_sort1 != '' && $cur_sort1_dir != '') {
+ if ( $cur_sort1 != '' && $cur_sort1_dir != '' ) {
$object->AddOrderField($cur_sort1, $cur_sort1_dir);
}
- if ($cur_sort2 != '' && $cur_sort2_dir != '') {
+ if ( $cur_sort2 != '' && $cur_sort2_dir != '' ) {
$object->AddOrderField($cur_sort2, $cur_sort2_dir);
}
}
@@ -1076,14 +1078,15 @@
*
* @param kEvent $event
* @param string $variable_name
- * @return string
+ * @return string|Array
+ * @access protected
*/
- function getListSetting(&$event, $variable_name)
+ protected function getListSetting(&$event, $variable_name)
{
$view_name = $this->Application->RecallVar($event->getPrefixSpecial() . '_current_view');
$storage_prefix = $event->getEventParam('same_special') ? $event->Prefix : $event->getPrefixSpecial();
- // get sorting from pesistent session
+ // get sorting from persistent session
$variable_value = $this->Application->RecallPersistentVar($storage_prefix . '_' . $variable_name . '.' . $view_name, ALLOW_DEFAULT_SETTINGS);
/*if (!$variable_value) {
@@ -1091,6 +1094,10 @@
$variable_value = $this->Application->RecallVar($storage_prefix . '_' . $variable_name);
}*/
+ if ( kUtil::IsSerialized($variable_value) ) {
+ $variable_value = unserialize($variable_value);
+ }
+
return $variable_value;
}
@@ -1099,14 +1106,20 @@
*
* @param kEvent $event
* @param string $variable_name
- * @param string $variable_value
+ * @param string|Array $variable_value
+ * @return void
+ * @access protected
*/
- function setListSetting(&$event, $variable_name, $variable_value = null)
+ protected function setListSetting(&$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
if ( isset($variable_value) ) {
+ if ( is_array($variable_value) ) {
+ $variable_value = serialize($variable_value);
+ }
+
$this->Application->StorePersistentVar($event->getPrefixSpecial() . '_' . $variable_name . '.' . $view_name, $variable_value, true); //true for optional
}
else {
@@ -1201,36 +1214,39 @@
*/
function OnSetSorting(&$event)
{
- $cur_sort1 = $this->getListSetting($event, 'Sort1');
- $cur_sort1_dir = $this->getListSetting($event, 'Sort1_Dir');
+ $sorting_settings = $this->getListSetting($event, 'Sortings');
+ $cur_sort1 = getArrayValue($sorting_settings, 'Sort1');
+ $cur_sort1_dir = getArrayValue($sorting_settings, 'Sort1_Dir');
$use_double_sorting = $this->Application->ConfigValue('UseDoubleSorting');
- if ($use_double_sorting) {
- $cur_sort2 = $this->getListSetting($event, 'Sort2');
- $cur_sort2_dir = $this->getListSetting($event, 'Sort2_Dir');
+ if ( $use_double_sorting ) {
+ $cur_sort2 = getArrayValue($sorting_settings, 'Sort2');
+ $cur_sort2_dir = getArrayValue($sorting_settings, 'Sort2_Dir');
}
$passed_sort1 = $this->Application->GetVar($event->getPrefixSpecial(true) . '_Sort1');
- if ($cur_sort1 == $passed_sort1) {
+ if ( $cur_sort1 == $passed_sort1 ) {
$cur_sort1_dir = $cur_sort1_dir == 'asc' ? 'desc' : 'asc';
}
else {
- if ($use_double_sorting) {
+ if ( $use_double_sorting ) {
$cur_sort2 = $cur_sort1;
$cur_sort2_dir = $cur_sort1_dir;
}
+
$cur_sort1 = $passed_sort1;
$cur_sort1_dir = 'asc';
}
- $this->setListSetting($event, 'Sort1', $cur_sort1);
- $this->setListSetting($event, 'Sort1_Dir', $cur_sort1_dir);
+ $sorting_settings = Array ('Sort1' => $cur_sort1, 'Sort1_Dir' => $cur_sort1_dir);
- if ($use_double_sorting) {
- $this->setListSetting($event, 'Sort2', $cur_sort2);
- $this->setListSetting($event, 'Sort2_Dir', $cur_sort2_dir);
+ if ( $use_double_sorting ) {
+ $sorting_settings['Sort2'] = $cur_sort2;
+ $sorting_settings['Sort2_Dir'] = $cur_sort2_dir;
}
+
+ $this->setListSetting($event, 'Sortings', $sorting_settings);
}
/**
@@ -1244,18 +1260,17 @@
$prefix_special = $event->getPrefixSpecial();
$combined = $this->Application->GetVar($event->getPrefixSpecial(true) . '_CombinedSorting');
- if ($combined) {
+ if ( $combined ) {
list ($field, $dir) = explode('|', $combined);
- if ($this->Application->isAdmin || !$this->Application->GetVar('main_list')) {
- $this->setListSetting($event, 'Sort1', $field);
- $this->setListSetting($event, 'Sort1_Dir', $dir);
+ if ( $this->Application->isAdmin || !$this->Application->GetVar('main_list') ) {
+ $this->setListSetting($event, 'Sortings', Array ('Sort1' => $field, 'Sort1_Dir' => $dir));
}
else {
$event->setPseudoClass('_List');
$this->Application->SetVar('sort_by', $field . ',' . $dir);
- $object =& $event->getObject( Array ('main_list' => 1) );
+ $object =& $event->getObject(Array ('main_list' => 1));
/* @var $object kDBList */
$list_helper =& $this->Application->recallObject('ListHelper');
@@ -1263,14 +1278,14 @@
$this->_passListParams($event, 'sort_by');
- if ($list_helper->hasUserSorting($object)) {
+ if ( $list_helper->hasUserSorting($object) ) {
$event->SetRedirectParam('sort_by', $field . ',' . strtolower($dir));
}
$event->SetRedirectParam('pass', 'm');
}
- return ;
+ return;
}
// used in "View Menu -> Sort" menu in administrative console
@@ -1286,10 +1301,7 @@
*/
function OnResetSorting(&$event)
{
- $this->setListSetting($event, 'Sort1');
- $this->setListSetting($event, 'Sort1_Dir');
- $this->setListSetting($event, 'Sort2');
- $this->setListSetting($event, 'Sort2_Dir');
+ $this->setListSetting($event, 'Sortings');
}
/**
|