N°3123 - Refactor Directories

This commit is contained in:
Eric
2020-12-02 13:18:01 +01:00
parent d1b12ee04b
commit 15aa9e508c
259 changed files with 862 additions and 869 deletions

View File

@@ -0,0 +1,68 @@
<?php
/**
* Copyright (C) 2013-2020 Combodo SARL
*
* This file is part of iTop.
*
* iTop is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* iTop is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
*/
namespace Combodo\iTop\Application\UI\Base\Component\PopoverMenu\NewsroomMenu;
use Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenu;
/**
* Class NewsroomMenu
*
* @author Stephen Abello <stephen.abello@combodo.com>
* @package Combodo\iTop\Application\UI\Base\Component\NewsroomMenu
* @internal
* @since 3.0.0
*/
class NewsroomMenu extends PopoverMenu
{
// Overloaded constants
public const HTML_TEMPLATE_REL_PATH = 'base/components/popover-menu/newsroom-menu/layout';
public const JS_TEMPLATE_REL_PATH = 'base/components/popover-menu/newsroom-menu/layout';
public const JS_FILES_REL_PATH = [
'js/components/newsroom-menu.js',
];
/** @var array $aParams */
protected $aParams;
/**
* Set all parameters at once
*
* @param array $aParams
*
* @return $this
*/
public function SetParams(array $aParams)
{
$this->aParams = $aParams;
return $this;
}
/**
* Return all parameters as a JSON string
*
* @return false|string
*/
public function GetParamsAsJson()
{
return json_encode($this->aParams);
}
}

View File

@@ -0,0 +1,103 @@
<?php
/**
* Copyright (C) 2013-2020 Combodo SARL
*
* This file is part of iTop.
*
* iTop is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* iTop is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
*/
namespace Combodo\iTop\Application\UI\Base\Component\PopoverMenu\NewsroomMenu;
use appUserPreferences;
use Dict;
use MetaModel;
use UserRights;
use utils;
/**
* Class NewsroomMenuFactory
*
* @author Stephen Abello <stephen.abello@combodo.com>
* @package Combodo\iTop\Application\UI\Base\Component\NewsroomMenu
* @internal
* @since 3.0.0
*/
class NewsroomMenuFactory
{
/**
* Make a standard NewsroomMenu layout for backoffice pages
*
* @return \Combodo\iTop\Application\UI\Base\Component\PopoverMenu\NewsroomMenu\NewsroomMenu
* @throws \CoreException
* @throws \Exception
*/
public static function MakeNewsroomMenuForNavigationMenu()
{
$oMenu = new NewsroomMenu('ibo-navigation-menu--notifications-menu');
$oMenu->SetParams(static::PrepareParametersForNewsroomMenu());
return $oMenu;
}
/**
* Prepare parameters for the newsroom JS widget
*
* @return array
* @throws \CoreException
* @throws \CoreUnexpectedValue
* @throws \MySQLException
* @throws \OQLException
*/
protected static function PrepareParametersForNewsroomMenu()
{
$aProviderParams=[];
$oUser = UserRights::GetUserObject();
/**
* @var \iNewsroomProvider[] $aProviders
*/
$aProviders = MetaModel::EnumPlugins('iNewsroomProvider');
foreach($aProviders as $oProvider) {
$oConfig = MetaModel::GetConfig();
$oProvider->SetConfig($oConfig);
$bProviderEnabled = appUserPreferences::GetPref('newsroom_provider_'.get_class($oProvider), true);
if ($bProviderEnabled && $oProvider->IsApplicable($oUser)) {
$aProviderParams[] = array(
'label' => $oProvider->GetLabel(),
'fetch_url' => $oProvider->GetFetchURL(),
'target' => utils::StartsWith($oProvider->GetFetchURL(), $oConfig->Get('app_root_url')) ? '_self' : '_blank',
'view_all_url' => $oProvider->GetViewAllURL(),
'mark_all_as_read_url' => $oProvider->GetMarkAllAsReadURL(),
'placeholders' => $oProvider->GetPlaceholders(),
'ttl' => $oProvider->GetTTL(),
);
}
}
$sImageUrl= 'fas fa-comment-dots';
$sPlaceholderImageUrl= 'far fa-envelope';
$aParams = array(
'image_icon' => $sImageUrl,
'no_message_icon' => file_get_contents(APPROOT.'images/illustrations/undraw_empty.svg'),
'placeholder_image_icon' => $sPlaceholderImageUrl,
'cache_uuid' => 'itop-newsroom-'.UserRights::GetUserId().'-'.md5(APPROOT),
'providers' => $aProviderParams,
'display_limit' => (int)appUserPreferences::GetPref('newsroom_display_size', 7),
'labels' => array(
'no_message' => Dict::S('UI:Newsroom:NoNewMessage'),
'mark_all_as_read' => Dict::S('UI:Newsroom:MarkAllAsRead'),
'view_all' => Dict::S('UI:Newsroom:ViewAllMessages'),
),
);
return $aParams;
}
}

