Index: branches/RC/core/units/admin/admin_tag_processor.php =================================================================== diff -u -N -r9313 -r9359 --- branches/RC/core/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 9313) +++ branches/RC/core/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 9359) @@ -626,6 +626,8 @@ $main_prefix = $this->Application->RecallVar('main_prefix'); $cols = $picker_helper->LoadColumns($main_prefix); + $this->Application->Phrases->AddCachedPhrase('__FREEZER__', '-------------'); + $o = ''; if (isset($params['hidden']) && $params['hidden']) { foreach ($cols['hidden_fields'] as $col) { Index: branches/RC/core/units/general/helpers/col_picker_helper.php =================================================================== diff -u -N -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 Index: branches/RC/core/kernel/db/db_event_handler.php =================================================================== diff -u -N -r9313 -r9359 --- branches/RC/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 9313) +++ branches/RC/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 9359) @@ -152,6 +152,7 @@ 'OnUploadFile' => Array('self'=>true, 'subitem'=>true), 'OnViewFile' => Array('self'=>true, 'subitem'=>true), + 'OnSaveWidths' => Array('self'=>true, 'subitem'=>true), ); $this->permMapping = array_merge($this->permMapping, $permissions); } @@ -2128,6 +2129,25 @@ $event->status = erSTOP; } + /** + * Enter description here... + * + * @param kEvent $event + */ + function OnSaveWidths(&$event) + { + safeDefine('DBG_SKIP_REPORTING', 1); + $lang =& $this->Application->recallObject('lang.current'); +// header('Content-type: text/xml; charset='.$lang->GetDBField('Charset')); + + $picker_helper =& $this->Application->RecallObject('ColumnPickerHelper'); + /* @var $picker_helper kColumnPickerHelper */ + $picker_helper->PreparePicker($event->getPrefixSpecial(), $this->Application->GetVar('grid_name')); + + $picker_helper->SaveWidths($event->getPrefixSpecial(), $this->Application->GetVar('widths')); + exit; + } + } Index: branches/RC/core/admin_templates/incs/grid_blocks.tpl =================================================================== diff -u -N -r8929 -r9359 --- branches/RC/core/admin_templates/incs/grid_blocks.tpl (.../grid_blocks.tpl) (revision 8929) +++ branches/RC/core/admin_templates/incs/grid_blocks.tpl (.../grid_blocks.tpl) (revision 9359) @@ -422,8 +422,8 @@ Grids[''] = new Grid('', '', ':original', edit, a_toolbar); Grids[''].AddItemsByIdMask('', /^_([\d\w-]+)/, '[$$ID$$][]'); - Grids[''].InitItems(); - + Grids[''].InitItems(); + Index: branches/RC/core/units/admin/admin_events_handler.php =================================================================== diff -u -N -r9260 -r9359 --- branches/RC/core/units/admin/admin_events_handler.php (.../admin_events_handler.php) (revision 9260) +++ branches/RC/core/units/admin/admin_events_handler.php (.../admin_events_handler.php) (revision 9359) @@ -183,9 +183,9 @@ } function OnSaveColumns(&$event) { + /* @var $picker_helper kColumnPickerHelper */ $picker_helper =& $this->Application->RecallObject('ColumnPickerHelper'); $picker_helper->SetGridName($this->Application->GetLinkedVar('grid_name')); - /* @var $picker_helper kColumnPickerHelper */ $picked = trim($this->Application->GetVar('picked_str'), '|'); $hidden = trim($this->Application->GetVar('hidden_str'), '|'); @@ -245,4 +245,13 @@ } + function OnCheckPrefixConfig(&$event) + { + $prefix = $this->Application->GetVar('config_prefix'); + $cfg =& $this->Application->recallObject('kConfigReflection'); + /* @var $cfg kConfigReflection */ + $cfg->LoadConfig($prefix); + $event->redirect = false; + } + } \ No newline at end of file Index: branches/RC/core/kernel/utility/debugger/debugger.js =================================================================== diff -u -N -r9335 -r9359 --- branches/RC/core/kernel/utility/debugger/debugger.js (.../debugger.js) (revision 9335) +++ branches/RC/core/kernel/utility/debugger/debugger.js (.../debugger.js) (revision 9359) @@ -96,7 +96,7 @@ case 'dbg_ReloadFrame': self.location.reload(); break; - + case 'dbg_ShowDebugger': this.Toggle(); break; @@ -113,14 +113,14 @@ document.body.style.textAlign = 'left'; var $toolbar_content = 'Reload Frame'; - + if (this.ErrorsCount > 0) { $toolbar_content += 'Show Debugger (' + this.ErrorsCount + ' errors)'; } else { $toolbar_content += 'Show Debugger'; } - + if (this.SQLCount > 0) { $toolbar_content += '' + this.SQLCount + ' sqls'; } @@ -257,9 +257,9 @@ function GetWindowHeight() { var currWinHeight; - + // if (document.body.clientHeight) { -// currWinHeight = document.body.clientHeight; +// currWinHeight = document.body.clientHeight; if (window.innerHeight) {//FireFox with correction for status bar at bottom of window currWinHeight = window.innerHeight; @@ -379,23 +379,23 @@ } } var the_debugger = this; - drag_object.onmousedown = function(ev){ + this.AddEvent(drag_object, 'mousedown', function(ev){ ev = ev || window.event; the_debugger.InitialPos = findPos(drag_object); var coords = the_debugger.mouseCoords(ev); - var pos = findPos(this); + var pos = findPos(drag_object); the_debugger.MouseOffset = [coords.x - pos[0], coords.y - pos[1]]; - the_debugger.DragObject = this; - the_debugger.LastDragObject = this; + the_debugger.DragObject = drag_object; + the_debugger.LastDragObject = drag_object; the_debugger.DragObject.style.position = 'absolute'; the_debugger.Options = cur_options; startCallback(drag_object); - } - document.onmousemove = function(ev){ - ev = ev || window.event; - var coords = the_debugger.mouseCoords(ev); + }); + this.AddEvent(document, 'mousemove', function(ev) { // window.status = 'mouse at: '+coords.x+','+coords.y; if(the_debugger.DragObject){ + ev = ev || window.event; + var coords = the_debugger.mouseCoords(ev); if (the_debugger.Options.VerticalDrag) { the_debugger.DragObject.style.top = (coords.y - the_debugger.MouseOffset[1] ) + 'px' // ; } @@ -405,13 +405,13 @@ moveCallback(drag_object, coords) return false; } - } - document.onmouseup = function(ev){ + }); + this.AddEvent(document, 'mouseup', function(ev){ var tmp = the_debugger.DragObject; the_debugger.DragObject = null; if(tmp){ endCallback(tmp); } var pos = findPos(drag_object); - } + }); } \ No newline at end of file Index: branches/RC/core/admin_templates/js/drag.js =================================================================== diff -u -N -r9299 -r9359 --- branches/RC/core/admin_templates/js/drag.js (.../drag.js) (revision 9299) +++ branches/RC/core/admin_templates/js/drag.js (.../drag.js) (revision 9359) @@ -6,6 +6,7 @@ DragManager.ResizeHappening = false; DragManager.ResizeTimer = null; DragManager.InitialPos = null; +DragManager.Options = {}; DragManager.mouseCoords = function(ev) { @@ -30,22 +31,21 @@ cur_options[i] = options[i]; } } - drag_object.onmousedown = function(ev){ + addEvent(drag_object, 'mousedown', function(ev){ ev = ev || window.event; DragManager.InitialPos = findPos(drag_object); var coords = DragManager.mouseCoords(ev); - var pos = findPos(this); + var pos = findPos(drag_object); DragManager.MouseOffset = [coords.x - pos[0], coords.y - pos[1]]; - DragManager.DragObject = this; - DragManager.LastDragObject = this; + DragManager.DragObject = drag_object; + DragManager.LastDragObject = drag_object; DragManager.DragObject.style.position = 'absolute'; DragManager.Options = cur_options; startCallback(drag_object); - } - document.onmousemove = function(ev){ + }); + addEvent(document, 'mousemove', function(ev){ ev = ev || window.event; - var coords = DragManager.mouseCoords(ev); -// window.status = 'mouse at: '+coords.x+','+coords.y; + var coords = DragManager.mouseCoords(ev); if(DragManager.DragObject){ if (DragManager.Options.VerticalDrag) { DragManager.DragObject.style.top = (coords.y - DragManager.MouseOffset[1] ) + 'px' // ; @@ -56,14 +56,14 @@ moveCallback(drag_object, coords) return false; } - } - document.onmouseup = function(ev){ + }); + addEvent(document, 'mouseup', function(ev){ var tmp = DragManager.DragObject; DragManager.DragObject = null; if(tmp){ endCallback(tmp); } - } + }) } function init_resizer() Index: branches/RC/core/admin_templates/incs/menu_blocks.tpl =================================================================== diff -u -N -r9358 -r9359 --- branches/RC/core/admin_templates/incs/menu_blocks.tpl (.../menu_blocks.tpl) (revision 9358) +++ branches/RC/core/admin_templates/incs/menu_blocks.tpl (.../menu_blocks.tpl) (revision 9359) @@ -1,5 +1,5 @@ - $Menus[''+'_sorting_menu'].addItem(rs('.sort.'), '','javascript:direct_sort_grid("","","", null, );',['img/menu_dot.gif']); + $Menus[''+'_sorting_menu'].addItem(rs('.sort.'), '','javascript:direct_sort_grid("","","", null, );',['img/menu_dot.gif']); @@ -31,10 +31,10 @@ $Menus[''+'_sorting_menu'].applyBorder(false, false, false, false); $Menus[''+'_sorting_menu'].dropShadow("none"); $Menus[''+'_sorting_menu'].showIcon = true; - $Menus[''+'_sorting_menu'].addItem(rs('.sort.asc'), '','javascript:direct_sort_grid("","","asc",null,);',['img/menu_dot.gif']); - $Menus[''+'_sorting_menu'].addItem(rs('.sort.desc'), '','javascript:direct_sort_grid("","","desc",null,);',['img/menu_dot.gif']); + $Menus[''+'_sorting_menu'].addItem(rs('.sort.asc'), '','javascript:direct_sort_grid("","","asc",null,);',['img/menu_dot.gif']); + $Menus[''+'_sorting_menu'].addItem(rs('.sort.desc'), '','javascript:direct_sort_grid("","","desc",null,);',['img/menu_dot.gif']); $Menus[''+'_sorting_menu'].addSeparator(); - $Menus[''+'_sorting_menu'].addItem(rs('.sort.def'), '','javascript:reset_sorting("");'); + $Menus[''+'_sorting_menu'].addItem(rs('.sort.def'), '','javascript:reset_sorting("");'); @@ -57,9 +57,9 @@ $Menus[''+'_select_menu'].applyBorder(false, false, false, false); $Menus[''+'_select_menu'].dropShadow("none"); $Menus[''+'_select_menu'].showIcon = true; - $Menus[''+'_select_menu'].addItem(rs('.select.all'), '','javascript:Grids[""].SelectAll();'); - $Menus[''+'_select_menu'].addItem(rs('.unselect'), '','javascript:Grids[""].ClearSelection();'); - $Menus[''+'_select_menu'].addItem(rs('.invert'), '','javascript:Grids[""].InvertSelection();'); + $Menus[''+'_select_menu'].addItem(rs('.select.all'), '','javascript:Grids[""].SelectAll();'); + $Menus[''+'_select_menu'].addItem(rs('.unselect'), '','javascript:Grids[""].ClearSelection();'); + $Menus[''+'_select_menu'].addItem(rs('.invert'), '','javascript:Grids[""].InvertSelection();'); processHooks('ViewMenu', hBEFORE, ''); @@ -70,20 +70,22 @@ $Menus[''+'_view_menu'].showIcon = true; - $Menus[''+'_view_menu'].addItem(rs('.columns'),'','javascript:openSelector("", "")'); + $Menus[''+'_view_menu'].addItem(rs('.columns'),'','javascript:openSelector("", "")'); + // currently the widths are saved automatically shortly after it have been changed + // $Menus[''+'_view_menu'].addItem(rs('.save_view'),'','javascript:myGrid.SaveWidths()'); - $Menus[''+'_view_menu'].addItem(rs('.filters'), '', 'javascript:void()', null, true, null, rs('.filter.menu'), null); + $Menus[''+'_view_menu'].addItem(rs('.filters'), '', 'javascript:void()', null, true, null, rs('.filter.menu'), null); - $Menus[''+'_view_menu'].addItem(rs('.sorting'), '', 'javascript:void()', null, true, null, rs('.sorting.menu'), null); + $Menus[''+'_view_menu'].addItem(rs('.sorting'), '', 'javascript:void()', null, true, null, rs('.sorting.menu'), null); - $Menus[''+'_view_menu'].addItem(rs('.perpage'), '', 'javascript:void()', null, true, null, rs('.perpage.menu'), null); + $Menus[''+'_view_menu'].addItem(rs('.perpage'), '', 'javascript:void()', null, true, null, rs('.perpage.menu'), null); - $Menus[''+'_view_menu'].addItem(rs('.select'), '', 'javascript:void()', null, true, null, rs('.select.menu'), null); + $Menus[''+'_view_menu'].addItem(rs('.select'), '', 'javascript:void()', null, true, null, rs('.select.menu'), null); $MenuNames[''+'_view_menu'] = ''; Index: branches/RC/core/kernel/db/db_tag_processor.php =================================================================== diff -u -N -r9257 -r9359 --- branches/RC/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 9257) +++ branches/RC/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 9359) @@ -151,6 +151,9 @@ $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']; } @@ -191,6 +194,16 @@ return $data['crc']; } + function FreezerPosition($params) + { + /* @var $picker_helper kColumnPickerHelper */ + $picker_helper =& $this->Application->RecallObject('ColumnPickerHelper'); + $picker_helper->SetGridName($params['grid']); + $data = $picker_helper->LoadColumns($this->getPrefixSpecial()); + $freezer_pos = array_search('__FREEZER__', $data['order']); + return $freezer_pos === false || in_array('__FREEZER__', $data['hidden_fields']) ? 1 : ++$freezer_pos; + } + function GridFieldsCount($params) { $grids = $this->Application->getUnitOption($this->Prefix, 'Grids'); Index: branches/RC/core/admin_templates/js/grid_scroller.js =================================================================== diff -u -N -r9299 -r9359 --- branches/RC/core/admin_templates/js/grid_scroller.js (.../grid_scroller.js) (revision 9299) +++ branches/RC/core/admin_templates/js/grid_scroller.js (.../grid_scroller.js) (revision 9359) @@ -182,7 +182,7 @@ this.Render('main_div_'+this.GridId); return; } - var dot = '
'; + var dot = '
'; document.write(dot); var dot = document.getElementById('my_measure_'+this.GridId); var measure = document.getElementById('my_measure_'+this.GridId); @@ -615,6 +615,7 @@ this.SetLeftHeights(); this.UpdateTotalDimensions(); this.SyncScroll(); + this.ScheduleSaveWidths(); } GridScroller.prototype.ScrollResizeHandles = function() @@ -1054,9 +1055,23 @@ this.Footer = a_footer; } -GridScroller.prototype.SaveWidths = function(prefix, url) +GridScroller.prototype.SaveWidths = function() { + if (!this.SaveURL) return; var w = this.MinWidths.join(':'); - Request.makeRequest(url.replace('#WIDTHS#', w), this.BusyRequest, '', this.successCallback, this.errorCallback, '', this); + Request.makeRequest(this.SaveURL.replace('#WIDTHS#', w), this.BusyRequest, '', this.successCallback, this.errorCallback, '', this); +} +GridScroller.prototype.ScheduleSaveWidths = function() +{ + var obj = this; + if (this.SaveWidthsScheduled && this.SaveWidthsTimer) { + window.clearTimeout(this.SaveWidthsTimer); + this.SaveWidthsTimer = false; + } + this.SaveWidthsScheduled = true; + this.SaveWidthsTimer = window.setTimeout(function() { + obj.SaveWidths(); + obj.SaveWidthsScheduled = false; + }, 800) } \ No newline at end of file