Index: branches/RC/core/units/general/helpers/col_picker_helper.php =================================================================== diff -u -r8929 -r9359 --- branches/RC/core/units/general/helpers/col_picker_helper.php (.../col_picker_helper.php) (revision 8929) +++ branches/RC/core/units/general/helpers/col_picker_helper.php (.../col_picker_helper.php) (revision 9359) @@ -24,11 +24,15 @@ return $cols; } - function ApplyPicker($prefix, &$fields, $grid_name) + function PreparePicker($prefix, $grid_name) { $this->SetGridName($grid_name); $this->PickerData = $this->LoadColumns($prefix); + } + function ApplyPicker($prefix, &$fields, $grid_name) + { + $this->PreparePicker($prefix, $grid_name); uksort($fields, array($this, 'CmpElems')); $this->RemoveHiddenColumns($fields); } @@ -59,9 +63,16 @@ //get added columns - present in xml, but not in db $added = array_diff($cols['order'], $current['order']); + if (in_array('__FREEZER__', $added)) { + array_unshift($common, '__FREEZER__'); + unset($added[array_search('__FREEZER__', $added)]); + } $cols['order'] = array_merge($common, $added); $cols['hidden_fields'] = array_intersect($current['order'], $current['hidden_fields']); + foreach($common as $col) { + $cols['widths'][$col] = isset($current['widths'][$col]) ? $current['widths'][$col] : 100; + } $this->SetCRC($cols); } $this->StoreCols($prefix, $cols); @@ -79,7 +90,11 @@ { $splited = $this->Application->processPrefix($prefix); $grids = $this->Application->getUnitOption($splited['prefix'], 'Grids'); - $conf_fields = $grids[$this->GridName]['Fields']; + $conf_fields = array_merge_recursive( + array('__FREEZER__' => array('title' => '__FREEZER__')), + $grids[$this->GridName]['Fields'] + ); +// $conf_fields = $grids[$this->GridName]['Fields']; // we NEED to recall dummy here to apply fields changes imposed by formatters, // such as replacing multilingual field titles etc. @@ -89,9 +104,11 @@ $hidden = array(); $fields = array(); $titles = array(); + $widths = array(); foreach ($conf_fields as $name => $options) { $fields[$counter] = $name; $titles[$name] = $options['title']; + $widths[$name] = 100; if (isset($options['hidden']) && $options['hidden']) { $hidden[$counter] = $name; @@ -103,7 +120,8 @@ $cols = array( 'order' => $fields, 'titles' => $titles, - 'hidden_fields' => $hidden + 'hidden_fields' => $hidden, + 'widths' => $widths, ); $this->SetCRC($cols); return $cols; @@ -137,11 +155,28 @@ $hidden = $hidden ? explode('|', $hidden) : array(); $order = array_merge($order, $hidden); - $cols = array(); + $cols = $this->LoadColumns($prefix); $cols['order'] = $order; $cols['hidden_fields'] = $hidden; $this->SetCRC($cols); $this->StoreCols($prefix, $cols); } + + function SaveWidths($prefix, $widths) + { + if (!is_array($widths)) $widths = explode(':', $widths); + array_shift($widths); // removing first col (checkbox col) width + $i = 0; + foreach ($this->PickerData['order'] as $ord => $field) { + if ($field == '__FREEZER__') continue; + $this->PickerData['widths'][$field] = $widths[$i++]; + } + $this->StoreCols($prefix, $this->PickerData); + } + + function GetWidth($field) + { + return isset($this->PickerData['widths'][$field]) ? $this->PickerData['widths'][$field] : false; + } } \ No newline at end of file