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 Copyright (C) 2010-2024 Combodo SAS
* @license http://opensource.org/licenses/AGPL-3.0
@@ -93,10 +94,10 @@ class BlockDirectLinkSetEditTable extends UIContentBlock
$this->oUILinksDirectWidget = $oUILinksDirectWidget;
// compute
$this->aLabels = array(
$this->aLabels = [
'creation_title' => Dict::Format('UI:CreationTitle_Class', MetaModel::GetName($this->oUILinksDirectWidget->GetLinkedClass())),
'selection_title' => Dict::Format('UI:SelectionOf_Class', MetaModel::GetName($this->oUILinksDirectWidget->GetLinkedClass())),
);
];
$oContext = new ApplicationContext();
$this->sSubmitUrl = utils::GetAbsoluteUrlAppRoot().'pages/ajax.render.php?'.$oContext->GetForLink();
@@ -182,8 +183,7 @@ class BlockDirectLinkSetEditTable extends UIContentBlock
$oTablePanel->AddToolbarBlock($oToolbar);
$oTablePanel->AddSubBlock($oDatatable);
$this->AddSubBlock($oTablePanel);
}
catch (\Exception $e) {
} catch (\Exception $e) {
$oAlert = AlertUIBlockFactory::MakeForDanger('error', Dict::S('UI:Datatables:Language:Error'));
$oAlert->SetIsClosable(false);
$oAlert->SetIsCollapsible(false);
@@ -217,20 +217,20 @@ class BlockDirectLinkSetEditTable extends UIContentBlock
case LINKSET_EDITMODE_INPLACE: // The whole linkset can be edited 'in-place'
case LINKSET_EDITMODE_ACTIONS: // Show the usual 'Actions' popup menu
if ($this->bIsAllowCreate) {
$oActionButtonCreate = ButtonUIBlockFactory::MakeNeutral(Dict::S('UI:Button:Create'));
$oActionButtonCreate->SetTooltip(Dict::Format('UI:ClickToCreateNew', MetaModel::GetName($this->oAttributeLinkedSet->GetLinkedClass())))
->AddDataAttribute('action', 'create')
->SetOnClickJsCode("$('#{$this->oUILinksDirectWidget->GetInputId()}').directlinks('createRow');");
$oToolbar->AddSubBlock($oActionButtonCreate);
}
if ($this->bIsAllowCreate) {
$oActionButtonCreate = ButtonUIBlockFactory::MakeNeutral(Dict::S('UI:Button:Create'));
$oActionButtonCreate->SetTooltip(Dict::Format('UI:ClickToCreateNew', MetaModel::GetName($this->oAttributeLinkedSet->GetLinkedClass())))
->AddDataAttribute('action', 'create')
->SetOnClickJsCode("$('#{$this->oUILinksDirectWidget->GetInputId()}').directlinks('createRow');");
$oToolbar->AddSubBlock($oActionButtonCreate);
}
if ($this->bIsAllowDelete) {
$oActionButtonDelete = ButtonUIBlockFactory::MakeNeutral(Dict::S('UI:Button:Delete'));
$oActionButtonDelete->AddDataAttribute('action', 'delete')
->SetOnClickJsCode("$('#{$this->oUILinksDirectWidget->GetInputId()}').directlinks('deleteSelection');");
$oToolbar->AddSubBlock($oActionButtonDelete);
}
if ($this->bIsAllowDelete) {
$oActionButtonDelete = ButtonUIBlockFactory::MakeNeutral(Dict::S('UI:Button:Delete'));
$oActionButtonDelete->AddDataAttribute('action', 'delete')
->SetOnClickJsCode("$('#{$this->oUILinksDirectWidget->GetInputId()}').directlinks('deleteSelection');");
$oToolbar->AddSubBlock($oActionButtonDelete);
}
break;
case LINKSET_EDITMODE_ADDREMOVE: // The whole linkset can be edited 'in-place'
@@ -273,14 +273,14 @@ class BlockDirectLinkSetEditTable extends UIContentBlock
private function GetTableRows(WebPage $oPage, iDBObjectSetIterator $oValue): array
{
// result data
$aRows = array();
$aRows = [];
// set pointer to start
$oValue->Rewind();
// create a row table for each value...
while ($oLinkObj = $oValue->Fetch()) {
$aRow = array();
$aRow = [];
$aRow['form::select'] = '<input type="checkbox" class="selectList'.$this->oUILinksDirectWidget->GetInputId().'" onClick="oWidget'.$this->oUILinksDirectWidget->GetInputId().'.directlinks(\'instance\')._onSelectChange();" value="'.$oLinkObj->GetKey().'"/>';
foreach ($this->oUILinksDirectWidget->GetZList() as $sLinkedAttCode) {
$aRow[$sLinkedAttCode] = $oLinkObj->GetAsHTML($sLinkedAttCode);
@@ -307,19 +307,27 @@ class BlockDirectLinkSetEditTable extends UIContentBlock
*/
private function GetRowActions(DBObject $oHostObject): array
{
$aRowActions = array();
$aRowActions = [];
$sDeleteButtonTooltip = $this->oAttributeLinkedSet->SearchSpecificLabel('UI:Links:Delete:Button+', '', true,
$sDeleteButtonTooltip = $this->oAttributeLinkedSet->SearchSpecificLabel(
'UI:Links:Delete:Button+',
'',
true,
MetaModel::GetName($this->oAttributeLinkedSet->GetHostClass()),
$oHostObject->Get('friendlyname'),
$this->oAttributeLinkedSet->GetLabel(),
MetaModel::GetName($this->oUILinksDirectWidget->GetLinkedClass()));
MetaModel::GetName($this->oUILinksDirectWidget->GetLinkedClass())
);
$sRemoveButtonTooltip = $this->oAttributeLinkedSet->SearchSpecificLabel('UI:Links:Remove:Button+', '', true,
$sRemoveButtonTooltip = $this->oAttributeLinkedSet->SearchSpecificLabel(
'UI:Links:Remove:Button+',
'',
true,
MetaModel::GetName($this->oAttributeLinkedSet->GetHostClass()),
$oHostObject->Get('friendlyname'),
$this->oAttributeLinkedSet->GetLabel(),
MetaModel::GetName($this->oUILinksDirectWidget->GetLinkedClass()));
MetaModel::GetName($this->oUILinksDirectWidget->GetLinkedClass())
);
// until a full link set refactoring (continue using edit_mode property)
switch ($this->oAttributeLinkedSet->GetEditMode()) {
@@ -331,24 +339,24 @@ class BlockDirectLinkSetEditTable extends UIContentBlock
case LINKSET_EDITMODE_INPLACE: // The whole linkset can be edited 'in-place'
case LINKSET_EDITMODE_ACTIONS: // Show the usual 'Actions' popup menu
if ($this->bIsAllowDelete) {
$aRowActions[] = array(
'label' => 'UI:Links:Delete:Button',
'tooltip' => $sDeleteButtonTooltip,
'icon_classes' => 'fas fa-trash',
'js_row_action' => "$('#{$this->oUILinksDirectWidget->GetInputId()}').directlinks('Remove', $(':checkbox', oTrElement));",
);
}
if ($this->bIsAllowDelete) {
$aRowActions[] = [
'label' => 'UI:Links:Delete:Button',
'tooltip' => $sDeleteButtonTooltip,
'icon_classes' => 'fas fa-trash',
'js_row_action' => "$('#{$this->oUILinksDirectWidget->GetInputId()}').directlinks('Remove', $(':checkbox', oTrElement));",
];
}
break;
case LINKSET_EDITMODE_ADDREMOVE: // The whole linkset can be edited 'in-place'
if ($this->bIsAllowModify) {
$aRowActions[] = array(
$aRowActions[] = [
'label' => 'UI:Links:Remove:Button',
'tooltip' => $sRemoveButtonTooltip,
'icon_classes' => 'fas fa-minus',
'js_row_action' => "$('#{$this->oUILinksDirectWidget->GetInputId()}').directlinks('Remove', $(':checkbox', oTrElement));",
);
];
}
break;
@@ -358,4 +366,4 @@ class BlockDirectLinkSetEditTable extends UIContentBlock
return $aRowActions;
}
}
}