diff --git a/lib/composer/autoload_classmap.php b/lib/composer/autoload_classmap.php index 0c4afec18..22c6cf1ed 100644 --- a/lib/composer/autoload_classmap.php +++ b/lib/composer/autoload_classmap.php @@ -179,6 +179,7 @@ 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\\Html\\HtmlFactory' => $baseDir . '/sources/application/UI/Base/Component/Html/HtmlFactory.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', diff --git a/lib/composer/autoload_static.php b/lib/composer/autoload_static.php index a951a1167..b207a89aa 100644 --- a/lib/composer/autoload_static.php +++ b/lib/composer/autoload_static.php @@ -409,6 +409,7 @@ 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\\Html\\HtmlFactory' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/Html/HtmlFactory.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', diff --git a/pages/run_query.php b/pages/run_query.php index ce70e9efd..26515f469 100644 --- a/pages/run_query.php +++ b/pages/run_query.php @@ -23,6 +23,7 @@ use Combodo\iTop\Application\UI\Base\Component\CollapsibleSection\CollapsibleSec use Combodo\iTop\Application\UI\Base\Component\FieldSet\FieldSet; 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\Html\HtmlFactory; use Combodo\iTop\Application\UI\Base\Component\Input\InputFactory; use Combodo\iTop\Application\UI\Base\Component\Input\TextArea; use Combodo\iTop\Application\UI\Base\Component\Panel\PanelFactory; @@ -83,6 +84,8 @@ function ShowExamples($oP, $sExpression) $aDisplayData[Dict::S('UI:RunQuery:QueryExamples')][] = array( 'desc' => "
".utils::EscapeHtml($sDescription)."
", 'oql' => "
".utils::EscapeHtml($sOql)."
", + //TODO 3.0.0 : buttons are not styled properly yet... + // This whole "query examples" may be migrated to TWIG using iTop Twig tags ? 'go' => "
$sContext
\n", ); } @@ -301,6 +304,9 @@ EOF $oMoreInfoSection->EnableSaveCollapsibleState('run_query__more-info'); $oP->AddUiBlock($oMoreInfoSection); } elseif ($sSyntaxError) { + $oSyntaxErrorPanel = PanelFactory::MakeForFailure(Dict::S('UI:RunQuery:Error')); + $oP->AddUiBlock($oSyntaxErrorPanel); + if ($e instanceof OqlException) { $sWrongWord = $e->GetWrongWord(); $aSuggestedWords = $e->GetSuggestions(); @@ -313,27 +319,27 @@ EOF $sAfter = substr($sExpression, $e->GetColumn() + strlen($sWrongWord)); $sFixedExpression = $sBefore.$sSuggestedWord.$sAfter; $sFixedExpressionHtml = $sBefore.''.$sSuggestedWord.''.$sAfter; - $sSyntaxErrorText .= $oP->GetP("Suggesting: $sFixedExpressionHtml"); + $sSyntaxErrorText .= "

Suggesting: $sFixedExpressionHtml

"; + $oSyntaxErrorPanel->AddSubBlock(new Html($sSyntaxErrorText)); + $sEscapedExpression = utils::EscapeHtml(addslashes($sFixedExpression)); - $sSyntaxErrorText .= $oP->GetP(<<Use this query -HTML + $oUseSuggestedQueryButton = ButtonFactory::MakeForDestructiveAction('Use this query'); + $oUseSuggestedQueryButton->SetOnClickJsCode(<<AddSubBlock($oUseSuggestedQueryButton); } else { - $sSyntaxErrorText = $oP->GetP($e->getHtmlDesc()); + $oSyntaxErrorPanel->AddSubBlock(HtmlFactory::MakeP($e->getHtmlDesc())); } } else { - $sSyntaxErrorText = $oP->GetP($e->getHtmlDesc()); + $oSyntaxErrorPanel->AddSubBlock(HtmlFactory::MakeP($e->getHtmlDesc())); } } else { - $sSyntaxErrorText = $oP->GetP($e->getMessage()); + $oSyntaxErrorPanel->AddSubBlock(HtmlFactory::MakeP($e->getMessage())); } - - $oSyntaxErrorPanel = AlertFactory::MakeForFailure(Dict::S('UI:RunQuery:Error'), $sSyntaxErrorText); - $oSyntaxErrorPanel->SetOpenedByDefault(true); - $oP->AddUiBlock($oSyntaxErrorPanel); } } catch (Exception $e) { diff --git a/sources/application/UI/Base/Component/Html/HtmlFactory.php b/sources/application/UI/Base/Component/Html/HtmlFactory.php new file mode 100644 index 000000000..732d90025 --- /dev/null +++ b/sources/application/UI/Base/Component/Html/HtmlFactory.php @@ -0,0 +1,33 @@ +'.$sContent.'

'); + } +} \ No newline at end of file