Index: branches/5.3.x/core/units/helpers/list_helper.php
===================================================================
diff -u -r15483 -r15698
--- branches/5.3.x/core/units/helpers/list_helper.php (.../list_helper.php) (revision 15483)
+++ branches/5.3.x/core/units/helpers/list_helper.php (.../list_helper.php) (revision 15698)
@@ -1,6 +1,6 @@
getPrefixSpecial(), $cache)) {
- return $cache[ $list->getPrefixSpecial() ];
+ if ( array_key_exists($list->getPrefixSpecial(), $cache) ) {
+ return $cache[$list->getPrefixSpecial()];
}
$user_sorting_start = $this->getUserSortIndex($list);
- $sorting_configs = $this->Application->getUnitOption($list->Prefix, 'ConfigMapping', Array ());
- $list_sortings = $this->Application->getUnitOption($list->Prefix, 'ListSortings', Array ());
- $sorting_prefix = getArrayValue($list_sortings, $list->Special) ? $list->Special : '';
+ $config = $list->getUnitConfig();
+ $sorting_configs = $config->getConfigMapping(Array ());
+ $list_sortings = $config->getListSortingsBySpecial($list, Array ());
- if (array_key_exists('DefaultSorting1Field', $sorting_configs)) {
- $list_sortings[$sorting_prefix]['Sorting'] = Array (
+ if ( array_key_exists('DefaultSorting1Field', $sorting_configs) ) {
+ $list_sortings['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');
+ $sorting = getArrayValue($list_sortings, 'Sorting');
$sort_fields = is_array($sorting) ? array_keys($sorting) : Array ();
for ($order_number = 0; $order_number < 2; $order_number++) {
@@ -52,39 +52,42 @@
$current_order_field = $list->GetOrderField($sorting_pos, true);
$current_order_direction = $list->GetOrderDirection($sorting_pos, true);
- if (!$current_order_field || !$current_order_direction) {
+ if ( !$current_order_field || !$current_order_direction ) {
// no sorting defined for this sorting position
continue;
}
// remove language prefix from field
$field_options = $list->GetFieldOptions($current_order_field);
- if (array_key_exists('formatter', $field_options) && $field_options['formatter'] == 'kMultiLanguage') {
+ if ( array_key_exists('formatter', $field_options) && $field_options['formatter'] == 'kMultiLanguage' ) {
// remove language prefix
$current_order_field = preg_replace('/^l[\d]+_(.*)/', '\\1', $current_order_field);
}
// user sorting found
- if (array_key_exists($order_number, $sort_fields)) {
+ 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]; // because people can write
- if ($current_order_field != $default_order_field || strcasecmp($current_order_direction, $default_order_direction) != 0) {
+ if ( $current_order_field != $default_order_field || strcasecmp($current_order_direction, $default_order_direction) != 0 ) {
// #1. user sorting differs from default sorting -> changed
- $cache[ $list->getPrefixSpecial() ] = true;
+ $cache[$list->getPrefixSpecial()] = true;
+
return true;
}
}
else {
// #2. user sorting + no default sorting -> changed
- $cache[ $list->getPrefixSpecial() ] = true;
+ $cache[$list->getPrefixSpecial()] = true;
+
return true;
}
}
// #3. user sorting match default or not defined -> not changed
- $cache[ $list->getPrefixSpecial() ] = false;
+ $cache[$list->getPrefixSpecial()] = false;
+
return false;
}
@@ -98,16 +101,16 @@
function getDefaultPerPage($prefix, $default = 10)
{
$ret = false;
- $config_mapping = $this->Application->getUnitOption($prefix, 'ConfigMapping');
+ $config_mapping = $this->Application->getUnitConfig($prefix)->getConfigMapping();
- if ($config_mapping) {
- if (!array_key_exists('PerPage', $config_mapping)) {
+ if ( $config_mapping ) {
+ if ( !array_key_exists('PerPage', $config_mapping) ) {
trigger_error('Incorrect mapping of PerPage key in config for prefix ' . $prefix . '', E_USER_WARNING);
}
$per_page = $this->Application->ConfigValue($config_mapping['PerPage']);
- if ($per_page) {
+ if ( $per_page ) {
return $per_page;
}
}
@@ -127,11 +130,10 @@
*/
function getUserSortIndex(&$list)
{
- $list_sortings = $this->Application->getUnitOption($list->Prefix, 'ListSortings', Array ());
- $sorting_prefix = getArrayValue($list_sortings, $list->Special) ? $list->Special : '';
+ $list_sortings = $list->getUnitConfig()->getListSortingsBySpecial($list, Array ());
$user_sorting_start = 0;
- $forced_sorting = getArrayValue($list_sortings, $sorting_prefix, 'ForcedSorting');
+ $forced_sorting = getArrayValue($list_sortings, 'ForcedSorting');
if ( $forced_sorting ) {
$user_sorting_start = count($forced_sorting);