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

This commit is contained in:
odain
2025-11-07 15:39:53 +01:00
parent 12f23113f5
commit 890a2568c8
2110 changed files with 53099 additions and 63885 deletions

View File

@@ -1,4 +1,5 @@
<?php
/**
* Copyright (C) 2013-2024 Combodo SAS
*
@@ -19,7 +20,6 @@
namespace Combodo\iTop\Application\UI\Base\Component\PopoverMenu\NewsroomMenu;
use Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenu;
/**
@@ -65,4 +65,4 @@ class NewsroomMenu extends PopoverMenu
{
return json_encode($this->aParams);
}
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Copyright (C) 2013-2024 Combodo SAS
*
@@ -62,17 +63,17 @@ class NewsroomMenuFactory
*/
protected static function PrepareParametersForNewsroomMenu()
{
$aProviderParams=[];
$aProviderParams = [];
$oUser = UserRights::GetUserObject();
/** @var iNewsroomProvider[] $aProviders */
$aProviders = InterfaceDiscovery::GetInstance()->FindItopClasses(iNewsroomProvider::class);
foreach($aProviders as $cProvider) {
foreach ($aProviders as $cProvider) {
$oProvider = new $cProvider();
$oConfig = MetaModel::GetConfig();
$oProvider->SetConfig($oConfig);
$bProviderEnabled = appUserPreferences::GetPref('newsroom_provider_'.get_class($oProvider), true);
if ($bProviderEnabled && $oProvider->IsApplicable($oUser)) {
$aProviderParams[] = array(
$aProviderParams[] = [
'label' => $oProvider->GetLabel(),
'fetch_url' => $oProvider->GetFetchURL(),
'target' => utils::StartsWith($oProvider->GetFetchURL(), $oConfig->Get('app_root_url')) ? '_self' : '_blank',
@@ -80,25 +81,25 @@ class NewsroomMenuFactory
'mark_all_as_read_url' => $oProvider->GetMarkAllAsReadURL(),
'placeholders' => $oProvider->GetPlaceholders(),
'ttl' => $oProvider->GetTTL(),
);
];
}
}
$sImageUrl= 'fas fa-comment-dots';
$sPlaceholderImageUrl= 'far fa-envelope';
$aParams = array(
$sImageUrl = 'fas fa-comment-dots';
$sPlaceholderImageUrl = 'far fa-envelope';
$aParams = [
'image_icon' => $sImageUrl,
'no_message_icon' => file_get_contents(APPROOT.'images/illustrations/undraw_social_serenity.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(
'labels' => [
'no_notification' => 'UI:Newsroom:NoNewMessage',
'x_notifications' => 'UI:Newsroom:XNewMessage',
'mark_all_as_read' => 'UI:Newsroom:MarkAllAsRead',
'view_all' => 'UI:Newsroom:ViewAllMessages'
),
);
'view_all' => 'UI:Newsroom:ViewAllMessages',
],
];
return $aParams;
}
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Copyright (C) 2013-2024 Combodo SAS
*
@@ -19,7 +20,6 @@
namespace Combodo\iTop\Application\UI\Base\Component\PopoverMenu;
use Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenuItem\PopoverMenuItem;
use Combodo\iTop\Application\UI\Base\iUIBlock;
use Combodo\iTop\Application\UI\Base\UIBlock;
@@ -336,8 +336,7 @@ class PopoverMenu extends UIBlock
*/
public function AddSection(string $sId)
{
if (false === $this->HasSection($sId))
{
if (false === $this->HasSection($sId)) {
$this->aSections[$sId] = [
'aItems' => [],
];
@@ -357,8 +356,7 @@ class PopoverMenu extends UIBlock
*/
public function RemoveSection(string $sId)
{
if (true === $this->HasSection($sId))
{
if (true === $this->HasSection($sId)) {
unset($this->aSections[$sId]);
}
@@ -387,8 +385,7 @@ class PopoverMenu extends UIBlock
*/
public function ClearSection(string $sId)
{
if (false === $this->HasSection($sId))
{
if (false === $this->HasSection($sId)) {
throw new Exception('Could not clear section "'.$sId.'" as it does not exist in the "'.$this->GetId().'" menu');
}
@@ -448,13 +445,11 @@ class PopoverMenu extends UIBlock
*/
public function RemoveItem(string $sSectionId, string $sItemId)
{
if (false === $this->HasSection($sSectionId))
{
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']))
{
if (array_key_exists($sItemId, $this->aSections[$sSectionId]['aItems'])) {
unset($this->aSections[$sSectionId]['aItems'][$sItemId]);
}
@@ -472,7 +467,7 @@ class PopoverMenu extends UIBlock
*/
public function AddItems(string $sSectionId, array $aItems)
{
foreach($aItems as $oItem){
foreach ($aItems as $oItem) {
$this->AddItem($sSectionId, $oItem);
}
@@ -525,12 +520,11 @@ class PopoverMenu extends UIBlock
$aSubBlocks = [];
foreach ($this->aSections as $sSectionId => $aSectionData) {
foreach($aSectionData['aItems'] as $sItemId => $oItem)
{
foreach ($aSectionData['aItems'] as $sItemId => $oItem) {
$aSubBlocks[$sItemId] = $oItem;
}
}
return $aSubBlocks;
}
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Copyright (C) 2013-2024 Combodo SAS
*
@@ -19,8 +20,6 @@
namespace Combodo\iTop\Application\UI\Base\Component\PopoverMenu;
use Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenuItem\PopoverMenuItemFactory;
use Dict;
use JSPopupMenuItem;
@@ -80,7 +79,7 @@ class PopoverMenuFactory
return $oMenu;
}
/**
* Return the allowed portals items for the current user
*
@@ -89,10 +88,8 @@ class PopoverMenuFactory
protected static function PrepareAllowedPortalsItemsForUserMenu()
{
$aItems = [];
foreach (UserRights::GetAllowedPortals() as $aAllowedPortal)
{
if ($aAllowedPortal['id'] !== 'backoffice')
{
foreach (UserRights::GetAllowedPortals() as $aAllowedPortal) {
if ($aAllowedPortal['id'] !== 'backoffice') {
$oPopupMenuItem = new URLPopupMenuItem(
'portal:'.$aAllowedPortal['id'],
Dict::S($aAllowedPortal['label']),
@@ -127,8 +124,7 @@ class PopoverMenuFactory
);
// Archive mode
if(true === utils::IsArchiveMode())
{
if (true === utils::IsArchiveMode()) {
$aItems[] = PopoverMenuItemFactory::MakeFromApplicationPopupMenuItem(
new JSPopupMenuItem(
'UI:ArchiveModeOff',
@@ -136,9 +132,7 @@ class PopoverMenuFactory
'return ArchiveMode(false);'
)
);
}
elseif(UserRights::CanBrowseArchive())
{
} elseif (UserRights::CanBrowseArchive()) {
$aItems[] = PopoverMenuItemFactory::MakeFromApplicationPopupMenuItem(
new JSPopupMenuItem(
'UI:ArchiveModeOn',
@@ -149,8 +143,7 @@ class PopoverMenuFactory
}
// Logoff
if(utils::CanLogOff())
{
if (utils::CanLogOff()) {
$aItems[] = PopoverMenuItemFactory::MakeFromApplicationPopupMenuItem(
new URLPopupMenuItem(
'UI:LogOffMenu',
@@ -161,8 +154,7 @@ class PopoverMenuFactory
}
// Change password
if (UserRights::CanChangePassword())
{
if (UserRights::CanChangePassword()) {
$aItems[] = PopoverMenuItemFactory::MakeFromApplicationPopupMenuItem(
new URLPopupMenuItem(
'UI:ChangePwdMenu',
@@ -189,7 +181,7 @@ class PopoverMenuFactory
utils::GetPopupMenuItemsBlock($oMenu, iPopupMenuExtension::MENU_USER_ACTIONS, null, $aOriginalItems);
$aTransformedItems = [];
foreach($aOriginalItems as $sItemID => $aItemData) {
foreach ($aOriginalItems as $sItemID => $aItemData) {
$aTransformedItems[] = PopoverMenuItemFactory::MakeFromApplicationPopupMenuItemData($sItemID, $aItemData);
}
@@ -273,4 +265,4 @@ class PopoverMenuFactory
return $oMenu;
}
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Copyright (C) 2013-2024 Combodo SAS
*
@@ -19,7 +20,6 @@
namespace Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenuItem;
use JSPopupMenuItem;
/**
@@ -27,7 +27,7 @@ use JSPopupMenuItem;
*
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @package Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenuItem
* @property \JSPopupMenuItem $oPopupMenuItem
* @property \JSPopupMenuItem $oPopupMenuItem
* @since 3.0.0
*/
class JsPopoverMenuItem extends PopoverMenuItem
@@ -63,4 +63,4 @@ class JsPopoverMenuItem extends PopoverMenuItem
return $aJsFiles;
}
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Copyright (C) 2013-2024 Combodo SAS
*
@@ -19,7 +20,6 @@
namespace Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenuItem;
use ApplicationPopupMenuItem;
use Combodo\iTop\Application\UI\Base\UIBlock;
use utils;
@@ -106,7 +106,7 @@ class PopoverMenuItem extends UIBlock
{
return $this->oPopupMenuItem->GetCssClasses();
}
/**
* @return string
* @uses oPopupMenuItem
@@ -137,7 +137,7 @@ class PopoverMenuItem extends UIBlock
{
return $this->oPopupMenuItem->GetTooltip();
}
/**
* @return $this
* @uses oPopupMenuItem
@@ -149,7 +149,6 @@ class PopoverMenuItem extends UIBlock
return $this;
}
/**
* @return string
* @uses oPopupMenuItem
@@ -160,5 +159,4 @@ class PopoverMenuItem extends UIBlock
return $this->oPopupMenuItem->GetUID();
}
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Copyright (C) 2013-2024 Combodo SAS
*
@@ -19,8 +20,6 @@
namespace Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenuItem;
use ApplicationPopupMenuItem;
use JSPopupMenuItem;
use SeparatorPopupMenuItem;
@@ -46,14 +45,13 @@ class PopoverMenuItemFactory
public static function MakeFromApplicationPopupMenuItem(ApplicationPopupMenuItem $oItem)
{
$sNamespace = 'Combodo\\iTop\\Application\\UI\\Base\\Component\\PopoverMenu\\PopoverMenuItem\\';
switch(true)
{
switch (true) {
case $oItem instanceof URLPopupMenuItem:
$sTargetClass = 'UrlPopoverMenuItem';
break;
case $oItem instanceof JSPopupMenuItem:
$sTargetClass = 'JsPopoverMenuItem';
break;
break;
case $oItem instanceof SeparatorPopupMenuItem:
$sTargetClass = 'SeparatorPopoverMenuItem';
break;
@@ -99,7 +97,8 @@ class PopoverMenuItemFactory
new JSPopupMenuItem(
$aRefactoredItem['uid'],
$aRefactoredItem['label'],
$aRefactoredItem['on_click'])
$aRefactoredItem['on_click']
)
);
} elseif (!empty($aRefactoredItem['url'])) {
// URL
@@ -108,7 +107,8 @@ class PopoverMenuItemFactory
$aRefactoredItem['uid'],
$aRefactoredItem['label'],
$aRefactoredItem['url'],
$aRefactoredItem['target'])
$aRefactoredItem['target']
)
);
} else {
// Separator
@@ -140,4 +140,4 @@ class PopoverMenuItemFactory
{
return new SeparatorPopoverMenuItem(new SeparatorPopupMenuItem());
}
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Copyright (C) 2013-2024 Combodo SAS
*
@@ -19,7 +20,6 @@
namespace Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenuItem;
/**
* Class SeparatorPopoverMenuItem
*
@@ -33,4 +33,4 @@ class SeparatorPopoverMenuItem extends PopoverMenuItem
// Overloaded constants
public const BLOCK_CODE = 'ibo-popover-menu--item-separator';
public const DEFAULT_HTML_TEMPLATE_REL_PATH = 'base/components/popover-menu/item/mode_separator';
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* Copyright (C) 2013-2024 Combodo SAS
*
@@ -19,7 +20,6 @@
namespace Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenuItem;
/**
* Class UrlPopoverMenuItem
*
@@ -41,7 +41,7 @@ class UrlPopoverMenuItem extends PopoverMenuItem
{
return $this->oPopupMenuItem->GetUrl();
}
/**
* @see \URLPopupMenuItem::GetTarget()
* @return string
@@ -50,4 +50,4 @@ class UrlPopoverMenuItem extends PopoverMenuItem
{
return $this->oPopupMenuItem->GetTarget();
}
}
}