Added menu box implementation
authorMarcel Werk <burntime@woltlab.com>
Wed, 30 Dec 2015 13:07:23 +0000 (14:07 +0100)
committerMarcel Werk <burntime@woltlab.com>
Wed, 30 Dec 2015 13:07:23 +0000 (14:07 +0100)
17 files changed:
com.woltlab.wcf/menu.xml
com.woltlab.wcf/menuItem.xml
com.woltlab.wcf/templates/__menu.tpl [new file with mode: 0644]
wcfsetup/install/files/acp/templates/menuAdd.tpl
wcfsetup/install/files/lib/acp/form/BoxAddForm.class.php
wcfsetup/install/files/lib/acp/form/BoxEditForm.class.php
wcfsetup/install/files/lib/acp/form/MenuAddForm.class.php
wcfsetup/install/files/lib/acp/form/MenuEditForm.class.php
wcfsetup/install/files/lib/acp/page/BoxListPage.class.php
wcfsetup/install/files/lib/data/box/Box.class.php
wcfsetup/install/files/lib/data/box/BoxAction.class.php
wcfsetup/install/files/lib/data/menu/Menu.class.php
wcfsetup/install/files/lib/data/menu/MenuAction.class.php
wcfsetup/install/files/lib/data/menu/item/MenuItem.class.php
wcfsetup/install/files/lib/data/page/Page.class.php
wcfsetup/install/files/lib/system/package/plugin/MenuPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/template/plugin/PageBlockTemplatePlugin.class.php

index 80da9c4f5e8e838b44c0e0529f71cd9d3d287975..03955034c40697a4a6d3eb1ca541356858ffb5e9 100644 (file)
                                <visibleeveryhwere>1</visibleeveryhwere>
                        </box>
                </menu>
+               
+               <menu identifier="com.woltlab.wcf.FooterMenu">
+                       <title language="de">Footer-Menü</title>
+                       <title language="en">Footer Menu</title>
+                       
+                       <box>
+                               <position>footer</position>
+                               <showheader>0</showheader>
+                               <visibleeveryhwere>1</visibleeveryhwere>
+                       </box>
+               </menu>
        </import>
 </data>
index cb2f054c1f0ca68b7e558370c353ad9deb4313ac..c9087974bbebf22b5ab264aa8a2470a170147bbf 100644 (file)
                        <page>com.woltlab.wcf.UserSearch</page>
                </item>
                
-               <!-- TODO: privacy policy / footer menu? -->
+               <item identifier="com.woltlab.wcf.PrivacyPolicy">
+                       <menu>com.woltlab.wcf.FooterMenu</menu>
+                       <title language="de"><![CDATA[Datenschutzerklärung]]></title>
+                       <title language="en"><![CDATA[Privacy Policy]]></title>
+                       <page>com.woltlab.wcf.PrivacyPolicy</page>
+               </item>
        </import>
 </data>
diff --git a/com.woltlab.wcf/templates/__menu.tpl b/com.woltlab.wcf/templates/__menu.tpl
new file mode 100644 (file)
index 0000000..91a4298
--- /dev/null
@@ -0,0 +1,12 @@
+<ol>
+       {foreach from=$menuItemNodeList item=menuItemNode}
+               <li>
+                       <a href="{$menuItemNode->getMenuItem()->getURL()}">{lang}{$menuItemNode->getMenuItem()->title}{/lang}</a>
+                       
+                       {if $menuItemNode->hasChildren()}<ol>{else}</li>{/if}
+                               
+                       {if !$menuItemNode->hasChildren() && $menuItemNode->isLastSibling()}
+                               {@"</ol></li>"|str_repeat:$menuItemNode->getOpenParentNodes()}
+                       {/if}
+       {/foreach}
+</ol>
index 82677d9ce2ec519136dc2d2ca63cf93b2556b62d..8459533de3b9d1b183346f1966b3f23587fe67e8 100644 (file)
                        </dd>
                </dl>
                