View File

@@ -0,0 +1,223 @@
<?php
/**
* Copyright (C) 2013-2020 Combodo SARL
*
* This file is part of iTop.
*
* iTop is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* iTop is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
*/
namespace Combodo\iTop\Application\UI\Base\Component\PopoverMenu;
use Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenuItem\PopoverMenuItem;
use Combodo\iTop\Application\UI\Base\UIBlock;
use Exception;
/**
* Class PopoverMenu
*
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @package Combodo\iTop\Application\UI\Base\Component\PopoverMenu
* @internal
* @since 3.0.0
*/
class PopoverMenu extends UIBlock
{
// Overloaded constants
public const BLOCK_CODE = 'ibo-popover-menu';
public const HTML_TEMPLATE_REL_PATH = 'base/components/popover-menu/layout';
public const JS_FILES_REL_PATH = [
'js/components/popover-menu.js',
];
/** @var array $aSections */
protected $aSections;
/**
* PopoverMenu constructor.
*
* @param string|null $sId
*/
public function __construct(?string $sId = null)
{
parent::__construct($sId);
$this->aSections = [];
}
/**
* Add a section $sId if not already existing.
* Important: It does not reset the section.
*
* @param string $sId
*
* @return $this
*/
public function AddSection(string $sId)
{
if (false === $this->HasSection($sId))
{
$this->aSections[$sId] = [
'aItems' => [],
];
}
return $this;
}
/**
* Remove the $sId section.
* Note: If the section does not exist, we silently proceed anyway.
*
* @param string $sId
*
* @return $this
* @throws \Exception
*/
public function RemoveSection(string $sId)
{
if (true === $this->HasSection($sId))
{
unset($this->aSections[$sId]);
}
return $this;
}
/**
* Return true if the $sId section exists
*
* @param string $sId
*
* @return bool
*/
public function HasSection(string $sId)
{
return array_key_exists($sId, $this->aSections);
}
/**
* Clear the $sId section from all its items.
*
* @param string $sId
*
* @return $this
* @throws \Exception
*/
public function ClearSection(string $sId)
{
if (false === $this->HasSection($sId))
{
throw new Exception('Could not clear section "'.$sId.'" as it does not exist in the "'.$this->GetId().'" menu');
}
$this->aSections[$sId]['aItems'] = [];
return $this;
}
/**
* Return the sections
*
* @return array
*/
public function GetSections()
{
return $this->aSections;
}
/**
* Add the $oItem in the $sSectionId. If an item with the same ID already exists it will be overwritten.
*
* @param string $sSectionId
* @param \Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenuItem\PopoverMenuItem $oItem
*
* @return $this
* @throws \Exception
*/
public function AddItem(string $sSectionId, PopoverMenuItem $oItem)
{
if (false === $this->HasSection($sSectionId))
{
throw new Exception('Could not add an item to the "'.$sSectionId.'" section has it does not seem to exist in the "'.$this->GetId().'" menu.');
}
$this->aSections[$sSectionId]['aItems'][$oItem->GetId()] = $oItem;
return $this;
}
/**
* Remove the $sItemId from the $sSectionId.
* Note: If the item is not in the section, we proceed silently.
*
* @param string $sSectionId
* @param string $sItemId
*
* @return $this
* @throws \Exception
*/
public function RemoveItem(string $sSectionId, string $sItemId)
{
if (false === $this->HasSection($sSectionId))
{
throw new Exception('Could not remove en item from the "'.$sSectionId.'" as it does not seem to exist in the "'.$this->GetId().'" menu.');
}
if (array_key_exists($sItemId, $this->aSections[$sSectionId]['aItems']))
{
unset($this->aSections[$sSectionId]['aItems'][$sItemId]);
}
return $this;
}
/**
* Set all $aItems at once in the $sSectionId, overwriting all existing.
*
* @param string $sSectionId
* @param PopoverMenuItem[] $aItems
*
* @return $this
* @throws \Exception
*/
public function SetItems(string $sSectionId, array $aItems)
{
if (false === $this->HasSection($sSectionId))
{
throw new Exception('Could not set items to the "'.$sSectionId.'" section has it does not seem to exist in the "'.$this->GetId().'" menu.');
}
$this->aSections[$sSectionId]['aItems'] = $aItems;
return $this;
}
/**
* @inheritDoc
*/
public function GetSubBlocks()
{
$aSubBlocks = [];
foreach($this->aSections as $sSectionId => $aSectionData)
{
foreach($aSectionData['aItems'] as $sItemId => $oItem)
{
$aSubBlocks[$sItemId] = $oItem;
}
}
return $aSubBlocks;
}
}

