Properly provide frontend main menu items in ACP
authorAlexander Ebert <ebert@woltlab.com>
Tue, 5 Apr 2016 10:45:43 +0000 (12:45 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 5 Apr 2016 10:45:43 +0000 (12:45 +0200)
wcfsetup/install/files/acp/templates/pageHeaderUser.tpl
wcfsetup/install/files/acp/templates/pageMenuMobile.tpl
wcfsetup/install/files/lib/data/menu/MenuCache.class.php
wcfsetup/install/files/lib/system/WCFACP.class.php
wcfsetup/install/files/lib/system/cache/builder/MenuCacheBuilder.class.php

index 60324aaae8a431a7e321c6d9eec23bf7cf421498..9ba2ce34da74fba0efaa5c61c44258dde17b1fd5 100644 (file)
                                <li id="jumpToPage" class="dropdown">
                                        <a href="{link forceFrontend=true}{/link}" class="dropdownToggle" data-toggle="jumpToPage"><span class="icon icon32 fa-home"></span> <span>{lang}wcf.global.jumpToPage{/lang}</span></a>
                                        <ul class="dropdownMenu">
-                                               {* TODO *}
-                                               {*foreach from=$__wcf->getPageMenu()->getMenuItems('header') item=_menuItem}
-                                                       <li><a href="{$_menuItem->getProcessor()->getLink()}">{lang}{$_menuItem->menuItem}{/lang}</a></li>
-                                               {/foreach*}
+                                               {foreach from=$__wcf->getFrontendMenu()->getMenuItemNodeList() item=_menuItem}
+                                                       {if !$_menuItem->getMenuItem()->parentItemID && $_menuItem->getMenuItem()->getPage()}
+                                                               <li><a href="{$_menuItem->getMenuItem()->getPage()->getLink()}">{$_menuItem->getMenuItem()->getPage()}</a></li>
+                                                       {/if}
+                                               {/foreach}
                                        </ul>
                                </li>
                                
index 29cdc459a12b13ab148662c01b836d6657571a1b..b65583287a834f045ec22116f50a2e291a302bd3 100644 (file)
@@ -1,7 +1,7 @@
 {* main menu *}
 <div id="pageMainMenuMobile" class="pageMainMenuMobile menuOverlayMobile" data-page-logo="{$__wcf->getPath()}images/default-logo.png">
-       <ol class="menuOverlayItemList" data-title="TODO: menu">
-               <li class="menuOverlayTitle">TODO: menu</li>
+       <ol class="menuOverlayItemList" data-title="{lang}wcf.menu.page{/lang}">
+               <li class="menuOverlayTitle">{lang}wcf.menu.page{/lang}</li>
                {foreach from=$__wcf->getACPMenu()->getMenuItems('') item=_sectionMenuItem}
                        <li class="menuOverlayItem">
                                <a href="#" class="menuOverlayItemLink box24{if $_sectionMenuItem->menuItem|in_array:$_activeMenuItems} active{/if}">
 
 {* user menu *}
 <div id="pageUserMenuMobile" class="pageUserMenuMobile menuOverlayMobile" data-page-logo="{$__wcf->getPath()}images/default-logo.png">
-       <ol class="menuOverlayItemList" data-title="TODO: user menu">
-               <li class="menuOverlayTitle">TODO: user menu</li>
+       <ol class="menuOverlayItemList" data-title="{lang}wcf.menu.user{/lang}">
+               <li class="menuOverlayTitle">{lang}wcf.menu.user{/lang}</li>
                <li class="menuOverlayItem">
                        <a href="#" class="menuOverlayItemLink box24">
                                <span class="icon icon24 fa-home"></span>
                                <span class="menuOverlayItemTitle">{lang}wcf.global.jumpToPage{/lang}</span>
                        </a>
                        <ol class="menuOverlayItemList">
-                               {* TODO *}
-                               {*foreach from=$__wcf->getPageMenu()->getMenuItems('header') item=_menuItem}
-                                       <li class="menuOverlayItem"><a href="{$_menuItem->getProcessor()->getLink()}" class="menuOverlayItemLink">{lang}{$_menuItem->menuItem}{/lang}</a></li>
-                               {/foreach*}
+                               {foreach from=$__wcf->getFrontendMenu()->getMenuItemNodeList() item=_menuItem}
+                                       {if !$_menuItem->getMenuItem()->parentItemID && $_menuItem->getMenuItem()->getPage()}
+                                               <li class="menuOverlayItem"><a href="{$_menuItem->getMenuItem()->getPage()->getLink()}" class="menuOverlayItemLink">{$_menuItem->getMenuItem()->getPage()}</a></li>
+                                       {/if}
+                               {/foreach}
                        </ol>
                </li>
                <li class="menuOverlayItem">
index 38fc6996cc267aaabd3700df172abd5d90985d8f..41e673641a235cc2223539f9632ea9de1caf3ccf 100644 (file)
@@ -61,4 +61,13 @@ class MenuCache extends SingletonFactory {
                
                return null;
        }
+       
+       /**
+        * Returns the main menu or null.
+        * 
+        * @return      Menu|null       menu object
+        */
+       public function getMainMenu() {
+               return $this->getMenuByID(MenuCacheBuilder::getInstance()->getData([], 'mainMenuID'));
+       }
 }
index 6e0a71e7c7d9f53af75dd0914c22021e4a3ba295..cd0a87fba31ff8b91d02ed7638a7724fe43abf3c 100644 (file)
@@ -2,6 +2,8 @@
 namespace wcf\system;
 use wcf\acp\form\MasterPasswordForm;
 use wcf\acp\form\MasterPasswordInitForm;
+use wcf\data\menu\Menu;
+use wcf\data\menu\MenuCache;
 use wcf\system\application\ApplicationHandler;
 use wcf\system\event\EventHandler;
 use wcf\system\exception\AJAXException;
@@ -18,7 +20,7 @@ use wcf\util\HeaderUtil;
  * Extends WCF class with functions for the ACP.
  * 
  * @author     Marcel Werk
- * @copyright  2001-2015 WoltLab GmbH
+ * @copyright  2001-2016 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    com.woltlab.wcf
  * @subpackage system
@@ -68,6 +70,16 @@ class WCFACP extends WCF {
                EventHandler::getInstance()->fireAction($this, 'initialized');
        }
        
+       /**
+        * Returns the main menu object.
+        * 
+        * @return      Menu|null       menu object
+        * @since       2.2
+        */
+       public function getFrontendMenu() {
+               return MenuCache::getInstance()->getMainMenu();
+       }
+       
        /**
         * Returns true if ACP is currently in rescue mode.
         * 
index 0a8b1468b2e1d30703d3f7d62f7d2a14ec3f3eec..47de5c5d257f62d745a4ed13e377365b92580d96 100644 (file)
@@ -20,6 +20,7 @@ class MenuCacheBuilder extends AbstractCacheBuilder {
         */
        protected function rebuild(array $parameters) {
                $data = [
+                       'mainMenuID' => null,
                        'menus' => [],
                        'menuItems' => []
                ];
@@ -47,6 +48,10 @@ class MenuCacheBuilder extends AbstractCacheBuilder {
                        
                        $data['menus'][$menu->menuID] = $menu;
                        $data['menuItems'][$menu->menuID] = $menuItemList;
+                       
+                       if ($menu->identifier === 'com.woltlab.wcf.MainMenu') {
+                               $data['mainMenuID'] = $menu->menuID;
+                       }
                }
                
                return $data;