+               {if $action == 'add' || $menu->identifier != 'com.woltlab.wcf.MainMenu'}
+                       <dl{if $errorField == 'position'} class="formError"{/if}>
+                               <dt><label for="position">{lang}wcf.acp.box.position{/lang}</label></dt>
+                               <dd>
+                                       <select name="position" id="position">
+                                               {foreach from=$availablePositions item=availablePosition}
+                                                       <option value="{@$availablePosition}"{if $availablePosition == $position} selected="selected"{/if}>{lang}wcf.acp.box.position.{@$availablePosition}{/lang}</option>
+                                               {/foreach}
+                                       </select>
+                                       
+                                       {if $errorField == 'position'}
+                                               <small class="innerError">
+                                                       {if $errorType == 'empty'}
+                                                               {lang}wcf.global.form.error.empty{/lang}
+                                                       {else}
+                                                               {lang}wcf.acp.box.position.error.{@$errorType}{/lang}
+                                                       {/if}
+                                               </small>
+                                       {/if}
+                               </dd>
+                       </dl>
+                       
+                       <dl>
+                               <dt><label for="showOrder">{lang}wcf.acp.box.showOrder{/lang}</label></dt>
+                               <dd>
+                                       <input type="number" id="showOrder" name="showOrder" value="{@$showOrder}" class="tiny" min="0" />
+                               </dd>
+                       </dl>
+                       
+                       <dl{if $errorField == 'cssClassName'} class="formError"{/if}>
+                               <dt><label for="cssClassName">{lang}wcf.acp.box.cssClassName{/lang}</label></dt>
+                               <dd>
+                                       <input type="text" id="cssClassName" name="cssClassName" value="{$cssClassName}" class="long" />
+                                       {if $errorField == 'cssClassName'}
+                                               <small class="innerError">
+                                                       {if $errorType == 'empty'}
+                                                               {lang}wcf.global.form.error.empty{/lang}
+                                                       {else}
+                                                               {lang}wcf.acp.box.cssClassName.error.{@$errorType}{/lang}
+                                                       {/if}
+                                               </small>
+                                       {/if}
+                               </dd>
+                       </dl>
+                       
+                       <dl>
+                               <dt></dt>
+                               <dd>
+                                       <label><input type="checkbox" id="showHeader" name="showHeader" value="1" {if $showHeader}checked="checked" {/if}/> {lang}wcf.acp.box.showHeader{/lang}</label>
+                               </dd>
+                       </dl>
+                       
+                       <dl>
+                               <dt></dt>
+                               <dd>
+                                       <label><input type="checkbox" id="visibleEverywhere" name="visibleEverywhere" value="1" {if $visibleEverywhere}checked="checked" {/if}/> {lang}wcf.acp.box.visibleEverywhere{/lang}</label>
+                               </dd>
+                       </dl>
+               {/if}
+               
                {event name='dataFields'}
        </section>
        