View File

@@ -0,0 +1,247 @@
<?php
/**
* Copyright (C) 2013-2020 Combodo SARL
*
* This file is part of iTop.
*
* iTop is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* iTop is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
*/
namespace Combodo\iTop\Application\UI\Base\Component\PopoverMenu;
use Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenuItem\PopoverMenuItemFactory;
use Dict;
use JSPopupMenuItem;
use MetaModel;
use URLPopupMenuItem;
use UserRights;
use utils;
/**
* Class PopoverMenuFactory
*
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @package Combodo\iTop\Application\UI\Base\Component\PopoverMenu
* @internal
* @since 3.0.0
*/
class PopoverMenuFactory
{
/**
* Make a standard NavigationMenu layout for backoffice pages
*
* @return \Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenu
* @throws \CoreException
* @throws \Exception
*/
public static function MakeUserMenuForNavigationMenu()
{
$oMenu = new PopoverMenu('ibo-navigation-menu--user-menu');
// Allowed portals
$aAllowedPortalsItems = static::PrepareAllowedPortalsItemsForUserMenu();
if(!empty($aAllowedPortalsItems))
{
$oMenu->AddSection('allowed_portals')
->SetItems('allowed_portals', $aAllowedPortalsItems);
}
// User related pages
$oMenu->AddSection('user_related')
->SetItems('user_related', static::PrepareUserRelatedItemsForUserMenu());
// Misc links
$oMenu->AddSection('misc')
->SetItems('misc', static::PrepareMiscItemsForUserMenu());
return $oMenu;
}
/**
* Return the allowed portals items for the current user
*
* @return \Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenuItem\PopoverMenuItem[]
*/
protected static function PrepareAllowedPortalsItemsForUserMenu()
{
$aItems = [];
foreach (UserRights::GetAllowedPortals() as $aAllowedPortal)
{
if ($aAllowedPortal['id'] !== 'backoffice')
{
$oPopupMenuItem = new URLPopupMenuItem(
'portal:'.$aAllowedPortal['id'],
Dict::S($aAllowedPortal['label']),
$aAllowedPortal['url'],
'_blank'
);
$aItems[] = PopoverMenuItemFactory::MakeFromApplicationPopupMenuItem($oPopupMenuItem);
}
}
return $aItems;
}
/**
* Return the user related items (preferences, change password, log off, ...)
*
* @return \Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenuItem\PopoverMenuItem[]
* @throws \CoreException
* @throws \Exception
*/
protected static function PrepareUserRelatedItemsForUserMenu()
{
$aItems = [];
// Preferences
$aItems[] = PopoverMenuItemFactory::MakeFromApplicationPopupMenuItem(
new URLPopupMenuItem(
'UI:Preferences',
Dict::S('UI:Preferences'),
utils::GetAbsoluteUrlAppRoot().'pages/preferences.php'
)
);
// Archive mode
if(true === utils::IsArchiveMode())
{
$aItems[] = PopoverMenuItemFactory::MakeFromApplicationPopupMenuItem(
new JSPopupMenuItem(
'UI:ArchiveModeOff',
Dict::S('UI:ArchiveModeOff'),
'return ArchiveMode(false);'
)
);
}
elseif(UserRights::CanBrowseArchive())
{
$aItems[] = PopoverMenuItemFactory::MakeFromApplicationPopupMenuItem(
new JSPopupMenuItem(
'UI:ArchiveModeOn',
Dict::S('UI:ArchiveModeOn'),
'return ArchiveMode(true);'
)
);
}
// Logoff
if(utils::CanLogOff())
{
$aItems[] = PopoverMenuItemFactory::MakeFromApplicationPopupMenuItem(
new URLPopupMenuItem(
'UI:LogOffMenu',
Dict::S('UI:LogOffMenu'),
utils::GetAbsoluteUrlAppRoot().'pages/logoff.php?operation=do_logoff'
)
);
}
// Change password
if (UserRights::CanChangePassword())
{
$aItems[] = PopoverMenuItemFactory::MakeFromApplicationPopupMenuItem(
new URLPopupMenuItem(
'UI:ChangePwdMenu',
Dict::S('UI:ChangePwdMenu'),
utils::GetAbsoluteUrlAppRoot().'pages/UI.php?loginop=change_pwd'
)
);
}
// TODO: iPopupMenuExtension::MENU_USER_ACTIONS
// Legacy code: utils::GetPopupMenuItems($this, iPopupMenuExtension::MENU_USER_ACTIONS, null, $aActions);
return $aItems;
}
/**
* Return the misc. items for the user menu (online doc., about box)
*
* @return \Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenuItem\PopoverMenuItem[]
*/
protected static function PrepareMiscItemsForUserMenu()
{
$aItems = [];
// Online documentation
$aItems[] = PopoverMenuItemFactory::MakeFromApplicationPopupMenuItem(
new URLPopupMenuItem(
'UI:Help',
Dict::S('UI:Help'),
MetaModel::GetConfig()->Get('online_help'),
'_blank'
)
);
// About box
$aItems[] = PopoverMenuItemFactory::MakeFromApplicationPopupMenuItem(
new JSPopupMenuItem(
'UI:AboutBox',
Dict::S('UI:AboutBox'),
'return ShowAboutBox();'
)
);
return $aItems;
}
public static function MakeMenuForActions(string $sId, array $aMenuItems): PopoverMenu
{
$oMenu = new PopoverMenu($sId);
$bFirst = true;
foreach ($aMenuItems as $sSection => $aActions) {
$aItems = [];
if (!$bFirst) {
$aItems[] = PopoverMenuItemFactory::MakeFromApplicationPopupMenuItem(
new \SeparatorPopupMenuItem()
);
}
foreach ($aActions as $aAction) {
if (!empty($aAction['on_click'])) {
// JS
$oPopoverMenuItem = PopoverMenuItemFactory::MakeFromApplicationPopupMenuItem(
new JSPopupMenuItem(
$aAction['uid'],
$aAction['label'],
$aAction['on_click'])
);
} else {
// URL
$oPopoverMenuItem = PopoverMenuItemFactory::MakeFromApplicationPopupMenuItem(
new URLPopupMenuItem(
$aAction['uid'],
$aAction['label'],
$aAction['url'],
$aAction['target'])
);
}
if (!empty($aAction['css_classes'])) {
$oPopoverMenuItem->SetCssClasses($aAction['css_classes']);
}
$aItems[] = $oPopoverMenuItem;
}
$oMenu->AddSection($sSection)
->SetItems($sSection, $aItems);
$bFirst = false;
}
return $oMenu;
}
}

