From 1538596db89ceeeb02777071e1ad3220a7a7e97a Mon Sep 17 00:00:00 2001 From: Eric Espie Date: Fri, 9 Jan 2026 11:04:38 +0100 Subject: [PATCH] PHP CS-Fixer --- application/dashboard.class.inc.php | 17 +++++++------- .../Base/Layout/Dashboard/DashboardGrid.php | 2 +- .../Layout/Dashboard/DashboardGridSlot.php | 1 - .../Base/Layout/Dashboard/DashboardLayout.php | 22 +++++++++++++------ .../Base/Layout/DashletPanel/DashletEntry.php | 5 ++--- .../Base/Layout/DashletPanel/DashletPanel.php | 12 ++++++---- .../DashletPanel/DashletPanelFactory.php | 12 +++++----- .../Layout/PageContent/PageContentFactory.php | 3 ++- sources/Service/Dashboard/DashletService.php | 6 +++-- 9 files changed, 46 insertions(+), 34 deletions(-) diff --git a/application/dashboard.class.inc.php b/application/dashboard.class.inc.php index f3d0bbb09..834c6f368 100644 --- a/application/dashboard.class.inc.php +++ b/application/dashboard.class.inc.php @@ -1067,8 +1067,7 @@ JS $oUDSet = new DBObjectSet($oUDSearch); return ($oUDSet->Count() > 0); - } - catch (Exception $e) { + } catch (Exception $e) { return false; } } @@ -1102,7 +1101,8 @@ JS } // TODO 3.3 Check if we need different action for custom dashboard creation / edition - $oActionEditButton = ButtonUIBlockFactory::MakeIconAction('fas fa-pen', + $oActionEditButton = ButtonUIBlockFactory::MakeIconAction( + 'fas fa-pen', $this->HasCustomDashboard() ? Dict::S('UI:Dashboard:EditCustom') : Dict::S('UI:Dashboard:CreateCustom'), $sActionEditId, '', @@ -1123,8 +1123,8 @@ JS $sFile = addslashes(utils::LocalPath($this->sDefinitionFile)); $sJSExtraParams = json_encode($aExtraParams); if ($this->HasCustomDashboard()) { -// $oEdit = new JSPopupMenuItem('UI:Dashboard:Edit', Dict::S('UI:Dashboard:EditCustom'), "return EditDashboard('{$this->sId}', '$sFile', $sJSExtraParams)"); -// $aActions[$oEdit->GetUID()] = $oEdit->GetMenuItem(); + // $oEdit = new JSPopupMenuItem('UI:Dashboard:Edit', Dict::S('UI:Dashboard:EditCustom'), "return EditDashboard('{$this->sId}', '$sFile', $sJSExtraParams)"); + // $aActions[$oEdit->GetUID()] = $oEdit->GetMenuItem(); $oRevert = new JSPopupMenuItem( 'UI:Dashboard:RevertConfirm', Dict::S('UI:Dashboard:DeleteCustom'), @@ -1132,8 +1132,8 @@ JS ); $aActions[$oRevert->GetUID()] = $oRevert->GetMenuItem(); } else { -// $oEdit = new JSPopupMenuItem('UI:Dashboard:Edit', Dict::S('UI:Dashboard:CreateCustom'), "return EditDashboard('{$this->sId}', '$sFile', $sJSExtraParams)"); -// $aActions[$oEdit->GetUID()] = $oEdit->GetMenuItem(); + // $oEdit = new JSPopupMenuItem('UI:Dashboard:Edit', Dict::S('UI:Dashboard:CreateCustom'), "return EditDashboard('{$this->sId}', '$sFile', $sJSExtraParams)"); + // $aActions[$oEdit->GetUID()] = $oEdit->GetMenuItem(); } utils::GetPopupMenuItems($oPage, iPopupMenuExtension::MENU_DASHBOARD_ACTIONS, $this, $aActions); @@ -1639,8 +1639,7 @@ JS try { $oFilter = $oDashlet->GetDBSearch($aExtraParams); $aClassAliases = $oFilter->GetSelectedClasses(); - } - catch (Exception $e) { + } catch (Exception $e) { //on error, return default value return null; } diff --git a/sources/Application/UI/Base/Layout/Dashboard/DashboardGrid.php b/sources/Application/UI/Base/Layout/Dashboard/DashboardGrid.php index 48d6d6aaf..0ce741bc3 100644 --- a/sources/Application/UI/Base/Layout/Dashboard/DashboardGrid.php +++ b/sources/Application/UI/Base/Layout/Dashboard/DashboardGrid.php @@ -61,4 +61,4 @@ class DashboardGrid extends UIBlock return $this; } -} \ No newline at end of file +} diff --git a/sources/Application/UI/Base/Layout/Dashboard/DashboardGridSlot.php b/sources/Application/UI/Base/Layout/Dashboard/DashboardGridSlot.php index d350ec187..5ad135b0d 100644 --- a/sources/Application/UI/Base/Layout/Dashboard/DashboardGridSlot.php +++ b/sources/Application/UI/Base/Layout/Dashboard/DashboardGridSlot.php @@ -36,7 +36,6 @@ class DashboardGridSlot extends UIBlock $this->iHeight = random_int(1, 4) || $iHeight; } - public function GetSubBlocks(): array { return [$this->oUIBlock]; diff --git a/sources/Application/UI/Base/Layout/Dashboard/DashboardLayout.php b/sources/Application/UI/Base/Layout/Dashboard/DashboardLayout.php index f82146014..2a33d0a85 100644 --- a/sources/Application/UI/Base/Layout/Dashboard/DashboardLayout.php +++ b/sources/Application/UI/Base/Layout/Dashboard/DashboardLayout.php @@ -13,6 +13,7 @@ use Combodo\iTop\Application\UI\Base\Component\Input\Select\SelectOptionUIBlockF use Combodo\iTop\Application\UI\Base\Layout\UIContentBlock; use Combodo\iTop\Application\UI\Base\UIBlock; use Dict; + use function Combodo\iTop\Application\UI\Base\Component\Button\ButtonUIBlockFactory; // TODO 3.3 Remove old dashboard methods, make dict entries for elements, etc @@ -54,7 +55,8 @@ class DashboardLayout extends UIBlock $this->oButtonsToolbar = $this->MakeButtonsToolbar(); } - public function MakeTitleInput() { + public function MakeTitleInput() + { $oTitleInput = new \Combodo\iTop\Application\UI\Base\Component\Input\Input(); $oTitleInput->SetName('dashboard_title'); $oTitleInput->SetType('text'); @@ -63,7 +65,8 @@ class DashboardLayout extends UIBlock return $oTitleInput; } - public function MakeRefreshInput() { + public function MakeRefreshInput() + { $oRefreshInput = \Combodo\iTop\Application\UI\Base\Component\Input\Select\SelectUIBlockFactory::MakeForSelect('refresh_interval'); $aRefreshRateOptions = [ ['value' => '0', 'label' => 'No auto-refresh'], @@ -82,7 +85,8 @@ class DashboardLayout extends UIBlock return $oRefreshInput; } - public function MakeButtonsToolbar() { + public function MakeButtonsToolbar() + { $oContainer = new UIContentBlock(null, ['ibo-dashboard--buttons-toolbar']); $oCancelButton = ButtonUIBlockFactory::MakeForCancel(Dict::S('UI:Button:Cancel'), 'cancel', 'cancel'); $oSaveButton = ButtonUIBlockFactory::MakeForPrimaryAction(Dict::S('UI:Button:Save'), 'save', 'save'); @@ -162,13 +166,15 @@ class DashboardLayout extends UIBlock return $this->aDashboardRows; } - public function SetGrid(DashboardGrid $oDashboardGrid) { + public function SetGrid(DashboardGrid $oDashboardGrid) + { $this->oDashboardGrid = $oDashboardGrid; return $this; } - public function GetGrid() { + public function GetGrid() + { return $this->oDashboardGrid; } @@ -177,11 +183,13 @@ class DashboardLayout extends UIBlock return $this->oTitleInput; } - public function GetRefreshInput() { + public function GetRefreshInput() + { return $this->oRefreshInput; } - public function GetButtonsToolbar() { + public function GetButtonsToolbar() + { return $this->oButtonsToolbar; } } diff --git a/sources/Application/UI/Base/Layout/DashletPanel/DashletEntry.php b/sources/Application/UI/Base/Layout/DashletPanel/DashletEntry.php index 7b9c3f58d..644565ced 100644 --- a/sources/Application/UI/Base/Layout/DashletPanel/DashletEntry.php +++ b/sources/Application/UI/Base/Layout/DashletPanel/DashletEntry.php @@ -5,7 +5,8 @@ namespace Combodo\iTop\Application\UI\Base\Layout\DashletPanel; use Combodo\iTop\Application\UI\Base\UIBlock; use utils; -class DashletEntry extends UIBlock { +class DashletEntry extends UIBlock +{ public const BLOCK_CODE = 'ibo-dashlet-entry'; public const DEFAULT_HTML_TEMPLATE_REL_PATH = 'base/layouts/dashlet-panel/dashlet-entry'; @@ -18,7 +19,6 @@ class DashletEntry extends UIBlock { protected $sDashletPreferredWidth; protected $sDashletPreferredHeight; - public function __construct(string $sDashletClass, string $sDashletLabel, string $sDashletDescription, string $sDashletIconRelUrl, ?string $sId = null) { parent::__construct($sId); @@ -159,5 +159,4 @@ class DashletEntry extends UIBlock { return $this; } - } diff --git a/sources/Application/UI/Base/Layout/DashletPanel/DashletPanel.php b/sources/Application/UI/Base/Layout/DashletPanel/DashletPanel.php index 843daf31b..2d838fc81 100644 --- a/sources/Application/UI/Base/Layout/DashletPanel/DashletPanel.php +++ b/sources/Application/UI/Base/Layout/DashletPanel/DashletPanel.php @@ -5,7 +5,8 @@ namespace Combodo\iTop\Application\UI\Base\Layout\DashletPanel; use Combodo\iTop\Application\UI\Base\UIBlock; use Dashlet; -class DashletPanel extends UIBlock { +class DashletPanel extends UIBlock +{ public const BLOCK_CODE = 'ibo-dashlet-panel'; public const DEFAULT_HTML_TEMPLATE_REL_PATH = 'base/layouts/dashlet-panel/layout'; public const DEFAULT_JS_TEMPLATE_REL_PATH = 'base/layouts/dashlet-panel/layout'; @@ -19,17 +20,20 @@ class DashletPanel extends UIBlock { $this->AddDataAttribute('role', static::BLOCK_CODE); } - public function AddDashletEntry(DashletEntry $oDashletEntry) { + public function AddDashletEntry(DashletEntry $oDashletEntry) + { $this->aDashletsEntries[] = $oDashletEntry; return $this; } - public function GetDashletEntries() : array { + public function GetDashletEntries(): array + { return $this->aDashletsEntries; } - public function SetDashletEntries(array $aDashletEntries) { + public function SetDashletEntries(array $aDashletEntries) + { $this->aDashletsEntries = $aDashletEntries; return $this; diff --git a/sources/Application/UI/Base/Layout/DashletPanel/DashletPanelFactory.php b/sources/Application/UI/Base/Layout/DashletPanel/DashletPanelFactory.php index 1dcc9013b..404b10a25 100644 --- a/sources/Application/UI/Base/Layout/DashletPanel/DashletPanelFactory.php +++ b/sources/Application/UI/Base/Layout/DashletPanel/DashletPanelFactory.php @@ -2,10 +2,10 @@ namespace Combodo\iTop\Application\UI\Base\Layout\DashletPanel; - use Combodo\iTop\Service\Dashboard\DashletService; -class DashletPanelFactory { +class DashletPanelFactory +{ public static function MakeForDashboardEditor(string $sId = null): DashletPanel { $oDashletPanel = new DashletPanel($sId); @@ -15,16 +15,16 @@ class DashletPanelFactory { foreach ($aAvailableDashlets as $sDashletClass => $aDashletInformation) { $oDashletEntry = new DashletEntry($sDashletClass, $aDashletInformation['label'], $aDashletInformation['description'], $aDashletInformation['icon']); - if(isset($aDashletInformation['min_width'])) { + if (isset($aDashletInformation['min_width'])) { $oDashletEntry->SetDashletMinWidth($aDashletInformation['min_width']); } - if(isset($aDashletInformation['min_height'])) { + if (isset($aDashletInformation['min_height'])) { $oDashletEntry->SetDashletMinHeight($aDashletInformation['min_height']); } - if(isset($aDashletInformation['preferred_width'])) { + if (isset($aDashletInformation['preferred_width'])) { $oDashletEntry->SetDashletPreferredWidth($aDashletInformation['preferred_width']); } - if(isset($aDashletInformation['preferred_height'])) { + if (isset($aDashletInformation['preferred_height'])) { $oDashletEntry->SetDashletPreferredHeight($aDashletInformation['preferred_height']); } diff --git a/sources/Application/UI/Base/Layout/PageContent/PageContentFactory.php b/sources/Application/UI/Base/Layout/PageContent/PageContentFactory.php index 7b55beb53..9166af311 100644 --- a/sources/Application/UI/Base/Layout/PageContent/PageContentFactory.php +++ b/sources/Application/UI/Base/Layout/PageContent/PageContentFactory.php @@ -74,7 +74,8 @@ class PageContentFactory return $oLayout; } - public static function MakeForDashboard() { + public static function MakeForDashboard() + { $oLayout = new PageContentWithSideContent(); // TODO 3.3 Add dashboard specific blocks diff --git a/sources/Service/Dashboard/DashletService.php b/sources/Service/Dashboard/DashletService.php index 2b34e9641..10acc3f77 100644 --- a/sources/Service/Dashboard/DashletService.php +++ b/sources/Service/Dashboard/DashletService.php @@ -4,8 +4,10 @@ namespace Combodo\iTop\Service\Dashboard; use ReflectionClass; -class DashletService { - public static function GetAvailableDashlets(): array { +class DashletService +{ + public static function GetAvailableDashlets(): array + { $aDashlets = []; foreach (get_declared_classes() as $sDashletClass) {