Fixed handling for external links in menu.tpl
authorMarcel Werk <burntime@woltlab.com>
Thu, 29 Dec 2016 12:40:40 +0000 (13:40 +0100)
committerMarcel Werk <burntime@woltlab.com>
Thu, 29 Dec 2016 12:40:40 +0000 (13:40 +0100)
com.woltlab.wcf/templates/__menu.tpl
wcfsetup/install/files/lib/data/menu/item/MenuItem.class.php

index bc8e7b5897e8614ec1d84d10f06807abf3b6493c..86c0d13f73aa722e2588f2618bd5e35eef160b2d 100644 (file)
@@ -2,7 +2,7 @@
        <ol class="boxMenu">
                {foreach from=$menuItemNodeList item=menuItemNode}
                        <li class="{if $menuItemNode->isActiveNode()}active{/if}{if $menuItemNode->hasChildren()} boxMenuHasChildren{/if}">
-                               <a href="{$menuItemNode->getURL()}" class="boxMenuLink">
+                               <a href="{$menuItemNode->getURL()}" class="boxMenuLink"{if $menuItemNode->isExternalLink()}{if EXTERNAL_LINK_REL_NOFOLLOW} rel="nofollow"{/if}{if EXTERNAL_LINK_TARGET_BLANK} target="_blank"{/if}{/if}>
                                        <span class="boxMenuLinkTitle">{lang}{$menuItemNode->title}{/lang}</span>
                                        {if $menuItemNode->getOutstandingItems() > 0}
                                                <span class="boxMenuLinkOutstandingItems badge badgeUpdate">{#$menuItemNode->getOutstandingItems()}</span>
index 860f957b6a7b753850303803e2f28325179bf801..7ecfeee0f97bc40bb228944dab71f546e30d9699 100644 (file)
@@ -3,6 +3,7 @@ namespace wcf\data\menu\item;
 use wcf\data\page\Page;
 use wcf\data\page\PageCache;
 use wcf\data\DatabaseObject;
+use wcf\system\application\ApplicationHandler;
 use wcf\system\exception\ImplementationException;
 use wcf\system\page\handler\ILookupPageHandler;
 use wcf\system\page\handler\IMenuPageHandler;
@@ -136,6 +137,15 @@ class MenuItem extends DatabaseObject {
                return 0;
        }
        
+       /**
+        * Returns true if this item is an external link.
+        * 
+        * @return boolean
+        */
+       public function isExternalLink() {
+               return ($this->externalURL ? !ApplicationHandler::getInstance()->isInternalURL($this->externalURL) : false);
+       }
+       
        /**
         * Returns the page handler for this item.
         *