View File

@@ -0,0 +1,66 @@
<?php
/**
* Copyright (C) 2013-2020 Combodo SARL
*
* This file is part of iTop.
*
* iTop is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* iTop is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
*/
namespace Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenuItem;
use JSPopupMenuItem;
/**
* Class JsPopoverMenuItem
*
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @package Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenuItem
* @property \JSPopupMenuItem $oPopupMenuItem
* @since 3.0.0
*/
class JsPopoverMenuItem extends PopoverMenuItem
{
// Overloaded constants
public const HTML_TEMPLATE_REL_PATH = 'base/components/popover-menu/item/mode_js';
/**
* @see \JSPopupMenuItem::GetJsCode()
* @return string
*/
public function GetJsCode()
{
return $this->oPopupMenuItem->GetJSCode();
}
/**
* @see \JSPopupMenuItem::GetUrl()
* @return string
*/
public function GetUrl()
{
return $this->oPopupMenuItem->GetUrl();
}
/**
* @inheritDoc
* @throws \Exception
*/
public function GetJsFilesUrlRecursively(bool $bAbsoluteUrl = false)
{
$aJsFiles = array_merge(parent::GetJsFilesUrlRecursively($bAbsoluteUrl), $this->oPopupMenuItem->GetLinkedScripts());
return $aJsFiles;
}
}

View File

