Index: branches/5.2.x/core/kernel/db/db_tag_processor.php =================================================================== diff -u -N -r13840 -r14092 --- branches/5.2.x/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 13840) +++ branches/5.2.x/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 14092) @@ -1,6 +1,6 @@ Application->RecallObject('ColumnPickerHelper'); /* @var $picker_helper kColumnPickerHelper */ + $picker_helper->ApplyPicker($this->getPrefixSpecial(), $grid_config, $params['grid']); if ($mode == 'fields') { return "'".join("','", array_keys($grid_config))."'"; } - $std_params['pass_params'] = 'true'; - $std_params['PrefixSpecial'] = $this->getPrefixSpecial(); - $object =& $this->GetList($params); $o = ''; $i = 0; + foreach ($grid_config as $field => $options) { $i++; - $block_params = Array(); - $block_params['name'] = $force_block ? $force_block : (isset($options[$mode.'_block']) ? $options[$mode.'_block'] : $def_block); + $block_params = $this->prepareTagParams($params); + $block_params = array_merge($block_params, $options); + + $block_params['block_name'] = array_key_exists($mode . '_block', $block_params) ? $block_params[$mode . '_block'] : $def_block; + $block_params['name'] = $force_block ? $force_block : $block_params['block_name']; $block_params['field'] = $field; $block_params['sort_field'] = isset($options['sort_field']) ? $options['sort_field'] : $field; $block_params['filter_field'] = isset($options['filter_field']) ? $options['filter_field'] : $field; $w = $picker_helper->GetWidth($field); - if ($w) $options['width'] = $w; - /*if (isset($options['filter_width'])) { - $block_params['filter_width'] = $options['filter_width']; + if ($w) { + // column picker width overrides width from unit config + $block_params['width'] = $w; } - elseif (isset($options['width'])) { - if (isset($options['filter_block']) && preg_match('/range/', $options['filter_block'])) { - if ($options['width'] < 60) { - $options['width'] = 60; - $block_params['filter_width'] = 20; - } - else { - $block_params['filter_width'] = $options['width'] - 40; - } - } - else { - $block_params['filter_width'] = max($options['width']-10, 20); - } - }*/ - /*if (isset($block_params['filter_width'])) $block_params['filter_width'] .= 'px'; - - if (isset($options['filter_block']) && preg_match('/range/', $options['filter_block'])) { - $block_params['filter_width'] = '20px'; - } - else { - $block_params['filter_width'] = '97%'; -// $block_params['filter_width'] = max($options['width']-10, 20); - }*/ - - $field_options = $object->GetFieldOptions($field); if (array_key_exists('use_phrases', $field_options)) { $block_params['use_phrases'] = $field_options['use_phrases']; } $block_params['is_last'] = ($i == count($grid_config)); - $block_params = array_merge($std_params, $options, $block_params); + $o.= $this->Application->ParseBlock($block_params, 1); } + return $o; } @@ -1495,7 +1473,7 @@ */ function getUserSortIndex() { - $list_sortings = $this->Application->getUnitOption($this->Prefix, 'ListSortings'); + $list_sortings = $this->Application->getUnitOption($this->Prefix, 'ListSortings', Array ()); $sorting_prefix = getArrayValue($list_sortings, $this->Special) ? $this->Special : ''; $user_sorting_start = 0; @@ -1562,7 +1540,6 @@ { $user_sorting_start = $this->getUserSortIndex() + --$params['pos']; $list =& $this->GetList($params); -// $object =& $this->Application->recallObject( $this->getPrefixSpecial() ); if($params['type'] == 'field') return $list->GetOrderField($user_sorting_start); if($params['type'] == 'direction') return $list->GetOrderDirection($user_sorting_start); @@ -2333,8 +2310,27 @@ function FieldTotal($params) { $list =& $this->GetList($params); + $field = $this->SelectParam($params, 'field,name'); + $total_function = array_key_exists('function', $params) ? $params['function'] : $list->getTotalFunction($field); - return $list->GetFormattedTotal($this->SelectParam($params, 'field,name'), $params['function']); + if (array_key_exists('function_only', $params) && $params['function_only']) { + return $total_function; + } + + if (array_key_exists('currency', $params) && $params['currency']) { + $iso = $this->GetISO($params['currency']); + $original = $list->getTotal($field, $total_function); + $value = $this->ConvertCurrency($original, $iso); + $list->setTotal($field, $total_function, $value); + } + + $value = $list->GetFormattedTotal($field, $total_function); + + if (array_key_exists('currency', $params) && $params['currency']) { + $value = $this->AddCurrencySymbol($value, $iso); + } + + return $value; } /** @@ -2757,4 +2753,26 @@ return false; } + + /** + * Checks, that requested option is checked inside field value + * + * @param Array $params + * @return bool + */ + function Selected($params) + { + $object =& $this->getObject($params); + /* @var $object kDBItem */ + + $field = $this->SelectParam($params, 'name,field'); + $value = $object->GetDBField($field); + + if (strpos($value, '|') !== false) { + $value = explode('|', substr($value, 1, -1)); + return in_array($params['value'], $value); + } + + return $value; + } } \ No newline at end of file