diff --git a/pages/preferences.php b/pages/preferences.php index 9249e4f91..36b9d1b5a 100644 --- a/pages/preferences.php +++ b/pages/preferences.php @@ -21,6 +21,7 @@ use Combodo\iTop\Application\UI\Component\Button\ButtonFactory; use Combodo\iTop\Application\UI\Component\Form\Form; use Combodo\iTop\Application\UI\Component\Html\Html; use Combodo\iTop\Application\UI\Component\Input\InputFactory; +use Combodo\iTop\Application\UI\Component\Input\RichText\RichText; use Combodo\iTop\Application\UI\Component\Panel\Panel; use Combodo\iTop\Application\UI\Component\Title\TitleFactory; use Combodo\iTop\Application\UI\Layout\PageContent\PageContentFactory; @@ -463,10 +464,12 @@ function GetUserLanguageForm(ApplicationContext $oAppContext, string $sURL): For $aSortedLang[$aLang['description']] = $sCode; } ksort($aSortedLang); - $oUserLanguageBlockSelect = InputFactory::MakeForSelect('language', Dict::S('UI:Favorites:SelectYourLanguage')); + $oUserLanguageBlockSelect = InputFactory::MakeForSelectWithLabel('language', Dict::S('UI:Favorites:SelectYourLanguage')); + /** @var \Combodo\iTop\Application\UI\Component\Input\Select $oUserLanguageBlockSelectInput */ + $oUserLanguageBlockSelectInput = $oUserLanguageBlockSelect->GetInput(); foreach ($aSortedLang as $sCode) { $bSelected = ($sCode == Dict::GetUserLanguage()); - $oUserLanguageBlockSelect->AddOption(InputFactory::MakeForSelectOption($sCode, $aLanguages[$sCode]['description'].' ('.$aLanguages[$sCode]['localized_description'].')', $bSelected)); + $oUserLanguageBlockSelectInput->AddOption(InputFactory::MakeForSelectOption($sCode, $aLanguages[$sCode]['description'].' ('.$aLanguages[$sCode]['localized_description'].')', $bSelected)); } $oUserLanguageForm->AddSubBlock($oUserLanguageBlockSelect); @@ -478,6 +481,9 @@ function GetUserLanguageForm(ApplicationContext $oAppContext, string $sURL): For // - Submit button $oUserLanguageSubmitButton = ButtonFactory::MakeForValidationAction(Dict::S('UI:Button:Apply'), null, null, true); $oUserLanguageForm->AddSubBlock($oUserLanguageSubmitButton); + + $oTestRichText = new RichText(); + $oUserLanguageForm->AddSubBlock($oTestRichText); return $oUserLanguageForm; } diff --git a/sources/application/UI/Component/Input/InputFactory.php b/sources/application/UI/Component/Input/InputFactory.php index b0e58f32e..dd06e1d21 100644 --- a/sources/application/UI/Component/Input/InputFactory.php +++ b/sources/application/UI/Component/Input/InputFactory.php @@ -8,6 +8,9 @@ namespace Combodo\iTop\Application\UI\Component\Input; +use Combodo\iTop\Application\UI\Component\Input\Select\Select; +use Combodo\iTop\Application\UI\Component\Input\Select\SelectOption; + class InputFactory { @@ -22,13 +25,20 @@ class InputFactory return $oInput; } - public static function MakeForSelect(string $sName, string $sLabel, ?string $sId = null): Select + public static function MakeForSelectWithLabel(string $sName, string $sLabel, ?string $sId = null): InputWithLabel + { + $oInput = new Select(); + $oInput->SetName($sName); + + $oInputWithLabel = new InputWithLabel($sLabel, $oInput, $sId); + + return $oInputWithLabel; + } + public static function MakeForSelect(string $sName, ?string $sId = null): Select { $oInput = new Select($sId); - - $oInput->SetName($sName) - ->SetLabel($sLabel); - + $oInput->SetName($sName); + return $oInput; } diff --git a/sources/application/UI/Component/Input/InputWithLabel.php b/sources/application/UI/Component/Input/InputWithLabel.php index e96dc4213..47266b483 100644 --- a/sources/application/UI/Component/Input/InputWithLabel.php +++ b/sources/application/UI/Component/Input/InputWithLabel.php @@ -8,12 +8,49 @@ namespace Combodo\iTop\Application\UI\Component\Input; -class InputWithLabel extends Input +use Combodo\iTop\Application\UI\UIBlock; + +class InputWithLabel extends UIBlock { public const HTML_TEMPLATE_REL_PATH = 'components/input/inputwithlabel'; /** @var string */ protected $sLabel; + /** @var \Combodo\iTop\Application\UI\Component\Input\Input */ + protected $oInput; + + /** + * InputWithLabel constructor. + * + * @param string $sLabel + * @param \Combodo\iTop\Application\UI\Component\Input\Input $oInput + */ + public function __construct(string $sLabel, \Combodo\iTop\Application\UI\Component\Input\Input $oInput, ?string $sId) + { + parent::__construct($sId); + $this->sLabel = $sLabel; + $this->oInput = $oInput; + } + + /** + * @return \Combodo\iTop\Application\UI\Component\Input\Input + */ + public function GetInput(): \Combodo\iTop\Application\UI\Component\Input\Input + { + return $this->oInput; + } + + /** + * @param \Combodo\iTop\Application\UI\Component\Input\Input $oInput + * + * @return $this + */ + public function SetInput(\Combodo\iTop\Application\UI\Component\Input\Input $oInput): InputWithLabel + { + $this->oInput = $oInput; + return $this; + } + /** * @return string diff --git a/sources/application/UI/Component/Input/Select.php b/sources/application/UI/Component/Input/Select/Select.php similarity index 67% rename from sources/application/UI/Component/Input/Select.php rename to sources/application/UI/Component/Input/Select/Select.php index 15bebd4eb..2db7bc793 100644 --- a/sources/application/UI/Component/Input/Select.php +++ b/sources/application/UI/Component/Input/Select/Select.php @@ -5,12 +5,14 @@ */ -namespace Combodo\iTop\Application\UI\Component\Input; +namespace Combodo\iTop\Application\UI\Component\Input\Select; -class Select extends InputWithLabel +use Combodo\iTop\Application\UI\Component\Input\Input; + +class Select extends Input { - public const HTML_TEMPLATE_REL_PATH = 'components/input/select'; + public const HTML_TEMPLATE_REL_PATH = 'components/input/select/select'; /** @var array */ protected $aOptions; diff --git a/sources/application/UI/Component/Input/SelectOption.php b/sources/application/UI/Component/Input/Select/SelectOption.php similarity index 89% rename from sources/application/UI/Component/Input/SelectOption.php rename to sources/application/UI/Component/Input/Select/SelectOption.php index 524b0cf2f..7fe853671 100644 --- a/sources/application/UI/Component/Input/SelectOption.php +++ b/sources/application/UI/Component/Input/Select/SelectOption.php @@ -5,14 +5,14 @@ */ -namespace Combodo\iTop\Application\UI\Component\Input; +namespace Combodo\iTop\Application\UI\Component\Input\Select; use Combodo\iTop\Application\UI\UIBlock; class SelectOption extends UIBlock { - public const HTML_TEMPLATE_REL_PATH = 'components/input/selectoption'; + public const HTML_TEMPLATE_REL_PATH = 'components/input/select/selectoption'; /** @var string */ protected $sValue; diff --git a/templates/components/input/inputwithlabel.html.twig b/templates/components/input/inputwithlabel.html.twig index c2a7c1d8e..38642aab6 100644 --- a/templates/components/input/inputwithlabel.html.twig +++ b/templates/components/input/inputwithlabel.html.twig @@ -1,4 +1,4 @@ -{% extends "components/input/layout.html.twig" %} {% block iboInputLabel %} + {{ render_block(oUIBlock.GetInput()) }} {% endblock %} diff --git a/templates/components/input/select.html.twig b/templates/components/input/select/select.html.twig similarity index 86% rename from templates/components/input/select.html.twig rename to templates/components/input/select/select.html.twig index 67fb296bd..d2afdce60 100644 --- a/templates/components/input/select.html.twig +++ b/templates/components/input/select/select.html.twig @@ -1,6 +1,6 @@ {# @copyright Copyright (C) 2010-2020 Combodo SARL #} {# @license http://opensource.org/licenses/AGPL-3.0 #} -{% extends "components/input/inputwithlabel.html.twig" %} +{% extends "components/input/layout.html.twig" %} {% block iboInput %}