diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index 492a3c4db..3e9ba7f47 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -1894,7 +1894,7 @@ HTML null, $sPredefinedBtnId ); - $oPredefQueryButton->AddCSSClasses('ibo-action-button'); + $oPredefQueryButton->AddCSSClass('ibo-action-button'); $oPredefQueryRenderer = new BlockRenderer($oPredefQueryButton); $sAdditionalStuff = $oPredefQueryRenderer->RenderHtml(); $oPage->add_ready_script(<<AddCSSClasses('ibo-action-button'); + $oTestQueryButton->AddCSSClass('ibo-action-button'); $oPage->add_ready_script(<<SetCSSClasses("object-details") + $oContentBlock->SetCSSClasses(['object-details']) ->AddDataAttribute('object-class', $sClass) ->AddDataAttribute('object-id', $iKey) ->AddDataAttribute('object-mode', $sMode); @@ -2538,7 +2538,7 @@ JS } $oContentBlock = new UIContentBlock(); - $oContentBlock->SetCSSClasses("object-details") + $oContentBlock->SetCSSClasses(['object-details']) ->AddDataAttribute('object-class', $sClass) ->AddDataAttribute('object-id', $iKey) ->AddDataAttribute('object-mode', $sMode); @@ -2587,13 +2587,13 @@ JS CSS ); $oToolbarTop = new Toolbar(); - $oToolbarTop->SetCSSClasses('ibo-toolbar ibo-toolbar-top'); + $oToolbarTop->SetCSSClasses(['ibo-toolbar', 'ibo-toolbar-top']); $oCancelButton = ButtonUIBlockFactory::MakeForSecondaryAction(Dict::S('UI:Button:Cancel')); - $oCancelButton->AddCSSClasses('action cancel'); + $oCancelButton->AddCSSClasses(['action', 'cancel']); $oToolbarTop->AddSubBlock($oCancelButton); $oApplyButton = ButtonUIBlockFactory::MakeForPrimaryAction($sApplyButton, null, null, true); - $oApplyButton->AddCSSClasses('action'); + $oApplyButton->AddCSSClass('action'); $oToolbarTop->AddSubBlock($oApplyButton); $aTransitions = $this->EnumTransitions(); @@ -2607,7 +2607,7 @@ CSS switch ($iActionAllowed) { case UR_ALLOWED_YES: $oButton = ButtonUIBlockFactory::MakeForPrimaryAction($aStimuli[$sStimulusCode]->GetLabel(), 'next_action', $sStimulusCode, true); - $oButton->AddCSSClasses('action'); + $oButton->AddCSSClass('action'); $oButton->SetColor(Button::ENUM_COLOR_NEUTRAL); $oToolbarTop->AddSubBlock($oButton); break; @@ -2714,7 +2714,7 @@ EOF // bottom or both: display the buttons here $oPage->p($sStatesSelection); $oToolbarBottom = new Toolbar(); - $oToolbarBottom->SetCSSClasses('ibo-toolbar'); + $oToolbarBottom->SetCSSClasses(['ibo-toolbar']); foreach ($oToolbarTop->GetSubBlocks() as $oButton) { $oToolbarBottom->AddSubBlock($oButton); } @@ -3047,7 +3047,7 @@ HTML $this->DisplayDetails($oPage, false, $sMode); } - $oFormContainer = new UIContentBlock(null, 'ibo-wizard-container'); + $oFormContainer = new UIContentBlock(null, ['ibo-wizard-container']); $oPage->AddUiBlock($oFormContainer); $oForm = new Combodo\iTop\Application\UI\Base\Component\Form\Form('apply_stimulus'); $oFormContainer->AddSubBlock($oForm); diff --git a/application/dashboard.class.inc.php b/application/dashboard.class.inc.php index e10716e72..49302f467 100644 --- a/application/dashboard.class.inc.php +++ b/application/dashboard.class.inc.php @@ -1090,7 +1090,7 @@ JS $sName = 'UI:Dashboard:Actions'; $oToolbar = $oPage->GetTopBarLayout()->GetToolbar(); $oActionButton = ButtonUIBlockFactory::MakeLinkNeutral('', '', 'fas fa-ellipsis-v', $sName, '', $sMenuTogglerId); - $oActionButton->AddCSSClasses("ibo-top-bar--toolbar-dashboard-menu-toggler"); + $oActionButton->AddCSSClass('ibo-top-bar--toolbar-dashboard-menu-toggler'); $oToolbar->AddSubBlock($oActionButton); @@ -1115,7 +1115,7 @@ JS utils::GetPopupMenuItems($oPage, iPopupMenuExtension::MENU_DASHBOARD_ACTIONS, $this, $aActions); $oToolbar->AddSubBlock($oPage->GetPopoverMenu($sPopoverMenuId, $aActions)); - $oActionButton->AddCSSClasses('ibo-action-button') + $oActionButton->AddCSSClass('ibo-action-button') ->SetJsCode(<<GetID(); - $sCSSClasses = implode(' ', $this->aCSSClasses); if ($bEnclosingDiv) { if ($bEditMode) { $oDashletContainer = new DashletContainer("dashlet_{$sId}"); } else { $oDashletContainer = new DashletContainer(); } - $oDashletContainer->AddCSSClasses($sCSSClasses); + $oDashletContainer->AddCSSClasses($this->aCSSClasses); } else { $oDashletContainer = new DashletContainer(); @@ -239,14 +238,14 @@ abstract class Dashlet // Maybe the class is part of a non-installed module, fail silently // Except in Edit mode if ($bEditMode) { - $oDashletContainer->AddCSSClasses("dashlet-content"); + $oDashletContainer->AddCSSClass("dashlet-content"); $oDashletContainer->AddHtml('

'.$e->GetUserFriendlyDescription().'

'); } } catch (OqlException $e) { - $oDashletContainer->AddCSSClasses("dashlet-content"); + $oDashletContainer->AddCSSClass("dashlet-content"); $oDashletContainer->AddHtml('

'.$e->GetUserFriendlyDescription().'

'); } catch (Exception $e) { - $oDashletContainer->AddCSSClasses("dashlet-content"); + $oDashletContainer->AddCSSClass("dashlet-content"); $oDashletContainer->AddHtml('

'.$e->getMessage().'

'); } @@ -602,7 +601,7 @@ class DashletUnknown extends Dashlet $sIconUrl = utils::HtmlEntities(utils::GetAbsoluteUrlAppRoot().$aInfos['icon']); $sExplainText = ($bEditMode) ? Dict::Format('UI:DashletUnknown:RenderText:Edit', $this->GetDashletType()) : Dict::S('UI:DashletUnknown:RenderText:View'); - $oDashletContainer = new DashletContainer(null, 'dashlet-content'); + $oDashletContainer = new DashletContainer(null, ['dashlet-content']); $oDashletContainer->AddHtml('
'); $oDashletContainer->AddHtml('
'.$sExplainText.'
'); @@ -622,7 +621,7 @@ class DashletUnknown extends Dashlet $sIconUrl = utils::HtmlEntities(utils::GetAbsoluteUrlAppRoot().$aInfos['icon']); $sExplainText = Dict::Format('UI:DashletUnknown:RenderNoDataText:Edit', $this->GetDashletType()); - $oDashletContainer = new DashletContainer(null, 'dashlet-content'); + $oDashletContainer = new DashletContainer(null, ['dashlet-content']); $oDashletContainer->AddHtml('
'); $oDashletContainer->AddHtml('
'.$sExplainText.'
'); @@ -746,7 +745,7 @@ class DashletProxy extends DashletUnknown public function Render($oPage, $bEditMode = false, $aExtraParams = array()) { // This should never be called. - $oDashletContainer = new DashletContainer(null, 'dashlet-content'); + $oDashletContainer = new DashletContainer(null, ['dashlet-content']); $oDashletContainer->AddHtml('
This dashlet is not supposed to be rendered as it is just a proxy for third-party widgets.
'); return $oDashletContainer; } @@ -763,7 +762,7 @@ class DashletProxy extends DashletUnknown $sIconUrl = utils::HtmlEntities(utils::GetAbsoluteUrlAppRoot().$aInfos['icon']); $sExplainText = Dict::Format('UI:DashletProxy:RenderNoDataText:Edit', $this->GetDashletType()); - $oDashletContainer = new DashletContainer(null, 'dashlet-content'); + $oDashletContainer = new DashletContainer(null, ['dashlet-content']); $sHtml = ''; $sHtml .= '
'; @@ -1333,7 +1332,7 @@ abstract class DashletGroupBy extends Dashlet */ public function RenderNoData($oPage, $bEditMode = false, $aExtraParams = array()) { - $oDashletContainer = new DashletContainer(null, 'dashlet-content'); + $oDashletContainer = new DashletContainer(null, ['dashlet-content']); $oDashletContainer->AddHtml('error!'); return $oDashletContainer; } @@ -1656,7 +1655,7 @@ class DashletGroupByPie extends DashletGroupBy */ public function RenderNoData($oPage, $bEditMode = false, $aExtraParams = array()) { - $oDashletContainer = new DashletContainer(null, 'dashlet-content'); + $oDashletContainer = new DashletContainer(null, ['dashlet-content']); $sTitle = $this->aProperties['title']; @@ -1731,7 +1730,7 @@ class DashletGroupByBars extends DashletGroupBy */ public function RenderNoData($oPage, $bEditMode = false, $aExtraParams = array()) { - $oDashletContainer = new DashletContainer(null, 'dashlet-content'); + $oDashletContainer = new DashletContainer(null, ['dashlet-content']); $sTitle = $this->aProperties['title']; @@ -2087,7 +2086,7 @@ class DashletHeaderDynamic extends Dashlet $oIconSelect = $this->oModelReflection->GetIconSelectionField('icon'); $sIconPath = utils::HtmlEntities($oIconSelect->MakeFileUrl($sIcon)); - $oDashletContainer = new DashletContainer(null, 'dashlet-content'); + $oDashletContainer = new DashletContainer(null, ['dashlet-content']); $sHtml = ''; $sHtml .= ''; @@ -2284,7 +2283,7 @@ class DashletBadge extends Dashlet */ public function Render($oPage, $bEditMode = false, $aExtraParams = array()) { - $oDashletContainer = new DashletContainer($this->sId, 'dashlet-content'); + $oDashletContainer = new DashletContainer($this->sId, ['dashlet-content']); $sClass = $this->aProperties['class']; $oFilter = new DBObjectSearch($sClass); @@ -2301,7 +2300,7 @@ class DashletBadge extends Dashlet */ public function RenderNoData($oPage, $bEditMode = false, $aExtraParams = array()) { - $oDashletContainer = new DashletContainer($this->sId, 'dashlet-content'); + $oDashletContainer = new DashletContainer($this->sId, ['dashlet-content']); $sClass = $this->aProperties['class']; $sIconUrl = $this->oModelReflection->GetClassIcon($sClass, false); diff --git a/application/displayblock.class.inc.php b/application/displayblock.class.inc.php index 9d5c18c95..08bb7a773 100644 --- a/application/displayblock.class.inc.php +++ b/application/displayblock.class.inc.php @@ -396,7 +396,7 @@ class DisplayBlock public function GetDisplay(WebPage $oPage, $sId, $aExtraParams = array()): UIContentBlock { $oHtml = new UIContentBlock($sId); - $oHtml->AddCSSClasses("display_block"); + $oHtml->AddCSSClass("display_block"); $aExtraParams = array_merge($aExtraParams, $this->m_aParams); $aExtraParams['currentId'] = $sId; $sExtraParams = addslashes(str_replace('"', "'", json_encode($aExtraParams))); // JSON encode, change the style of the quotes and escape them @@ -432,7 +432,7 @@ HTML; } } else { // render it as an Ajax (asynchronous) call - $oHtml->AddCSSClasses("loading"); + $oHtml->AddCSSClass("loading"); $oHtml->AddHtml("

".Dict::S('UI:Loading').'

'); $oPage->add_script(' $.post("ajax.render.php?style='.$this->m_sStyle.'", @@ -976,7 +976,7 @@ JS } } - $oBlock = new UIContentBlock(null, "ibo-dashlet-header-dynamic--container"); + $oBlock = new UIContentBlock(null, ["ibo-dashlet-header-dynamic--container"]); foreach ($aStateLabels as $sStateValue => $sStateLabel) { $aCount = $aCounts[$sStateValue]; $oBadge = BadgeFactory::MakeForState($sClass, $sStateValue); @@ -2071,7 +2071,7 @@ class MenuBlock extends DisplayBlock } } - $oActionsBlock = new Toolbar("ibo-action-toolbar-{$sId}", 'ibo-action-toolbar'); + $oActionsBlock = new Toolbar("ibo-action-toolbar-{$sId}", ['ibo-action-toolbar']); $oRenderBlock->AddSubBlock($oActionsBlock); $sMenuTogglerId = "ibo-actions-menu-toggler-{$sId}"; $sPopoverMenuId = "ibo-other-action-popover-{$sId}"; @@ -2087,7 +2087,7 @@ class MenuBlock extends DisplayBlock // TODO Add Js $oActionsBlock->AddSubBlock($oActionButton) ->AddSubBlock($oPage->GetPopoverMenu($sPopoverMenuId, $aActions)); - $oActionButton->AddCSSClasses('ibo-action-button') + $oActionButton->AddCSSClass('ibo-action-button') ->SetJsCode(<<m_sStyle == 'details') { $oActionButton = ButtonUIBlockFactory::MakeLinkNeutral("{$sRootUrl}pages/UI.php?operation=search_form&do_search=0&class=$sClass{$sContext}", '', 'fas fa-search', 'UI:SearchFor_Class'); $oActionButton->SetTooltip(Dict::Format('UI:SearchFor_Class', MetaModel::GetName($sClass))) - ->AddCSSClasses('ibo-action-button'); + ->AddCSSClass('ibo-action-button'); $oActionsBlock->AddSubBlock($oActionButton); } @@ -2118,7 +2118,7 @@ JS $oActionButton->SetIconClass('fas fa-sync') ->SetOnClickJsCode($sRefreshAction) ->SetTooltip(Dict::S('UI:Button:Refresh')) - ->AddCSSClasses('ibo-action-button'); + ->AddCSSClass('ibo-action-button'); $oActionsBlock->AddSubBlock($oActionButton); } @@ -2158,7 +2158,7 @@ JS $sTarget = isset($aAction['target']) ? $aAction['target'] : ''; $oActionButton = ButtonUIBlockFactory::MakeLinkNeutral($sUrl, $sLabel, $sIconClass, $sActionId, $sTarget); - $oActionButton->AddCSSClasses('ibo-action-button'); + $oActionButton->AddCSSClass('ibo-action-button'); $oActionsBlock->AddSubBlock($oActionButton); } } diff --git a/application/ui.linkswidget.class.inc.php b/application/ui.linkswidget.class.inc.php index dc81c3b4e..92f7bcffe 100644 --- a/application/ui.linkswidget.class.inc.php +++ b/application/ui.linkswidget.class.inc.php @@ -379,7 +379,7 @@ JS { $sLinkedSetId = "{$this->m_sAttCode}{$this->m_sNameSuffix}"; - $oBlock = new BlockIndirectLinksEdit("linkedset_{$sLinkedSetId}", "ibo-block-indirect-links--edit"); + $oBlock = new BlockIndirectLinksEdit("linkedset_{$sLinkedSetId}", ["ibo-block-indirect-links--edit"]); $oBlock->sLinkedSetId = $sLinkedSetId; $oBlock->sClass = $this->m_sClass; diff --git a/datamodels/2.x/itop-core-update/view/ConfirmUpdate.html.twig b/datamodels/2.x/itop-core-update/view/ConfirmUpdate.html.twig index 4245702ff..6cba29d1f 100644 --- a/datamodels/2.x/itop-core-update/view/ConfirmUpdate.html.twig +++ b/datamodels/2.x/itop-core-update/view/ConfirmUpdate.html.twig @@ -2,7 +2,7 @@ {# @license http://opensource.org/licenses/AGPL-3.0 #} {% apply spaceless %} -{% UIContentBlock Standard {'sContainerClass':'ibo-update-core display_block display-files'} %} +{% UIContentBlock Standard {'aContainerClasses' []:'ibo-update-core', 'display_block', 'display-files']} %} {% if bSuccess %} diff --git a/datamodels/2.x/itop-core-update/view/SelectUpdateFile.html.twig b/datamodels/2.x/itop-core-update/view/SelectUpdateFile.html.twig index 7dbb85f32..a1960f9f6 100644 --- a/datamodels/2.x/itop-core-update/view/SelectUpdateFile.html.twig +++ b/datamodels/2.x/itop-core-update/view/SelectUpdateFile.html.twig @@ -2,16 +2,16 @@ {# @license http://opensource.org/licenses/AGPL-3.0 #} {% apply spaceless %} -{% UIContentBlock Standard {'sContainerClass':'ibo-update-core'} %} +{% UIContentBlock Standard {'aContainerClasses':['ibo-update-core']} %} {% UITitle ForPage {'sTitle':'iTopUpdate:UI:PageTitle'|dict_s} %}
 
