From 5f8f7ba88e9bc2a166fb6c2730a3bcd9b3a2d996 Mon Sep 17 00:00:00 2001 From: Dan Ungureanu Date: Mon, 9 Mar 2015 01:22:56 +0200 Subject: [PATCH] RFE #1570, part 2. Added the possibility of permanently using Enter instead of Ctrl+Enter in console. Signed-off-by: Dan Ungureanu --- doc/config.rst | 11 +++++++++++ js/console.js | 2 +- libraries/Console.class.php | 3 ++- libraries/Header.class.php | 2 ++ libraries/config.default.php | 7 +++++++ libraries/config/messages.inc.php | 4 ++++ libraries/config/user_preferences.forms.php | 3 ++- 7 files changed, 29 insertions(+), 3 deletions(-) diff --git a/doc/config.rst b/doc/config.rst index aae9743e8d..237df7f45a 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -144,6 +144,17 @@ Basic settings set, and the :config:option:`$cfg['UserprefsDisallow']` directive should contain ``'SendErrorReports'`` in one of its array values. +.. config:option:: $cfg['ConsoleEnterExecutes'] + + :type: boolean + :default: false + + Setting this to ``true`` allows the user to execute queries by pressing Enter + instead of Ctrl+Enter. A new line can be inserted by pressing Shift + Enter. + + The behaviour of the console can be temporary changed using console's + settings interface. + .. config:option:: $cfg['AllowThirdPartyFraming'] :type: boolean diff --git a/js/console.js b/js/console.js index 3d95e7a234..6f37411da6 100644 --- a/js/console.js +++ b/js/console.js @@ -107,7 +107,7 @@ var PMA_console = { if(tempConfig.currentQuery === true) { $('#pma_console_options input[name=current_query]').prop('checked', true); } - if(tempConfig.enterExecutes === true) { + if(ConsoleEnterExecutes === true) { $('#pma_console_options input[name=enter_executes]').prop('checked', true); } } else { diff --git a/libraries/Console.class.php b/libraries/Console.class.php index 1da0c229c1..daf70052e9 100644 --- a/libraries/Console.class.php +++ b/libraries/Console.class.php @@ -314,7 +314,8 @@ class PMA_Console . '
' . '
' + . __('Execute queries on Enter and insert new line with Shift + Enter. ' + . 'To make this permanent, view settings.') . '
' . ''; $output .= ''; // Options card diff --git a/libraries/Header.class.php b/libraries/Header.class.php index a95e3eecc3..43bf79ee13 100644 --- a/libraries/Header.class.php +++ b/libraries/Header.class.php @@ -397,6 +397,8 @@ class PMA_Header $this->_scripts->addFile('codemirror/addon/hint/show-hint.js'); $this->_scripts->addFile('codemirror/addon/hint/sql-hint.js'); } + $this->_scripts->addCode('ConsoleEnterExecutes=' + . ($GLOBALS['cfg']['ConsoleEnterExecutes'] ? 'true' : 'false')); if ($this->_userprefsOfferImport) { $this->_scripts->addFile('config.js'); } diff --git a/libraries/config.default.php b/libraries/config.default.php index 652bdda4c6..672bcbe9be 100644 --- a/libraries/config.default.php +++ b/libraries/config.default.php @@ -2958,6 +2958,13 @@ $cfg['DisableMultiTableMaintenance'] = false; */ $cfg['SendErrorReports'] = 'ask'; +/** + * Whether Enter or Ctrl+Enter executes queries in the console. + * + * @global boolean $cfg['ConsoleEnterExecutes'] + */ +$cfg['ConsoleEnterExecutes'] = false; + /** * Zero Configuration mode. * diff --git a/libraries/config/messages.inc.php b/libraries/config/messages.inc.php index 6985fa26d2..4141213d01 100644 --- a/libraries/config/messages.inc.php +++ b/libraries/config/messages.inc.php @@ -807,6 +807,10 @@ $strConfigCaptchaLoginPrivateKey_name = __('Private key for reCaptcha'); $strConfigSendErrorReports_desc = __('Choose the default action when sending error reports.'); $strConfigSendErrorReports_name = __('Send error reports'); + +$strConfigConsoleEnterExecutes_desc = __('Queries are executed by pressing Enter (instead of Ctrl+Enter). New lines will be inserted with Shift+Enter'); +$strConfigConsoleEnterExecutes_name = __('Enter executes queries in console'); + $strConfigZeroConf_desc = __( 'Enable Zero Configuration mode which lets you setup phpMyAdmin ' . 'configuration storage tables automatically.' diff --git a/libraries/config/user_preferences.forms.php b/libraries/config/user_preferences.forms.php index 150642e93f..442bb35a15 100644 --- a/libraries/config/user_preferences.forms.php +++ b/libraries/config/user_preferences.forms.php @@ -34,7 +34,8 @@ $forms['Features']['General'] = array( 'MaxTableList', 'NumFavoriteTables', 'ShowHint', - 'SendErrorReports' + 'SendErrorReports', + 'ConsoleEnterExecutes' ); $forms['Features']['Text_fields'] = array( 'CharEditing',