From 3151d41d0e13e2f422aaf88faeffd5e1f93c897a Mon Sep 17 00:00:00 2001 From: Eric Krona Date: Sun, 29 Jan 2012 22:02:13 +0100 Subject: [PATCH 1/3] Activated codemirror for inline edits of queries. --- js/functions.js | 18 +++++++++++++++++- sql.php | 4 ++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/js/functions.js b/js/functions.js index 12c6a653c7..46869fb919 100644 --- a/js/functions.js +++ b/js/functions.js @@ -1150,8 +1150,24 @@ $(document).ready(function(){ new_content += "\n"; new_content += "\n"; $inner_sql.replaceWith(new_content); + + // These settings are duplicated from the .ready()function in functions.js + var height = $('#sql_query_edit').css('height'); + codemirror_editor = CodeMirror.fromTextArea($('textarea[name="sql_query_edit"]')[0], { + lineNumbers: true, + matchBrackets: true, + indentUnit: 4, + mode: "text/x-mysql", + lineWrapping: true + }); + codemirror_editor.getScrollerElement().style.height = height; + codemirror_editor.refresh(); + $(".btnSave").click(function(){ - var sql_query = $(this).prev().val(); + if( codemirror_editor!==undefined ) + var sql_query = codemirror_editor.getValue(); + else + var sql_query = $(this).prev().val(); var $fake_form = $('
', {action: 'import.php', method: 'post'}) .append($form.find("input[name=server], input[name=db], input[name=table], input[name=token]").clone()) .append($('', {type: 'hidden', name: 'show_query', value: 1})) diff --git a/sql.php b/sql.php index 3e6e6d445f..d736bdf58c 100644 --- a/sql.php +++ b/sql.php @@ -20,6 +20,10 @@ $GLOBALS['js_include'][] = 'tbl_change.js'; // the next one needed because sql.php may do a "goto" to tbl_structure.php $GLOBALS['js_include'][] = 'tbl_structure.js'; $GLOBALS['js_include'][] = 'gis_data_editor.js'; +$GLOBALS['js_include'][] = 'codemirror/lib/codemirror.js'; +$GLOBALS['js_include'][] = 'codemirror/mode/mysql/mysql.js'; + + if (isset($_SESSION['profiling'])) { $GLOBALS['js_include'][] = 'highcharts/highcharts.js'; From a952ee531ab944bd19f0cb073a41d78a83001285 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Wed, 1 Feb 2012 11:49:05 +0100 Subject: [PATCH 2/3] Coding style --- js/functions.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/js/functions.js b/js/functions.js index 46869fb919..ed8ebafa6b 100644 --- a/js/functions.js +++ b/js/functions.js @@ -1164,10 +1164,11 @@ $(document).ready(function(){ codemirror_editor.refresh(); $(".btnSave").click(function(){ - if( codemirror_editor!==undefined ) + if (codemirror_editor !== undefined) { var sql_query = codemirror_editor.getValue(); - else + } else { var sql_query = $(this).prev().val(); + } var $fake_form = $('', {action: 'import.php', method: 'post'}) .append($form.find("input[name=server], input[name=db], input[name=table], input[name=token]").clone()) .append($('', {type: 'hidden', name: 'show_query', value: 1})) From aa8eb9360b768d0056a096eff969f72e98785ed6 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Wed, 1 Feb 2012 11:40:46 -0500 Subject: [PATCH 3/3] bug #3482734 [interface] No warning on syntax error in search form --- ChangeLog | 1 + js/tbl_select.js | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 308b374b71..787c57fa36 100644 --- a/ChangeLog +++ b/ChangeLog @@ -70,6 +70,7 @@ phpMyAdmin - ChangeLog + patch #3303195 [interface] Checkbox to have SQL input remain - patch #3472899 [export] Fixed CSV escape for the export - patch #3475424 [import] Fixed CSV escape for the import +- bug #3482734 [interface] No warning on syntax error in search form 3.4.11.0 (not yet released) diff --git a/js/tbl_select.js b/js/tbl_select.js index ac700f0b9a..ba144959a4 100644 --- a/js/tbl_select.js +++ b/js/tbl_select.js @@ -73,7 +73,13 @@ $(document).ready(function() { PMA_init_slider(); } else { // error message (zero rows) - $("#sqlqueryresults").html(response['message']); + if (response.message != undefined) { + $("#sqlqueryresults").html(response['message']); + } + // other error (syntax error?) + if (response.error != undefined) { + $("#sqlqueryresults").html(response['error']); + } } }) // end $.post() })