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

@@ -30,38 +30,36 @@ use utils;
*/
class BsSetFieldRenderer extends BsFieldRenderer
{
/**
* @inheritDoc
*/
/**
* @inheritDoc
*/
public function Render()
{
$oOutput = parent::Render();
$oOutput = parent::Render();
$sFieldMandatoryClass = ($this->oField->GetMandatory()) ? 'form_mandatory' : '';
$sFieldDescriptionForHTMLTag = ($this->oField->HasDescription()) ? 'data-tooltip-content="'.utils::HtmlEntities($this->oField->GetDescription()).'"' : '';
// Vars to build the table
// $sAttributesToDisplayAsJson = json_encode($this->oField->GetAttributesToDisplay());
// $sAttCodesToDisplayAsJson = json_encode($this->oField->GetAttributesToDisplay(true));
// $aItems = array();
// $aItemIds = array();
// $this->PrepareItems($aItems, $aItemIds);
// $sItemsAsJson = json_encode($aItems);
// $sItemIdsAsJson = htmlentities(json_encode(array('current' => $aItemIds)), ENT_QUOTES, 'UTF-8');
// $sAttributesToDisplayAsJson = json_encode($this->oField->GetAttributesToDisplay());
// $sAttCodesToDisplayAsJson = json_encode($this->oField->GetAttributesToDisplay(true));
// $aItems = array();
// $aItemIds = array();
// $this->PrepareItems($aItems, $aItemIds);
// $sItemsAsJson = json_encode($aItems);
// $sItemIdsAsJson = htmlentities(json_encode(array('current' => $aItemIds)), ENT_QUOTES, 'UTF-8');
// Rendering field
if (!$this->oField->GetHidden())
{
if (!$this->oField->GetHidden()) {
/** @var \ormSet $oOrmItemSet */
$oOrmItemSet = $this->oField->GetCurrentValue();
// Opening container
$oOutput->AddHtml('<div class="form-group form_group_small ' . $sFieldMandatoryClass . '">');
$oOutput->AddHtml('<div class="form-group form_group_small '.$sFieldMandatoryClass.'">');
// Label
$oOutput->AddHtml('<div class="form_field_label">');
if ($this->oField->GetLabel() !== '')
{
$oOutput->AddHtml('<label for="' . $this->oField->GetGlobalId() . '" class="control-label" '.$sFieldDescriptionForHTMLTag.'>')
if ($this->oField->GetLabel() !== '') {
$oOutput->AddHtml('<label for="'.$this->oField->GetGlobalId().'" class="control-label" '.$sFieldDescriptionForHTMLTag.'>')
->AddHtml($this->oField->GetLabel(), true)
->AddHtml('</label>');
}
@@ -70,8 +68,7 @@ class BsSetFieldRenderer extends BsFieldRenderer
// Value
$oOutput->AddHtml('<div class="form_field_control">');
// ... in edit mode
if(!$this->oField->GetReadOnly())
{
if (!$this->oField->GetReadOnly()) {
$oAttDef = MetaModel::GetAttributeDef($oOrmItemSet->GetClass(), $oOrmItemSet->GetAttCode());
$sJSONForWidget = $oAttDef->GetJsonForWidget($oOrmItemSet);
@@ -79,16 +76,16 @@ class BsSetFieldRenderer extends BsFieldRenderer
$oOutput->AddHtml('<div class="help-block"></div>');
// - Value regarding the field type
$oOutput->AddHtml('<input type="hidden" id="' . $this->oField->GetGlobalId() . '" name="' . $this->oField->GetId() . '" value="')
$oOutput->AddHtml('<input type="hidden" id="'.$this->oField->GetGlobalId().'" name="'.$this->oField->GetId().'" value="')
->AddHtml($sJSONForWidget, true)
->AddHtml('" class="form-control" />');
// Attaching JS widget only if field is hidden or NOT read only
// JS Form field widget construct
$aValidators = array();
$aValidators = [];
$sValidators = json_encode($aValidators);
$oOutput->AddJs(
<<<EOF
<<<EOF
$("[data-field-id='{$this->oField->GetId()}'][data-form-path='{$this->oField->GetFormPath()}']").portal_form_field_set({
validators: $sValidators,
// Overloading default callback as the Selectize widget adds several inputs and we want to retrieve only the one with the value.
@@ -105,18 +102,17 @@ EOF
);
}
// ... in view mode
else
{
else {
if ($oOrmItemSet instanceof \ormTagSet) {
$aItems = $oOrmItemSet->GetTags();
$fExtractTagData = static function($oTag, &$sItemLabel, &$sItemDescription) {
$fExtractTagData = static function ($oTag, &$sItemLabel, &$sItemDescription) {
$sItemLabel = $oTag->Get('label');
$sItemDescription = $oTag->Get('description');
};
} else {
$aItems = $oOrmItemSet->GetValues();
$oAttDef = MetaModel::GetAttributeDef($oOrmItemSet->GetClass(), $oOrmItemSet->GetAttCode());
$fExtractTagData = static function($sEnumSetValue, &$sItemLabel, &$sItemDescription) use ($oAttDef) {
$fExtractTagData = static function ($sEnumSetValue, &$sItemLabel, &$sItemDescription) use ($oAttDef) {
$sItemLabel = $oAttDef->GetValueLabel($sEnumSetValue);
$sItemDescription = '';
};
@@ -124,8 +120,7 @@ EOF
$oOutput->AddHtml('<div class="form-control-static">')
->AddHtml('<span class="label-group">');
foreach($aItems as $sItemCode => $value)
{
foreach ($aItems as $sItemCode => $value) {
$fExtractTagData($value, $sItemLabel, $sItemDescription);
$sDescriptionAttr = (empty($sItemDescription))