Index: trunk/kernel/units/categories/categories_event_handler.php =================================================================== diff -u -N -r4755 -r5036 --- trunk/kernel/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 4755) +++ trunk/kernel/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 5036) @@ -14,42 +14,8 @@ ); $this->permMapping = array_merge($this->permMapping, $permissions); } - - /** - * Goes one level up from current category - * - * @param kEvent $event - */ - function OnCategoryUp(&$event) - { - $category_table = $this->Application->getUnitOption($event->Prefix,'TableName'); - $current_cat = $this->Application->GetVar('m_cat_id'); - if($current_cat) - { - $sql = 'SELECT ParentId FROM '.$category_table.' WHERE CategoryId = '.$current_cat; - $cat_to_go = $this->Conn->GetOne($sql); - } - else - { - $cat_to_go = 0; - } - - $event->redirect_params = Array('m_cat_id' => $cat_to_go); - } - /** - * Goes to home category - * - * @param kEvent $event - */ - function OnGoHome(&$event) - { - $cat_to_go = 0; - $event->redirect_params = Array('m_cat_id' => $cat_to_go); - } - - /** * Apply system filter to categories list * * @param kEvent $event Index: trunk/core/admin_templates/js/catalog.js =================================================================== diff -u -N -r5033 -r5036 --- trunk/core/admin_templates/js/catalog.js (.../catalog.js) (revision 5033) +++ trunk/core/admin_templates/js/catalog.js (.../catalog.js) (revision 5036) @@ -5,7 +5,8 @@ this.BusyRequest = false; this.URLMask = $url_mask; this.Separator = '#separator#'; - + this.ParentCategoryID = 0; + this.TabRegistry = new Array(); this.ActivePrefix = getCookie(this.CookiePrefix + 'active_prefix'); this.PreviousPrefix = this.ActivePrefix; @@ -68,13 +69,23 @@ document.getElementById($params[0]).innerHTML = $text; } + if ($params[0] != 'categories_div') { + $Catalog.setViewMenu(); + } + if (isset($Debugger)) $Debugger.Clear(); } Catalog.prototype.errorCallback = function($request, $params) { alert('AJAX ERROR: ' + Request.getErrorHtml($request)); } +Catalog.prototype.setViewMenu = function() { + if (Grids[this.ActivePrefix]) { + $ViewMenus = new Array('c', this.ActivePrefix); + } +} + Catalog.prototype.submit_event = function($prefix_special, $event, $t) { if (!isset($prefix_special)) $prefix_special = this.getCurrentPrefix(); var $tab_id = this.queryTabRegistry('prefix', $prefix_special, 'tab_id'); @@ -136,7 +147,6 @@ document.getElementById($div_id).style.display = 'block'; this.ShowDependentButtons(this.ActivePrefix); setCookie(this.CookiePrefix + 'active_prefix', this.ActivePrefix); - $ViewMenus = new Array('c', this.ActivePrefix); // this.TabRegistry.length == 1 var $cat_id = get_hidden_field('m_cat_id'); Index: trunk/core/units/categories/categories_event_handler.php =================================================================== diff -u -N -r4755 -r5036 --- trunk/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 4755) +++ trunk/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 5036) @@ -14,42 +14,8 @@ ); $this->permMapping = array_merge($this->permMapping, $permissions); } - - /** - * Goes one level up from current category - * - * @param kEvent $event - */ - function OnCategoryUp(&$event) - { - $category_table = $this->Application->getUnitOption($event->Prefix,'TableName'); - $current_cat = $this->Application->GetVar('m_cat_id'); - if($current_cat) - { - $sql = 'SELECT ParentId FROM '.$category_table.' WHERE CategoryId = '.$current_cat; - $cat_to_go = $this->Conn->GetOne($sql); - } - else - { - $cat_to_go = 0; - } - - $event->redirect_params = Array('m_cat_id' => $cat_to_go); - } - /** - * Goes to home category - * - * @param kEvent $event - */ - function OnGoHome(&$event) - { - $cat_to_go = 0; - $event->redirect_params = Array('m_cat_id' => $cat_to_go); - } - - /** * Apply system filter to categories list * * @param kEvent $event Index: trunk/core/admin_templates/catalog/catalog.tpl =================================================================== diff -u -N -r5033 -r5036 --- trunk/core/admin_templates/catalog/catalog.tpl (.../catalog.tpl) (revision 5033) +++ trunk/core/admin_templates/catalog/catalog.tpl (.../catalog.tpl) (revision 5036) @@ -22,12 +22,12 @@ var a_toolbar = new ToolBar(); a_toolbar.AddButton( new ToolBarButton('upcat', '', function() { - $Catalog.submit_event('c', 'OnCategoryUp'); + $Catalog.go_to_cat($Catalog.ParentCategoryID); } ) ); a_toolbar.AddButton( new ToolBarButton('homecat', '', function() { - $Catalog.submit_event('c', 'OnGoHome'); + $Catalog.go_to_cat(0); } ) ); Index: trunk/kernel/admin_templates/incs/catalog.js =================================================================== diff -u -N -r5033 -r5036 --- trunk/kernel/admin_templates/incs/catalog.js (.../catalog.js) (revision 5033) +++ trunk/kernel/admin_templates/incs/catalog.js (.../catalog.js) (revision 5036) @@ -5,7 +5,8 @@ this.BusyRequest = false; this.URLMask = $url_mask; this.Separator = '#separator#'; - + this.ParentCategoryID = 0; + this.TabRegistry = new Array(); this.ActivePrefix = getCookie(this.CookiePrefix + 'active_prefix'); this.PreviousPrefix = this.ActivePrefix; @@ -68,13 +69,23 @@ document.getElementById($params[0]).innerHTML = $text; } + if ($params[0] != 'categories_div') { + $Catalog.setViewMenu(); + } + if (isset($Debugger)) $Debugger.Clear(); } Catalog.prototype.errorCallback = function($request, $params) { alert('AJAX ERROR: ' + Request.getErrorHtml($request)); } +Catalog.prototype.setViewMenu = function() { + if (Grids[this.ActivePrefix]) { + $ViewMenus = new Array('c', this.ActivePrefix); + } +} + Catalog.prototype.submit_event = function($prefix_special, $event, $t) { if (!isset($prefix_special)) $prefix_special = this.getCurrentPrefix(); var $tab_id = this.queryTabRegistry('prefix', $prefix_special, 'tab_id'); @@ -136,7 +147,6 @@ document.getElementById($div_id).style.display = 'block'; this.ShowDependentButtons(this.ActivePrefix); setCookie(this.CookiePrefix + 'active_prefix', this.ActivePrefix); - $ViewMenus = new Array('c', this.ActivePrefix); // this.TabRegistry.length == 1 var $cat_id = get_hidden_field('m_cat_id'); Index: trunk/kernel/admin_templates/catalog.tpl =================================================================== diff -u -N -r5033 -r5036 --- trunk/kernel/admin_templates/catalog.tpl (.../catalog.tpl) (revision 5033) +++ trunk/kernel/admin_templates/catalog.tpl (.../catalog.tpl) (revision 5036) @@ -22,12 +22,12 @@ var a_toolbar = new ToolBar(); a_toolbar.AddButton( new ToolBarButton('upcat', '', function() { - $Catalog.submit_event('c', 'OnCategoryUp'); + $Catalog.go_to_cat($Catalog.ParentCategoryID); } ) ); a_toolbar.AddButton( new ToolBarButton('homecat', '', function() { - $Catalog.submit_event('c', 'OnGoHome'); + $Catalog.go_to_cat(0); } ) ); Index: trunk/kernel/admin_templates/xml/categories_list.tpl =================================================================== diff -u -N -r5024 -r5036 --- trunk/kernel/admin_templates/xml/categories_list.tpl (.../categories_list.tpl) (revision 5024) +++ trunk/kernel/admin_templates/xml/categories_list.tpl (.../categories_list.tpl) (revision 5036) @@ -6,7 +6,8 @@ Grids['c'].InitItems(); Grids['c'].SetDependantToolbarButtons( new Array('edit','delete','approve','decline','sep3','cut','copy','move_up','move_down','sep6')); -$Catalog.setItemCount('c', ''); +$Catalog.setItemCount('c', ''); +$Catalog.ParentCategoryID = ; Index: trunk/core/admin_templates/categories/xml/categories_list.tpl =================================================================== diff -u -N -r5024 -r5036 --- trunk/core/admin_templates/categories/xml/categories_list.tpl (.../categories_list.tpl) (revision 5024) +++ trunk/core/admin_templates/categories/xml/categories_list.tpl (.../categories_list.tpl) (revision 5036) @@ -6,7 +6,8 @@ Grids['c'].InitItems(); Grids['c'].SetDependantToolbarButtons( new Array('edit','delete','approve','decline','sep3','cut','copy','move_up','move_down','sep6')); -$Catalog.setItemCount('c', ''); +$Catalog.setItemCount('c', ''); +$Catalog.ParentCategoryID = ; Index: trunk/kernel/units/categories/categories_tag_processor.php =================================================================== diff -u -N -r5024 -r5036 --- trunk/kernel/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 5024) +++ trunk/kernel/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 5036) @@ -306,6 +306,21 @@ $this->Application->SetVar('m_cat_id', $category_id); $this->Application->Session->SaveLastTemplate($params['template']); } + + function GetParentCategory($params) + { + $parent_id = 0; + $id_field = $this->Application->getUnitOption($this->Prefix, 'IDField'); + $table = $this->Application->getUnitOption($this->Prefix,'TableName'); + $cat_id = $this->Application->GetVar('m_cat_id'); + if ($cat_id > 0) { + $sql = 'SELECT ParentId + FROM '.$table.' + WHERE '.$id_field.' = '.$cat_id; + $parent_id = $this->Conn->GetOne($sql); + } + return $parent_id; + } } Index: trunk/core/units/categories/categories_tag_processor.php =================================================================== diff -u -N -r5024 -r5036 --- trunk/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 5024) +++ trunk/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 5036) @@ -306,6 +306,21 @@ $this->Application->SetVar('m_cat_id', $category_id); $this->Application->Session->SaveLastTemplate($params['template']); } + + function GetParentCategory($params) + { + $parent_id = 0; + $id_field = $this->Application->getUnitOption($this->Prefix, 'IDField'); + $table = $this->Application->getUnitOption($this->Prefix,'TableName'); + $cat_id = $this->Application->GetVar('m_cat_id'); + if ($cat_id > 0) { + $sql = 'SELECT ParentId + FROM '.$table.' + WHERE '.$id_field.' = '.$cat_id; + $parent_id = $this->Conn->GetOne($sql); + } + return $parent_id; + } }