index 160628691efda692caa2e53ff56d4a66ce70abb3..807948f0d92539807d23131b0c297d159d0b551e 100644 (file)
@@ -257,7 +257,7 @@ class BoxAddForm extends AbstractForm {
                // set generic box identifier
                $boxEditor = new BoxEditor($returnValues['returnValues']);
                $boxEditor->update([
-                       'identifier' => 'com.woltlab.wcf.generic'.$boxEditor->boxID
+                       'identifier' => 'com.woltlab.wcf.genericBox'.$boxEditor->boxID
                ]);
                
                // call saved event
index 827fbff123eacd2f2cf748127eb748ca52bdd887..dd4a8e9be962afc2d1042738260f32554365eebc 100644 (file)
@@ -47,6 +47,10 @@ class BoxEditForm extends BoxAddForm {
                if (!$this->box->boxID) {
                        throw new IllegalLinkException();
                }
+               if ($this->box->boxType == 'menu') {
+                       // it's not allowed to edit menu boxes directly
+                       throw new IllegalLinkException();
+               }
                if ($this->box->isMultilingual) $this->isMultilingual = 1;
        }
        
index c63717d474e6924b638b6e550a56a93e81024d61..6744d3ce5ce923744367195386bf944f0338d153 100644 (file)
@@ -1,11 +1,13 @@
 <?php
 namespace wcf\acp\form;
+use wcf\data\box\Box;
 use wcf\data\menu\MenuAction;
 use wcf\data\menu\MenuEditor;
 use wcf\form\AbstractForm;
 use wcf\system\exception\UserInputException;
 use wcf\system\language\I18nHandler;
 use wcf\system\WCF;
+use wcf\util\StringUtil;
 
 /**
  * Shows the menu add form.
@@ -35,6 +37,36 @@ class MenuAddForm extends AbstractForm {
         */
        public $title = '';
        
+       /**
+        * box position
+        * @var string
+        */
+       public $position = '';
+       
+       /**
+        * show order
+        * @var integer
+        */
+       public $showOrder = 0;
+       
+       /**
+        * true if created box is visible everywhere
+        * @var boolean
+        */
+       public $visibleEverywhere = 1;
+       
+       /**
+        * css class name of created box
+        * @var string
+        */
+       public $cssClassName = '';
+       
+       /**
+        * true if box header is visible
+        * @var boolean
+        */
+       public $showHeader = 1;
+       
        /**
         * @inheritDoc
         */
@@ -53,6 +85,13 @@ class MenuAddForm extends AbstractForm {
                I18nHandler::getInstance()->readValues();
                
                if (I18nHandler::getInstance()->isPlainValue('title')) $this->title = I18nHandler::getInstance()->getValue('title');
+               
+               $this->visibleEverywhere = $this->showOrder = 0;
+               if (isset($_POST['position'])) $this->position = $_POST['position'];
+               if (isset($_POST['showOrder'])) $this->showOrder = intval($_POST['showOrder']);
+               if (isset($_POST['visibleEverywhere'])) $this->visibleEverywhere = intval($_POST['visibleEverywhere']);
+               if (isset($_POST['cssClassName'])) $this->cssClassName = StringUtil::trim($_POST['cssClassName']);
+               if (isset($_POST['showHeader'])) $this->showHeader = intval($_POST['showHeader']);
        }
        
        /**
@@ -70,6 +109,20 @@ class MenuAddForm extends AbstractForm {
                                throw new UserInputException('title', 'multilingual');
                        }
                }
+               
+               // validate box position
+               $this->validatePosition();
+       }
+       
+       /**
+        * Validates box position.
+        * 
+        * @throws      UserInputException
+        */
+       protected function validatePosition() {
+               if (!in_array($this->position, Box::$availablePositions)) {
+                       throw new UserInputException('position');
+               }
        }
        
        /**
@@ -83,12 +136,21 @@ class MenuAddForm extends AbstractForm {
                        'title' => $this->title,
                        'packageID' => 1,
                        'identifier' => ''
-               ))));
+               )), 'boxData' => array(
+                       'name' => $this->title,
+                       'boxType' => 'menu',
+                       'position' => $this->position,
+                       'visibleEverywhere' => ($this->visibleEverywhere) ? 1 : 0,
+                       'showHeader' => ($this->showHeader) ? 1 : 0,
+                       'showOrder' => $this->showOrder,
+                       'cssClassName' => $this->cssClassName,
+                       'packageID' => 1
+               )));
                $returnValues = $this->objectAction->executeAction();
                // set generic identifier
                $menuEditor = new MenuEditor($returnValues['returnValues']);
                $menuEditor->update(array(
-                       'identifier' => 'com.woltlab.wcf.generic'.$menuEditor->menuID
+                       'identifier' => 'com.woltlab.wcf.genericMenu'.$menuEditor->menuID
                ));
                // save i18n
                if (!I18nHandler::getInstance()->isPlainValue('title')) {
@@ -122,7 +184,13 @@ class MenuAddForm extends AbstractForm {
                
                WCF::getTPL()->assign(array(
                        'action' => 'add',
-                       'title' => 'title'
+                       'title' => 'title',
+                       'position' => $this->position,
+                       'cssClassName' => $this->cssClassName,
+                       'showOrder' => $this->showOrder,
+                       'visibleEverywhere' => $this->visibleEverywhere,
+                       'showHeader' => $this->showHeader,
+                       'availablePositions' => Box::$availableMenuPositions
                ));
        }
 }
index cbaf394dc523361b6894891165052bd9e8261e94..954b5bcbc03fb4f1478036e980c90048968c47eb 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 namespace wcf\acp\form;
+use wcf\data\box\BoxAction;
 use wcf\data\menu\Menu;
 use wcf\data\menu\MenuAction;
 use wcf\form\AbstractForm;
@@ -49,6 +50,15 @@ class MenuEditForm extends MenuAddForm {
                }
        }
        
+       /**
+        * @inheritDoc
+        */
+       protected function validatePosition() {
+               if ($this->menu->identifier != 'com.woltlab.wcf.MainMenu') {
+                       parent::validatePosition();
+               }
+       }
+       
        /**
         * @inheritDoc
         */
@@ -69,6 +79,19 @@ class MenuEditForm extends MenuAddForm {
                        'title' => $this->title
                ))));
                $this->objectAction->executeAction();
