diff --git a/lib/composer/autoload_classmap.php b/lib/composer/autoload_classmap.php index 9a841e47a..bafd156c2 100644 --- a/lib/composer/autoload_classmap.php +++ b/lib/composer/autoload_classmap.php @@ -151,8 +151,6 @@ return array( 'Combodo\\iTop\\Application\\TwigBase\\Controller\\PageNotFoundException' => $baseDir . '/sources/application/TwigBase/Controller/Controller.php', 'Combodo\\iTop\\Application\\TwigBase\\Twig\\Extension' => $baseDir . '/sources/application/TwigBase/Twig/Extension.php', 'Combodo\\iTop\\Application\\TwigBase\\Twig\\TwigHelper' => $baseDir . '/sources/application/TwigBase/Twig/TwigHelper.php', - 'Combodo\\iTop\\Application\\TwigBase\\UI\\Component\\UIHtmlNode' => $baseDir . '/sources/application/TwigBase/UI/Component/Html/UIHtmlNode.php', - 'Combodo\\iTop\\Application\\TwigBase\\UI\\Component\\UIHtmlParser' => $baseDir . '/sources/application/TwigBase/UI/Component/Html/UIHtmlParser.php', 'Combodo\\iTop\\Application\\TwigBase\\UI\\UIBlockExtension' => $baseDir . '/sources/application/TwigBase/UI/UIBlockExtension.php', 'Combodo\\iTop\\Application\\TwigBase\\UI\\UIBlockNode' => $baseDir . '/sources/application/TwigBase/UI/UIBlockNode.php', 'Combodo\\iTop\\Application\\TwigBase\\UI\\UIBlockParser' => $baseDir . '/sources/application/TwigBase/UI/UIBlockParser.php', @@ -194,8 +192,10 @@ return array( 'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\InputUIBlockFactory' => $baseDir . '/sources/application/UI/Base/Component/Input/InputUIBlockFactory.php', 'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\InputWithLabel' => $baseDir . '/sources/application/UI/Base/Component/Input/InputWithLabel.php', 'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\RichText\\RichText' => $baseDir . '/sources/application/UI/Base/Component/Input/RichText/RichText.php', + 'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\SelectUIBlockFactory' => $baseDir . '/sources/application/UI/Base/Component/Input/Select/SelectUIBlockFactory.php', 'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\Select\\Select' => $baseDir . '/sources/application/UI/Base/Component/Input/Select/Select.php', 'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\Select\\SelectOption' => $baseDir . '/sources/application/UI/Base/Component/Input/Select/SelectOption.php', + 'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\Select\\SelectOptionUIBlockFactory' => $baseDir . '/sources/application/UI/Base/Component/Input/Select/SelectOptionUIBlockFactory.php', 'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\TextArea' => $baseDir . '/sources/application/UI/Base/Component/Input/TextArea.php', 'Combodo\\iTop\\Application\\UI\\Base\\Component\\Panel\\Panel' => $baseDir . '/sources/application/UI/Base/Component/Panel/Panel.php', 'Combodo\\iTop\\Application\\UI\\Base\\Component\\Panel\\PanelEnhanced' => $baseDir . '/sources/application/UI/Base/Component/Panel/PanelEnhanced.php', @@ -528,31 +528,8 @@ return array( 'PEAR' => $vendorDir . '/pear/pear-core-minimal/src/PEAR.php', 'PEAR_ErrorStack' => $vendorDir . '/pear/pear-core-minimal/src/PEAR/ErrorStack.php', 'PEAR_Exception' => $vendorDir . '/pear/pear_exception/PEAR/Exception.php', - 'PHP_LexerGenerator' => $baseDir . '/core/oql/build/PHP/LexerGenerator.php', - 'PHP_LexerGenerator_Exception' => $baseDir . '/core/oql/build/PHP/LexerGenerator/Exception.php', - 'PHP_LexerGenerator_Lexer' => $baseDir . '/core/oql/build/PHP/LexerGenerator/Lexer.php', - 'PHP_LexerGenerator_Parser' => $baseDir . '/core/oql/build/PHP/LexerGenerator/Parser.php', - 'PHP_LexerGenerator_ParseryyStackEntry' => $baseDir . '/core/oql/build/PHP/LexerGenerator/Parser.php', - 'PHP_LexerGenerator_ParseryyToken' => $baseDir . '/core/oql/build/PHP/LexerGenerator/Parser.php', - 'PHP_LexerGenerator_Regex_Lexer' => $baseDir . '/core/oql/build/PHP/LexerGenerator/Regex/Lexer.php', - 'PHP_LexerGenerator_Regex_Parser' => $baseDir . '/core/oql/build/PHP/LexerGenerator/Regex/Parser.php', - 'PHP_LexerGenerator_Regex_yyStackEntry' => $baseDir . '/core/oql/build/PHP/LexerGenerator/Regex/Parser.php', - 'PHP_LexerGenerator_Regex_yyToken' => $baseDir . '/core/oql/build/PHP/LexerGenerator/Regex/Parser.php', - 'PHP_ParserGenerator' => $baseDir . '/core/oql/build/PHP/ParserGenerator.php', - 'PHP_ParserGenerator_Action' => $baseDir . '/core/oql/build/PHP/ParserGenerator/Action.php', - 'PHP_ParserGenerator_ActionTable' => $baseDir . '/core/oql/build/PHP/ParserGenerator/ActionTable.php', - 'PHP_ParserGenerator_Config' => $baseDir . '/core/oql/build/PHP/ParserGenerator/Config.php', - 'PHP_ParserGenerator_Data' => $baseDir . '/core/oql/build/PHP/ParserGenerator/Data.php', - 'PHP_ParserGenerator_Parser' => $baseDir . '/core/oql/build/PHP/ParserGenerator/Parser.php', - 'PHP_ParserGenerator_PropagationLink' => $baseDir . '/core/oql/build/PHP/ParserGenerator/PropagationLink.php', - 'PHP_ParserGenerator_Rule' => $baseDir . '/core/oql/build/PHP/ParserGenerator/Rule.php', - 'PHP_ParserGenerator_State' => $baseDir . '/core/oql/build/PHP/ParserGenerator/State.php', - 'PHP_ParserGenerator_StateNode' => $baseDir . '/core/oql/build/PHP/ParserGenerator/State.php', - 'PHP_ParserGenerator_Symbol' => $baseDir . '/core/oql/build/PHP/ParserGenerator/Symbol.php', 'Page' => $baseDir . '/sources/application/WebPage/Page.php', 'ParseError' => $vendorDir . '/symfony/polyfill-php70/Resources/stubs/ParseError.php', - 'ParseyyStackEntry' => $baseDir . '/core/oql/build/PHP/Lempar.php', - 'ParseyyToken' => $baseDir . '/core/oql/build/PHP/Lempar.php', 'Pelago\\Emogrifier' => $vendorDir . '/pelago/emogrifier/src/Emogrifier.php', 'Pelago\\Emogrifier\\CssConcatenator' => $vendorDir . '/pelago/emogrifier/src/Emogrifier/CssConcatenator.php', 'Pelago\\Emogrifier\\CssInliner' => $vendorDir . '/pelago/emogrifier/src/Emogrifier/CssInliner.php', diff --git a/lib/composer/autoload_static.php b/lib/composer/autoload_static.php index e705813b4..7ce2ea249 100644 --- a/lib/composer/autoload_static.php +++ b/lib/composer/autoload_static.php @@ -381,8 +381,6 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b 'Combodo\\iTop\\Application\\TwigBase\\Controller\\PageNotFoundException' => __DIR__ . '/../..' . '/sources/application/TwigBase/Controller/Controller.php', 'Combodo\\iTop\\Application\\TwigBase\\Twig\\Extension' => __DIR__ . '/../..' . '/sources/application/TwigBase/Twig/Extension.php', 'Combodo\\iTop\\Application\\TwigBase\\Twig\\TwigHelper' => __DIR__ . '/../..' . '/sources/application/TwigBase/Twig/TwigHelper.php', - 'Combodo\\iTop\\Application\\TwigBase\\UI\\Component\\UIHtmlNode' => __DIR__ . '/../..' . '/sources/application/TwigBase/UI/Component/Html/UIHtmlNode.php', - 'Combodo\\iTop\\Application\\TwigBase\\UI\\Component\\UIHtmlParser' => __DIR__ . '/../..' . '/sources/application/TwigBase/UI/Component/Html/UIHtmlParser.php', 'Combodo\\iTop\\Application\\TwigBase\\UI\\UIBlockExtension' => __DIR__ . '/../..' . '/sources/application/TwigBase/UI/UIBlockExtension.php', 'Combodo\\iTop\\Application\\TwigBase\\UI\\UIBlockNode' => __DIR__ . '/../..' . '/sources/application/TwigBase/UI/UIBlockNode.php', 'Combodo\\iTop\\Application\\TwigBase\\UI\\UIBlockParser' => __DIR__ . '/../..' . '/sources/application/TwigBase/UI/UIBlockParser.php', @@ -424,8 +422,10 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b 'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\InputUIBlockFactory' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/Input/InputUIBlockFactory.php', 'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\InputWithLabel' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/Input/InputWithLabel.php', 'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\RichText\\RichText' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/Input/RichText/RichText.php', + 'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\SelectUIBlockFactory' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/Input/Select/SelectUIBlockFactory.php', 'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\Select\\Select' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/Input/Select/Select.php', 'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\Select\\SelectOption' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/Input/Select/SelectOption.php', + 'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\Select\\SelectOptionUIBlockFactory' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/Input/Select/SelectOptionUIBlockFactory.php', 'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\TextArea' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/Input/TextArea.php', 'Combodo\\iTop\\Application\\UI\\Base\\Component\\Panel\\Panel' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/Panel/Panel.php', 'Combodo\\iTop\\Application\\UI\\Base\\Component\\Panel\\PanelEnhanced' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/Panel/PanelEnhanced.php', @@ -758,31 +758,8 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b 'PEAR' => __DIR__ . '/..' . '/pear/pear-core-minimal/src/PEAR.php', 'PEAR_ErrorStack' => __DIR__ . '/..' . '/pear/pear-core-minimal/src/PEAR/ErrorStack.php', 'PEAR_Exception' => __DIR__ . '/..' . '/pear/pear_exception/PEAR/Exception.php', - 'PHP_LexerGenerator' => __DIR__ . '/../..' . '/core/oql/build/PHP/LexerGenerator.php', - 'PHP_LexerGenerator_Exception' => __DIR__ . '/../..' . '/core/oql/build/PHP/LexerGenerator/Exception.php', - 'PHP_LexerGenerator_Lexer' => __DIR__ . '/../..' . '/core/oql/build/PHP/LexerGenerator/Lexer.php', - 'PHP_LexerGenerator_Parser' => __DIR__ . '/../..' . '/core/oql/build/PHP/LexerGenerator/Parser.php', - 'PHP_LexerGenerator_ParseryyStackEntry' => __DIR__ . '/../..' . '/core/oql/build/PHP/LexerGenerator/Parser.php', - 'PHP_LexerGenerator_ParseryyToken' => __DIR__ . '/../..' . '/core/oql/build/PHP/LexerGenerator/Parser.php', - 'PHP_LexerGenerator_Regex_Lexer' => __DIR__ . '/../..' . '/core/oql/build/PHP/LexerGenerator/Regex/Lexer.php', - 'PHP_LexerGenerator_Regex_Parser' => __DIR__ . '/../..' . '/core/oql/build/PHP/LexerGenerator/Regex/Parser.php', - 'PHP_LexerGenerator_Regex_yyStackEntry' => __DIR__ . '/../..' . '/core/oql/build/PHP/LexerGenerator/Regex/Parser.php', - 'PHP_LexerGenerator_Regex_yyToken' => __DIR__ . '/../..' . '/core/oql/build/PHP/LexerGenerator/Regex/Parser.php', - 'PHP_ParserGenerator' => __DIR__ . '/../..' . '/core/oql/build/PHP/ParserGenerator.php', - 'PHP_ParserGenerator_Action' => __DIR__ . '/../..' . '/core/oql/build/PHP/ParserGenerator/Action.php', - 'PHP_ParserGenerator_ActionTable' => __DIR__ . '/../..' . '/core/oql/build/PHP/ParserGenerator/ActionTable.php', - 'PHP_ParserGenerator_Config' => __DIR__ . '/../..' . '/core/oql/build/PHP/ParserGenerator/Config.php', - 'PHP_ParserGenerator_Data' => __DIR__ . '/../..' . '/core/oql/build/PHP/ParserGenerator/Data.php', - 'PHP_ParserGenerator_Parser' => __DIR__ . '/../..' . '/core/oql/build/PHP/ParserGenerator/Parser.php', - 'PHP_ParserGenerator_PropagationLink' => __DIR__ . '/../..' . '/core/oql/build/PHP/ParserGenerator/PropagationLink.php', - 'PHP_ParserGenerator_Rule' => __DIR__ . '/../..' . '/core/oql/build/PHP/ParserGenerator/Rule.php', - 'PHP_ParserGenerator_State' => __DIR__ . '/../..' . '/core/oql/build/PHP/ParserGenerator/State.php', - 'PHP_ParserGenerator_StateNode' => __DIR__ . '/../..' . '/core/oql/build/PHP/ParserGenerator/State.php', - 'PHP_ParserGenerator_Symbol' => __DIR__ . '/../..' . '/core/oql/build/PHP/ParserGenerator/Symbol.php', 'Page' => __DIR__ . '/../..' . '/sources/application/WebPage/Page.php', 'ParseError' => __DIR__ . '/..' . '/symfony/polyfill-php70/Resources/stubs/ParseError.php', - 'ParseyyStackEntry' => __DIR__ . '/../..' . '/core/oql/build/PHP/Lempar.php', - 'ParseyyToken' => __DIR__ . '/../..' . '/core/oql/build/PHP/Lempar.php', 'Pelago\\Emogrifier' => __DIR__ . '/..' . '/pelago/emogrifier/src/Emogrifier.php', 'Pelago\\Emogrifier\\CssConcatenator' => __DIR__ . '/..' . '/pelago/emogrifier/src/Emogrifier/CssConcatenator.php', 'Pelago\\Emogrifier\\CssInliner' => __DIR__ . '/..' . '/pelago/emogrifier/src/Emogrifier/CssInliner.php', diff --git a/pages/preferences.php b/pages/preferences.php index 0e0d1d30d..c5e4b4ec2 100644 --- a/pages/preferences.php +++ b/pages/preferences.php @@ -21,6 +21,7 @@ use Combodo\iTop\Application\UI\Base\Component\Button\ButtonUIBlockFactory; use Combodo\iTop\Application\UI\Base\Component\Form\Form; use Combodo\iTop\Application\UI\Base\Component\Html\Html; use Combodo\iTop\Application\UI\Base\Component\Input\InputUIBlockFactory; +use Combodo\iTop\Application\UI\Base\Component\Input\Select\SelectOptionUIBlockFactory; use Combodo\iTop\Application\UI\Base\Component\Panel\Panel; use Combodo\iTop\Application\UI\Base\Component\Title\TitleUIBlockFactory; use Combodo\iTop\Application\UI\Base\Layout\PageContent\PageContentFactory; @@ -305,8 +306,8 @@ JS $sRichTextToolbarDefaultState = isset(utils::GetCkeditorPref()['toolbarStartupExpanded']) ? (bool)utils::GetCkeditorPref()['toolbarStartupExpanded'] : false; $oRichTextToolbarDefaultStateInput = InputUIBlockFactory::MakeForSelectWithLabel('toolbarexpanded', Dict::S('UI:RichText:ToolbarState')); - $oRichTextToolbarDefaultStateInput->GetInput()->AddOption(InputUIBlockFactory::MakeForSelectOption('true', Dict::S('UI:RichText:ToolbarState:Expanded'), $sRichTextToolbarDefaultState)); - $oRichTextToolbarDefaultStateInput->GetInput()->AddOption(InputUIBlockFactory::MakeForSelectOption('false', Dict::S('UI:RichText:ToolbarState:Collapsed'), !$sRichTextToolbarDefaultState)); + $oRichTextToolbarDefaultStateInput->GetInput()->AddOption(SelectOptionUIBlockFactory::MakeForSelectOption('true', Dict::S('UI:RichText:ToolbarState:Expanded'), $sRichTextToolbarDefaultState)); + $oRichTextToolbarDefaultStateInput->GetInput()->AddOption(SelectOptionUIBlockFactory::MakeForSelectOption('false', Dict::S('UI:RichText:ToolbarState:Collapsed'), !$sRichTextToolbarDefaultState)); $oRichTextForm->AddSubBlock($oRichTextToolbarDefaultStateInput); // - Cancel button @@ -333,8 +334,8 @@ JS $sTabsScrollableValue = appUserPreferences::GetPref('tab_scrollable', false);; $oTabsScrollable = InputUIBlockFactory::MakeForSelectWithLabel('tab_scrollable', Dict::S('UI:Tabs:Scrollable:Label')); - $oTabsScrollable->GetInput()->AddOption(InputUIBlockFactory::MakeForSelectOption('true', Dict::S('UI:Tabs:Scrollable:Scrollable'), true === $sTabsScrollableValue)); - $oTabsScrollable->GetInput()->AddOption(InputUIBlockFactory::MakeForSelectOption('false', Dict::S('UI:Tabs:Scrollable:Classic'), false === $sTabsScrollableValue)); + $oTabsScrollable->GetInput()->AddSubBlock(SelectOptionUIBlockFactory::MakeForSelectOption('true', Dict::S('UI:Tabs:Scrollable:Scrollable'), true === $sTabsScrollableValue)); + $oTabsScrollable->GetInput()->AddSubBlock(SelectOptionUIBlockFactory::MakeForSelectOption('false', Dict::S('UI:Tabs:Scrollable:Classic'), false === $sTabsScrollableValue)); $oTabsForm->AddSubBlock($oTabsScrollable); // - Cancel button @@ -434,7 +435,7 @@ function GetUserLanguageForm(ApplicationContext $oAppContext, string $sURL): For $oUserLanguageBlockSelectInput = $oUserLanguageBlockSelect->GetInput(); foreach ($aSortedLang as $sCode) { $bSelected = ($sCode == Dict::GetUserLanguage()); - $oUserLanguageBlockSelectInput->AddOption(InputUIBlockFactory::MakeForSelectOption($sCode, $aLanguages[$sCode]['description'].' ('.$aLanguages[$sCode]['localized_description'].')', $bSelected)); + $oUserLanguageBlockSelectInput->AddSubBlock(SelectOptionUIBlockFactory::MakeForSelectOption($sCode, $aLanguages[$sCode]['description'].' ('.$aLanguages[$sCode]['localized_description'].')', $bSelected)); } $oUserLanguageForm->AddSubBlock($oUserLanguageBlockSelect); diff --git a/sources/application/UI/Base/Component/Alert/AlertUIBlockFactory.php b/sources/application/UI/Base/Component/Alert/AlertUIBlockFactory.php index 894e4f3bc..e0ea85de6 100644 --- a/sources/application/UI/Base/Component/Alert/AlertUIBlockFactory.php +++ b/sources/application/UI/Base/Component/Alert/AlertUIBlockFactory.php @@ -33,7 +33,7 @@ use Combodo\iTop\Application\UI\Base\AbstractUIBlockFactory; class AlertUIBlockFactory extends AbstractUIBlockFactory { public const TWIG_TAG_NAME = 'UIAlert'; - public const UI_BLOCK_CLASS_NAME = "Combodo\\iTop\\Application\\UI\\Base\\Component\\Alert\\Alert"; + public const UI_BLOCK_CLASS_NAME = Alert::class; /** * Make a basis Alert component diff --git a/sources/application/UI/Base/Component/Button/ButtonUIBlockFactory.php b/sources/application/UI/Base/Component/Button/ButtonUIBlockFactory.php index 122204a00..8aae8d674 100644 --- a/sources/application/UI/Base/Component/Button/ButtonUIBlockFactory.php +++ b/sources/application/UI/Base/Component/Button/ButtonUIBlockFactory.php @@ -34,7 +34,7 @@ use Combodo\iTop\Application\UI\Base\AbstractUIBlockFactory; class ButtonUIBlockFactory extends AbstractUIBlockFactory { public const TWIG_TAG_NAME = 'UIButton'; - public const UI_BLOCK_CLASS_NAME = "Combodo\\iTop\\Application\\UI\\Base\\Component\\Button\\Button"; + public const UI_BLOCK_CLASS_NAME = Button::class; //--------------------------------------------- // Regular action buttons, mostly used in forms diff --git a/sources/application/UI/Base/Component/CollapsibleSection/CollapsibleSectionUIBlockFactory.php b/sources/application/UI/Base/Component/CollapsibleSection/CollapsibleSectionUIBlockFactory.php index cc4ac009c..1c842fcff 100644 --- a/sources/application/UI/Base/Component/CollapsibleSection/CollapsibleSectionUIBlockFactory.php +++ b/sources/application/UI/Base/Component/CollapsibleSection/CollapsibleSectionUIBlockFactory.php @@ -13,7 +13,7 @@ use Combodo\iTop\Application\UI\Base\AbstractUIBlockFactory; class CollapsibleSectionUIBlockFactory extends AbstractUIBlockFactory { public const TWIG_TAG_NAME = 'UICollapsibleSection'; - public const UI_BLOCK_CLASS_NAME = "Combodo\\iTop\\Application\\UI\\Base\\Component\\CollapsibleSection\\CollapsibleSection"; + public const UI_BLOCK_CLASS_NAME = CollapsibleSection::class; public static function MakeStandard(string $sTitle, ?string $sId = null) { diff --git a/sources/application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php b/sources/application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php index 04a8b006d..08ea1ace5 100644 --- a/sources/application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php +++ b/sources/application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php @@ -36,7 +36,7 @@ use WebPage; class DataTableUIBlockFactory extends AbstractUIBlockFactory { public const TWIG_TAG_NAME = 'UIDataTable'; - public const UI_BLOCK_CLASS_NAME = "Combodo\\iTop\\Application\\UI\\Base\\Component\\DataTable\\DataTable"; + public const UI_BLOCK_CLASS_NAME = DataTable::class; /** * @param \WebPage $oPage diff --git a/sources/application/UI/Base/Component/Field/FieldUIBlockFactory.php b/sources/application/UI/Base/Component/Field/FieldUIBlockFactory.php index 94b579da8..d880e3d25 100644 --- a/sources/application/UI/Base/Component/Field/FieldUIBlockFactory.php +++ b/sources/application/UI/Base/Component/Field/FieldUIBlockFactory.php @@ -17,7 +17,7 @@ use Combodo\iTop\Application\UI\Base\UIBlock; class FieldUIBlockFactory extends AbstractUIBlockFactory { public const TWIG_TAG_NAME = 'UIField'; - public const UI_BLOCK_CLASS_NAME = "Combodo\\iTop\\Application\\UI\\Base\\Component\\Field\\Field"; + public const UI_BLOCK_CLASS_NAME = Field::class; public static function MakeFromParams($aParams) { diff --git a/sources/application/UI/Base/Component/FieldBadge/FieldBadgeUIBlockFactory.php b/sources/application/UI/Base/Component/FieldBadge/FieldBadgeUIBlockFactory.php index 119ae1cb0..6fdec5a67 100644 --- a/sources/application/UI/Base/Component/FieldBadge/FieldBadgeUIBlockFactory.php +++ b/sources/application/UI/Base/Component/FieldBadge/FieldBadgeUIBlockFactory.php @@ -13,9 +13,9 @@ use ormStyle; class FieldBadgeUIBlockFactory extends AbstractUIBlockFactory { - public const UI_BLOCK_CLASS_NAME = "Combodo\\iTop\\Application\\UI\\Base\\Component\\FieldBadge\\FieldBadge"; public const TWIG_TAG_NAME = 'UIFieldBadge'; - + public const UI_BLOCK_CLASS_NAME = FieldBadge::class; + /** * @param string $sValue * @param \ormStyle|null $oStyle diff --git a/sources/application/UI/Base/Component/FieldSet/FieldSetUIBlockFactory.php b/sources/application/UI/Base/Component/FieldSet/FieldSetUIBlockFactory.php index c96b6426e..050114fcd 100644 --- a/sources/application/UI/Base/Component/FieldSet/FieldSetUIBlockFactory.php +++ b/sources/application/UI/Base/Component/FieldSet/FieldSetUIBlockFactory.php @@ -12,8 +12,8 @@ use Combodo\iTop\Application\UI\Base\AbstractUIBlockFactory; class FieldSetUIBlockFactory extends AbstractUIBlockFactory { - public const UI_BLOCK_CLASS_NAME = "Combodo\\iTop\\Application\\UI\\Base\\Component\\FieldSet\\FieldSet"; public const TWIG_TAG_NAME = 'UIFieldSet'; + public const UI_BLOCK_CLASS_NAME = FieldSet::class; public static function MakeStandard(string $sLegend, ?string $sId = null): FieldSet { diff --git a/sources/application/UI/Base/Component/Form/FormUIBlockFactory.php b/sources/application/UI/Base/Component/Form/FormUIBlockFactory.php index 694bafdcf..5be5cf935 100644 --- a/sources/application/UI/Base/Component/Form/FormUIBlockFactory.php +++ b/sources/application/UI/Base/Component/Form/FormUIBlockFactory.php @@ -12,8 +12,8 @@ use Combodo\iTop\Application\UI\Base\AbstractUIBlockFactory; class FormUIBlockFactory extends AbstractUIBlockFactory { - public const UI_BLOCK_CLASS_NAME = "Combodo\\iTop\\Application\\UI\\Base\\Component\\Form\\Form"; public const TWIG_TAG_NAME = 'UIForm'; + public const UI_BLOCK_CLASS_NAME = Form::class; public static function MakeStandard(string $sId = null) { diff --git a/sources/application/UI/Base/Component/Input/InputUIBlockFactory.php b/sources/application/UI/Base/Component/Input/InputUIBlockFactory.php index 47dbb13b2..67f9b7b94 100644 --- a/sources/application/UI/Base/Component/Input/InputUIBlockFactory.php +++ b/sources/application/UI/Base/Component/Input/InputUIBlockFactory.php @@ -11,12 +11,11 @@ namespace Combodo\iTop\Application\UI\Base\Component\Input; use Combodo\iTop\Application\UI\Base\AbstractUIBlockFactory; use Combodo\iTop\Application\UI\Base\Component\Field\Field; use Combodo\iTop\Application\UI\Base\Component\Input\Select\Select; -use Combodo\iTop\Application\UI\Base\Component\Input\Select\SelectOption; class InputUIBlockFactory extends AbstractUIBlockFactory { public const TWIG_TAG_NAME = 'UIInput'; - public const UI_BLOCK_CLASS_NAME = "Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\Input"; + public const UI_BLOCK_CLASS_NAME = Input::class; public static function MakeForHidden(string $sName, string $sValue, ?string $sId = null): Input { @@ -63,6 +62,17 @@ class InputUIBlockFactory extends AbstractUIBlockFactory return static::MakeInputWithLabel($sInputName, $sLabel, $oInput, $sInputId); } + private static function MakeInputWithLabel(string $sName, string $sLabel, Input $oInput, ?string $sId = null) + { + $oInput->SetName($sName); + + if (is_null($sId)) { + $sId = $oInput->GetId(); + } + + return new InputWithLabel($sLabel, $oInput, $sId); + } + /** * If you need to have a real field with a label, you might use a {@link Field} component instead * @@ -75,12 +85,6 @@ class InputUIBlockFactory extends AbstractUIBlockFactory public static function MakeForSelectWithLabel(string $sName, string $sLabel, ?string $sId = null): InputWithLabel { $oInput = new Select($sId); - - return static::MakeInputWithLabel($sName, $sLabel, $oInput, $sId); - } - - private static function MakeInputWithLabel(string $sName, string $sLabel, Input $oInput, ?string $sId = null) - { $oInput->SetName($sName); if (is_null($sId)) { @@ -90,23 +94,4 @@ class InputUIBlockFactory extends AbstractUIBlockFactory return new InputWithLabel($sLabel, $oInput, $sId); } - public static function MakeForSelect(string $sName, ?string $sId = null): Select - { - $oInput = new Select($sId); - $oInput->SetName($sName); - - return $oInput; - } - - public static function MakeForSelectOption(string $sValue, string $sLabel, bool $bSelected, ?string $sId = null): SelectOption - { - $oInput = new SelectOption($sId); - - $oInput->SetValue($sValue) - ->SetLabel($sLabel) - ->SetSelected($bSelected); - - return $oInput; - } - } \ No newline at end of file diff --git a/sources/application/UI/Base/Component/Input/InputWithLabel.php b/sources/application/UI/Base/Component/Input/InputWithLabel.php index a07f12cac..bd5ed1d1b 100644 --- a/sources/application/UI/Base/Component/Input/InputWithLabel.php +++ b/sources/application/UI/Base/Component/Input/InputWithLabel.php @@ -21,15 +21,15 @@ class InputWithLabel extends UIBlock /** @var string */ protected $sLabel; - /** @var \Combodo\iTop\Application\UI\Base\Component\Input\Input */ + /** @var \Combodo\iTop\Application\UI\Base\UIBlock */ protected $oInput; /** * @param string $sLabel - * @param \Combodo\iTop\Application\UI\Base\Component\Input\AbstractInput $oInput + * @param \Combodo\iTop\Application\UI\Base\UIBlock $oInput * @param string|null $sId */ - public function __construct(string $sLabel, AbstractInput $oInput, ?string $sId) + public function __construct(string $sLabel, UIBlock $oInput, ?string $sId) { parent::__construct($sId); $this->sLabel = $sLabel; @@ -37,7 +37,7 @@ class InputWithLabel extends UIBlock } /** - * @return \Combodo\iTop\Application\UI\Base\Component\Input\AbstractInput + * @return UIBlock */ public function GetInput() { @@ -45,11 +45,11 @@ class InputWithLabel extends UIBlock } /** - * @param \Combodo\iTop\Application\UI\Base\Component\Input\AbstractInput $oInput + * @param \Combodo\iTop\Application\UI\Base\UIBlock $oInput * * @return $this */ - public function SetInput(AbstractInput $oInput) + public function SetInput(UIBlock $oInput) { $this->oInput = $oInput; diff --git a/sources/application/UI/Base/Component/Input/Select/Select.php b/sources/application/UI/Base/Component/Input/Select/Select.php index 474ce67c4..8996a36ad 100644 --- a/sources/application/UI/Base/Component/Input/Select/Select.php +++ b/sources/application/UI/Base/Component/Input/Select/Select.php @@ -8,28 +8,81 @@ namespace Combodo\iTop\Application\UI\Base\Component\Input\Select; -use Combodo\iTop\Application\UI\Base\Component\Input\Input; +use Combodo\iTop\Application\UI\Base\Layout\UIContentBlock; -class Select extends Input +class Select extends UIContentBlock { public const DEFAULT_HTML_TEMPLATE_REL_PATH = 'base/components/input/select/select'; - /** @var array */ - protected $aOptions; + /** @var string */ + protected $sName; + /** @var string */ + protected $sValue; + /** @var bool */ + protected $bSubmitOnChange = false; + public function __construct(?string $sId = null) { parent::__construct($sId); - $this->aOptions = []; } public function AddOption(SelectOption $oOption) { - $this->aOptions[$oOption->GetId()] = $oOption; + $this->AddSubBlock($oOption); } - public function GetSubBlocks() + public function GetName(): string { - return $this->aOptions; + return $this->sName; } + + /** + * @param string $sName + * + * @return $this + */ + public function SetName(string $sName) + { + $this->sName = $sName; + + return $this; + } + + public function GetValue(): ?string + { + return $this->sValue; + } + + /** + * @param string|null $sValue + * + * @return $this + */ + public function SetValue(?string $sValue) + { + $this->sValue = $sValue; + + return $this; + } + + /** + * @return bool + */ + public function GetSubmitOnChange(): bool + { + return $this->bSubmitOnChange; + } + + /** + * @param bool $bSubmitOnChange + * + * @return $this + */ + public function SetSubmitOnChange(bool $bSubmitOnChange) + { + $this->bSubmitOnChange = $bSubmitOnChange; + return $this; + } + } \ No newline at end of file diff --git a/sources/application/UI/Base/Component/Input/Select/SelectOptionUIBlockFactory.php b/sources/application/UI/Base/Component/Input/Select/SelectOptionUIBlockFactory.php new file mode 100644 index 000000000..3a4f3d0b4 --- /dev/null +++ b/sources/application/UI/Base/Component/Input/Select/SelectOptionUIBlockFactory.php @@ -0,0 +1,28 @@ +SetValue($sValue) + ->SetLabel($sLabel) + ->SetSelected($bSelected); + + return $oInput; + } +} \ No newline at end of file diff --git a/sources/application/UI/Base/Component/Input/Select/SelectUIBlockFactory.php b/sources/application/UI/Base/Component/Input/Select/SelectUIBlockFactory.php new file mode 100644 index 000000000..58be68a97 --- /dev/null +++ b/sources/application/UI/Base/Component/Input/Select/SelectUIBlockFactory.php @@ -0,0 +1,33 @@ +SetName($sName); + + return $oInput; + } + +} \ No newline at end of file diff --git a/sources/application/UI/Base/Component/Panel/Panel.php b/sources/application/UI/Base/Component/Panel/Panel.php index 021183652..cc415be89 100644 --- a/sources/application/UI/Base/Component/Panel/Panel.php +++ b/sources/application/UI/Base/Component/Panel/Panel.php @@ -273,9 +273,10 @@ class Panel extends UIContentBlock * * @inheritDoc */ - public function AddSubBlock(iUIBlock $oSubBlock) { - $this->AddMainBlock($oSubBlock); - + public function AddSubBlock(?iUIBlock $oSubBlock) { + if ($oSubBlock) { + $this->AddMainBlock($oSubBlock); + } return $this; } diff --git a/sources/application/UI/Base/Component/Panel/PanelUIBlockFactory.php b/sources/application/UI/Base/Component/Panel/PanelUIBlockFactory.php index 3cfa06051..16730c818 100644 --- a/sources/application/UI/Base/Component/Panel/PanelUIBlockFactory.php +++ b/sources/application/UI/Base/Component/Panel/PanelUIBlockFactory.php @@ -36,7 +36,7 @@ use ormStyle; class PanelUIBlockFactory extends AbstractUIBlockFactory { public const TWIG_TAG_NAME = 'UIPanel'; - public const UI_BLOCK_CLASS_NAME = "Combodo\\iTop\\Application\\UI\\Base\\Component\\Panel\\Panel"; + public const UI_BLOCK_CLASS_NAME = Panel::class; /** * Make a basis Panel component diff --git a/sources/application/UI/Base/Component/Spinner/SpinnerUIBlockFactory.php b/sources/application/UI/Base/Component/Spinner/SpinnerUIBlockFactory.php index e69bad341..ab784eb47 100644 --- a/sources/application/UI/Base/Component/Spinner/SpinnerUIBlockFactory.php +++ b/sources/application/UI/Base/Component/Spinner/SpinnerUIBlockFactory.php @@ -12,8 +12,8 @@ use Combodo\iTop\Application\UI\Base\AbstractUIBlockFactory; class SpinnerUIBlockFactory extends AbstractUIBlockFactory { - public const UI_BLOCK_CLASS_NAME = "Combodo\\iTop\\Application\\UI\\Base\\Component\\Spinner\\Spinner"; public const TWIG_TAG_NAME = 'UISpinner'; + public const UI_BLOCK_CLASS_NAME = Spinner::class; public static function MakeStandard(?string $sId = null) { diff --git a/sources/application/UI/Base/Component/Title/TitleUIBlockFactory.php b/sources/application/UI/Base/Component/Title/TitleUIBlockFactory.php index 280af5238..522bab5c9 100644 --- a/sources/application/UI/Base/Component/Title/TitleUIBlockFactory.php +++ b/sources/application/UI/Base/Component/Title/TitleUIBlockFactory.php @@ -15,8 +15,8 @@ use MetaModel; class TitleUIBlockFactory extends AbstractUIBlockFactory { - public const UI_BLOCK_CLASS_NAME = "Combodo\\iTop\\Application\\UI\\Base\\Component\\Title\\Title"; public const TWIG_TAG_NAME = 'UITitle'; + public const UI_BLOCK_CLASS_NAME = Title::class; public static function MakeForPage(string $sTitle, ?string $sId = null) { diff --git a/sources/application/UI/Base/Layout/PageContent/PageContent.php b/sources/application/UI/Base/Layout/PageContent/PageContent.php index 674e176c0..79decd56a 100644 --- a/sources/application/UI/Base/Layout/PageContent/PageContent.php +++ b/sources/application/UI/Base/Layout/PageContent/PageContent.php @@ -154,9 +154,10 @@ class PageContent extends UIBlock implements iUIContentBlock { * * @inheritDoc */ - public function AddSubBlock(iUIBlock $oSubBlock) { - $this->AddMainBlock($oSubBlock); - + public function AddSubBlock(?iUIBlock $oSubBlock) { + if ($oSubBlock) { + $this->AddMainBlock($oSubBlock); + } return $this; } diff --git a/sources/application/UI/Base/Layout/TabContainer/Tab/AjaxTab.php b/sources/application/UI/Base/Layout/TabContainer/Tab/AjaxTab.php index c366dd101..a87568864 100644 --- a/sources/application/UI/Base/Layout/TabContainer/Tab/AjaxTab.php +++ b/sources/application/UI/Base/Layout/TabContainer/Tab/AjaxTab.php @@ -114,7 +114,7 @@ class AjaxTab extends Tab { * @inheritDoc * @throws \Combodo\iTop\Application\UI\Base\UIException */ - public function AddSubBlock(iUIBlock $oSubBlock) { + public function AddSubBlock(?iUIBlock $oSubBlock) { throw new UIException($this, Dict::Format('UIBlock:Error:AddBlockForbidden', $this->GetId())); } diff --git a/sources/application/UI/Base/Layout/TabContainer/TabContainer.php b/sources/application/UI/Base/Layout/TabContainer/TabContainer.php index 32aed9064..c41026ae7 100644 --- a/sources/application/UI/Base/Layout/TabContainer/TabContainer.php +++ b/sources/application/UI/Base/Layout/TabContainer/TabContainer.php @@ -147,7 +147,7 @@ class TabContainer extends UIContentBlock * @return iUIContentBlock * @throws \Combodo\iTop\Application\UI\Base\UIException */ - public function AddSubBlock(iUIBlock $oSubBlock): iUIContentBlock + public function AddSubBlock(?iUIBlock $oSubBlock): iUIContentBlock { if (!($oSubBlock instanceof Tab)) { throw new UIException($this, Dict::Format('UIBlock:Error:AddBlockNotTabForbidden', $oSubBlock->GetId(), $this->GetId())); diff --git a/sources/application/UI/Base/Layout/UIContentBlock.php b/sources/application/UI/Base/Layout/UIContentBlock.php index 523875712..9238e0f05 100644 --- a/sources/application/UI/Base/Layout/UIContentBlock.php +++ b/sources/application/UI/Base/Layout/UIContentBlock.php @@ -65,10 +65,11 @@ class UIContentBlock extends UIBlock implements iUIContentBlock /** * @inheritDoc */ - public function AddSubBlock(iUIBlock $oSubBlock) + public function AddSubBlock(?iUIBlock $oSubBlock) { - $this->aSubBlocks[$oSubBlock->GetId()] = $oSubBlock; - + if ($oSubBlock) { + $this->aSubBlocks[$oSubBlock->GetId()] = $oSubBlock; + } return $this; } diff --git a/sources/application/UI/Base/Layout/UIContentBlockUIBlockFactory.php b/sources/application/UI/Base/Layout/UIContentBlockUIBlockFactory.php index c499f295c..b9e87d1f3 100644 --- a/sources/application/UI/Base/Layout/UIContentBlockUIBlockFactory.php +++ b/sources/application/UI/Base/Layout/UIContentBlockUIBlockFactory.php @@ -12,8 +12,8 @@ use Combodo\iTop\Application\UI\Base\AbstractUIBlockFactory; class UIContentBlockUIBlockFactory extends AbstractUIBlockFactory { - public const UI_BLOCK_CLASS_NAME = "Combodo\\iTop\\Application\\UI\\Base\\Layout\\UIContentBlock"; public const TWIG_TAG_NAME = 'UIContentBlock'; + public const UI_BLOCK_CLASS_NAME = UIContentBlock::class; public static function MakeStandard(string $sId = null, string $sContainerClass = '') { diff --git a/sources/application/UI/Base/Layout/iUIContentBlock.php b/sources/application/UI/Base/Layout/iUIContentBlock.php index af25123ba..cd3d1fbc1 100644 --- a/sources/application/UI/Base/Layout/iUIContentBlock.php +++ b/sources/application/UI/Base/Layout/iUIContentBlock.php @@ -34,7 +34,7 @@ interface iUIContentBlock { * * @return $this */ - public function AddSubBlock(iUIBlock $oSubBlock); + public function AddSubBlock(?iUIBlock $oSubBlock); /** * Remove the sub block identified by $sId. diff --git a/templates/base/components/input/select/select.html.twig b/templates/base/components/input/select/select.html.twig index 6f5df97f4..c4818eb5a 100644 --- a/templates/base/components/input/select/select.html.twig +++ b/templates/base/components/input/select/select.html.twig @@ -2,7 +2,10 @@ {# @license http://opensource.org/licenses/AGPL-3.0 #} {% extends "base/components/input/layout.html.twig" %} {% block iboInput %} - {% for oSubBlock in oUIBlock.GetSubBlocks() %} {{ render_block(oSubBlock, {aPage: aPage}) }} {% endfor %}