diff --git a/application/menunode.class.inc.php b/application/menunode.class.inc.php index 82bfa09f8..0c1314221 100644 --- a/application/menunode.class.inc.php +++ b/application/menunode.class.inc.php @@ -291,14 +291,22 @@ EOF $aChildren = self::GetChildren($index); $sCSSClass = (count($aChildren) > 0) ? ' class="submenu"' : ''; $sHyperlink = $oMenu->GetHyperlink($aExtraParams); + $sItemHtml = '
  • '; if ($sHyperlink != '') { - $oPage->AddToMenu('
  • '.$oMenu->GetTitle().'
  • '); + $sLinkTarget = ''; + if ($oMenu->IsHyperLinkInNewWindow()) + { + $sLinkTarget .= ' target="_blank"'; + } + $sItemHtml .= ''.$oMenu->GetTitle().''; } else { - $oPage->AddToMenu('
  • '.$oMenu->GetTitle().'
  • '); + $sItemHtml .= $oMenu->GetTitle(); } + $sItemHtml .= ''; + $oPage->AddToMenu($sItemHtml); if ($iActiveMenu == $index) { $bActive = true; @@ -606,6 +614,15 @@ abstract class MenuNode $aExtraParams['c[menu]'] = $this->GetMenuId(); return $this->AddParams(utils::GetAbsoluteUrlAppRoot().'pages/UI.php', $aExtraParams); } + + /** + * @return bool true if the link should be opened in a new window + * @since 2.7.0 N°1283 + */ + public function IsHyperLinkInNewWindow() + { + return false; + } /** * Add a limiting display condition for the same menu node. The conditions will be combined with a AND @@ -989,8 +1006,12 @@ class WebPageMenuNode extends MenuNode */ protected $sHyperlink; + /** @var bool */ + protected $bIsLinkInNewWindow; + /** * Create a menu item that points to any web page (not only UI.php) + * * @param string $sMenuId Unique identifier of the menu (used to identify the menu for bookmarking, and for getting the labels from the dictionary) * @param string $sHyperlink URL to the page to load. Use relative URL if you want to keep the application portable ! * @param integer $iParentIndex ID of the parent menu @@ -999,12 +1020,17 @@ class WebPageMenuNode extends MenuNode * @param integer $iActionCode Either UR_ACTION_READ, UR_ACTION_MODIFY, UR_ACTION_DELETE, UR_ACTION_BULKREAD, UR_ACTION_BULKMODIFY or UR_ACTION_BULKDELETE * @param integer $iAllowedResults Expected "rights" for the action: either UR_ALLOWED_YES, UR_ALLOWED_NO, UR_ALLOWED_DEPENDS or a mix of them... * @param string $sEnableStimulus + * @param bool $bIsLinkInNewWindow for the {@link WebPageMenuNode::IsHyperLinkInNewWindow} method */ - public function __construct($sMenuId, $sHyperlink, $iParentIndex, $fRank = 0.0, $sEnableClass = null, $iActionCode = null, $iAllowedResults = UR_ALLOWED_YES, $sEnableStimulus = null) + public function __construct( + $sMenuId, $sHyperlink, $iParentIndex, $fRank = 0.0, $sEnableClass = null, $iActionCode = null, + $iAllowedResults = UR_ALLOWED_YES, $sEnableStimulus = null, $bIsLinkInNewWindow = false + ) { parent::__construct($sMenuId, $iParentIndex, $fRank, $sEnableClass, $iActionCode, $iAllowedResults, $sEnableStimulus); $this->sHyperlink = $sHyperlink; $this->aReflectionProperties['url'] = $sHyperlink; + $this->bIsLinkInNewWindow = $bIsLinkInNewWindow; } /** @@ -1017,6 +1043,11 @@ class WebPageMenuNode extends MenuNode return $this->AddParams( $this->sHyperlink, $aExtraParams); } + public function IsHyperLinkInNewWindow() + { + return $this->bIsLinkInNewWindow; + } + /** * @param WebPage $oPage * @param array $aExtraParams diff --git a/setup/compiler.class.inc.php b/setup/compiler.class.inc.php index 4b3b18944..1b154fe60 100644 --- a/setup/compiler.class.inc.php +++ b/setup/compiler.class.inc.php @@ -17,6 +17,8 @@ // along with iTop. If not, see +use Combodo\iTop\DesignElement; + require_once(APPROOT.'setup/setuputils.class.inc.php'); require_once(APPROOT.'setup/modelfactory.class.inc.php'); require_once(APPROOT.'core/moduledesign.class.inc.php'); @@ -2026,11 +2028,11 @@ EOF /** - * @param $oMenu - * @param $sTempTargetDir - * @param $sFinalTargetDir - * @param $sModuleRelativeDir - * @param $oP + * @param DesignElement $oMenu + * @param string $sTempTargetDir + * @param string $sFinalTargetDir + * @param string $sModuleRelativeDir + * @param \iTopWebPage $oP * * @return array * @throws \DOMFormatException @@ -2077,6 +2079,11 @@ EOF case 'WebPageMenuNode': $sUrl = $oMenu->GetChildText('url'); $sUrlSpec = $this->PathToPHP($sUrl, $sModuleRelativeDir, true /* Url */); + $bIsLinkInNewWindow = $this->GetPropBooleanConverted($oMenu, 'in_new_window', false); + if ($bIsLinkInNewWindow) + { + $sOptionalEnableParams .= ', true'; + } $sNewMenu = "new WebPageMenuNode('$sMenuId', $sUrlSpec, $sParentSpec, $fRank {$sOptionalEnableParams});"; break;