+               
+               // update box
+               if ($this->menu->identifier != 'com.woltlab.wcf.MainMenu') {
+                       $boxAction = new BoxAction(array($this->menu->getBox()->boxID), 'update', array('data' => array_merge($this->additionalFields, array(
+                               'position' => $this->position,
+                               'visibleEverywhere' => ($this->visibleEverywhere) ? 1 : 0,
+                               'showHeader' => ($this->showHeader) ? 1 : 0,
+                               'showOrder' => $this->showOrder,
+                               'cssClassName' => $this->cssClassName
+                       ))));
+                       $boxAction->executeAction();
+               }
+               
                $this->saved();
        
                // show success
@@ -87,6 +110,12 @@ class MenuEditForm extends MenuAddForm {
                        I18nHandler::getInstance()->setOptions('title', 1, $this->menu->title, 'wcf.menu.menu\d+');
                        
                        $this->title = $this->menu->title;
+                       $this->position = $this->menu->getBox()->position;
+                       $this->cssClassName = $this->menu->getBox()->cssClassName;
+                       $this->cssClassName = $this->menu->getBox()->cssClassName;
+                       $this->showOrder = $this->menu->getBox()->showOrder;
+                       $this->visibleEverywhere = $this->menu->getBox()->visibleEverywhere;
+                       $this->showHeader = $this->menu->getBox()->showHeader;
                }
        }
        
index 195bf83125f8f35b78c4bf095895be2bfc335fb1..e8fb0c717073668c9a7ed9a6edf1296425e448dd 100644 (file)
@@ -38,4 +38,14 @@ class BoxListPage extends SortablePage {
         * @see \wcf\page\SortablePage::$validSortFields
         */
        public $validSortFields = array('boxID', 'name', 'boxType', 'position', 'showOrder');
+       
+       /**
+        * @inheritdoc
+        */
+       protected function initObjectList() {
+               parent::initObjectList();
+               
+               // hide menu boxes
+               $this->objectList->getConditionBuilder()->add('box.boxType <> ?', array('menu'));
+       }
 }
index e61422c729eb59d14c9f5e36f1c21d34aaaae43c..7d7cb4c6aae2ab67a65ecae89adf7ba876f55e25 100644 (file)
@@ -53,6 +53,12 @@ class Box extends DatabaseObject {
         */
        public static $availablePositions = ['hero', 'headerBoxes', 'top', 'sidebarLeft', 'contentTop', 'sidebarRight', 'contentBottom', 'bottom', 'footerBoxes', 'footer'];
        
+       /**
+        * available menu positions
+        * @var string[]
+        */
+       public static $availableMenuPositions = ['top', 'sidebarLeft', 'sidebarRight', 'bottom', 'footer'];
+       
        /**
         * menu object
         * @var Menu
@@ -177,22 +183,19 @@ class Box extends DatabaseObject {
                        return $this->getController()->hasContent();
                }
                else if ($this->boxType == 'menu') {
-                       // TODO:
-                       return false;
                        return $this->getMenu()->hasContent();
                }
+               
+               $boxContent = $this->getBoxContent();
+               $content = '';
+               if ($this->isMultilingual) {
+                       if (isset($boxContent[WCF::getLanguage()->languageID])) $content = $boxContent[WCF::getLanguage()->languageID]['content'];
+               }
                else {
-                       $boxContent = $this->getBoxContent();
-                       $content = '';
-                       if ($this->isMultilingual) {
-                               if (isset($boxContent[WCF::getLanguage()->languageID])) $content = $boxContent[WCF::getLanguage()->languageID]['content'];
-                       }
-                       else {
-                               if (isset($boxContent[0])) $content = $boxContent[0]['content'];
-                       }
-                       
-                       return !empty($content);
+                       if (isset($boxContent[0])) $content = $boxContent[0]['content'];
                }
+               
+               return !empty($content);
        }
        
        public function getController() {
@@ -283,4 +286,20 @@ class Box extends DatabaseObject {
                
                return $statement->fetchObject(Box::class);
        }
+       
+       /**
+        * Returns the box with the menu id.
+        *
+        * @param       int             $menuID
+        * @return      Box
+        */
+       public static function getBoxByMenuID($menuID) {
+               $sql = "SELECT  *
+                       FROM    wcf".WCF_N."_box
+                       WHERE   menuID = ?";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               $statement->execute([$menuID]);
+               
+               return $statement->fetchObject(Box::class);
+       }
 }
index a23b4de7f9aed2c09da6b77c2da43d4365ac7234..dc8911b629806b3e790dc164550775c7f10e4316 100644 (file)
@@ -99,8 +99,6 @@ class BoxAction extends AbstractDatabaseObjectAction {
                                }
                        }
                }
