diff --git a/lib/composer/autoload_classmap.php b/lib/composer/autoload_classmap.php index b52d135a7..dfaf5ffab 100644 --- a/lib/composer/autoload_classmap.php +++ b/lib/composer/autoload_classmap.php @@ -175,12 +175,14 @@ return array( 'Combodo\\iTop\\Application\\UI\\Base\\Component\\GlobalSearch\\GlobalSearchFactory' => $baseDir . '/sources/application/UI/Base/Component/GlobalSearch/GlobalSearchFactory.php', 'Combodo\\iTop\\Application\\UI\\Base\\Component\\GlobalSearch\\GlobalSearchHelper' => $baseDir . '/sources/application/UI/Base/Component/GlobalSearch/GlobalSearchHelper.php', 'Combodo\\iTop\\Application\\UI\\Base\\Component\\Html\\Html' => $baseDir . '/sources/application/UI/Base/Component/Html/Html.php', + 'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\AbstractInput' => $baseDir . '/sources/application/UI/Base/Component/Input/AbstractInput.php', 'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\Input' => $baseDir . '/sources/application/UI/Base/Component/Input/Input.php', 'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\InputFactory' => $baseDir . '/sources/application/UI/Base/Component/Input/InputFactory.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\\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\\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', 'Combodo\\iTop\\Application\\UI\\Base\\Component\\Panel\\PanelFactory' => $baseDir . '/sources/application/UI/Base/Component/Panel/PanelFactory.php', @@ -196,7 +198,6 @@ return array( 'Combodo\\iTop\\Application\\UI\\Base\\Component\\QuickCreate\\QuickCreate' => $baseDir . '/sources/application/UI/Base/Component/QuickCreate/QuickCreate.php', 'Combodo\\iTop\\Application\\UI\\Base\\Component\\QuickCreate\\QuickCreateFactory' => $baseDir . '/sources/application/UI/Base/Component/QuickCreate/QuickCreateFactory.php', 'Combodo\\iTop\\Application\\UI\\Base\\Component\\QuickCreate\\QuickCreateHelper' => $baseDir . '/sources/application/UI/Base/Component/QuickCreate/QuickCreateHelper.php', - 'Combodo\\iTop\\Application\\UI\\Base\\Component\\SearchBlock\\SearchBlock' => $baseDir . '/sources/application/UI/Base/Component/SearchBlock/SearchBlock.php', 'Combodo\\iTop\\Application\\UI\\Base\\Component\\Title\\Title' => $baseDir . '/sources/application/UI/Base/Component/Title/Title.php', 'Combodo\\iTop\\Application\\UI\\Base\\Component\\Title\\TitleFactory' => $baseDir . '/sources/application/UI/Base/Component/Title/TitleFactory.php', 'Combodo\\iTop\\Application\\UI\\Base\\Component\\Title\\TitleForObjectDetails' => $baseDir . '/sources/application/UI/Base/Component/Title/TitleForObjectDetails.php', diff --git a/lib/composer/autoload_static.php b/lib/composer/autoload_static.php index 89836d15e..b15b805fd 100644 --- a/lib/composer/autoload_static.php +++ b/lib/composer/autoload_static.php @@ -405,12 +405,14 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b 'Combodo\\iTop\\Application\\UI\\Base\\Component\\GlobalSearch\\GlobalSearchFactory' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/GlobalSearch/GlobalSearchFactory.php', 'Combodo\\iTop\\Application\\UI\\Base\\Component\\GlobalSearch\\GlobalSearchHelper' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/GlobalSearch/GlobalSearchHelper.php', 'Combodo\\iTop\\Application\\UI\\Base\\Component\\Html\\Html' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/Html/Html.php', + 'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\AbstractInput' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/Input/AbstractInput.php', 'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\Input' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/Input/Input.php', 'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\InputFactory' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/Input/InputFactory.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\\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\\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', 'Combodo\\iTop\\Application\\UI\\Base\\Component\\Panel\\PanelFactory' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/Panel/PanelFactory.php', @@ -426,7 +428,6 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b 'Combodo\\iTop\\Application\\UI\\Base\\Component\\QuickCreate\\QuickCreate' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/QuickCreate/QuickCreate.php', 'Combodo\\iTop\\Application\\UI\\Base\\Component\\QuickCreate\\QuickCreateFactory' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/QuickCreate/QuickCreateFactory.php', 'Combodo\\iTop\\Application\\UI\\Base\\Component\\QuickCreate\\QuickCreateHelper' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/QuickCreate/QuickCreateHelper.php', - 'Combodo\\iTop\\Application\\UI\\Base\\Component\\SearchBlock\\SearchBlock' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/SearchBlock/SearchBlock.php', 'Combodo\\iTop\\Application\\UI\\Base\\Component\\Title\\Title' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/Title/Title.php', 'Combodo\\iTop\\Application\\UI\\Base\\Component\\Title\\TitleFactory' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/Title/TitleFactory.php', 'Combodo\\iTop\\Application\\UI\\Base\\Component\\Title\\TitleForObjectDetails' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/Title/TitleForObjectDetails.php', diff --git a/pages/run_query.php b/pages/run_query.php index 0cb09ed99..410e5522b 100644 --- a/pages/run_query.php +++ b/pages/run_query.php @@ -17,6 +17,10 @@ * You should have received a copy of the GNU Affero General Public License */ +use Combodo\iTop\Application\UI\Base\Component\Button\ButtonFactory; +use Combodo\iTop\Application\UI\Base\Component\Html\Html; +use Combodo\iTop\Application\UI\Base\Component\Input\InputFactory; + require_once('../approot.inc.php'); require_once(APPROOT.'/application/application.inc.php'); require_once(APPROOT.'/application/startup.inc.php'); @@ -138,12 +142,9 @@ try foreach($oFilter->GetQueryParams() as $sParam => $foo) { $value = utils::ReadParam('arg_'.$sParam, null, true, 'raw_data'); - if (!is_null($value)) - { + if (!is_null($value)) { $aArgs[$sParam] = $value; - } - else - { + } else { $aArgs[$sParam] = ''; } } @@ -152,9 +153,29 @@ try } } - $oP->add("
\n"); - $oP->add(Dict::S('UI:RunQuery:ExpressionToEvaluate')."
\n"); - $oP->add("\n"); + $oQueryForm = new \Combodo\iTop\Application\UI\Base\Component\Form\Form(); + $oP->AddUiBlock($oQueryForm); + + $oHiddenParams = new Html($oAppContext->GetForForm()); + $oQueryForm->AddSubBlock($oHiddenParams); + + $oQueryTextarea = InputFactory::MakeForTextareaWithLabel( + 'expression', + Dict::S('UI:RunQuery:ExpressionToEvaluate'), + 'expression', + utils::HtmlEntities($sExpression), + 120, 8 + ); + $oQueryForm->AddSubBlock($oQueryTextarea); + + $oQuerySubmit = ButtonFactory::MakeForPrimaryAction( + Dict::S('UI:Button:Evaluate'), + null, + null, + true + ); + $oQueryForm->AddSubBlock($oQuerySubmit); + $oP->add_linked_script(utils::GetAbsoluteUrlAppRoot()."/js/jquery.hotkeys.js"); $oP->add_ready_script(<< 0) - { + if (count($aArgs) > 0) { $oP->add("
\n"); $oP->add("

Query arguments

\n"); - foreach($aArgs as $sParam => $sValue) - { + foreach ($aArgs as $sParam => $sValue) { $oP->p("$sParam: \n"); } - $oP->add("
\n"); + $oP->add("\n"); } - $oP->add("\n"); - $oP->add($oAppContext->GetForForm()); - $oP->add("\n"); - - if ($oFilter) - { + if ($oFilter) { $oP->add("

Query results

\n"); - + $oResultBlock = new DisplayBlock($oFilter, 'list', false); $oResultBlock->Display($oP, 'runquery'); diff --git a/sources/application/UI/Base/Component/Input/AbstractInput.php b/sources/application/UI/Base/Component/Input/AbstractInput.php new file mode 100644 index 000000000..66dda5462 --- /dev/null +++ b/sources/application/UI/Base/Component/Input/AbstractInput.php @@ -0,0 +1,45 @@ +sName; + } + + public function SetName(string $sName): AbstractInput + { + $this->sName = $sName; + + return $this; + } + + public function GetValue(): ?string + { + return $this->sValue; + } + + public function SetValue(?string $sValue): AbstractInput + { + $this->sValue = $sValue; + + return $this; + } +} \ No newline at end of file diff --git a/sources/application/UI/Base/Component/Input/Input.php b/sources/application/UI/Base/Component/Input/Input.php index f5d56275e..df3bcb9fc 100644 --- a/sources/application/UI/Base/Component/Input/Input.php +++ b/sources/application/UI/Base/Component/Input/Input.php @@ -7,14 +7,12 @@ namespace Combodo\iTop\Application\UI\Base\Component\Input; -use Combodo\iTop\Application\UI\Base\UIBlock; - /** * Class Input * * @package Combodo\iTop\Application\UI\Base\Component\Input */ -class Input extends UIBlock +class Input extends AbstractInput { // Overloaded constants public const BLOCK_CODE = 'ibo-input'; @@ -24,67 +22,15 @@ class Input extends UIBlock /** @var string */ protected $sType; - /** @var string */ - protected $sName; - /** @var string */ - protected $sValue; - /** - * @return string - */ public function GetType(): string { return $this->sType; } - /** - * @param string $sType - * - * @return Input - */ public function SetType(string $sType): Input { $this->sType = $sType; return $this; } - - /** - * @return string - */ - public function GetName(): string - { - return $this->sName; - } - - /** - * @param string $sName - * - * @return Input - */ - public function SetName(string $sName): Input - { - $this->sName = $sName; - return $this; - } - - /** - * @return string - */ - public function GetValue(): string - { - return $this->sValue; - } - - /** - * @param string $sValue - * - * @return Input - */ - public function SetValue(string $sValue): Input - { - $this->sValue = $sValue; - return $this; - } - - } \ No newline at end of file diff --git a/sources/application/UI/Base/Component/Input/InputFactory.php b/sources/application/UI/Base/Component/Input/InputFactory.php index 3e429dd8c..c84fd4668 100644 --- a/sources/application/UI/Base/Component/Input/InputFactory.php +++ b/sources/application/UI/Base/Component/Input/InputFactory.php @@ -27,18 +27,38 @@ class InputFactory public static function MakeForSelectWithLabel(string $sName, string $sLabel, ?string $sId = null): InputWithLabel { - $oInput = new Select(); + $oInput = new Select($sId); $oInput->SetName($sName); + if (is_null($sId)) { + $sId = $oInput->GetId(); + } $oInputWithLabel = new InputWithLabel($sLabel, $oInput, $sId); - + return $oInputWithLabel; - } + } + + public static function MakeForTextareaWithLabel( + string $sName, string $sLabel, ?string $sId = null, ?string $sValue = null, + ?int $iCols = null, ?int $iRows = null + ): InputWithLabel + { + $oTextArea = new TextArea($sValue, $sId, $iCols, $iRows); + $oTextArea->SetName($sName); + + if (is_null($sId)) { + $sId = $oTextArea->GetId(); + } + $oInputWithLabel = new InputWithLabel($sLabel, $oTextArea, $sId); + + return $oInputWithLabel; + } + public static function MakeForSelect(string $sName, ?string $sId = null): Select { $oInput = new Select($sId); $oInput->SetName($sName); - + return $oInput; } diff --git a/sources/application/UI/Base/Component/Input/InputWithLabel.php b/sources/application/UI/Base/Component/Input/InputWithLabel.php index d7f772454..785ad3e60 100644 --- a/sources/application/UI/Base/Component/Input/InputWithLabel.php +++ b/sources/application/UI/Base/Component/Input/InputWithLabel.php @@ -16,38 +16,33 @@ class InputWithLabel extends UIBlock /** @var string */ protected $sLabel; - /** @var \Combodo\iTop\Application\UI\Base\Component\Input\Input */ + /** @var \Combodo\iTop\Application\UI\Base\Component\Input\AbstractInput */ protected $oInput; + /** @var bool */ + protected $bHasBr; - /** - * InputWithLabel constructor. - * - * @param string $sLabel - * @param \Combodo\iTop\Application\UI\Base\Component\Input\Input $oInput - */ - public function __construct(string $sLabel, \Combodo\iTop\Application\UI\Base\Component\Input\Input $oInput, ?string $sId) + public function __construct(string $sLabel, AbstractInput $oInput, ?string $sId, ?bool $bHasBr = null) { parent::__construct($sId); $this->sLabel = $sLabel; $this->oInput = $oInput; + + if (is_null($bHasBr)) { + $this->bHasBr = ($oInput instanceof TextArea); + } else { + $this->bHasBr = $bHasBr; + } } - /** - * @return \Combodo\iTop\Application\UI\Base\Component\Input\Input - */ - public function GetInput(): \Combodo\iTop\Application\UI\Base\Component\Input\Input + public function GetInput(): AbstractInput { return $this->oInput; } - /** - * @param \Combodo\iTop\Application\UI\Base\Component\Input\Input $oInput - * - * @return $this - */ - public function SetInput(\Combodo\iTop\Application\UI\Base\Component\Input\Input $oInput): InputWithLabel + public function SetInput(AbstractInput $oInput): InputWithLabel { $this->oInput = $oInput; + return $this; } @@ -68,7 +63,12 @@ class InputWithLabel extends UIBlock public function SetLabel(string $sLabel): InputWithLabel { $this->sLabel = $sLabel; + return $this; } + public function HasBr(): bool + { + return $this->bHasBr; + } } \ No newline at end of file diff --git a/sources/application/UI/Base/Component/Input/TextArea.php b/sources/application/UI/Base/Component/Input/TextArea.php new file mode 100644 index 000000000..a1f984d49 --- /dev/null +++ b/sources/application/UI/Base/Component/Input/TextArea.php @@ -0,0 +1,56 @@ +sValue = $sValue; + $this->iCols = $iCols; + $this->iRows = $iRows; + } + + public function GetCols(): int + { + return $this->iCols; + } + + public function SetCols(int $iCols): TextArea + { + $this->iCols = $iCols; + + return $this; + } + + public function GetRows(): int + { + return $this->iRows; + } + + public function SetRows(int $iRows): TextArea + { + $this->iRows = $iRows; + + return $this; + } +} \ No newline at end of file diff --git a/templates/base/components/input/input-textarea.html.twig b/templates/base/components/input/input-textarea.html.twig new file mode 100644 index 000000000..d95b545f7 --- /dev/null +++ b/templates/base/components/input/input-textarea.html.twig @@ -0,0 +1,8 @@ +{% block iboInputLabel %} +{% endblock %} +{% block iboInput %} + +{% endblock %} \ No newline at end of file diff --git a/templates/base/components/input/inputwithlabel.html.twig b/templates/base/components/input/inputwithlabel.html.twig index 38642aab6..ad879eb57 100644 --- a/templates/base/components/input/inputwithlabel.html.twig +++ b/templates/base/components/input/inputwithlabel.html.twig @@ -1,4 +1,5 @@ {% block iboInputLabel %} - + + {% if oUIBlock.HasBr() %}
{% endif %} {{ render_block(oUIBlock.GetInput()) }} {% endblock %}