- {% UIContentBlock Standard {'sContainerClass':'display_block display-files'} %} + {% UIContentBlock Standard {'aContainerClasses': ['display_block', 'display-files']} %} {% UIFieldSet Standard {'sLegend':'iTopUpdate:UI:Status'|dict_s} %} {% UIAlert ForInformation {'sId':'header-requirements', 'IsCollapsible':false, 'IsClosable':false} %} - {% UIContentBlock Standard {'sContainerClass':'ibo-update-core-header-requirements', 'sId':'can-core-update'} %} + {% UIContentBlock Standard {'aContainerClasses':['ibo-update-core-header-requirements'], 'sId':'can-core-update'} %} {{ 'iTopUpdate:UI:CanCoreUpdate:Loading'|dict_s }} {% UISpinner Standard {} %} {% EndUIContentBlock %} @@ -45,18 +45,18 @@ {% UIInput ForHidden {'sName':'transaction_id', 'sValue':sTransactionId} %} {% UIAlert ForFailure {'sId':'header-file-size', 'IsHidden':true} %} - {% UIContentBlock Standard {'sContainerClass':'ibo-file-size-error'} %} + {% UIContentBlock Standard {'aContainerClasses':['ibo-file-size-error']} %} {{ 'iTopUpdate:Error:FileUploadMaxSizeTooSmall'|dict_s }} {% EndUIContentBlock %} - {% UIContentBlock Standard {'sContainerClass':'ibo-file-size-error'} %} + {% UIContentBlock Standard {'aContainerClasses':['ibo-file-size-error']} %} {{ 'iTopUpdate:UI:PostMaxSize'|dict_format(sPostMaxSize) }} {% EndUIContentBlock %} - {% UIContentBlock Standard {'sContainerClass':'ibo-file-size-error'} %} + {% UIContentBlock Standard {'aContainerClasses':['ibo-file-size-error']} %} {{ 'iTopUpdate:UI:UploadMaxFileSize'|dict_format(sUploadMaxSize) }} {% EndUIContentBlock %} {% EndUIAlert %} - {% UIContentBlock Standard {'sContainerClass':'upload_container'} %} + {% UIContentBlock Standard {'aContainerClasses':['upload_container']} %} {% UIInput Standard {'sType':'file', 'sId':'file', 'sName':'file', 'sValue':''} %} {% EndUIContentBlock %} @@ -72,7 +72,7 @@ {% UIInput Standard {'sType':'checkbox', 'sId':'doFilesArchive', 'sName':'doFilesArchive', 'sValue':'1', 'IsChecked':true} %} {% EndUIField %} - {% UIContentBlock Standard {'sContainerClass':'ibo_check_update_submit'} %} + {% UIContentBlock Standard {'aContainerClasses':['ibo_check_update_submit']} %} {% UIButton ForPrimaryAction {'sLabel':'iTopUpdate:UI:CheckUpdate'|dict_s, 'sId':'check-update', 'bIsSubmit':true, 'IsDisabled':true} %} {% UISpinner Standard {'sId':'submit-wait', 'IsHidden':true} %} {% EndUIContentBlock %} diff --git a/datamodels/2.x/itop-core-update/view/UpdateCoreFiles.html.twig b/datamodels/2.x/itop-core-update/view/UpdateCoreFiles.html.twig index e2afe70e1..083ca03eb 100644 --- a/datamodels/2.x/itop-core-update/view/UpdateCoreFiles.html.twig +++ b/datamodels/2.x/itop-core-update/view/UpdateCoreFiles.html.twig @@ -3,7 +3,7 @@ {% apply spaceless %} - {% UIContentBlock Standard {'sContainerClass':'ibo-update-core display_block display-files'} %} + {% UIContentBlock Standard {'aContainerClasses': []'ibo-update-core', 'display_block', 'display-files']} %} {% UIFieldSet Standard {'sLegend':'iTopUpdate:UI:Progress'|dict_s, 'sId':'installation_progress'} %} {# Todo 3.0 Add Progress bar UIBlock #} @@ -18,13 +18,13 @@ {% UIFieldSet Standard {'sLegend':'iTopUpdate:UI:Status'|dict_s} %} {% UIField Large {'sId':'new_version', 'sLabel':'iTopUpdate:UI:NewVersion'|dict_s, 'ValueId':'db-disk-space', 'IsHidden':true} %}{% EndUIField %} {% UIAlert ForInformation {'sId':'current_version', 'IsCollapsible':false, 'IsClosable':false} %} - {% UIContentBlock Standard {'sId':'current-version','sContainerClass':'ibo-update-core--current-version'} %} + {% UIContentBlock Standard {'sId':'current-version','aContainerClasses':['ibo-update-core--current-version']} %} {{ sCurrentVersion }} {% EndUIContentBlock %} {% EndUIAlert %} {% if bDoBackup %} - {% UIContentBlock Standard {'sId':'do_backup_done','sContainerClass':'ibo-update-core--backup-done', 'IsHidden':true} %} + {% UIContentBlock Standard {'sId':'do_backup_done','aContainerClasses':['ibo-update-core--backup-done'], 'IsHidden':true} %} {% UIField Standard {'sLabel':'iTopUpdate:UI:WithDBBackup'|dict_s, 'sLayout':'large'} %} {% UIAlert ForInformation {'sContent':sBackupFile} %}{% EndUIAlert %} {% EndUIField %} @@ -32,7 +32,7 @@ {% endif %} {% if bDoFilesArchive %} - {% UIContentBlock Standard {'sId':'do_files_archive_done','sContainerClass':'ibo-update-core--archive-done', 'IsHidden':true} %} + {% UIContentBlock Standard {'sId':'do_files_archive_done','aContainerClasses':['ibo-update-core--archive-done'], 'IsHidden':true} %} {% UIField Large {'sLabel':'iTopUpdate:UI:WithFilesBackup'|dict_s} %}{% EndUIField %} {% UIAlert ForSuccess {'sContent':sItopArchive} %}{% EndUIAlert %} {% EndUIContentBlock %} @@ -42,7 +42,7 @@ {% UIFieldSet Standard {'sLegend':''} %} {% UIAlert ForFailure {'sId':'setup_error_outer', 'sContent':'', 'IsCollapsible':false, 'IsClosable':false, 'IsHidden':true} %} - {% UIContentBlock Standard {'sId':'setup_error','sContainerClass':'ibo-update-core--error'} %}{% EndUIContentBlock %} + {% UIContentBlock Standard {'sId':'setup_error','aContainerClasses':['ibo-update-core--error']} %}{% EndUIContentBlock %} {% if bDoFilesArchive %} {{ 'iTopUpdate:UI:RestoreArchive'|dict_format(sItopArchive) }} {% endif %} @@ -52,7 +52,7 @@ {{ 'iTopUpdate:UI:MaintenanceModeActive'|dict_s }} {% EndUIAlert %} - {% UIContentBlock Standard {'sId':'run_setup','sContainerClass':'ibo-update-core--run-setup', 'IsHidden':true} %} + {% UIContentBlock Standard {'sId':'run_setup','aContainerClasses':['ibo-update-core--run-setup'], 'IsHidden':true} %} {% UIForm Standard {'CSSClasses':'form-inline'} %} {% UIInput ForHidden {'sName':'operation', 'sValue':'RunSetup'} %} {% UIInput ForHidden {'sName':'authent', 'sValue':sSetupToken} %} diff --git a/pages/UI.php b/pages/UI.php index 1afcbab46..3cc16f19e 100644 --- a/pages/UI.php +++ b/pages/UI.php @@ -248,7 +248,7 @@ function DisplaySearchSet($oP, $oFilter, $bSearchForm = true, $sBaseClass = '', $oUIBlockForm = $oBlockForm->GetDisplay($oP, 'search_1',$aExtraParams); //add result block $oUIBlock = $oBlock->GetDisplay($oP, $sTableId); - $oUIBlock->AddCSSClasses("display_block sf_results_area"); + $oUIBlock->AddCSSClasses(['display_block', 'sf_results_area']); $oUIBlock->AddDataAttribute('target', 'search_results'); //$oUIBlockForm->AddSubBlock($oUIBlock); $oP->AddUiBlock($oUIBlockForm); diff --git a/pages/preferences.php b/pages/preferences.php index c5e4b4ec2..4337f74f2 100644 --- a/pages/preferences.php +++ b/pages/preferences.php @@ -150,7 +150,7 @@ JS ])); $oFavoriteOrganizationsForm->AddSubBlock($oAppContext->GetForFormBlock()); - $oFavoriteOrganizationsToolBar = new UIContentBlock(null, 'ibo-datatable--selection-validation-buttons-toolbar'); + $oFavoriteOrganizationsToolBar = new UIContentBlock(null, ['ibo-datatable--selection-validation-buttons-toolbar']); $oFavoriteOrganizationsForm->AddSubBlock($oFavoriteOrganizationsToolBar); // - Cancel button $oFavoriteOrganizationsCancelButton = ButtonUIBlockFactory::MakeForSecondaryAction(Dict::S('UI:Button:Cancel')); @@ -197,7 +197,7 @@ JS $oSet = new DBObjectSet($oShortcutsFilter); if ($oSet->Count() > 0) { - $oShortcutsToolBar = new UIContentBlock(null, 'ibo-datatable--selection-validation-buttons-toolbar'); + $oShortcutsToolBar = new UIContentBlock(null, ['ibo-datatable--selection-validation-buttons-toolbar']); $oShortcutsBlock->AddSubBlock($oShortcutsToolBar); // - Rename button $oShortcutsRenameButton = ButtonUIBlockFactory::MakeForSecondaryAction(Dict::S('UI:Button:Rename'), null, null, false, diff --git a/pages/run_query.php b/pages/run_query.php index 73992656d..1d5295082 100644 --- a/pages/run_query.php +++ b/pages/run_query.php @@ -196,7 +196,7 @@ EOF if (count($aArgs) > 0) { //--- Query arguments $oQueryArgsContainer = PanelFactory::MakeForInformation('Query arguments') - ->SetCSSClasses('wizContainer'); + ->SetCSSClasses(['wizContainer']); $oQueryForm->AddSubBlock($oQueryArgsContainer); foreach ($aArgs as $sParam => $sValue) { $oArgInput = InputFactory::MakeForInputWithLabel( diff --git a/sources/application/UI/Base/Component/Badge/Badge.php b/sources/application/UI/Base/Component/Badge/Badge.php index a7ea63d12..02d46d307 100644 --- a/sources/application/UI/Base/Component/Badge/Badge.php +++ b/sources/application/UI/Base/Component/Badge/Badge.php @@ -17,7 +17,7 @@ class Badge extends UIContentBlock public function __construct(string $sColor) { - parent::__construct(null, "ibo-badge ibo-badge-is-{$sColor}"); + parent::__construct(null, ["ibo-badge ibo-badge-is-{$sColor}"]); $this->SetColor($sColor); } diff --git a/sources/application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php b/sources/application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php index 08ea1ace5..c6f5b9065 100644 --- a/sources/application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php +++ b/sources/application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php @@ -114,7 +114,7 @@ class DataTableUIBlockFactory extends AbstractUIBlockFactory } if (!isset($aExtraParams['surround_with_panel']) || $aExtraParams['surround_with_panel']) { - $oContainer = PanelUIBlockFactory::MakeForClass($oSet->GetClass(), "Result")->AddCSSClasses('ibo-datatable-panel'); + $oContainer = PanelUIBlockFactory::MakeForClass($oSet->GetClass(), "Result")->AddCSSClass('ibo-datatable-panel'); $oContainer->AddToolbarBlock($oBlockMenu); $oContainer->AddMainBlock($oDataTable); } else { diff --git a/sources/application/UI/Base/Component/DataTable/StaticTable/FormTable/FormTable.php b/sources/application/UI/Base/Component/DataTable/StaticTable/FormTable/FormTable.php index a6a0c0863..33d4e9734 100644 --- a/sources/application/UI/Base/Component/DataTable/StaticTable/FormTable/FormTable.php +++ b/sources/application/UI/Base/Component/DataTable/StaticTable/FormTable/FormTable.php @@ -29,9 +29,9 @@ class FormTable extends StaticTable /** @var iUIBlock[] */ private $aRows; - public function __construct(string $sRef, string $sContainerCSSClasses = '') + public function __construct(string $sRef, array $aContainerCSSClasses = []) { - parent::__construct($sRef, $sContainerCSSClasses); + parent::__construct($sRef, $aContainerCSSClasses); $this->SetRef($sRef); $this->aRows = []; } diff --git a/sources/application/UI/Base/Component/DataTable/StaticTable/StaticTable.php b/sources/application/UI/Base/Component/DataTable/StaticTable/StaticTable.php index 9feb1d5f3..34e46cdad 100644 --- a/sources/application/UI/Base/Component/DataTable/StaticTable/StaticTable.php +++ b/sources/application/UI/Base/Component/DataTable/StaticTable/StaticTable.php @@ -52,9 +52,9 @@ class StaticTable extends UIContentBlock */ private $aData; - public function __construct(string $sId = null, string $sContainerCSSClasses = '') + public function __construct(string $sId = null, array $aContainerCSSClasses = []) { - parent::__construct($sId, $sContainerCSSClasses); + parent::__construct($sId, $aContainerCSSClasses); $this->aColumns = []; $this->aData = []; } diff --git a/sources/application/UI/Base/Component/FieldBadge/FieldBadge.php b/sources/application/UI/Base/Component/FieldBadge/FieldBadge.php index 6813f50f5..b1d972f97 100644 --- a/sources/application/UI/Base/Component/FieldBadge/FieldBadge.php +++ b/sources/application/UI/Base/Component/FieldBadge/FieldBadge.php @@ -19,8 +19,8 @@ class FieldBadge extends UIContentBlock // Overloaded constants public const BLOCK_CODE = 'ibo-field-badge'; - public function __construct(string $sId = null, string $sContainerClasses = '') + public function __construct(string $sId = null, array $aContainerClasses = []) { - parent::__construct($sId, $sContainerClasses); + parent::__construct($sId, $aContainerClasses); } } \ No newline at end of file diff --git a/sources/application/UI/Base/Component/FieldBadge/FieldBadgeUIBlockFactory.php b/sources/application/UI/Base/Component/FieldBadge/FieldBadgeUIBlockFactory.php index 6fdec5a67..beab28003 100644 --- a/sources/application/UI/Base/Component/FieldBadge/FieldBadgeUIBlockFactory.php +++ b/sources/application/UI/Base/Component/FieldBadge/FieldBadgeUIBlockFactory.php @@ -30,7 +30,8 @@ class FieldBadgeUIBlockFactory extends AbstractUIBlockFactory $sPrimaryColor = $oStyle->GetMainColor(); $sComplementaryColor = $oStyle->GetComplementaryColor(); if (!is_null($sPrimaryColor) && !is_null($sComplementaryColor)) { - $oBadge = new FieldBadge(null, $sStyleClass.' ibo-field-badge'); + $aCSSClasses = array_merge(explode(' ', $sStyleClass), ['ibo-field-badge']); + $oBadge = new FieldBadge(null, $aCSSClasses); $sDecorationClasses = $oStyle->GetDecorationClasses(); if (!is_null($sDecorationClasses)) { $oBadge->AddHtml(" "); diff --git a/sources/application/UI/Base/Layout/UIContentBlock.php b/sources/application/UI/Base/Layout/UIContentBlock.php index 84fc37623..0a7084e0d 100644 --- a/sources/application/UI/Base/Layout/UIContentBlock.php +++ b/sources/application/UI/Base/Layout/UIContentBlock.php @@ -35,18 +35,18 @@ class UIContentBlock extends UIBlock implements iUIContentBlock /** * UIContentBlock constructor. - * Generates a
only if $sContainerClass if not empty or block has data attributes + * Generates a
only if $aContainerClasses if not empty or block has data attributes * * @param string|null $sId - * @param string $sContainerClasses list of additional CSS classes, space as separator + * @param array $aContainerClasses Array of additional CSS classes */ - public function __construct(string $sId = null, string $sContainerClasses = '') + public function __construct(string $sId = null, array $aContainerClasses = []) { parent::__construct($sId); $this->aSubBlocks = []; $this->aDeferredBlocks = []; - $this->SetCSSClasses($sContainerClasses); + $this->SetCSSClasses($aContainerClasses); } /** diff --git a/sources/application/UI/Base/Layout/UIContentBlockUIBlockFactory.php b/sources/application/UI/Base/Layout/UIContentBlockUIBlockFactory.php index b9e87d1f3..840dc45bd 100644 --- a/sources/application/UI/Base/Layout/UIContentBlockUIBlockFactory.php +++ b/sources/application/UI/Base/Layout/UIContentBlockUIBlockFactory.php @@ -15,8 +15,8 @@ class UIContentBlockUIBlockFactory extends AbstractUIBlockFactory public const TWIG_TAG_NAME = 'UIContentBlock'; public const UI_BLOCK_CLASS_NAME = UIContentBlock::class; - public static function MakeStandard(string $sId = null, string $sContainerClass = '') + public static function MakeStandard(string $sId = null, array $aContainerClasses = []) { - return new UIContentBlock($sId, $sContainerClass); + return new UIContentBlock($sId, $aContainerClasses); } } \ No newline at end of file diff --git a/sources/application/UI/Base/UIBlock.php b/sources/application/UI/Base/UIBlock.php index 4bafd2c25..202521df7 100644 --- a/sources/application/UI/Base/UIBlock.php +++ b/sources/application/UI/Base/UIBlock.php @@ -307,17 +307,55 @@ abstract class UIBlock implements iUIBlock } /** - * @param string $sCSSClasses with space as separator, like ibo-is-hidden ibo-alert--body + * Note: If $sCSSClass is already present, proceeds silently + * + * @param string $sCSSClass * * @return $this * - * @use aAdditionalCSSClasses + * @uses $aAdditionalCSSClasses */ - public function AddCSSClasses(string $sCSSClasses) + public function AddCSSClass(string $sCSSClass) { - foreach (explode(' ', $sCSSClasses) as $sCSSClass) { + $sCSSClass = trim($sCSSClass); + + if (!array_key_exists($sCSSClass, $this->aAdditionalCSSClasses)) { + $this->aAdditionalCSSClasses[] = $sCSSClass; + } + + return $this; + } + + /** + * Note: If $sCSSClass is not present, proceeds silently + * + * @param string $sCSSClass + * + * @return $this + * + * @uses $aAdditionalCSSClasses + */ + public function RemoveCSSClass(string $sCSSClass) + { + if (array_key_exists($sCSSClass, $this->aAdditionalCSSClasses)) { + unset($this->aAdditionalCSSClasses[$sCSSClass]); + } + + return $this; + } + + /** + * @param array $aCSSClasses like ['ibo-is-hidden', 'ibo-alert--body'] + * + * @return $this + * + * @uses $aAdditionalCSSClasses + */ + public function AddCSSClasses(array $aCSSClasses) + { + foreach ($aCSSClasses as $sCSSClass) { if (!empty($sCSSClass)) { - $this->aAdditionalCSSClasses[$sCSSClass] = $sCSSClass; + $this->AddCSSClass($sCSSClass); } } @@ -327,26 +365,39 @@ abstract class UIBlock implements iUIBlock /** * Overrides additional classes with the specified value * - * @param string $sCSSClasses with space as separator, like ibo-is-hidden ibo-alert--body + * @param array $aCSSClasses like ['ibo-is-hidden', 'ibo-alert--body'] * * @return $this * - * @use aAdditionalCSSClasses + * @uses $aAdditionalCSSClasses */ - public function SetCSSClasses(string $sCSSClasses) + public function SetCSSClasses(array $aCSSClasses) { $this->aAdditionalCSSClasses = []; - $this->AddCSSClasses($sCSSClasses); + $this->AddCSSClasses($aCSSClasses); return $this; } /** - * @return string + * @return array + * + * @uses $aAdditionalCSSClasses + * @see static::GetAdditionalCSSClassesAsString() for a simpler usage in the views */ - public function GetAdditionalCSSClasses(): string + public function GetAdditionalCSSClasses(): array { - return implode(' ', $this->aAdditionalCSSClasses); + return $this->aAdditionalCSSClasses; + } + + /** + * @return string All additional CSS classes as a spec-separated string + * + * @uses static::GetAdditionalCSSClasses() + */ + public function GetAdditionalCSSClassesAsString(): string + { + return implode(' ', $this->GetAdditionalCSSClasses()); } /** diff --git a/sources/application/UI/Links/Indirect/BlockIndirectLinksEdit/BlockIndirectLinksEdit.php b/sources/application/UI/Links/Indirect/BlockIndirectLinksEdit/BlockIndirectLinksEdit.php index 93cc0b0e7..466703426 100644 --- a/sources/application/UI/Links/Indirect/BlockIndirectLinksEdit/BlockIndirectLinksEdit.php +++ b/sources/application/UI/Links/Indirect/BlockIndirectLinksEdit/BlockIndirectLinksEdit.php @@ -54,7 +54,7 @@ class BlockIndirectLinksEdit extends UIContentBlock { $this->AddSubBlock(InputUIBlockFactory::MakeForHidden("{$this->sFormPrefix}{$this->iInputId}", '', "{$this->sFormPrefix}{$this->iInputId}")); - $oToolbar = new Toolbar(null, 'ibo-datatable--selection-validation-buttons-toolbar'); + $oToolbar = new Toolbar(null, ['ibo-datatable--selection-validation-buttons-toolbar']); $this->AddSubBlock($oToolbar); $oRemoveButton = ButtonUIBlockFactory::MakeForSecondaryAction(Dict::S('UI:RemoveLinkedObjectsOf_Class'), null, null, false, "{$this->sLinkedSetId}_btnRemove"); $oRemoveButton->SetOnClickJsCode("oWidget{$this->iInputId}.RemoveSelected();"); @@ -65,7 +65,7 @@ class BlockIndirectLinksEdit extends UIContentBlock $oToolbar->AddSubBlock($oAddButton); // To prevent adding forms inside the main form - $oDeferredBlock = new UIContentBlock("dlg_{$this->sLinkedSetId}", 'ibo-block-indirect-links--edit--dialog'); + $oDeferredBlock = new UIContentBlock("dlg_{$this->sLinkedSetId}", ['ibo-block-indirect-links--edit--dialog']); $this->AddDeferredBlock($oDeferredBlock); } } \ No newline at end of file diff --git a/sources/application/UI/Links/Indirect/BlockObjectPickerDialog/BlockObjectPickerDialog.php b/sources/application/UI/Links/Indirect/BlockObjectPickerDialog/BlockObjectPickerDialog.php index 6c2d282fc..249dcdd6d 100644 --- a/sources/application/UI/Links/Indirect/BlockObjectPickerDialog/BlockObjectPickerDialog.php +++ b/sources/application/UI/Links/Indirect/BlockObjectPickerDialog/BlockObjectPickerDialog.php @@ -38,13 +38,13 @@ class BlockObjectPickerDialog extends UIContentBlock $oForm = new Form("ObjectsAddForm_{$this->sLinkedSetId}"); $this->AddSubBlock($oForm); - $oBlock = new UIContentBlock("SearchResultsToAdd_{$this->sLinkedSetId}", 'ibo-block-object-picker-dialog--results'); + $oBlock = new UIContentBlock("SearchResultsToAdd_{$this->sLinkedSetId}", ['ibo-block-object-picker-dialog--results']); $oForm->AddSubBlock($oBlock); $oBlock->AddHtml("

{$sEmptyList}

"); $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("count_{$this->sLinkedSetId}", '0', "count_{$this->sLinkedSetId}")); - $oToolbar = new Toolbar(null, 'ibo-datatable--selection-validation-buttons-toolbar'); + $oToolbar = new Toolbar(null, ['ibo-datatable--selection-validation-buttons-toolbar']); $this->AddSubBlock($oToolbar); $oRemoveButton = ButtonUIBlockFactory::MakeForSecondaryAction($sCancel, null, null, false); $oRemoveButton->SetOnClickJsCode("$('#dlg_{$this->sLinkedSetId}').dialog('close');"); diff --git a/sources/application/search/searchform.class.inc.php b/sources/application/search/searchform.class.inc.php index 64115816e..cab3404b0 100644 --- a/sources/application/search/searchform.class.inc.php +++ b/sources/application/search/searchform.class.inc.php @@ -180,11 +180,15 @@ class SearchForm $sAction = (isset($aExtraParams['action'])) ? $aExtraParams['action'] : utils::GetAbsoluteUrlAppRoot().'pages/UI.php'; - $sStyle = "ibo-search-form"; - $sStyle .= ($bOpen == 'true') ? '' : ' closed'; - $sStyle .= ($bAutoSubmit === true) ? '' : ' no_auto_submit'; + $aCSSClasses = ["ibo-search-form"]; + if ($bOpen == 'true') { + $aCSSClasses[] = 'closed'; + } + if ($bAutoSubmit === true) { + $aCSSClasses[] = 'no_auto_submit'; + } $oUiSearchBlock = new Panel(Dict::Format('UI:SearchFor_Class_Objects', $sClassesCombo), [],Panel::ENUM_COLOR_CYAN, $sSearchFormId); - $oUiSearchBlock->SetCSSClasses("ibo-search-form-panel display_block"); + $oUiSearchBlock->SetCSSClasses(["ibo-search-form-panel", "display_block"]); $oUiBlock->AddSubBlock($oUiSearchBlock); $sHtml = ""; if (!$bShowObsoleteData) @@ -203,12 +207,12 @@ class SearchForm $oFormSearch = new Form("fs_".$sSearchFormId); $oFormSearch->SetAction($sAction) - ->AddCSSClasses($sStyle); + ->AddCSSClasses($aCSSClasses); $oUiSearchBlock->AddSubBlock($oFormSearch); $oFormSearch->AddSubBlock(InputUIBlockFactory::MakeForHidden("class", $sClassName)); $oFormSearch->AddHtml("
");//class sf_message header_message - $oCriterionBlock = new UIContentBlock("fs_{$sSearchFormId}_criterion_outer", "sf_criterion_area ibo-criterion-area"); + $oCriterionBlock = new UIContentBlock("fs_{$sSearchFormId}_criterion_outer", ["sf_criterion_area ibo-criterion-area"]); $oFormSearch->AddSubBlock($oCriterionBlock); if (isset($aExtraParams['query_params'])) { diff --git a/templates/base/components/alert/layout.html.twig b/templates/base/components/alert/layout.html.twig index d67d3a224..789a9c4ac 100644 --- a/templates/base/components/alert/layout.html.twig +++ b/templates/base/components/alert/layout.html.twig @@ -1,5 +1,5 @@
+ class="ibo-alert ibo-is-{{ oUIBlock.GetColor() }}{% if oUIBlock.IsOpenedByDefault() %} ibo-is-opened{% endif %}{% if oUIBlock.IsHidden() %} ibo-is-hidden{% endif %} {{ oUIBlock.GetAdditionalCSSClasses()|join(' ') }}"> {% if oUIBlock.IsCollapsible() %}
diff --git a/templates/base/components/button/layout.html.twig b/templates/base/components/button/layout.html.twig index 856c334f6..2bb2e9138 100644 --- a/templates/base/components/button/layout.html.twig +++ b/templates/base/components/button/layout.html.twig @@ -1,5 +1,5 @@