Skip to content

Commit

Permalink
Merge branch 'master' into OOP_DBI
Browse files Browse the repository at this point in the history
Conflicts:
	libraries/database_interface.lib.php
  • Loading branch information
madhuracj committed May 26, 2013
2 parents 0dab7f2 + b8e4f34 commit 2baf473
Show file tree
Hide file tree
Showing 94 changed files with 2,660 additions and 2,348 deletions.
5 changes: 3 additions & 2 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ phpMyAdmin - ChangeLog
- bug #3941 Recent tables list always empty
- bug #3933 Do not translate "Open Document" in export settings
- bug #3927 List of tables is missing after expanding in the navigation frame
- bug #3942 Warnings about reserved word for many non reserved words
- bug #3942 Warnings about reserved word for many non reserved words
- bug #3912 Exporting row selection, resulted by ORDER BY query

4.0.2.0 (not yet released)
4.0.2.0 (2013-05-24)
- bug #3902 Cannot browse when table name contains keyword "call"
+ center loading indicator for navigation refresh, related to bug #3920
- bug #3925 Table sorting in navigation panel is case-sensitive
Expand Down
4 changes: 3 additions & 1 deletion js/ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ var AJAX = {
return true;
} else if (href && href.match(/^mailto/)) {
return true;
} else if ($(this).hasClass('ui-datepicker-next') ||
} else if ($(this).hasClass('ui-datepicker-next') ||
$(this).hasClass('ui-datepicker-prev')
) {
return true;
Expand Down Expand Up @@ -255,6 +255,7 @@ var AJAX = {
$('#page_content').replaceWith(
"<div id='page_content'>" + data.message + "</div>"
);
PMA_highlightSQL($('#page_content'));
}

if (data._selflink) {
Expand All @@ -277,6 +278,7 @@ var AJAX = {
}
if (data._displayMessage) {
$('#page_content').prepend(data._displayMessage);
PMA_highlightSQL($('#page_content'));
}

$('#pma_errors').remove();
Expand Down
56 changes: 56 additions & 0 deletions js/codemirror/addon/runmode/runmode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
CodeMirror.runMode = function(string, modespec, callback, options) {
var mode = CodeMirror.getMode(CodeMirror.defaults, modespec);
var ie = /MSIE \d/.test(navigator.userAgent);
var ie_lt9 = ie && (document.documentMode == null || document.documentMode < 9);

if (callback.nodeType == 1) {
var tabSize = (options && options.tabSize) || CodeMirror.defaults.tabSize;
var node = callback, col = 0;
node.innerHTML = "";
callback = function(text, style) {
if (text == "\n") {
// Emitting LF or CRLF on IE8 or earlier results in an incorrect display.
// Emitting a carriage return makes everything ok.
node.appendChild(document.createTextNode(ie_lt9 ? '\r' : text));
col = 0;
return;
}
var content = "";
// replace tabs
for (var pos = 0;;) {
var idx = text.indexOf("\t", pos);
if (idx == -1) {
content += text.slice(pos);
col += text.length - pos;
break;
} else {
col += idx - pos;
content += text.slice(pos, idx);
var size = tabSize - col % tabSize;
col += size;
for (var i = 0; i < size; ++i) content += " ";
pos = idx + 1;
}
}

if (style) {
var sp = node.appendChild(document.createElement("span"));
sp.className = "cm-" + style.replace(/ +/g, " cm-");
sp.appendChild(document.createTextNode(content));
} else {
node.appendChild(document.createTextNode(content));
}
};
}

var lines = CodeMirror.splitLines(string), state = CodeMirror.startState(mode);
for (var i = 0, e = lines.length; i < e; ++i) {
if (i) callback("\n");
var stream = new CodeMirror.StringStream(lines[i]);
while (!stream.eol()) {
var style = mode.token(stream, state);
callback(stream.current(), style, i, stream.start);
stream.start = stream.pos;
}
}
};
34 changes: 32 additions & 2 deletions js/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1352,6 +1352,7 @@ AJAX.registerOnload('functions.js', function () {
var $form = $(this).prev('form');
var sql_query = $form.find("input[name='sql_query']").val();
var $inner_sql = $(this).parent().prev().find('.inner_sql');
var $sql_highlight = $(this).parent().prev().find('.sql-highlight');
var old_text = $inner_sql.html();

var new_content = "<textarea name=\"sql_query_edit\" id=\"sql_query_edit\">" + sql_query + "</textarea>\n";
Expand All @@ -1364,6 +1365,7 @@ AJAX.registerOnload('functions.js', function () {
}
$editor_area.html(new_content);
$inner_sql.hide();
$sql_highlight.hide();

bindCodeMirrorToInlineEditor();
return false;
Expand All @@ -1387,8 +1389,8 @@ AJAX.registerOnload('functions.js', function () {

$("input#sql_query_edit_discard").live('click', function () {
$('div#inline_editor_outer')
.empty()
.siblings('.inner_sql').show();
.siblings('.sql-highlight').show();
$('div#inline_editor_outer').remove();
});

$('input.sqlbutton').click(function (evt) {
Expand Down Expand Up @@ -1486,6 +1488,25 @@ function catchKeypressesFromSqlTextboxes(event) {
}
}

/**
* Higlights SQL using CodeMirror.
*/
function PMA_highlightSQL(base)
{
var $elm = base.find('code.sql');
$elm.each(function () {
var $sql = $(this);
var $pre = $sql.find('pre');
/* We only care about visible elements to avoid double processing */
if ($pre.is(":visible")) {
var $highlight = $('<div class="sql-highlight cm-s-default"></div>');
$sql.append($highlight);
CodeMirror.runMode($sql.text(), 'text/x-mysql', $highlight[0]);
$pre.hide();
}
});
}

/**
* Show a message on the top of the page for an Ajax request
*
Expand Down Expand Up @@ -1597,6 +1618,7 @@ function PMA_ajaxShowMessage(message, timeout)
PMA_messages.strDismiss
);
}
PMA_highlightSQL($retval);

return $retval;
}
Expand Down Expand Up @@ -2117,6 +2139,7 @@ AJAX.registerOnload('functions.js', function () {
$.post($form.attr('action'), $form.serialize() + "&submit_num_fields=1", function (data) {
if (data.success) {
$("#page_content").html(data.message);
PMA_highlightSQL($('#page_content'));
PMA_verifyColumnsProperties();
PMA_ajaxRemoveMessage($msgbox);
} else {
Expand Down Expand Up @@ -2225,6 +2248,7 @@ AJAX.registerOnload('functions.js', function () {
PMA_commonParams.set('table', tbl);
PMA_commonActions.refreshMain(false, function () {
$('#page_content').html(data.message);
PMA_highlightSQL($('#page_content'));
});
} else {
PMA_ajaxShowMessage(data.error, false);
Expand Down Expand Up @@ -2255,6 +2279,7 @@ AJAX.registerOnload('functions.js', function () {
PMA_ajaxShowMessage(data.message);
$("<div id='sqlqueryresults' class='ajax'></div>").prependTo("#page_content");
$("#sqlqueryresults").html(data.sql_query);
PMA_highlightSQL($('#page_content'));
scrollToTop();
} else if (data.success === true) {
var $temp_div = $("<div id='temp_div'></div>");
Expand All @@ -2263,6 +2288,7 @@ AJAX.registerOnload('functions.js', function () {
PMA_ajaxShowMessage($success);
$("<div id='sqlqueryresults' class='ajax'></div>").prependTo("#page_content");
$("#sqlqueryresults").html(data.message);
PMA_highlightSQL($('#page_content'));
PMA_init_slider();
$("#sqlqueryresults").children("fieldset,br").remove();
scrollToTop();
Expand Down Expand Up @@ -2407,6 +2433,7 @@ AJAX.registerOnload('functions.js', function () {
$.post($the_form.attr('action'), $the_form.serialize() + '&change_pw=' + this_value, function (data) {
if (data.success === true) {
$("#page_content").prepend(data.message);
PMA_highlightSQL($('#page_content'));
$("#change_password_dialog").hide().remove();
$("#edit_user_dialog").dialog("close").remove();
PMA_ajaxRemoveMessage($msgbox);
Expand Down Expand Up @@ -2817,6 +2844,7 @@ function indexEditorDialog(url, title, callback_success, callback_failure)
$('<div id="result_query"></div>')
.html(data.sql_query)
.prependTo('#page_content');
PMA_highlightSQL($('#page_content'));
}
$("#result_query .notice").remove();
$("#result_query").prepend(data.message);
Expand Down Expand Up @@ -3421,6 +3449,7 @@ AJAX.registerOnload('functions.js', function () {
PMA_ajaxShowMessage(data.message);
$("<div id='sqlqueryresults'></div>").prependTo("#page_content");
$("#sqlqueryresults").html(data.sql_query);
PMA_highlightSQL($('#page_content'));
} else {
PMA_ajaxShowMessage(data.error, false);
}
Expand Down Expand Up @@ -3454,6 +3483,7 @@ AJAX.registerOnload('functions.js', function () {
$elm.focus().bind('keydown', catchKeypressesFromSqlTextboxes);
}
}
PMA_highlightSQL($('body'));
});
AJAX.registerTeardown('functions.js', function () {
if (codemirror_editor) {
Expand Down
1 change: 1 addition & 0 deletions js/indexes.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ AJAX.registerOnload('indexes.js', function () {
$('<div id="result_query"></div>')
.html(data.sql_query)
.prependTo('#page_content');
PMA_highlightSQL($('#page_content'));
}
PMA_commonActions.refreshMain(false, function () {
$("a.ajax[href^=#indexes]").click();
Expand Down
5 changes: 5 additions & 0 deletions js/server_privileges.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ function addUser($form)
PMA_ajaxShowMessage(data.message);
$("#result_query").remove();
$('#page_content').prepend(data.sql_query);
PMA_highlightSQL($('#page_content'));
$("#result_query").css({
'margin-top' : '0.5em'
});
Expand Down Expand Up @@ -234,6 +235,7 @@ AJAX.registerOnload('server_privileges.js', function () {
.find("form[name=usersForm]")
.append('<input type="hidden" name="ajax_request" value="true" />')
.end();
PMA_highlightSQL($div);
displayPasswordGenerateButton();
PMA_showHints($div);
PMA_ajaxRemoveMessage($msgbox);
Expand Down Expand Up @@ -361,6 +363,8 @@ AJAX.registerOnload('server_privileges.js', function () {
$div.empty();
}
$div.html(data.message);
PMA_highlightSQL($div);
var $div = $('#edit_user_dialog');
displayPasswordGenerateButton();
$(checkboxes_sel).trigger("change");
PMA_ajaxRemoveMessage($msgbox);
Expand Down Expand Up @@ -430,6 +434,7 @@ AJAX.registerOnload('server_privileges.js', function () {
if (data.sql_query) {
$("#result_query").remove();
$('#page_content').prepend(data.sql_query);
PMA_highlightSQL($('#page_content'));
$("#result_query").css({
'margin-top' : '0.5em'
});
Expand Down
3 changes: 2 additions & 1 deletion js/sql.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ AJAX.registerOnload('sql.js', function () {
$('<div id="result_query"></div>')
.html(data.sql_query)
.prependTo('#page_content');
PMA_highlightSQL($('#page_content'));
}
});
PMA_reloadNavigation();
Expand Down Expand Up @@ -635,4 +636,4 @@ function initProfilingTables()
AJAX.registerOnload('sql.js', function () {
makeProfilingChart();
initProfilingTables();
});
});
1 change: 1 addition & 0 deletions js/tbl_select.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ AJAX.registerOnload('tbl_select.js', function () {
} else {
$("#sqlqueryresults").html(data.error);
}
PMA_highlightSQL($('#sqlqueryresults'));
}); // end $.post()
});

Expand Down
5 changes: 5 additions & 0 deletions js/tbl_structure.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ AJAX.registerOnload('tbl_structure.js', function () {
.append(data.message)
.append(data.sql_query)
.show();
PMA_highlightSQL($('#page_content'));
$("#result_query .notice").remove();
$form.remove();
PMA_ajaxRemoveMessage($msg);
Expand All @@ -109,6 +110,7 @@ AJAX.registerOnload('tbl_structure.js', function () {
$('<div id="change_column_dialog" class="margin"></div>')
.html(data.message)
.insertBefore('#page_content');
PMA_highlightSQL($('#page_content'));
PMA_verifyColumnsProperties();
} else {
PMA_ajaxShowMessage(PMA_messages.strErrorProcessingRequest + " : " + data.error, false);
Expand All @@ -135,6 +137,7 @@ AJAX.registerOnload('tbl_structure.js', function () {
.html(data.message)
)
.show();
PMA_highlightSQL($('#page_content'));
PMA_verifyColumnsProperties();
} else {
$('#page_content').show();
Expand Down Expand Up @@ -180,6 +183,7 @@ AJAX.registerOnload('tbl_structure.js', function () {
$('<div id="result_query"></div>')
.html(data.sql_query)
.prependTo('#page_content');
PMA_highlightSQL($('#page_content'));
}
toggleRowColors($curr_row.next());
// Adjust the row numbers
Expand Down Expand Up @@ -235,6 +239,7 @@ AJAX.registerOnload('tbl_structure.js', function () {
$('<div id="result_query"></div>')
.html(data.sql_query)
.prependTo('#page_content');
PMA_highlightSQL($('#page_content'));
}
});
PMA_reloadNavigation();
Expand Down
2 changes: 1 addition & 1 deletion libraries/Config.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1766,7 +1766,7 @@ function removeCookie($cookie)
}

/**
* sets cookie if value is different from current cokkie value,
* sets cookie if value is different from current cookie value,
* or removes if value is equal to default
*
* @param string $cookie name of cookie to remove
Expand Down
1 change: 1 addition & 0 deletions libraries/Header.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ public function getDisplay()
if ($GLOBALS['cfg']['CodemirrorEnable']) {
$this->_scripts->addFile('codemirror/lib/codemirror.js');
$this->_scripts->addFile('codemirror/mode/sql/sql.js');
$this->_scripts->addFile('codemirror/addon/runmode/runmode.js');
}
if ($this->_userprefsOfferImport) {
$this->_scripts->addFile('config.js');
Expand Down
4 changes: 2 additions & 2 deletions libraries/Table.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ static public function moveCopy($source_db, $source_table, $target_db,
}

/* Generate query back */
$sql_structure = PMA_SQP_formatHtml($parsed_sql, 'query_only');
$sql_structure = PMA_SQP_format($parsed_sql, 'query_only');
// If table exists, and 'add drop table' is selected: Drop it!
$drop_query = '';
if (isset($_REQUEST['drop_if_exists'])
Expand Down Expand Up @@ -967,7 +967,7 @@ static public function moveCopy($source_db, $source_table, $target_db,
}

// Generate query back
$GLOBALS['sql_constraints_query'] = PMA_SQP_formatHtml(
$GLOBALS['sql_constraints_query'] = PMA_SQP_format(
$parsed_sql, 'query_only'
);
if ($mode == 'one_table') {
Expand Down
Loading

0 comments on commit 2baf473

Please sign in to comment.