@@ -0,0 +1,107 @@
<?php
/**
* Copyright (C) 2013-2020 Combodo SARL
*
* This file is part of iTop.
*
* iTop is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* iTop is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
*/
namespace Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenuItem;
use ApplicationPopupMenuItem;
use Combodo\iTop\Application\UI\Base\UIBlock;
/**
* Class PopoverMenuItem
*
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @package Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenuItem
* @internal
* @since 3.0.0
*/
class PopoverMenuItem extends UIBlock
{
// Overloaded constants
public const BLOCK_CODE = 'ibo-popover-menu--item';
public const HTML_TEMPLATE_REL_PATH = 'base/components/popover-menu/item/layout';
/** @var \ApplicationPopupMenuItem $oPopupMenuItem We decorate the class with the original \ApplicationPopupMenuItem as it is used among the application (backoffice, portal, extensions) and cannot be refactored without BC breaks */
protected $oPopupMenuItem;
/**
* PopoverMenuItem constructor.
*
* @param \ApplicationPopupMenuItem $oPopupMenuItem
*/
public function __construct(ApplicationPopupMenuItem $oPopupMenuItem)
{
$this->oPopupMenuItem = $oPopupMenuItem;
parent::__construct(/* ID will be generated from $oPopupMenuItem */);
}
/**
* @inheritDoc
*/
protected function GenerateId()
{
return static::BLOCK_CODE.'-'.$this->oPopupMenuItem->GetUID();
}
/**
* @see \ApplicationPopupMenuItem::GetLabel()
* @return string
*/
public function GetLabel()
{
return $this->oPopupMenuItem->GetLabel();
}
/**
* @see \ApplicationPopupMenuItem::SetCssClasses()
*
* @param array $aCssClasses
*
* @return $this
*/
public function SetCssClasses(array $aCssClasses)
{
$this->oPopupMenuItem->SetCssClasses($aCssClasses);
return $this;
}
/**
* @see \ApplicationPopupMenuItem::AddCssClass()
*
* @param string $sCssClass
*
* @return $this
*/
public function AddCssClass(string $sCssClass)
{
$this->oPopupMenuItem->AddCssClass($sCssClass);
return $this;
}
/**
* @see \ApplicationPopupMenuItem::GetCssClasses()
* @return array
*/
public function GetCssClasses()
{
return $this->oPopupMenuItem->GetCssClasses();
}
}

View File

@@ -0,0 +1,68 @@
<?php
/**
* Copyright (C) 2013-2020 Combodo SARL
*
* This file is part of iTop.
*
* iTop is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* iTop is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
*/
namespace Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenuItem;
use ApplicationPopupMenuItem;
use JSPopupMenuItem;
use SeparatorPopupMenuItem;
use URLPopupMenuItem;
/**
* Class PopupMenuItemFactory
*
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @package Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenuItem
* @internal
* @since 3.0.0
*/
class PopoverMenuItemFactory
{
/**
* Make a standard NavigationMenu layout for backoffice pages
*
* @param \ApplicationPopupMenuItem $oItem
*
* @return \Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenuItem\PopoverMenuItem
*/
public static function MakeFromApplicationPopupMenuItem(ApplicationPopupMenuItem $oItem)
{
$sNamespace = 'Combodo\\iTop\\Application\\UI\\Base\\Component\\PopoverMenu\\PopoverMenuItem\\';
switch(true)
{
case $oItem instanceof URLPopupMenuItem:
$sTargetClass = 'UrlPopoverMenuItem';
break;
case $oItem instanceof JSPopupMenuItem:
$sTargetClass = 'JsPopoverMenuItem';
break;
case $oItem instanceof SeparatorPopupMenuItem:
$sTargetClass = 'SeparatorPopoverMenuItem';
break;
default:
$sTargetClass = 'PopoverMenuItem';
break;
}
$sTargetClass = $sNamespace.$sTargetClass;
return new $sTargetClass($oItem);
}
}

View File

@@ -0,0 +1,35 @@
<?php
/**
* Copyright (C) 2013-2020 Combodo SARL
*
* This file is part of iTop.
*
* iTop is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* iTop is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
*/
namespace Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenuItem;
/**
* Class SeparatorPopoverMenuItem
*
* @author Stephen Abello <stephen.abello@combodo.com>
* @package Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenuItem
* @property \SeparatorPopupMenuItem $oPopupMenuItem
* @since 3.0.0
*/
class SeparatorPopoverMenuItem extends PopoverMenuItem
{
public const HTML_TEMPLATE_REL_PATH = 'base/components/popover-menu/item/mode_separator';
}

View File

@@ -0,0 +1,53 @@
<?php
/**
* Copyright (C) 2013-2020 Combodo SARL
*
* This file is part of iTop.
*
* iTop is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* iTop is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
*/
namespace Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenuItem;
/**
* Class UrlPopoverMenuItem
*
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @package Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenuItem
* @property \URLPopupMenuItem $oPopupMenuItem
* @since 3.0.0
*/
class UrlPopoverMenuItem extends PopoverMenuItem
{
// Overloaded constants
public const HTML_TEMPLATE_REL_PATH = 'base/components/popover-menu/item/mode_url';
/**
* @see \URLPopupMenuItem::GetUrl()
* @return string
*/
public function GetUrl()
{
return $this->oPopupMenuItem->GetUrl();
}
/**
* @see \URLPopupMenuItem::GetTarget()
* @return string
*/
public function GetTarget()
{
return $this->oPopupMenuItem->GetTarget();
}
}