N°8796 - Add PHP code style validation in iTop and extensions - format whole code base

This commit is contained in:
odain
2025-11-07 20:39:38 +01:00
parent 7681c157ec
commit b0a792afab
369 changed files with 22041 additions and 26866 deletions

View File

@@ -1,4 +1,5 @@
<?php
/*
* @copyright Copyright (C) 2010-2024 Combodo SAS
* @license http://opensource.org/licenses/AGPL-3.0
@@ -12,7 +13,6 @@ use Combodo\iTop\Application\WebPage\WebPage;
require_once(APPROOT.'/application/utils.inc.php');
require_once(APPROOT."/application/user.dashboard.class.inc.php");
/**
* This class manipulates, stores and displays the navigation menu used in the application
* In order to improve the modularity of the data model and to ease the update/migration
@@ -51,43 +51,40 @@ class ApplicationMenu
/**
* @var bool
*/
static $bAdditionalMenusLoaded = false;
public static $bAdditionalMenusLoaded = false;
/**
* @var array
*/
static $aRootMenus = array();
public static $aRootMenus = [];
/**
* @var array
*/
static $aMenusIndex = array();
public static $aMenusIndex = [];
/**
* @var array
*/
static $aMenusById = [];
public static $aMenusById = [];
/**
* @var string
*/
static $sFavoriteSiloQuery = 'SELECT Organization';
public static $sFavoriteSiloQuery = 'SELECT Organization';
/**
* @return void
*/
public static function LoadAdditionalMenus()
{
if (!self::$bAdditionalMenusLoaded)
{
if (!self::$bAdditionalMenusLoaded) {
// Build menus from module handlers
//
/** @var \ModuleHandlerApiInterface $oPHPClass */
foreach(MetaModel::EnumPlugins('ModuleHandlerApiInterface') as $oPHPClass)
{
$oPHPClass::OnMenuCreation();
}
foreach (MetaModel::EnumPlugins('ModuleHandlerApiInterface') as $oPHPClass) {
$oPHPClass::OnMenuCreation();
}
// Build menus from the menus themselves (e.g. the ShortcutContainerMenuNode will do that)
//
foreach(self::$aRootMenus as $aMenu)
{
foreach (self::$aRootMenus as $aMenu) {
$oMenuNode = self::GetMenuNode($aMenu['index']);
$oMenuNode->PopulateChildMenus();
}
@@ -124,8 +121,7 @@ class ApplicationMenu
*/
public static function CheckMenuIdEnabled($sMenuId)
{
if (self::IsMenuIdEnabled($sMenuId) === false)
{
if (self::IsMenuIdEnabled($sMenuId) === false) {
require_once(APPROOT.'/setup/setuppage.class.inc.php');
$oP = new ErrorPage(Dict::S('UI:PageTitle:FatalError'));
$oP->add("<h1>".Dict::S('UI:Login:Error:AccessRestricted')."</h1>\n");
@@ -141,7 +137,7 @@ class ApplicationMenu
* @return bool true if the menu exists and current user is allowed to see the menu
* @since 3.2.0
*/
public static function IsMenuIdEnabled($sMenuId):bool
public static function IsMenuIdEnabled($sMenuId): bool
{
self::LoadAdditionalMenus();
$oMenuNode = self::GetMenuNode(self::GetMenuIndexById($sMenuId));
@@ -159,22 +155,18 @@ class ApplicationMenu
public static function InsertMenu(MenuNode $oMenuNode, $iParentIndex, $fRank)
{
$index = self::GetMenuIndexById($oMenuNode->GetMenuId());
if ($index == -1)
{
if ($index == -1) {
// The menu does not already exist, insert it
$index = count(self::$aMenusIndex);
if ($iParentIndex == -1)
{
if ($iParentIndex == -1) {
$sParentId = '';
self::$aRootMenus[] = array ('rank' => $fRank, 'index' => $index);
}
else
{
self::$aRootMenus[] = ['rank' => $fRank, 'index' => $index];
} else {
/** @var \MenuNode $oNode */
$oNode = self::$aMenusIndex[$iParentIndex]['node'];
$sParentId = $oNode->GetMenuId();
self::$aMenusIndex[$iParentIndex]['children'][] = array ('rank' => $fRank, 'index' => $index);
self::$aMenusIndex[$iParentIndex]['children'][] = ['rank' => $fRank, 'index' => $index];
}
// Note: At the time when 'parent', 'rank' and 'source_file' have been added for the reflection API,
@@ -182,11 +174,9 @@ class ApplicationMenu
//
$aBacktrace = debug_backtrace();
$sFile = isset($aBacktrace[2]["file"]) ? $aBacktrace[2]["file"] : $aBacktrace[1]["file"];
self::$aMenusIndex[$index] = array('node' => $oMenuNode, 'children' => array(), 'parent' => $sParentId, 'rank' => $fRank, 'source_file' => $sFile);
self::$aMenusIndex[$index] = ['node' => $oMenuNode, 'children' => [], 'parent' => $sParentId, 'rank' => $fRank, 'source_file' => $sFile];
self::$aMenusById[$oMenuNode->GetMenuId()] = $index;
}
else
{
} else {
// the menu already exists, let's combine the conditions that make it visible
/** @var \MenuNode $oNode */
$oNode = self::$aMenusIndex[$index]['node'];
@@ -216,7 +206,7 @@ class ApplicationMenu
* @throws \DictExceptionMissingString
* @since 3.0.0
*/
public static function GetMenusCount($aExtraParams = array())
public static function GetMenusCount($aExtraParams = [])
{
$aMenuGroups = static::GetMenuGroups($aExtraParams);
@@ -259,18 +249,16 @@ class ApplicationMenu
* @throws \DictExceptionMissingString
* @since 3.0.0
*/
public static function GetMenuGroups($aExtraParams = array())
public static function GetMenuGroups($aExtraParams = [])
{
self::LoadAdditionalMenus();
// Sort the root menu based on the rank
usort(self::$aRootMenus, array('ApplicationMenu', 'CompareOnRank'));
usort(self::$aRootMenus, ['ApplicationMenu', 'CompareOnRank']);
$aMenuGroups = [];
foreach(static::$aRootMenus as $aMenuGroup)
{
if(!static::CanDisplayMenu($aMenuGroup))
{
foreach (static::$aRootMenus as $aMenuGroup) {
if (!static::CanDisplayMenu($aMenuGroup)) {
continue;
}
@@ -321,26 +309,23 @@ class ApplicationMenu
* @throws \Exception
* @since 3.0.0
*/
public static function GetSubMenuNodes($sMenuGroupIdx, $aExtraParams = array())
public static function GetSubMenuNodes($sMenuGroupIdx, $aExtraParams = [])
{
$aSubMenuItems = self::GetChildren($sMenuGroupIdx);
// Sort the children based on the rank
usort($aSubMenuItems, array('ApplicationMenu', 'CompareOnRank'));
usort($aSubMenuItems, ['ApplicationMenu', 'CompareOnRank']);
$aSubMenuNodes = [];
foreach($aSubMenuItems as $aSubMenuItem)
{
if(!static::CanDisplayMenu($aSubMenuItem))
{
foreach ($aSubMenuItems as $aSubMenuItem) {
if (!static::CanDisplayMenu($aSubMenuItem)) {
continue;
}
$sSubMenuItemIdx = $aSubMenuItem['index'];
$oSubMenuNode = static::GetMenuNode($sSubMenuItemIdx);
if(!$oSubMenuNode->IsEnabled())
{
if (!$oSubMenuNode->IsEnabled()) {
continue;
}
@@ -366,21 +351,15 @@ class ApplicationMenu
private static function CanDisplayMenu($aMenu)
{
$oMenuNode = self::GetMenuNode($aMenu['index']);
if ($oMenuNode->IsEnabled())
{
if ($oMenuNode->IsEnabled()) {
$aChildren = self::GetChildren($aMenu['index']);
if (count($aChildren) > 0)
{
foreach($aChildren as $aSubMenu)
{
if (self::CanDisplayMenu($aSubMenu))
{
if (count($aChildren) > 0) {
foreach ($aChildren as $aSubMenu) {
if (self::CanDisplayMenu($aSubMenu)) {
return true;
}
}
}
else
{
} else {
return true;
}
}
@@ -396,12 +375,10 @@ class ApplicationMenu
public static function CompareOnRank($a, $b)
{
$result = 1;
if ($a['rank'] == $b['rank'])
{
if ($a['rank'] == $b['rank']) {
$result = 0;
}
if ($a['rank'] < $b['rank'])
{
if ($a['rank'] < $b['rank']) {
$result = -1;
}
return $result;
@@ -449,8 +426,7 @@ class ApplicationMenu
{
$oAppContext = new ApplicationContext();
$sMenuId = $oAppContext->GetCurrentValue('menu', null);
if ($sMenuId === null)
{
if ($sMenuId === null) {
$sMenuId = self::GetDefaultMenuId();
}
return $sMenuId;
@@ -462,13 +438,12 @@ class ApplicationMenu
public static function GetDefaultMenuId()
{
static $sDefaultMenuId = null;
if (is_null($sDefaultMenuId))
{
if (is_null($sDefaultMenuId)) {
// Make sure the root menu is sorted on 'rank'
usort(self::$aRootMenus, array('ApplicationMenu', 'CompareOnRank'));
usort(self::$aRootMenus, ['ApplicationMenu', 'CompareOnRank']);
$oFirstGroup = self::GetMenuNode(self::$aRootMenus[0]['index']);
$aChildren = self::$aMenusIndex[$oFirstGroup->GetIndex()]['children'];
usort($aChildren, array('ApplicationMenu', 'CompareOnRank'));
usort($aChildren, ['ApplicationMenu', 'CompareOnRank']);
$oMenuNode = self::GetMenuNode($aChildren[0]['index']);
$sDefaultMenuId = $oMenuNode->GetMenuId();
}
@@ -482,13 +457,11 @@ class ApplicationMenu
public static function GetRootMenuId($sMenuId)
{
$iMenuIndex = self::GetMenuIndexById($sMenuId);
if ($iMenuIndex == -1)
{
if ($iMenuIndex == -1) {
return '';
}
$oMenu = ApplicationMenu::GetMenuNode($iMenuIndex);
while ($oMenu->GetParentIndex() != -1)
{
while ($oMenu->GetParentIndex() != -1) {
$oMenu = ApplicationMenu::GetMenuNode($oMenu->GetParentIndex());
}
return $oMenu->GetMenuId();
@@ -575,17 +548,17 @@ abstract class MenuNode
{
$this->sMenuId = $sMenuId;
$this->iParentIndex = $iParentIndex;
$this->aReflectionProperties = array();
$this->aReflectionProperties = [];
if (utils::IsNotNullOrEmptyString($sEnableClass)) {
$this->aReflectionProperties['enable_class'] = $sEnableClass;
$this->aReflectionProperties['enable_action'] = $iActionCode;
$this->aReflectionProperties['enable_permission'] = $iAllowedResults;
$this->aReflectionProperties['enable_stimulus'] = $sEnableStimulus;
}
$this->m_aEnableClasses = array($sEnableClass);
$this->m_aEnableActions = array($iActionCode);
$this->m_aEnableActionResults = array($iAllowedResults);
$this->m_aEnableStimuli = array($sEnableStimulus);
$this->m_aEnableClasses = [$sEnableClass];
$this->m_aEnableActions = [$iActionCode];
$this->m_aEnableActionResults = [$iAllowedResults];
$this->m_aEnableStimuli = [$sEnableStimulus];
$this->index = ApplicationMenu::InsertMenu($this, $iParentIndex, $fRank);
}
@@ -639,7 +612,6 @@ abstract class MenuNode
$oSearch->SetShowObsoleteData(utils::ShowObsoleteData());
DBSearchHelper::AddContextFilter($oSearch);
$oSet = new DBObjectSet($oSearch);
$iCount = $oSet->CountWithLimit(99);
if ($iCount > 99) {
@@ -690,8 +662,7 @@ abstract class MenuNode
*/
public function PopulateChildMenus()
{
foreach (ApplicationMenu::GetChildren($this->GetIndex()) as $aMenu)
{
foreach (ApplicationMenu::GetChildren($this->GetIndex()) as $aMenu) {
$index = $aMenu['index'];
$oMenu = ApplicationMenu::GetMenuNode($index);
$oMenu->PopulateChildMenus();
@@ -726,8 +697,7 @@ abstract class MenuNode
*/
public function AddCondition(MenuNode $oMenuNode)
{
foreach($oMenuNode->m_aEnableClasses as $index => $sClass )
{
foreach ($oMenuNode->m_aEnableClasses as $index => $sClass) {
$this->m_aEnableClasses[] = $sClass;
$this->m_aEnableActions[] = $oMenuNode->m_aEnableActions[$index];
$this->m_aEnableActionResults[] = $oMenuNode->m_aEnableActionResults[$index];
@@ -740,33 +710,24 @@ abstract class MenuNode
*/
public function IsEnabled()
{
foreach($this->m_aEnableClasses as $index => $sClass)
{
if ($sClass != null)
{
if (MetaModel::IsValidClass($sClass))
{
if ($this->m_aEnableStimuli[$index] != null)
{
if (!UserRights::IsStimulusAllowed($sClass, $this->m_aEnableStimuli[$index]))
{
foreach ($this->m_aEnableClasses as $index => $sClass) {
if ($sClass != null) {
if (MetaModel::IsValidClass($sClass)) {
if ($this->m_aEnableStimuli[$index] != null) {
if (!UserRights::IsStimulusAllowed($sClass, $this->m_aEnableStimuli[$index])) {
return false;
}
}
if ($this->m_aEnableActions[$index] != null)
{
if ($this->m_aEnableActions[$index] != null) {
// Menus access rights ignore the archive mode
utils::PushArchiveMode(false);
$iResult = UserRights::IsActionAllowed($sClass, $this->m_aEnableActions[$index]);
utils::PopArchiveMode();
if (!($iResult & $this->m_aEnableActionResults[$index]))
{
if (!($iResult & $this->m_aEnableActionResults[$index])) {
return false;
}
}
}
else
{
} else {
return false;
}
}
@@ -779,7 +740,7 @@ abstract class MenuNode
* @param array $aExtraParams
* @return mixed
*/
public abstract function RenderContent(WebPage $oPage, $aExtraParams = array());
abstract public function RenderContent(WebPage $oPage, $aExtraParams = []);
/**
* @param string $sHyperlink
@@ -788,16 +749,13 @@ abstract class MenuNode
*/
protected function AddParams($sHyperlink, $aExtraParams)
{
if (count($aExtraParams) > 0)
{
$aQuery = array();
if (count($aExtraParams) > 0) {
$aQuery = [];
$sSeparator = '?';
if (strpos($sHyperlink, '?') !== false)
{
if (strpos($sHyperlink, '?') !== false) {
$sSeparator = '&';
}
foreach($aExtraParams as $sName => $sValue)
{
foreach ($aExtraParams as $sName => $sValue) {
$aQuery[] = urlencode($sName).'='.urlencode($sValue);
}
$sHyperlink .= $sSeparator.implode('&', $aQuery);
@@ -813,7 +771,7 @@ abstract class MenuNode
class MenuGroup extends MenuNode
{
/** @var string DEFAULT_DECORATION_CLASSES Set to null by default so it is replaced by initials when none is specified */
const DEFAULT_DECORATION_CLASSES = null;
public const DEFAULT_DECORATION_CLASSES = null;
/** @var string The CSS classes used to display the menu group's icon */
protected $sDecorationClasses = self::DEFAULT_DECORATION_CLASSES;
@@ -833,8 +791,7 @@ class MenuGroup extends MenuNode
{
parent::__construct($sMenuId, -1 /* no parent, groups are at root level */, $fRank, $sEnableClass, $iActionCode, $iAllowedResults, $sEnableStimulus);
if(!empty($sDecorationClasses))
{
if (!empty($sDecorationClasses)) {
$this->sDecorationClasses = $sDecorationClasses;
}
}
@@ -875,7 +832,7 @@ class MenuGroup extends MenuNode
/**
* @inheritDoc
*/
public function RenderContent(WebPage $oPage, $aExtraParams = array())
public function RenderContent(WebPage $oPage, $aExtraParams = [])
{
assert(false); // Shall never be called, groups do not display any content
}
@@ -887,7 +844,6 @@ class MenuGroup extends MenuNode
*/
class TemplateMenuNode extends MenuNode
{
/**
* Create a menu item based on a custom template and inserts it into the application's main menu
* @param string $sMenuId Unique identifier of the menu (used to identify the menu for bookmarking, and for getting the labels from the dictionary)
@@ -914,7 +870,7 @@ class TemplateMenuNode extends MenuNode
* @inheritDoc
* @throws \Exception
*/
public function RenderContent(WebPage $oPage, $aExtraParams = array())
public function RenderContent(WebPage $oPage, $aExtraParams = [])
{
//DO NOTHING this type of menu is only used for title not clickable
}
@@ -948,7 +904,6 @@ class OQLMenuNode extends MenuNode
*/
protected $m_aParams;
/**
* Create a menu item based on an OQL query and inserts it into the application's main menu
* @param string $sMenuId Unique identifier of the menu (used to identify the menu for bookmarking, and for getting the labels from the dictionary)
@@ -969,7 +924,7 @@ class OQLMenuNode extends MenuNode
$this->sOQL = $sOQL;
$this->bSearch = $bSearch;
$this->bSearchFormOpen = $bSearchFormOpen;
$this->m_aParams = array();
$this->m_aParams = [];
$this->aReflectionProperties['oql'] = $sOQL;
$this->aReflectionProperties['do_search'] = $bSearch;
// Enhancement: we could set as the "enable" condition that the user has enough rights to "read" the objects
@@ -983,8 +938,7 @@ class OQLMenuNode extends MenuNode
public function SetParameters($aParams)
{
$this->m_aParams = $aParams;
foreach($aParams as $sKey => $value)
{
foreach ($aParams as $sKey => $value) {
$this->aReflectionProperties[$sKey] = $value;
}
}
@@ -993,12 +947,11 @@ class OQLMenuNode extends MenuNode
* @inheritDoc
* @throws \Exception
*/
public function RenderContent(WebPage $oPage, $aExtraParams = array())
public function RenderContent(WebPage $oPage, $aExtraParams = [])
{
$oTag = new ContextTag(ContextTag::TAG_OBJECT_SEARCH);
ApplicationMenu::CheckMenuIdEnabled($this->GetMenuId());
OQLMenuNode::RenderOQLSearch
(
OQLMenuNode::RenderOQLSearch(
$this->sOQL,
Dict::S($this->sPageTitle),
'Menu_'.$this->GetMenuId(),
@@ -1023,26 +976,25 @@ class OQLMenuNode extends MenuNode
* @throws DictExceptionMissingString
* @throws OQLException
*/
public static function RenderOQLSearch($sOql, $sTitle, $sUsageId, $bSearchPane, $bSearchOpen, WebPage $oPage, $aExtraParams = array(), $bEnableBreadcrumb = false)
public static function RenderOQLSearch($sOql, $sTitle, $sUsageId, $bSearchPane, $bSearchOpen, WebPage $oPage, $aExtraParams = [], $bEnableBreadcrumb = false)
{
$sUsageId = utils::GetSafeId($sUsageId);
$oSearch = DBObjectSearch::FromOQL($sOql);
$sClass= $oSearch->GetClass();
$sClass = $oSearch->GetClass();
$sIcon = MetaModel::GetClassIcon($sClass, false);
if ($bSearchPane) {
$aParams = array_merge(['open' => $bSearchOpen, 'table_id' => $sUsageId, 'submit_on_load' => false], $aExtraParams);
$oBlock = new DisplayBlock($oSearch, DisplayBlock::ENUM_STYLE_SEARCH, false /* Asynchronous */, $aParams);
$oBlock->Display($oPage, 0);
$oPage->add("<div class='sf_results_area ibo-add-margin-top-250' data-target='search_results'>");
}
else {
} else {
$oPage->add("<div class='sf_results_area' data-target='search_results'>");
}
$aExtraParams['panel_class'] =$sClass;
$aExtraParams['panel_class'] = $sClass;
$aExtraParams['panel_title'] = $sTitle;
$aExtraParams['panel_icon'] = $sIcon;
$aParams = array_merge(array('table_id' => $sUsageId), $aExtraParams);
$aParams = array_merge(['table_id' => $sUsageId], $aExtraParams);
$oBlock = new DisplayBlock($oSearch, 'list', false /* Asynchronous */, $aParams);
$oBlock->Display($oPage, $sUsageId);
@@ -1107,14 +1059,14 @@ class SearchMenuNode extends MenuNode
* @throws \DictExceptionMissingString
* @throws \Exception
*/
public function RenderContent(WebPage $oPage, $aExtraParams = array())
public function RenderContent(WebPage $oPage, $aExtraParams = [])
{
ApplicationMenu::CheckMenuIdEnabled($this->GetMenuId());
$oPage->SetBreadCrumbEntry("menu-".$this->sMenuId, $this->GetTitle(), '', '', 'fas fa-search', iTopWebPage::ENUM_BREADCRUMB_ENTRY_ICON_TYPE_CSS_CLASSES);
$oSearch = new DBObjectSearch($this->sClass);
$sUsageId = 'Menu_'.utils::GetSafeId($this->GetMenuId());
$aParams = array_merge(array('table_id' =>$sUsageId), $aExtraParams);
$aParams = array_merge(['table_id' => $sUsageId], $aExtraParams);
$oBlock = new DisplayBlock($oSearch, 'search', false /* Asynchronous */, $aParams);
$oBlock->Display($oPage, 0);
}
@@ -1151,10 +1103,16 @@ class WebPageMenuNode extends MenuNode
* @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, $bIsLinkInNewWindow = false
)
{
$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;
@@ -1167,7 +1125,7 @@ class WebPageMenuNode extends MenuNode
public function GetHyperlink($aExtraParams)
{
$aExtraParams['c[menu]'] = $this->GetMenuId();
return $this->AddParams( $this->sHyperlink, $aExtraParams);
return $this->AddParams($this->sHyperlink, $aExtraParams);
}
/**
@@ -1181,7 +1139,7 @@ class WebPageMenuNode extends MenuNode
/**
* @inheritDoc
*/
public function RenderContent(WebPage $oPage, $aExtraParams = array())
public function RenderContent(WebPage $oPage, $aExtraParams = [])
{
assert(false); // Shall never be called, the external web page will handle the display by itself
}
@@ -1242,10 +1200,8 @@ class NewObjectMenuNode extends MenuNode
$aSubClasses = MetaModel::EnumChildClasses($this->sClass, ENUM_CHILD_CLASSES_ALL); // Including the specified class itself
$bActionIsAllowed = false;
foreach($aSubClasses as $sCandidateClass)
{
if (!MetaModel::IsAbstract($sCandidateClass) && (UserRights::IsActionAllowed($sCandidateClass, UR_ACTION_MODIFY) == UR_ALLOWED_YES))
{
foreach ($aSubClasses as $sCandidateClass) {
if (!MetaModel::IsAbstract($sCandidateClass) && (UserRights::IsActionAllowed($sCandidateClass, UR_ACTION_MODIFY) == UR_ALLOWED_YES)) {
$bActionIsAllowed = true;
break; // Enough for now
}
@@ -1256,7 +1212,7 @@ class NewObjectMenuNode extends MenuNode
/**
* @inheritDoc
*/
public function RenderContent(WebPage $oPage, $aExtraParams = array())
public function RenderContent(WebPage $oPage, $aExtraParams = [])
{
assert(false); // Shall never be called, the external web page will handle the display by itself
}
@@ -1296,7 +1252,9 @@ class DashboardMenuNode extends MenuNode
*/
public function GetHyperlink($aExtraParams)
{
if ($this->sDashboardFile == '') return '';
if ($this->sDashboardFile == '') {
return '';
}
return parent::GetHyperlink($aExtraParams);
}
@@ -1314,12 +1272,11 @@ class DashboardMenuNode extends MenuNode
* @inheritDoc
* @throws \Exception
*/
public function RenderContent(WebPage $oPage, $aExtraParams = array())
public function RenderContent(WebPage $oPage, $aExtraParams = [])
{
ApplicationMenu::CheckMenuIdEnabled($this->GetMenuId());
$oDashboard = $this->GetDashboard();
if ($oDashboard != null)
{
if ($oDashboard != null) {
WebResourcesHelper::EnableC3JSToWebPage($oPage);
$sDivId = utils::Sanitize($this->sMenuId, '', 'element_identifier');
@@ -1350,9 +1307,7 @@ class DashboardMenuNode extends MenuNode
}
$oPage->SetBreadCrumbEntry("ui-dashboard-".$this->sMenuId, $this->GetTitle(), $sDescription, '', $sIcon, iTopWebPage::ENUM_BREADCRUMB_ENTRY_ICON_TYPE_CSS_CLASSES);
}
}
else
{
} else {
$oPage->p("Error: failed to load dashboard file: '{$this->sDashboardFile}'");
}
}
@@ -1365,12 +1320,9 @@ class DashboardMenuNode extends MenuNode
public function RenderEditor(WebPage $oPage)
{
$oDashboard = $this->GetDashboard();
if ($oDashboard != null)
{
if ($oDashboard != null) {
$oDashboard->RenderEditor($oPage);
}
else
{
} else {
$oPage->p("Error: failed to load dashboard file: '{$this->sDashboardFile}'");
}
}
@@ -1382,13 +1334,10 @@ class DashboardMenuNode extends MenuNode
public function AddDashlet($oDashlet)
{
$oDashboard = $this->GetDashboard();
if ($oDashboard != null)
{
if ($oDashboard != null) {
$oDashboard->AddDashlet($oDashlet);
$oDashboard->Save();
}
else
{
} else {
throw new Exception("Error: failed to load dashboard file: '{$this->sDashboardFile}'");
}
}
@@ -1411,7 +1360,7 @@ class ShortcutContainerMenuNode extends MenuNode
/**
* @inheritDoc
*/
public function RenderContent(WebPage $oPage, $aExtraParams = array())
public function RenderContent(WebPage $oPage, $aExtraParams = [])
{
}
@@ -1426,10 +1375,9 @@ class ShortcutContainerMenuNode extends MenuNode
//
$oBMSearch = new DBObjectSearch('Shortcut');
$oBMSearch->AddCondition('user_id', UserRights::GetUserId(), '=');
$oBMSet = new DBObjectSet($oBMSearch, array('friendlyname' => true)); // ascending on friendlyname
$oBMSet = new DBObjectSet($oBMSearch, ['friendlyname' => true]); // ascending on friendlyname
$fRank = 1;
while ($oShortcut = $oBMSet->Fetch())
{
while ($oShortcut = $oBMSet->Fetch()) {
$sName = $this->GetMenuId().'_'.$oShortcut->GetKey();
new ShortcutMenuNode($sName, $oShortcut, $this->GetIndex(), $fRank++);
}
@@ -1440,7 +1388,6 @@ class ShortcutContainerMenuNode extends MenuNode
}
}
require_once(APPROOT.'application/shortcut.class.inc.php');
/**
* This class defines a menu item which content is a shortcut.
@@ -1477,12 +1424,10 @@ class ShortcutMenuNode extends MenuNode
{
$sContext = $this->oShortcut->Get('context');
$aContext = unserialize($sContext);
if (isset($aContext['menu']))
{
if (isset($aContext['menu'])) {
unset($aContext['menu']);
}
foreach ($aContext as $sArgName => $sArgValue)
{
foreach ($aContext as $sArgName => $sArgValue) {
$aExtraParams[$sArgName] = $sArgValue;
}
return parent::GetHyperlink($aExtraParams);
@@ -1492,7 +1437,7 @@ class ShortcutMenuNode extends MenuNode
* @inheritDoc
* @throws \Exception
*/
public function RenderContent(WebPage $oPage, $aExtraParams = array())
public function RenderContent(WebPage $oPage, $aExtraParams = [])
{
ApplicationMenu::CheckMenuIdEnabled($this->GetMenuId());
$this->oShortcut->RenderContent($oPage, $aExtraParams);
@@ -1529,11 +1474,9 @@ class ShortcutMenuNode extends MenuNode
return true;
}
public function GetEntriesCount()
{
return $this->GetEntriesCountFromOQL($this->oShortcut->Get('oql'));
}
}