From aed46acb8130bde35b7f1b9c3fd7bc731b92f94c Mon Sep 17 00:00:00 2001 From: Dan Ungureanu Date: Sat, 8 Jul 2017 18:20:15 +0100 Subject: [PATCH 1/3] Added Format button on edit view form. Fixes #13448. Signed-off-by: Dan Ungureanu --- ChangeLog | 1 + js/functions.js | 8 ++++---- themes/pmahomme/css/rte.css.php | 1 + view_create.php | 4 +++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 04f0a44baf..35226c5da9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24,6 +24,7 @@ phpMyAdmin - ChangeLog - issue #13095 Fixed alignmnet of foreign keys editing - issue #12944 Improved inline editor for JSON - issue #13145 Improved layout of operations pages +- issue #13448 Add "format" query button in edit view form 4.7.3 (not yet released) - issue #13447 Large multi-line query removes Export operation and blanks query box options diff --git a/js/functions.js b/js/functions.js index b00813499e..fd62cfcd67 100644 --- a/js/functions.js +++ b/js/functions.js @@ -4721,21 +4721,21 @@ AJAX.registerOnload('functions.js', function () { }); // end $(document).on() } - syntaxHighlighter = PMA_getSQLEditor($('textarea[name="view[as]"]')); + codemirror_editor = PMA_getSQLEditor($('textarea[name="view[as]"]')); }); function PMA_createViewDialog($this) { var $msg = PMA_ajaxShowMessage(); - var syntaxHighlighter = null; + var codemirror_editor = null; $.get($this.attr('href') + '&ajax_request=1&ajax_dialog=1', function (data) { if (typeof data !== 'undefined' && data.success === true) { PMA_ajaxRemoveMessage($msg); var buttonOptions = {}; buttonOptions[PMA_messages.strGo] = function () { if (typeof CodeMirror !== 'undefined') { - syntaxHighlighter.save(); + codemirror_editor.save(); } $msg = PMA_ajaxShowMessage(); $.post('view_create.php', $('#createViewDialog').find('form').serialize(), function (data) { @@ -4763,7 +4763,7 @@ function PMA_createViewDialog($this) } }); // Attach syntax highlighted editor - syntaxHighlighter = PMA_getSQLEditor($dialog.find('textarea')); + codemirror_editor = PMA_getSQLEditor($dialog.find('textarea')); $('input:visible[type=text]', $dialog).first().focus(); } else { PMA_ajaxShowMessage(data.error); diff --git a/themes/pmahomme/css/rte.css.php b/themes/pmahomme/css/rte.css.php index 55d7832e9a..f75488ccf0 100644 --- a/themes/pmahomme/css/rte.css.php +++ b/themes/pmahomme/css/rte.css.php @@ -38,6 +38,7 @@ if (! defined('PMA_MINIMUM_COMMON') && ! defined('TESTSUITE')) { -webkit-box-sizing: border-box; } +.rte_table input[type=button], .rte_table input[type=checkbox], .rte_table input[type=radio] { width: auto; diff --git a/view_create.php b/view_create.php index fbe8e6747c..f11784edad 100644 --- a/view_create.php +++ b/view_create.php @@ -275,7 +275,9 @@ $htmlString .= 'AS' if ($GLOBALS['cfg']['TextareaAutoSelect'] || true) { $htmlString .= ' onclick="selectContent(this, sql_box_locked, true)"'; } -$htmlString .= '>' . htmlspecialchars($view['as']) . '' +$htmlString .= '>' . htmlspecialchars($view['as']) . '
' + . '' + . '' . ''; $htmlString .= 'WITH CHECK OPTION' From 1dbc1667ed839d80b375a6b57f93f42bf8f17245 Mon Sep 17 00:00:00 2001 From: Dan Ungureanu Date: Sun, 9 Jul 2017 12:22:07 +0100 Subject: [PATCH 2/3] Refactored view_create to use Twig templates. Signed-off-by: Dan Ungureanu --- templates/view_create.twig | 123 +++++++++++++++++++++++++++++++++++ view_create.php | 128 ++----------------------------------- 2 files changed, 130 insertions(+), 121 deletions(-) create mode 100644 templates/view_create.twig diff --git a/templates/view_create.twig b/templates/view_create.twig new file mode 100644 index 0000000000..79e8b2457e --- /dev/null +++ b/templates/view_create.twig @@ -0,0 +1,123 @@ + +
+
+ {{ URL_getHiddenInputs(url_params) }} +
+ + {% if ajax_dialog %} + {% trans 'Details' %} + {% else %} + {% if view['operation'] == 'create' %} + {% trans 'Create view' %} + {% else %} + {% trans 'Edit view' %} + {% endif %} + {% endif %} + + + {% if view['operation'] == 'create' %} + + + + + {% endif %} + + + + + + + + + + + + + + + + + {% if view['operation'] == 'create' %} + + + + + {% else %} + + + + {% endif %} + + + + + + + + + + + + + + + + +
+ +
+ +
{% trans 'Definer' %}
SQL SECURITY + +
{% trans 'VIEW name' %} + +
+ +
{% trans 'Column names' %} + +
AS +
+ + +
WITH CHECK OPTION + +
+
+ + {% if ajax_dialog %} +
+ + +
+ {% else %} + + + + {% endif %} + +
+
diff --git a/view_create.php b/view_create.php index f11784edad..ca2672c019 100644 --- a/view_create.php +++ b/view_create.php @@ -11,6 +11,7 @@ use PhpMyAdmin\Core; use PhpMyAdmin\Url; use PhpMyAdmin\Response; +use PhpMyAdmin\Template; require_once './libraries/common.inc.php'; @@ -194,124 +195,9 @@ if (Core::isValid($_REQUEST['view'], 'array')) { $url_params['db'] = $GLOBALS['db']; $url_params['reload'] = 1; -/** - * Displays the page - */ -$htmlString = '' - . '
' - . '
' - . Url::getHiddenInputs($url_params) - . '
' - . '' - . (isset($_REQUEST['ajax_dialog']) ? - __('Details') : - ($view['operation'] == 'create' ? __('Create view') : __('Edit view')) - ) - . '' - . ''; - -if ($view['operation'] == 'create') { - $htmlString .= '' - . '' - . '' - . ''; - -$htmlString .= '' - . ''; - -$htmlString .= '' - . ''; - -if ($view['operation'] == 'create') { - $htmlString .= '' - . ''; -} else { - $htmlString .= ''; -} - -$htmlString .= '' - . ''; - -$htmlString .= '' - . ' @@ -97,9 +97,9 @@
' - . '
' . __('Definer') . '' - . '
SQL SECURITY' - . '
' . __('VIEW name') . '' - . '
' - . '
' . __('Column names') . '' - . '
AS' - . '
+