+ rfe #3517354 [interface] Allow disabling CodeMirror with $cfg['CodemirrorEnable'] = false
This commit is contained in:
parent
6557b71b88
commit
8744f8cf66
@ -27,6 +27,7 @@ phpMyAdmin - ChangeLog
|
||||
- bug [export] Texy! Text: Columns containing Pipe Character don't export properly
|
||||
+ [export] Show triggers in Open Document Text, Word and Texy! Text
|
||||
- Patch #3415061 [auth] Login screen appears under the page
|
||||
+ rfe #3517354 [interface] Allow disabling CodeMirror with $cfg['CodemirrorEnable'] = false
|
||||
|
||||
3.5.1.0 (not yet released)
|
||||
- bug #3510784 [edit] Limit clause ignored when sort order is remembered
|
||||
|
||||
@ -1453,6 +1453,12 @@ CREATE DATABASE,ALTER DATABASE,DROP DATABASE</pre>
|
||||
<dd>Defines whether the <abbr title="structured query language">SQL</abbr>
|
||||
query box should be kept displayed after its submission.</dd>
|
||||
|
||||
<dt id="cfg_CodemirrorEnable">$cfg['CodemirrorEnable'] boolean</dt>
|
||||
<dd>Defines whether to use a Javascript code editor for SQL query boxes.
|
||||
CodeMirror provides syntax highlighting and line numbers. <br />
|
||||
However, middle-clicking for pasting the clipboard contents in some Linux
|
||||
distributions (such as Ubuntu) is not supported by all browsers.</dd>
|
||||
|
||||
<dt id="cfg_AllowUserDropDatabase">$cfg['AllowUserDropDatabase'] boolean</dt>
|
||||
<dd>Defines whether normal users (non-administrator) are allowed to
|
||||
delete their own database or not. If set as FALSE, the link "Drop
|
||||
|
||||
@ -18,8 +18,11 @@ require_once 'libraries/common.lib.php';
|
||||
$GLOBALS['js_include'][] = 'jquery/timepicker.js';
|
||||
$GLOBALS['js_include'][] = 'rte/common.js';
|
||||
$GLOBALS['js_include'][] = 'rte/events.js';
|
||||
$GLOBALS['js_include'][] = 'codemirror/lib/codemirror.js';
|
||||
$GLOBALS['js_include'][] = 'codemirror/mode/mysql/mysql.js';
|
||||
|
||||
if ($GLOBALS['cfg']['CodemirrorEnable']) {
|
||||
$GLOBALS['js_include'][] = 'codemirror/lib/codemirror.js';
|
||||
$GLOBALS['js_include'][] = 'codemirror/mode/mysql/mysql.js';
|
||||
}
|
||||
|
||||
/**
|
||||
* Include all other files
|
||||
|
||||
@ -24,8 +24,11 @@ if (PMA_DRIZZLE) {
|
||||
$GLOBALS['js_include'][] = 'jquery/timepicker.js';
|
||||
$GLOBALS['js_include'][] = 'rte/common.js';
|
||||
$GLOBALS['js_include'][] = 'rte/routines.js';
|
||||
$GLOBALS['js_include'][] = 'codemirror/lib/codemirror.js';
|
||||
$GLOBALS['js_include'][] = 'codemirror/mode/mysql/mysql.js';
|
||||
|
||||
if ($GLOBALS['cfg']['CodemirrorEnable']) {
|
||||
$GLOBALS['js_include'][] = 'codemirror/lib/codemirror.js';
|
||||
$GLOBALS['js_include'][] = 'codemirror/mode/mysql/mysql.js';
|
||||
}
|
||||
|
||||
/**
|
||||
* Include all other files
|
||||
|
||||
@ -16,8 +16,11 @@ require_once 'libraries/common.inc.php';
|
||||
$GLOBALS['js_include'][] = 'functions.js';
|
||||
$GLOBALS['js_include'][] = 'makegrid.js';
|
||||
$GLOBALS['js_include'][] = 'sql.js';
|
||||
$GLOBALS['js_include'][] = 'codemirror/lib/codemirror.js';
|
||||
$GLOBALS['js_include'][] = 'codemirror/mode/mysql/mysql.js';
|
||||
|
||||
if ($GLOBALS['cfg']['CodemirrorEnable']) {
|
||||
$GLOBALS['js_include'][] = 'codemirror/lib/codemirror.js';
|
||||
$GLOBALS['js_include'][] = 'codemirror/mode/mysql/mysql.js';
|
||||
}
|
||||
|
||||
require 'libraries/db_common.inc.php';
|
||||
require_once 'libraries/sql_query_form.lib.php';
|
||||
|
||||
@ -17,8 +17,11 @@ require_once 'libraries/common.lib.php';
|
||||
*/
|
||||
$GLOBALS['js_include'][] = 'rte/common.js';
|
||||
$GLOBALS['js_include'][] = 'rte/triggers.js';
|
||||
$GLOBALS['js_include'][] = 'codemirror/lib/codemirror.js';
|
||||
$GLOBALS['js_include'][] = 'codemirror/mode/mysql/mysql.js';
|
||||
|
||||
if ($GLOBALS['cfg']['CodemirrorEnable']) {
|
||||
$GLOBALS['js_include'][] = 'codemirror/lib/codemirror.js';
|
||||
$GLOBALS['js_include'][] = 'codemirror/mode/mysql/mysql.js';
|
||||
}
|
||||
|
||||
/**
|
||||
* Include all other files
|
||||
|
||||
@ -1069,18 +1069,20 @@ $(document).ready(function() {
|
||||
|
||||
// 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();
|
||||
if (typeof CodeMirror !== 'undefined') {
|
||||
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();
|
||||
}
|
||||
|
||||
$("input.btnSave").click(function() {
|
||||
if (codemirror_editor !== undefined) {
|
||||
if (codemirror_editor) {
|
||||
var sql_query = codemirror_editor.getValue();
|
||||
} else {
|
||||
var sql_query = $(this).prev().val();
|
||||
@ -1673,6 +1675,10 @@ function PMA_prettyProfilingNum(num, acc)
|
||||
*/
|
||||
function PMA_SQLPrettyPrint(string)
|
||||
{
|
||||
if (typeof CodeMirror == 'undefined') {
|
||||
return string;
|
||||
}
|
||||
|
||||
var mode = CodeMirror.getMode({},"text/x-mysql");
|
||||
var stream = new CodeMirror.StringStream(string);
|
||||
var state = mode.startState();
|
||||
|
||||
@ -42,7 +42,12 @@ var RTE = {
|
||||
}
|
||||
$elm = $('table.rte_table').find('textarea[name=item_definition]');
|
||||
if ($elm.val() === '') {
|
||||
this.syntaxHiglighter.focus();
|
||||
if (this.syntaxHiglighter !== null) {
|
||||
this.syntaxHiglighter.focus();
|
||||
}
|
||||
else {
|
||||
$('textarea[name=item_definition]').last().focus();
|
||||
}
|
||||
alert(PMA_messages['strFormEmpty']);
|
||||
return false;
|
||||
}
|
||||
@ -106,7 +111,9 @@ $(document).ready(function () {
|
||||
RTE.buttonOptions[PMA_messages['strGo']] = function () {
|
||||
// Move the data from the codemirror editor back to the
|
||||
// textarea, where it can be used in the form submission.
|
||||
RTE.syntaxHiglighter.save();
|
||||
if (typeof CodeMirror != 'undefined') {
|
||||
RTE.syntaxHiglighter.save();
|
||||
}
|
||||
// Validate editor and submit request, if passed.
|
||||
if (RTE.validate()) {
|
||||
/**
|
||||
@ -241,7 +248,9 @@ $(document).ready(function () {
|
||||
* @var opts Options to pass to the codemirror editor.
|
||||
*/
|
||||
var opts = {lineNumbers: true, matchBrackets: true, indentUnit: 4, mode: "text/x-mysql"};
|
||||
RTE.syntaxHiglighter = CodeMirror.fromTextArea($elm[0], opts);
|
||||
if (typeof CodeMirror != 'undefined') {
|
||||
RTE.syntaxHiglighter = CodeMirror.fromTextArea($elm[0], opts);
|
||||
}
|
||||
// Execute item-specific code
|
||||
RTE.postDialogShow(data);
|
||||
} else {
|
||||
|
||||
@ -507,19 +507,22 @@ $(document).ready(function() {
|
||||
});
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
// Attach syntax highlited editor to export dialog
|
||||
CodeMirror.fromTextArea(
|
||||
$ajaxDialog.find('textarea')[0],
|
||||
{
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
indentUnit: 4,
|
||||
mode: "text/x-mysql"
|
||||
}
|
||||
);
|
||||
if (typeof CodeMirror != 'undefined') {
|
||||
CodeMirror.fromTextArea(
|
||||
$ajaxDialog.find('textarea')[0],
|
||||
{
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
indentUnit: 4,
|
||||
mode: "text/x-mysql"
|
||||
}
|
||||
);
|
||||
}
|
||||
}); //end $.post
|
||||
});
|
||||
// if exporting non-ajax, highlight anyways
|
||||
if ($("textarea.export").length > 0)
|
||||
if ($("textarea.export").length > 0
|
||||
&& typeof CodeMirror != 'undefined')
|
||||
{
|
||||
CodeMirror.fromTextArea(
|
||||
$('textarea.export')[0],
|
||||
@ -555,15 +558,17 @@ $(document).ready(function() {
|
||||
});
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
// Attach syntax highlited editor to export dialog
|
||||
CodeMirror.fromTextArea(
|
||||
$ajaxDialog.find('textarea')[0],
|
||||
{
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
indentUnit: 4,
|
||||
mode: "text/x-mysql"
|
||||
}
|
||||
);
|
||||
if (typeof CodeMirror != 'undefined') {
|
||||
CodeMirror.fromTextArea(
|
||||
$ajaxDialog.find('textarea')[0],
|
||||
{
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
indentUnit: 4,
|
||||
mode: "text/x-mysql"
|
||||
}
|
||||
);
|
||||
}
|
||||
}); //end $.get
|
||||
}); //end export privileges
|
||||
|
||||
|
||||
@ -155,10 +155,15 @@ $(function() {
|
||||
);
|
||||
// Delay loading a bit so the tab loads and the user gets to see a ajax loading icon
|
||||
setTimeout(function() {
|
||||
loadJavascript(['js/jquery/timepicker.js', 'js/jquery/jquery.json-2.2.js',
|
||||
'js/jquery/jquery.sortableTable.js',
|
||||
'js/codemirror/lib/codemirror.js', 'js/codemirror/mode/mysql/mysql.js',
|
||||
'js/server_status_monitor.js']);
|
||||
var scripts = [
|
||||
'js/jquery/timepicker.js',
|
||||
'js/jquery/jquery.json-2.2.js',
|
||||
'js/jquery/jquery.sortableTable.js'];
|
||||
if (cfg_CodemirrorEnable) {
|
||||
scripts.push('js/codemirror/lib/codemirror.js', 'js/codemirror/mode/mysql/mysql.js');
|
||||
}
|
||||
scripts.push('js/server_status_monitor.js');
|
||||
loadJavascript(scripts);
|
||||
}, 50);
|
||||
|
||||
monitorLoaded = true;
|
||||
|
||||
@ -1710,12 +1710,17 @@ $(function() {
|
||||
var rowData = $(this).parent().data('query');
|
||||
var query = rowData.argument || rowData.sql_text;
|
||||
|
||||
query = PMA_SQLPrettyPrint(query);
|
||||
codemirror_editor.setValue(query);
|
||||
// Codemirror is bugged, it doesn't refresh properly sometimes. Following lines seem to fix that
|
||||
setTimeout(function() {
|
||||
codemirror_editor.refresh();
|
||||
},50);
|
||||
if (codemirror_editor) {
|
||||
query = PMA_SQLPrettyPrint(query);
|
||||
codemirror_editor.setValue(query);
|
||||
// Codemirror is bugged, it doesn't refresh properly sometimes. Following lines seem to fix that
|
||||
setTimeout(function() {
|
||||
codemirror_editor.refresh();
|
||||
},50);
|
||||
}
|
||||
else {
|
||||
$('#sqlquery').val(query);
|
||||
}
|
||||
|
||||
var profilingChart = null;
|
||||
var dlgBtns = {};
|
||||
@ -1728,7 +1733,12 @@ $(function() {
|
||||
profilingChart.destroy();
|
||||
}
|
||||
$('div#queryAnalyzerDialog div.placeHolder').html('');
|
||||
codemirror_editor.setValue('');
|
||||
if (codemirror_editor) {
|
||||
codemirror_editor.setValue('');
|
||||
}
|
||||
else {
|
||||
$('#sqlquery').val('');
|
||||
}
|
||||
$(this).dialog("close");
|
||||
};
|
||||
|
||||
@ -1751,7 +1761,7 @@ $(function() {
|
||||
$.post('server_status.php?' + url_query, {
|
||||
ajax_request: true,
|
||||
query_analyzer: true,
|
||||
query: codemirror_editor.getValue(),
|
||||
query: codemirror_editor ? codemirror_editor.getValue() : $('#sqlquery').val(),
|
||||
database: db
|
||||
}, function(data) {
|
||||
data = $.parseJSON(data);
|
||||
|
||||
@ -406,6 +406,10 @@ class PMA_Theme
|
||||
*/
|
||||
function getCssCodeMirror()
|
||||
{
|
||||
if (! $GLOBALS['cfg']['CodemirrorEnable']) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$result[] = 'span.cm-keyword, span.cm-statement-verb {';
|
||||
$result[] = ' color: ' . $GLOBALS['cfg']['SQP']['fmtColor']['alpha_reservedWord'] . ';';
|
||||
$result[] = '}';
|
||||
|
||||
@ -645,6 +645,13 @@ $cfg['ShowSQL'] = true;
|
||||
*/
|
||||
$cfg['RetainQueryBox'] = false;
|
||||
|
||||
/**
|
||||
* use CodeMirror syntax highlighting for editing SQL
|
||||
*
|
||||
* @global boolean $cfg['CodemirrorEnable']
|
||||
*/
|
||||
$cfg['CodemirrorEnable'] = true;
|
||||
|
||||
/**
|
||||
* show a 'Drop database' link to normal users
|
||||
*
|
||||
|
||||
@ -31,6 +31,8 @@ $strConfigBZipDump_desc = __('Enable [a@http://en.wikipedia.org/wiki/Bzip2]bzip2
|
||||
$strConfigBZipDump_name = __('Bzip2');
|
||||
$strConfigCharEditing_desc = __('Defines which type of editing controls should be used for CHAR and VARCHAR columns; [kbd]input[/kbd] - allows limiting of input length, [kbd]textarea[/kbd] - allows newlines in columns');
|
||||
$strConfigCharEditing_name = __('CHAR columns editing');
|
||||
$strConfigCodemirrorEnable_desc = __('Use user-friendly editor for editing SQL queries ([a@http://codemirror.net/]CodeMirror[/a]) with syntax highlighting and line numbers');
|
||||
$strConfigCodemirrorEnable_name = __('Enable CodeMirror');
|
||||
$strConfigMinSizeForInputField_desc = __('Defines the minimum size for input fields generated for CHAR and VARCHAR columns');
|
||||
$strConfigMinSizeForInputField_name = __('Minimum size for input field');
|
||||
$strConfigMaxSizeForInputField_desc = __('Defines the maximum size for input fields generated for CHAR and VARCHAR columns');
|
||||
|
||||
@ -152,7 +152,8 @@ $forms['Sql_queries']['Sql_queries'] = array(
|
||||
//'QueryWindowWidth', // overridden in theme
|
||||
//'QueryWindowHeight',
|
||||
'QueryWindowDefTab',
|
||||
'RetainQueryBox');
|
||||
'RetainQueryBox',
|
||||
'CodemirrorEnable');
|
||||
$forms['Sql_queries']['Sql_box'] = array('SQLQuery' => array(
|
||||
'Edit',
|
||||
'Explain',
|
||||
|
||||
@ -69,7 +69,8 @@ $forms['Sql_queries']['Sql_queries'] = array(
|
||||
//'QueryWindowWidth', // overridden in theme
|
||||
//'QueryWindowHeight',
|
||||
'QueryWindowDefTab',
|
||||
'RetainQueryBox');
|
||||
'RetainQueryBox',
|
||||
'CodemirrorEnable');
|
||||
$forms['Sql_queries']['Sql_box'] = array(
|
||||
'SQLQuery/Edit',
|
||||
'SQLQuery/Explain',
|
||||
|
||||
@ -119,8 +119,11 @@ $sql_query = '';
|
||||
*/
|
||||
$js_include[] = 'common.js';
|
||||
$js_include[] = 'querywindow.js';
|
||||
$js_include[] = 'codemirror/lib/codemirror.js';
|
||||
$js_include[] = 'codemirror/mode/mysql/mysql.js';
|
||||
|
||||
if ($GLOBALS['cfg']['CodemirrorEnable']) {
|
||||
$GLOBALS['js_include'][] = 'codemirror/lib/codemirror.js';
|
||||
$GLOBALS['js_include'][] = 'codemirror/mode/mysql/mysql.js';
|
||||
}
|
||||
|
||||
if (PMA_isValid($_REQUEST['auto_commit'], 'identical', 'true')) {
|
||||
$js_events[] = array(
|
||||
|
||||
@ -15,8 +15,11 @@ require_once 'libraries/common.inc.php';
|
||||
*/
|
||||
$GLOBALS['js_include'][] = 'server_privileges.js';
|
||||
$GLOBALS['js_include'][] = 'functions.js';
|
||||
$GLOBALS['js_include'][] = 'codemirror/lib/codemirror.js';
|
||||
$GLOBALS['js_include'][] = 'codemirror/mode/mysql/mysql.js';
|
||||
|
||||
if ($GLOBALS['cfg']['CodemirrorEnable']) {
|
||||
$GLOBALS['js_include'][] = 'codemirror/lib/codemirror.js';
|
||||
$GLOBALS['js_include'][] = 'codemirror/mode/mysql/mysql.js';
|
||||
}
|
||||
$_add_user_error = false;
|
||||
|
||||
require 'libraries/server_common.inc.php';
|
||||
|
||||
@ -16,8 +16,11 @@ require_once 'libraries/common.inc.php';
|
||||
$GLOBALS['js_include'][] = 'functions.js';
|
||||
$GLOBALS['js_include'][] = 'makegrid.js';
|
||||
$GLOBALS['js_include'][] = 'sql.js';
|
||||
$GLOBALS['js_include'][] = 'codemirror/lib/codemirror.js';
|
||||
$GLOBALS['js_include'][] = 'codemirror/mode/mysql/mysql.js';
|
||||
|
||||
if ($GLOBALS['cfg']['CodemirrorEnable']) {
|
||||
$GLOBALS['js_include'][] = 'codemirror/lib/codemirror.js';
|
||||
$GLOBALS['js_include'][] = 'codemirror/mode/mysql/mysql.js';
|
||||
}
|
||||
|
||||
require_once 'libraries/server_common.inc.php';
|
||||
require_once 'libraries/sql_query_form.lib.php';
|
||||
|
||||
@ -432,7 +432,10 @@ if (PMA_DRIZZLE) {
|
||||
* JS Includes
|
||||
*/
|
||||
|
||||
// needed to decide whether to load codemirror.js in server_status.js
|
||||
PMA_AddJSVar('cfg_CodemirrorEnable', $GLOBALS['cfg']['CodemirrorEnable'] ? 1 : 0);
|
||||
$GLOBALS['js_include'][] = 'server_status.js';
|
||||
|
||||
$GLOBALS['js_include'][] = 'jquery/jquery.tablesorter.js';
|
||||
$GLOBALS['js_include'][] = 'jquery/jquery.cookie.js'; // For tab persistence
|
||||
// Charting
|
||||
|
||||
7
sql.php
7
sql.php
@ -19,8 +19,11 @@ $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 ($GLOBALS['cfg']['CodemirrorEnable']) {
|
||||
$GLOBALS['js_include'][] = 'codemirror/lib/codemirror.js';
|
||||
$GLOBALS['js_include'][] = 'codemirror/mode/mysql/mysql.js';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -11,8 +11,11 @@
|
||||
require_once 'libraries/common.inc.php';
|
||||
|
||||
$GLOBALS['js_include'][] = 'export.js';
|
||||
$GLOBALS['js_include'][] = 'codemirror/lib/codemirror.js';
|
||||
$GLOBALS['js_include'][] = 'codemirror/mode/mysql/mysql.js';
|
||||
|
||||
if ($GLOBALS['cfg']['CodemirrorEnable']) {
|
||||
$GLOBALS['js_include'][] = 'codemirror/lib/codemirror.js';
|
||||
$GLOBALS['js_include'][] = 'codemirror/mode/mysql/mysql.js';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets tables informations and displays top links
|
||||
|
||||
@ -16,8 +16,11 @@ require_once 'libraries/common.inc.php';
|
||||
$GLOBALS['js_include'][] = 'functions.js';
|
||||
$GLOBALS['js_include'][] = 'makegrid.js';
|
||||
$GLOBALS['js_include'][] = 'sql.js';
|
||||
$GLOBALS['js_include'][] = 'codemirror/lib/codemirror.js';
|
||||
$GLOBALS['js_include'][] = 'codemirror/mode/mysql/mysql.js';
|
||||
|
||||
if ($GLOBALS['cfg']['CodemirrorEnable']) {
|
||||
$GLOBALS['js_include'][] = 'codemirror/lib/codemirror.js';
|
||||
$GLOBALS['js_include'][] = 'codemirror/mode/mysql/mysql.js';
|
||||
}
|
||||
|
||||
require 'libraries/tbl_common.php';
|
||||
$url_query .= '&goto=tbl_sql.php&back=tbl_sql.php';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user