-               
-               return $box;
        }
        
        /**
index 088d39ccd7e6d33b52fd5ab957518afff298e587..631255f3fc6b82d83ad89012628caa80407d50bc 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 namespace wcf\data\menu;
+use wcf\data\box\Box;
 use wcf\data\DatabaseObject;
 use wcf\system\WCF;
 
@@ -25,6 +26,18 @@ class Menu extends DatabaseObject {
         */
        protected static $databaseTableIndexName = 'menuID';
        
+       /**
+        * menu item node list
+        * @var \RecursiveIteratorIterator
+        */
+       protected $menuItemNodeList = null;
+       
+       /**
+        * box object
+        * @var Box
+        */
+       protected $box = null;
+       
        /**
         * Returns true if the active user can delete this menu.
         * 
@@ -37,4 +50,59 @@ class Menu extends DatabaseObject {
                
                return false;
        }
+       
+       /**
+        * Returns the items of this menu.
+        * 
+        * @return      \RecursiveIteratorIterator
+        */
+       public function getMenuItemNodeList() {
+               if ($this->menuItemNodeList === null) {
+                       $this->menuItemNodeList = MenuCache::getInstance()->getMenuItemsByMenuID($this->menuID)->getNodeList();
+               }
+               
+               return $this->menuItemNodeList;
+       }
+       
+       /**
+        * Returns false if this menu has no content (has menu items).
+        *
+        * @return      boolean
+        */
+       public function hasContent() {
+               return true; // @todo
+               //return count(MenuCache::getInstance()->getMenuItemsByMenuID($this->menuID)->getNodeList());
+       }
+       
+       /**
+        * Returns the title for the rendered version of this menu.
+        *
+        * @return      string
+        */
+       public function getTitle() {
+               return WCF::getLanguage()->get($this->title);
+       }
+       
+       /**
+        * Returns the content for the rendered version of this menu.
+        *
+        * @return      string
+        */
+       public function getContent() {
+               WCF::getTPL()->assign(['menuItemNodeList' => $this->getMenuItemNodeList()]);
+               return WCF::getTPL()->fetch('__menu');
+       }
+       
+       /**
+        * Returns the box of this menu.
+        * 
+        * @return      Box
+        */
+       public function getBox() {
+               if ($this->box === null) {
+                       $this->box = Box::getBoxByMenuID($this->menuID);
+               }
+               
+               return $this->box;
+       }
 }
index 644100d287ecc1d4fc87090dbf70e86361bf3188..3aa0af9b44f788a1e039c95910af10485404cbfc 100644 (file)
@@ -1,6 +1,8 @@
 <?php
 namespace wcf\data\menu;
 use wcf\data\AbstractDatabaseObjectAction;
+use wcf\data\box\BoxAction;
+use wcf\data\box\BoxEditor;
 use wcf\system\exception\PermissionDeniedException;
 
 /**
@@ -40,6 +42,30 @@ class MenuAction extends AbstractDatabaseObjectAction {
         */
        protected $requireACP = ['create', 'delete', 'update'];
        
+       /**
+        * @inheritdoc
+        */
+       public function create() {
+               // create menu
+               $menu = parent::create();
+               
+               // create box
+               $boxData = $this->parameters['boxData'];
+               $boxData['menuID'] = $menu->menuID;
+               $boxData['identifier'] = '';
+               $boxAction = new BoxAction([], 'create', ['data' => $boxData]);
+               $returnValues = $boxAction->executeAction();
+               
+               // set generic box identifier
+               $boxEditor = new BoxEditor($returnValues['returnValues']);
+               $boxEditor->update([
+                       'identifier' => 'com.woltlab.wcf.genericMenuBox'.$boxEditor->boxID
+               ]);
+               
+               // return new menu
+               return $menu;
+       }
+       
        /**
         * @inheritDoc
         */
index 7aac56977e84ba596f4985574a5665d4c21efbfa..3f936b1043ebfdb185b2ec82d5b3c4880208ade2 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 namespace wcf\data\menu\item;
 use wcf\data\DatabaseObject;
+use wcf\data\page\Page;
 use wcf\system\WCF;
 
 /**
@@ -25,6 +26,12 @@ class MenuItem extends DatabaseObject {
         */
        protected static $databaseTableIndexName = 'itemID';
        
