Tries to fix ACP menu again
authorMatthias Schmidt <gravatronics@live.com>
Mon, 31 Dec 2012 13:47:31 +0000 (14:47 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Mon, 31 Dec 2012 13:47:31 +0000 (14:47 +0100)
Those top option category links are trying really hard to make one's life miserable.

Previously, the session ID of the active user was cached in the top option category links, which will break them in other sessions/for other users. Now, since these links are different and included in the core, `ACPMenuItem` is allowed to know that there are such "special" links and this it can handle them by building the link with the id of the option category which is cached with them as a "special" value.

wcfsetup/install/files/acp/templates/header.tpl
wcfsetup/install/files/lib/data/acp/menu/item/ACPMenuItem.class.php
wcfsetup/install/files/lib/system/cache/builder/ACPMenuCacheBuilder.class.php

index 7195abf09e57e09f23b15c8a941f1d5ead52c93e..6c3eab09a46234b404df0fb52f3438cc14e392f2 100644 (file)
                                                                        <div id="{$_parentMenuItem->menuItem}-container" style="display: none;" class="menuGroup collapsibleMenus" data-parent-menu-item="{$_parentMenuItem->menuItem}">
                                                                                {foreach from=$__wcf->getACPMenu()->getMenuItems($_parentMenuItem->menuItem) item=_menuItem}
                                                                                        <fieldset>
-                                                                                               <legend class="menuHeader" data-menu-item="{$_menuItem->menuItem}">{$_menuItem}</legend>
+                                                                                               <legend class="menuHeader" data-menu-item="{$_menuItem->menuItem}">{@$_menuItem}</legend>
                                                                                                
                                                                                                <nav class="menuGroupItems">
                                                                                                        <ul id="{$_menuItem->menuItem}">
                                                                                                                {foreach from=$__wcf->getACPMenu()->getMenuItems($_menuItem->menuItem) item=menuItemCategory}
                                                                                                                        {if $__wcf->getACPMenu()->getMenuItems($menuItemCategory->menuItem)|count > 0}
                                                                                                                                {foreach from=$__wcf->getACPMenu()->getMenuItems($menuItemCategory->menuItem) item=subMenuItem}
-                                                                                                                                       <li id="{$subMenuItem->menuItem}" data-menu-item="{$subMenuItem->menuItem}"><a href="{$subMenuItem->getLink()}">{$subMenuItem}</a></li>
+                                                                                                                                       <li id="{$subMenuItem->menuItem}" data-menu-item="{$subMenuItem->menuItem}"><a href="{$subMenuItem->getLink()}">{@$subMenuItem}</a></li>
                                                                                                                                {/foreach}
                                                                                                                        {else}
-                                                                                                                               <li id="{$menuItemCategory->menuItem}" data-menu-item="{$menuItemCategory->menuItem}"><a href="{$menuItemCategory->getLink()}">{$menuItemCategory}</a></li>
+                                                                                                                               <li id="{$menuItemCategory->menuItem}" data-menu-item="{$menuItemCategory->menuItem}"><a href="{$menuItemCategory->getLink()}">{@$menuItemCategory}</a></li>
                                                                                                                        {/if}
                                                                                                                {/foreach}
                                                                                                        </ul>
index eaf307682aeaddec0462616b085368a857bc1ff1..6c1b4cf1232dece4da5dea19f02b65c03df362a4 100644 (file)
@@ -47,9 +47,20 @@ class ACPMenuItem extends DatabaseObject implements ITreeMenuItem {
                if (!$this->menuItemController) {
                        return WCF::getLanguage()->get($this->menuItemLink);
                }
-       
+               
                $this->parseController();
-               return LinkHandler::getInstance()->getLink($this->controller, array('application' => $this->application), WCF::getLanguage()->get($this->menuItemLink));
+               
+               $linkParameters = array(
+                       'application' => $this->application
+               );
+               
+               // links of top option category menu items need the id of the option
+               // category
+               if ($this->parentMenuItem == 'wcf.acp.menu.link.option.category') {
+                       $linkParameters['id'] = $this->optionCategoryID;
+               }
+               
+               return LinkHandler::getInstance()->getLink($this->controller, $linkParameters, WCF::getLanguage()->get($this->menuItemLink));
        }
        
        /**
@@ -59,7 +70,7 @@ class ACPMenuItem extends DatabaseObject implements ITreeMenuItem {
         */
        public function getController() {
                $this->parseController();
-       
+               
                return $this->controller;
        }
        
@@ -69,13 +80,13 @@ class ACPMenuItem extends DatabaseObject implements ITreeMenuItem {
        protected function parseController() {
                if ($this->controller === null) {
                        $this->controller = '';
-       
+                       
                        // resolve application and controller
                        if ($this->menuItemController) {
                                $parts = explode('\\', $this->menuItemController);
                                $this->application = array_shift($parts);
                                $menuItemController = array_pop($parts);
-       
+                               
                                // drop controller suffix
                                $this->controller = Regex::compile('(Action|Form|Page)$')->replace($menuItemController, '');
                        }
index 7af4530a3033c436e1052081df8e3ae00ae48ced..96818fe1fa55556323fc9abe3ac46aac7f9928ed 100644 (file)
@@ -50,11 +50,9 @@ class ACPMenuCacheBuilder implements ICacheBuilder {
                        $data['wcf.acp.menu.link.option.category'][] = new ACPMenuItem(null, array(
                                'menuItem' => 'wcf.acp.option.category.'.$optionCategory->categoryName,
                                'parentMenuItem' => 'wcf.acp.menu.link.option.category',
-                               'menuItemLink' => LinkHandler::getInstance()->getLink('Option', array(
-                                       'application' => 'wcf',
-                                       'id' => $optionCategory->categoryID
-                               )),
+                               'menuItemController' => 'wcf\acp\form\OptionForm',
                                'permissions' => $optionCategory->permissions,
+                               'optionCategoryID' => $optionCategory->categoryID,
                                'options' => $optionCategory->options
                        ));
                }