Index: trunk/kernel/admin_templates/incs/catalog.js =================================================================== diff -u -N --- trunk/kernel/admin_templates/incs/catalog.js (revision 0) +++ trunk/kernel/admin_templates/incs/catalog.js (revision 5002) @@ -0,0 +1,127 @@ +var $is_catalog = true; + +function Catalog($url_mask) { + this.BusyRequest = false; + this.URLMask = $url_mask; + this.Separator = '#separator#'; + + this.TabRegistry = new Array(); + + // get from cookie + this.ActivePrefix = ''; +} + +Catalog.prototype.Init = function () { + var $prefix = this.queryTabRegistry('prefix', this.ActivePrefix, 'prefix'); + if ($prefix !== this.ActivePrefix && this.TabRegistry.length > 0) { + // ActivePrefix not set or has non-existing prefix value + this.ActivePrefix = this.TabRegistry[1]['prefix']; + } +} + +Catalog.prototype.submit_kernel_form = function($form_name, $result_div) { + var $kf = document.getElementById($form_name); + set_hidden_field('ajax', 'yes'); + + Request.params = Request.serializeForm($kf); + Request.method = $kf.method.toUpperCase(); + + Request.makeRequest($kf.action, this.BusyRequest, $result_div, this.successCallback, this.errorCallback, $result_div); +}; + +Catalog.prototype.successCallback = function($request, $params) { + var $text = $request.responseText; + $params = $params.split(','); + var $js_end = $text.indexOf($Catalog.Separator); + if ($js_end != -1) { + document.getElementById($params[0]).innerHTML = $text.substring($js_end + $Catalog.Separator.length); + eval($text.substring(0, $js_end)); + } + else { + document.getElementById($params[0]).innerHTML = $text; + } + + if ($params[0] == 'categories_div') { + // category has been changed -> refresh current item tab + $Catalog.switchTab(); + } + + if (isset($Debugger)) $Debugger.Clear(); +} + +Catalog.prototype.errorCallback = function($request, $params) { + alert('AJAX ERROR: ' + Request.getErrorHtml($request)); +} + +Catalog.prototype.submit_event = function($prefix_special, $event, $t, $result_div, $source_form) { + // set form name first, because set_hidden_field uses it + if (isset($source_form)) $form_name = $source_form; + + if (isset($event)) set_hidden_field('events['+$prefix_special+']', $event); + if (isset($t)) set_hidden_field('t', $t); + + this.submit_kernel_form($form_name, $result_div); +} + + +Catalog.prototype.go_to_cat = function($cat_id) { + if (!isset($cat_id)) { + $cat_id = get_hidden_field('m_cat_id'); + } + + var $url = this.URLMask.replace('#TEMPLATE_NAME#', 'xml/categories_list').replace('#CATEGORY_ID#', $cat_id); + Request.makeRequest($url, this.BusyRequest, 'categories_div', this.successCallback, this.errorCallback, 'categories_div'); +} + + +Catalog.prototype.switchTab = function($prefix) { + alert('switch tab called ['+$prefix+'/'+this.ActivePrefix+']'); + if (!isset($prefix)) $prefix = this.ActivePrefix; + + var $cat_id = get_hidden_field('m_cat_id'); + var $div_id = this.queryTabRegistry('prefix', $prefix, 'tab_id') + '_div'; + var $tab_cat_id = document.getElementById($div_id).getAttribute('category_id'); + + if ((this.ActivePrefix == $prefix && $cat_id == $tab_cat_id) || (this.TabRegistry.length == 1)) { + // clicked on current tab + same category || no item tabs = do nothing + alert('problems in switchtab, prefix: '+$prefix+'; cat_id: '+$cat_id+'; tab_cat_id:'+$tab_cat_id); + return true; + } + + // switch tab + if (this.ActivePrefix) { + document.getElementById(this.ActivePrefix + '_tab').className = 'catalog-tab-unselected'; + } + this.ActivePrefix = $prefix; + document.getElementById(this.ActivePrefix + '_tab').className = 'catalog-tab-selected'; + + // query tab content + var $url = this.URLMask.replace('#TEMPLATE_NAME#', this.queryTabRegistry('prefix', $prefix, 'module_path') + '/catalog_tab'); + $url = $url.replace('#CATEGORY_ID#', $cat_id); + + Request.makeRequest($url, this.BusyRequest, $div_id, this.successCallback, this.errorCallback, $div_id); +} + +// adds information about tab to tab_registry +Catalog.prototype.registerTab = function($tab_id) { + var $tab = document.getElementById($tab_id + '_div'); + var $index = this.TabRegistry.length; + this.TabRegistry[$index] = new Array(); + this.TabRegistry[$index]['tab_id'] = $tab_id; + this.TabRegistry[$index]['prefix'] = $tab.getAttribute('prefix'); + this.TabRegistry[$index]['module_path'] = $tab.getAttribute('edit_template').substring(0, $tab.getAttribute('edit_template').indexOf('/')); + this.TabRegistry[$index]['edit_template'] = $tab.getAttribute('edit_template'); +} + +// allows to get any information about tab +Catalog.prototype.queryTabRegistry = function($search_key, $search_value, $return_key) { + var $i = 0; + while ($i < this.TabRegistry.length) { + if (this.TabRegistry[$i][$search_key] == $search_value) { + return this.TabRegistry[$i][$return_key]; + break; + } + $i++; + } + return false; +} \ No newline at end of file Index: trunk/kernel/admin_templates/catalog.tpl =================================================================== diff -u -N -r4997 -r5002 --- trunk/kernel/admin_templates/catalog.tpl (.../catalog.tpl) (revision 4997) +++ trunk/kernel/admin_templates/catalog.tpl (.../catalog.tpl) (revision 5002) @@ -1,6 +1,6 @@ - + @@ -14,8 +14,11 @@ "/> + @@ -197,23 +158,22 @@ -
- +
+ - -
- ');"> +
+ _tab" cellpadding="0" cellspacing="0" width="100%" class="catalog-tab-unselected" onclick="$Catalog.switchTab('');"> @@ -197,23 +158,22 @@ -
- +
+
- + (_item_count">?) @@ -248,4 +208,5 @@ \ No newline at end of file Index: trunk/core/admin_templates/categories/xml/categories_list.tpl =================================================================== diff -u -N -r4996 -r5002 --- trunk/core/admin_templates/categories/xml/categories_list.tpl (.../categories_list.tpl) (revision 4996) +++ trunk/core/admin_templates/categories/xml/categories_list.tpl (.../categories_list.tpl) (revision 5002) @@ -1,4 +1,3 @@ - @@ -7,13 +6,13 @@ Grids['c'].InitItems(); setInnerHTML('category_count', ); - +set_hidden_field('m_cat_id', ); - + @@ -22,7 +21,7 @@ - );"> + );"> @@ -45,7 +44,7 @@ _"> " id=""> ">  - );">: + );">: Pick New ( / )
Index: trunk/kernel/admin_templates/incs/ajax.js =================================================================== diff -u -N -r4996 -r5002 --- trunk/kernel/admin_templates/incs/ajax.js (.../ajax.js) (revision 4996) +++ trunk/kernel/admin_templates/incs/ajax.js (.../ajax.js) (revision 5002) @@ -112,48 +112,4 @@ } } return queryString; -}; -// Catalog Related - -function Catalog() {} -Catalog.BusyRequest = false; - -Catalog.submit_kernel_form = function($form_name, $result_div) { - var $kf = document.getElementById($form_name); - set_hidden_field('ajax', 'yes'); - - Request.params = Request.serializeForm($kf); - Request.method = $kf.method.toUpperCase(); - - Request.makeRequest($kf.action, Catalog.BusyRequest, $result_div, Catalog.successCallback, Catalog.errorCallback, $result_div); -}; - -Catalog.successCallback = function($request, $params) { - var $text = $request.responseText; - $params = $params.split(','); - var $js_end = $text.indexOf($separator); - if ($js_end != -1) { - document.getElementById($params[0]).innerHTML = $text.substring($js_end + $separator.length); - eval($text.substring(0, $js_end)); - - } - else { - document.getElementById($params[0]).innerHTML = $text; - } - - if (isset($Debugger)) $Debugger.Clear(); -} - -Catalog.errorCallback = function($request, $params) { - alert('AJAX ERROR: ' + Request.getErrorHtml($request)); -} - -Catalog.submit_event = function($prefix_special, $event, $t, $result_div, $source_form) { - // set form name first, because set_hidden_field uses it - if (isset($source_form)) $form_name = $source_form; - - if (isset($event)) set_hidden_field('events['+$prefix_special+']', $event); - if (isset($t)) set_hidden_field('t', $t); - - Catalog.submit_kernel_form($form_name, $result_div); -} \ No newline at end of file +}; \ No newline at end of file Index: trunk/kernel/admin_templates/incs/tree.js =================================================================== diff -u -N -r4735 -r5002 --- trunk/kernel/admin_templates/incs/tree.js (.../tree.js) (revision 4735) +++ trunk/kernel/admin_templates/incs/tree.js (.../tree.js) (revision 5002) @@ -100,7 +100,10 @@ } else { // ensures, that click is made before AJAX request will be sent - window.parent.getFrame(link.target).location.href = this.href; + if (res === true) { + // only in case of "true" is returned, used in catalog + window.parent.getFrame(link.target).location.href = this.href; + } if (!this.treeItem.Expanded && typeof(this.treeItem.folderClick) == 'function') { if (this.treeItem.folderClick()); Index: trunk/core/admin_templates/js/catalog.js =================================================================== diff -u -N --- trunk/core/admin_templates/js/catalog.js (revision 0) +++ trunk/core/admin_templates/js/catalog.js (revision 5002) @@ -0,0 +1,127 @@ +var $is_catalog = true; + +function Catalog($url_mask) { + this.BusyRequest = false; + this.URLMask = $url_mask; + this.Separator = '#separator#'; + + this.TabRegistry = new Array(); + + // get from cookie + this.ActivePrefix = ''; +} + +Catalog.prototype.Init = function () { + var $prefix = this.queryTabRegistry('prefix', this.ActivePrefix, 'prefix'); + if ($prefix !== this.ActivePrefix && this.TabRegistry.length > 0) { + // ActivePrefix not set or has non-existing prefix value + this.ActivePrefix = this.TabRegistry[1]['prefix']; + } +} + +Catalog.prototype.submit_kernel_form = function($form_name, $result_div) { + var $kf = document.getElementById($form_name); + set_hidden_field('ajax', 'yes'); + + Request.params = Request.serializeForm($kf); + Request.method = $kf.method.toUpperCase(); + + Request.makeRequest($kf.action, this.BusyRequest, $result_div, this.successCallback, this.errorCallback, $result_div); +}; + +Catalog.prototype.successCallback = function($request, $params) { + var $text = $request.responseText; + $params = $params.split(','); + var $js_end = $text.indexOf($Catalog.Separator); + if ($js_end != -1) { + document.getElementById($params[0]).innerHTML = $text.substring($js_end + $Catalog.Separator.length); + eval($text.substring(0, $js_end)); + } + else { + document.getElementById($params[0]).innerHTML = $text; + } + + if ($params[0] == 'categories_div') { + // category has been changed -> refresh current item tab + $Catalog.switchTab(); + } + + if (isset($Debugger)) $Debugger.Clear(); +} + +Catalog.prototype.errorCallback = function($request, $params) { + alert('AJAX ERROR: ' + Request.getErrorHtml($request)); +} + +Catalog.prototype.submit_event = function($prefix_special, $event, $t, $result_div, $source_form) { + // set form name first, because set_hidden_field uses it + if (isset($source_form)) $form_name = $source_form; + + if (isset($event)) set_hidden_field('events['+$prefix_special+']', $event); + if (isset($t)) set_hidden_field('t', $t); + + this.submit_kernel_form($form_name, $result_div); +} + + +Catalog.prototype.go_to_cat = function($cat_id) { + if (!isset($cat_id)) { + $cat_id = get_hidden_field('m_cat_id'); + } + + var $url = this.URLMask.replace('#TEMPLATE_NAME#', 'xml/categories_list').replace('#CATEGORY_ID#', $cat_id); + Request.makeRequest($url, this.BusyRequest, 'categories_div', this.successCallback, this.errorCallback, 'categories_div'); +} + + +Catalog.prototype.switchTab = function($prefix) { + alert('switch tab called ['+$prefix+'/'+this.ActivePrefix+']'); + if (!isset($prefix)) $prefix = this.ActivePrefix; + + var $cat_id = get_hidden_field('m_cat_id'); + var $div_id = this.queryTabRegistry('prefix', $prefix, 'tab_id') + '_div'; + var $tab_cat_id = document.getElementById($div_id).getAttribute('category_id'); + + if ((this.ActivePrefix == $prefix && $cat_id == $tab_cat_id) || (this.TabRegistry.length == 1)) { + // clicked on current tab + same category || no item tabs = do nothing + alert('problems in switchtab, prefix: '+$prefix+'; cat_id: '+$cat_id+'; tab_cat_id:'+$tab_cat_id); + return true; + } + + // switch tab + if (this.ActivePrefix) { + document.getElementById(this.ActivePrefix + '_tab').className = 'catalog-tab-unselected'; + } + this.ActivePrefix = $prefix; + document.getElementById(this.ActivePrefix + '_tab').className = 'catalog-tab-selected'; + + // query tab content + var $url = this.URLMask.replace('#TEMPLATE_NAME#', this.queryTabRegistry('prefix', $prefix, 'module_path') + '/catalog_tab'); + $url = $url.replace('#CATEGORY_ID#', $cat_id); + + Request.makeRequest($url, this.BusyRequest, $div_id, this.successCallback, this.errorCallback, $div_id); +} + +// adds information about tab to tab_registry +Catalog.prototype.registerTab = function($tab_id) { + var $tab = document.getElementById($tab_id + '_div'); + var $index = this.TabRegistry.length; + this.TabRegistry[$index] = new Array(); + this.TabRegistry[$index]['tab_id'] = $tab_id; + this.TabRegistry[$index]['prefix'] = $tab.getAttribute('prefix'); + this.TabRegistry[$index]['module_path'] = $tab.getAttribute('edit_template').substring(0, $tab.getAttribute('edit_template').indexOf('/')); + this.TabRegistry[$index]['edit_template'] = $tab.getAttribute('edit_template'); +} + +// allows to get any information about tab +Catalog.prototype.queryTabRegistry = function($search_key, $search_value, $return_key) { + var $i = 0; + while ($i < this.TabRegistry.length) { + if (this.TabRegistry[$i][$search_key] == $search_value) { + return this.TabRegistry[$i][$return_key]; + break; + } + $i++; + } + return false; +} \ No newline at end of file Index: trunk/core/kernel/application.php =================================================================== diff -u -N -r4971 -r5002 --- trunk/core/kernel/application.php (.../application.php) (revision 4971) +++ trunk/core/kernel/application.php (.../application.php) (revision 5002) @@ -612,6 +612,11 @@ $this->LinkVar('return_template'); // template to go, when something was coosen from popup (from finalizePopup) $this->LinkVar('return_m'); // main env part to restore after popup will be closed (from finalizePopup) } + + if ($this->GetVar('ajax') == 'yes') { + // hide debug output from ajax requests automatically + define('DBG_SKIP_REPORTING', 1); + } } if (!$this->RequestProcessed) $this->ProcessRequest(); Index: trunk/kernel/admin_templates/tree.tpl =================================================================== diff -u -N -r4996 -r5002 --- trunk/kernel/admin_templates/tree.tpl (.../tree.tpl) (revision 4996) +++ trunk/kernel/admin_templates/tree.tpl (.../tree.tpl) (revision 5002) @@ -106,8 +106,8 @@ var $ret = checkEditMode(); var $right_frame = window.parent.getFrame('main'); if ($ret && $right_frame.$is_catalog) { - $right_frame.go_to_cat($cat_id); - return false; + $right_frame.$Catalog.go_to_cat($cat_id); + return 1; // this opens folder, but disables click } return $ret; } Index: trunk/core/admin_templates/catalog/catalog.tpl =================================================================== diff -u -N -r4997 -r5002 --- trunk/core/admin_templates/catalog/catalog.tpl (.../catalog.tpl) (revision 4997) +++ trunk/core/admin_templates/catalog/catalog.tpl (.../catalog.tpl) (revision 5002) @@ -1,6 +1,6 @@ - + @@ -14,8 +14,11 @@
"/> +
- -
- ');"> +
+ _tab" cellpadding="0" cellspacing="0" width="100%" class="catalog-tab-unselected" onclick="$Catalog.switchTab('');">
- + (_item_count">?) @@ -248,4 +208,5 @@ \ No newline at end of file Index: trunk/kernel/admin_templates/xml/categories_list.tpl =================================================================== diff -u -N -r4996 -r5002 --- trunk/kernel/admin_templates/xml/categories_list.tpl (.../categories_list.tpl) (revision 4996) +++ trunk/kernel/admin_templates/xml/categories_list.tpl (.../categories_list.tpl) (revision 5002) @@ -1,4 +1,3 @@ - @@ -7,13 +6,13 @@ Grids['c'].InitItems(); setInnerHTML('category_count', ); - +set_hidden_field('m_cat_id', ); - + @@ -22,7 +21,7 @@ - );"> + );"> @@ -45,7 +44,7 @@ _"> " id=""> ">  - );">: + );">: Pick New ( / )
Index: trunk/kernel/admin_templates/incs/grid_blocks.tpl =================================================================== diff -u -N -r4872 -r5002 --- trunk/kernel/admin_templates/incs/grid_blocks.tpl (.../grid_blocks.tpl) (revision 4872) +++ trunk/kernel/admin_templates/incs/grid_blocks.tpl (.../grid_blocks.tpl) (revision 5002) @@ -313,7 +313,7 @@ _Sort1_Dir" name="_Sort1_Dir" value="asc"> - + nobottomnotop"> @@ -338,20 +338,27 @@
- - - - - - + + + + + + + + + _Sort1" name="_Sort1" value=""> _Sort1_Dir" name="_Sort1_Dir" value="asc"> - \ No newline at end of file + + + + + Grids[''] = new Grid('table_white_selected', ':original', edit, a_toolbar); + Grids[''].AddItemsByIdMask('td', /^_([0-9-]+)/, '[$$ID$$][]'); + Grids[''].InitItems(); + + + $ViewMenus = new Array(''); + \ No newline at end of file Index: trunk/kernel/units/admin/admin_tag_processor.php =================================================================== diff -u -N -r4997 -r5002 --- trunk/kernel/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 4997) +++ trunk/kernel/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 5002) @@ -339,12 +339,14 @@ function ListCatalogTabs($params) { $ret = ''; + $special = $params['special']; $block_params = Array('name' => $params['render_as']); foreach ($this->Application->ModuleInfo as $module_name => $module_info) { $prefix = $module_info['Var']; - $view_perm = $this->Application->getUnitOption($prefix, 'PermItemPrefix'); + $view_perm = $this->Application->getUnitOption($prefix, 'PermItemPrefix').'.VIEW'; if (!$this->Application->CheckPermission($view_perm, 0) || ($prefix == 'm')) continue; - $block_params['title'] = '['.$prefix.'] Items'; + $label = $this->Application->getUnitOption($prefix, 'ViewMenuPhrase'); + $block_params['title'] = $this->Application->Phrase($label); $block_params['prefix'] = $prefix; $ret .= $this->Application->ParseBlock($block_params); } Index: trunk/kernel/units/general/cat_tag_processor.php =================================================================== diff -u -N -r4243 -r5002 --- trunk/kernel/units/general/cat_tag_processor.php (.../cat_tag_processor.php) (revision 4243) +++ trunk/kernel/units/general/cat_tag_processor.php (.../cat_tag_processor.php) (revision 5002) @@ -128,6 +128,12 @@ return $export_options['start_from'] * 100 / $export_options['total_records']; } + function CatalogItemCount($params) + { + $object =& $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix.'_List', $params); + return $object->NoFilterCount != $object->RecordsCount ? $object->RecordsCount.' / '.$object->NoFilterCount : $object->RecordsCount; + } + } ?> \ No newline at end of file Index: trunk/core/units/admin/admin_tag_processor.php =================================================================== diff -u -N -r4997 -r5002 --- trunk/core/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 4997) +++ trunk/core/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 5002) @@ -339,12 +339,14 @@ function ListCatalogTabs($params) { $ret = ''; + $special = $params['special']; $block_params = Array('name' => $params['render_as']); foreach ($this->Application->ModuleInfo as $module_name => $module_info) { $prefix = $module_info['Var']; - $view_perm = $this->Application->getUnitOption($prefix, 'PermItemPrefix'); + $view_perm = $this->Application->getUnitOption($prefix, 'PermItemPrefix').'.VIEW'; if (!$this->Application->CheckPermission($view_perm, 0) || ($prefix == 'm')) continue; - $block_params['title'] = '['.$prefix.'] Items'; + $label = $this->Application->getUnitOption($prefix, 'ViewMenuPhrase'); + $block_params['title'] = $this->Application->Phrase($label); $block_params['prefix'] = $prefix; $ret .= $this->Application->ParseBlock($block_params); } Index: trunk/core/units/general/cat_tag_processor.php =================================================================== diff -u -N -r4243 -r5002 --- trunk/core/units/general/cat_tag_processor.php (.../cat_tag_processor.php) (revision 4243) +++ trunk/core/units/general/cat_tag_processor.php (.../cat_tag_processor.php) (revision 5002) @@ -128,6 +128,12 @@ return $export_options['start_from'] * 100 / $export_options['total_records']; } + function CatalogItemCount($params) + { + $object =& $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix.'_List', $params); + return $object->NoFilterCount != $object->RecordsCount ? $object->RecordsCount.' / '.$object->NoFilterCount : $object->RecordsCount; + } + } ?> \ No newline at end of file Index: trunk/kernel/admin_templates/incs/style.css =================================================================== diff -u -N -r4996 -r5002 --- trunk/kernel/admin_templates/incs/style.css (.../style.css) (revision 4996) +++ trunk/kernel/admin_templates/incs/style.css (.../style.css) (revision 5002) @@ -563,8 +563,10 @@ .catalog-tab-selected td { background-color: #E0E0DA; + cursor: default; } -.catalog-tab-unselected td { +.catalog-tab-unselected td, .catalog-tab-unselected td span { background-color: #F0F1EB; + cursor: pointer; }