+       /**
+        * page object
+        * @var Page
+        */
+       protected $page = null;
+       
        /**
         * Returns true if the active user can delete this menu item.
         *
@@ -50,4 +57,33 @@ class MenuItem extends DatabaseObject {
                        
                return false;
        }
+       
+       /**
+        * Returns the URL of this menu item.
+        * 
+        * @return      string
+        */
+       public function getURL() {
+               if ($this->pageID) {
+                       return $this->getPage()->getURL();
+               }
+               else {
+                       return $this->externalURL;
+               }
+       }
+       
+       /**
+        * Returns the page that is linked by this menu item.
+        * 
+        * @return      Page
+        */
+       public function getPage() {
+               if ($this->page === null) {
+                       if ($this->pageID) {
+                               $this->page = new Page($this->pageID);
+                       }
+               }
+               
+               return $this->page;
+       }
 }
index 9d567c7d52fed674fc864949d2fcc7a4f5970207..322f97b7fdd97e7cf4db8fe648ad30f6b69da9fb 100644 (file)
@@ -2,6 +2,7 @@
 namespace wcf\data\page;
 use wcf\data\DatabaseObject;
 use wcf\system\database\util\PreparedStatementConditionBuilder;
+use wcf\system\request\LinkHandler;
 use wcf\system\WCF;
 
 /**
@@ -108,7 +109,18 @@ class Page extends DatabaseObject {
         * @return string
         */
        public function getURL() {
-               // @todo
+               if ($this->controller) {
+                       // todo
+                       $controllerParts = explode('\\', $this->controller);
+                       $controllerName = $controllerParts[count($controllerParts) - 1];
+                       $controllerName = preg_replace('/(page|action|form)$/i', '', $controllerName);
+                       return LinkHandler::getInstance()->getLink($controllerName, [
+                               'application' => $controllerParts[0]
+                       ]);
+               }
+               else {
+                       return LinkHandler::getInstance()->getCmsLink($this->pageID);
+               }       
        }
        
        /**
index 76ae7eedb093f171c5f4fec3e12101cfb27e529f..e5124a79a681aeb7fcac7b040c2be0fb3300dbb7 100644 (file)
@@ -106,13 +106,11 @@ class MenuPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin
                
                if (!empty($data['elements']['box'])) {
                        $position = $data['elements']['box']['position'];
-                       $visibleEverywhere = false;
                        
                        if ($identifier === 'com.woltlab.wcf.MainMenu') {
                                $position = 'mainMenu';
-                               $visibleEverywhere = true;
                        }
-                       else if (!in_array($position, ['bottom', 'contentBottom', 'contentTop', 'footer', 'footerBoxes', 'headerBoxes', 'hero', 'sidebarLeft', 'sidebarRight', 'top'])) {
+                       else if (!in_array($position, Box::$availableMenuPositions)) {
                                throw new SystemException("Unknown box position '{$position}' for menu box '{$identifier}'");
                        }
                        
@@ -121,7 +119,8 @@ class MenuPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin
                                'name' => $this->getI18nValues($data['elements']['title'], true),
                                'boxType' => 'menu',
                                'position' => $position,
-                               'visibleEverywhere' => ($visibleEverywhere) ? 1 : 0,
+                               'showHeader' => (!empty($data['elements']['box']['showheader']) ? 1 : 0),
+                               'visibleEverywhere' => (!empty($data['elements']['box']['visibleeveryhwere']) ? 1 : 0),
                                'cssClassName' => (!empty($data['elements']['box']['cssclassname'])),
                                'originIsSystem' => 1,
                                'packageID' => $this->installation->getPackageID()
index 1446d01907be82ab0f4954b62dc4750e2fc8f4bd..04155980a7835d9fb06889c70cab88c2d1852e06 100644 (file)
@@ -5,6 +5,7 @@ use wcf\system\exception\SystemException;
 use wcf\system\language\LanguageFactory;
 use wcf\system\request\LinkHandler;
 use wcf\system\template\TemplateEngine;
+use wcf\util\StringUtil;
 
 /**
  * Template block plugin which generates a link to a CMS page.
@@ -68,7 +69,12 @@ class PageBlockTemplatePlugin implements IBlockTemplatePlugin {
                        if ($language !== null) $languageID = $language->languageID;
                }
                
-               return LinkHandler::getInstance()->getCmsLink($pageID, $languageID);
+               $link = LinkHandler::getInstance()->getCmsLink($pageID, $languageID);
+               if (!empty($tagArgs['encode'])) {
+                       return StringUtil::encodeHTML($link);
+               }
+               
+               return $link;
        }
        
        /**