diff --git a/import.php b/import.php index 9d11397a54..cad37f8607 100644 --- a/import.php +++ b/import.php @@ -29,11 +29,38 @@ if (isset($_REQUEST['simulate_dml'])) { } // If it's a refresh console bookmarks request -if (isset($_GET['console_bookmark_refresh'])) { +if (isset($_REQUEST['console_bookmark_refresh'])) { $response = PMA_Response::getInstance(); $response->addJSON('console_message_bookmark', PMA_Console::getBookmarkContent()); exit; } +// If it's a console bookmark add request +if (isset($_REQUEST['console_bookmark_add'])) { + $response = PMA_Response::getInstance(); + if(isset($_REQUEST['label']) && isset($_REQUEST['db']) + && isset($_REQUEST['bookmark_query']) && isset($_REQUEST['shared'])) + { + $cfgBookmark = PMA_Bookmark_getParams(); + $bookmarkFields = array( + 'bkm_database' => $_REQUEST['db'], + 'bkm_user' => $cfgBookmark['user'], + 'bkm_sql_query' => urlencode($_REQUEST['bookmark_query']), + 'bkm_label' => $_REQUEST['label'] + ); + $isShared = ($_REQUEST['shared'] == 'true' ? true : false); + if(PMA_Bookmark_save($bookmarkFields, $isShared)) { + $response->addJSON('message', __('Successed')); + $response->addJSON('data', $bookmarkFields); + $response->addJSON('isShared', $isShared); + } else { + $response->addJSON('message', __('Failed')); + } + die(); + } else { + $response->addJSON('message', __('Incomplete params')); + die(); + } +} /** * Sets globals from $_POST diff --git a/js/ajax.js b/js/ajax.js index 4c441ec8bd..3a290a001a 100644 --- a/js/ajax.js +++ b/js/ajax.js @@ -458,9 +458,6 @@ var AJAX = { $('#'+data.fieldWithError).addClass("error"); } } - if(PMA_console && PMA_console.isEnabled) { - PMA_console.ajaxCallback(data); - } }, /** * This object is in charge of downloading scripts, diff --git a/js/console.js b/js/console.js index bdb3c025a5..97018d1e13 100644 --- a/js/console.js +++ b/js/console.js @@ -104,16 +104,16 @@ var PMA_console = { var tempConfig = JSON.parse($.cookie('pma_console_config')); if(tempConfig) { if(tempConfig.alwaysExpand === true) { - $('#pma_console_options input[name=always_expand]').attr('checked', true); + $('#pma_console_options input[name=always_expand]').prop('checked', true); } if(tempConfig.startHistory === true) { - $('#pma_console_options input[name=start_history]').attr('checked', true); + $('#pma_console_options input[name=start_history]').prop('checked', true); } if(tempConfig.currentQuery === true) { - $('#pma_console_options input[name=current_query]').attr('checked', true); + $('#pma_console_options input[name=current_query]').prop('checked', true); } } else { - $('#pma_console_options input[name=current_query]').attr('checked', true); + $('#pma_console_options input[name=current_query]').prop('checked', true); } PMA_console.updateConfig(); @@ -166,6 +166,11 @@ var PMA_console = { PMA_console.updateConfig(); }); + $(document).ajaxComplete(function (event, xhr) { + var data = $.parseJSON(xhr.responseText); + PMA_console.ajaxCallback(data); + }); + PMA_console.isInitialized = true; } @@ -192,15 +197,15 @@ var PMA_console = { * * @return void */ - execute: function(queryString, target) { + execute: function(queryString, options) { if(typeof(queryString) != 'string' || ! /[a-z]|[A-Z]/.test(queryString)){ return; } PMA_console.$requestForm.children('textarea').val(queryString); - if(target && target.db) { - PMA_console.$requestForm.children('[name=db]').attr('value', target.db); - if(target.table) { - PMA_console.$requestForm.children('[name=table]').attr('value', target.table); + if(options && options.db) { + PMA_console.$requestForm.children('[name=db]').attr('value', options.db); + if(options.table) { + PMA_console.$requestForm.children('[name=table]').attr('value', options.table); } else { PMA_console.$requestForm.children('[name=table]').attr('value', ''); } @@ -208,21 +213,26 @@ var PMA_console = { PMA_console.$requestForm.children('[name=db]').attr('value', (PMA_commonParams.get('db').length > 0 ? PMA_commonParams.get('db') : '')); } + PMA_console.$requestForm.find('[name=profiling]').remove(); + if(options && options.profiling === true) { + PMA_console.$requestForm.append(''); + } if (! confirmQuery(PMA_console.$requestForm[0], PMA_console.$requestForm.children('textarea')[0])) { return; } PMA_console.$requestForm.children('[name=console_message_id]') - .attr('value', PMA_consoleMessages.appendQuery({sql_query: queryString})); + .attr('value', PMA_consoleMessages.appendQuery({sql_query: queryString}).message_id); PMA_console.$requestForm.trigger('submit'); PMA_consoleInput.clear(); }, ajaxCallback: function(data) { - if(data.console_message_id) { + if(data && data.console_message_id) { PMA_consoleMessages.updateQuery(data.console_message_id, data.success, (data._reloadQuerywindow ? data._reloadQuerywindow : false)); - } else if(data._reloadQuerywindow) { + } else if( data && data._reloadQuerywindow) { if(data._reloadQuerywindow.sql_query.length > 0) { - PMA_consoleMessages.appendQuery(data._reloadQuerywindow, 'successed'); + PMA_consoleMessages.appendQuery(data._reloadQuerywindow, 'successed') + .$message.addClass(PMA_console.config.currentQuery ? '' : 'hide'); } } }, @@ -373,6 +383,10 @@ var PMA_console = { currentQuery: $('#pma_console_options input[name=current_query]').prop('checked') }; $.cookie('pma_console_config', JSON.stringify(PMA_console.config)); + }, + isSelect: function (queryString) { + var reg_exp = /^SELECT\s+/i; + return reg_exp.test(queryString); } }; @@ -453,10 +467,15 @@ var PMA_consoleResizer = { */ var PMA_consoleInput = { /** - * @var CodeMirror object + * @var array, contains Codemirror objects or input jQuery objects * @access private */ - _cm: null, + _inputs: null, + /** + * @var bool, if codemirror enabled + * @access private + */ + _codemirror: false, /** * Used for console input initialize * @@ -464,15 +483,35 @@ var PMA_consoleInput = { */ initialize: function() { // _cm object can't be reinitialize - if(PMA_consoleInput._cm !== null) { + if(PMA_consoleInput._inputs !== null) { return; } - PMA_consoleInput._cm = CodeMirror($('#query_input')[0], { - theme: 'pma', - mode: 'text/x-sql', - lineWrapping: true - }); - $('#pma_console .CodeMirror.cm-s-pma').keydown(PMA_consoleInput._keydown); + if(typeof CodeMirror !== 'undefined') { + PMA_consoleInput._codemirror = true; + } + PMA_consoleInput._inputs = []; + if (PMA_consoleInput._codemirror) { + PMA_consoleInput._inputs.console = CodeMirror($('#pma_console .console_query_input')[0], { + theme: 'pma', + mode: 'text/x-sql', + lineWrapping: true + }); + if ($('#pma_bookmarks').length !== 0) { + PMA_consoleInput._inputs.bookmark = CodeMirror($('#pma_console .bookmark_add_input')[0], { + theme: 'pma', + mode: 'text/x-sql', + lineWrapping: true + }); + } + } else { + PMA_consoleInput._inputs.console = + $('').appendTo('#pma_console .console_query_input'); + if ($('#pma_bookmarks').length !== 0) { + PMA_consoleInput._inputs.bookmark = + $('').appendTo('#pma_console .bookmark_add_input'); + } + } + $('#pma_console .console_query_input').keydown(PMA_consoleInput._keydown); }, /** * Mousedown event handler for bind to input @@ -491,19 +530,20 @@ var PMA_consoleInput = { * @return void */ execute: function() { - PMA_console.execute(PMA_consoleInput._cm.getValue()); + if (PMA_consoleInput._codemirror) { + PMA_console.execute(PMA_consoleInput._inputs.console.getValue()); + } else { + PMA_console.execute(PMA_consoleInput._inputs.console.val()); + } }, /** * Used for clear the input * - * @param bool clearHistory if true, clear type history + * @param string target, default target is console input * @return void */ - clear: function(clearHistory) { - PMA_consoleInput._cm.setValue(''); - if(clearHistory){ - PMA_consoleInput._cm.clearHistory(); - } + clear: function(target) { + PMA_consoleInput.setText('', target); }, /** * Used for set focus to input @@ -511,7 +551,7 @@ var PMA_consoleInput = { * @return void */ focus: function() { - PMA_consoleInput._cm.focus(); + PMA_consoleInput._inputs.console.focus(); }, /** * Used for blur input @@ -519,15 +559,60 @@ var PMA_consoleInput = { * @return void */ blur: function() { - PMA_consoleInput._cm.getInputField().blur(); + if (PMA_consoleInput._codemirror) { + PMA_consoleInput._inputs.console.getInputField().blur(); + } else { + PMA_consoleInput._inputs.console.blur(); + } }, /** * Used for set text in input * + * @param string text + * @param string target * @return void */ - setText: function(text) { - PMA_consoleInput._cm.setValue(text); + setText: function(text, target) { + if (PMA_consoleInput._codemirror) { + switch(target) { + case 'bookmark': + PMA_console.execute(PMA_consoleInput._inputs.bookmark.setValue(text)); + break; + default: + case 'console': + PMA_console.execute(PMA_consoleInput._inputs.console.setValue(text)); + } + } else { + switch(target) { + case 'bookmark': + PMA_console.execute(PMA_consoleInput._inputs.bookmark.val(text)); + break; + default: + case 'console': + PMA_console.execute(PMA_consoleInput._inputs.console.val(text)); + } + } + }, + getText: function(target) { + if (PMA_consoleInput._codemirror) { + switch(target) { + case 'bookmark': + return PMA_consoleInput._inputs.bookmark.getValue(); + break; + default: + case 'console': + return PMA_consoleInput._inputs.console.getValue(); + } + } else { + switch(target) { + case 'bookmark': + return PMA_consoleInput._inputs.bookmark.val(); + break; + default: + case 'console': + return PMA_consoleInput._inputs.console.val(); + } + } } }; @@ -545,6 +630,7 @@ var PMA_consoleMessages = { clear: function() { $('#pma_console .content .console_message_container .message:not(.welcome)').addClass('hide'); $('#pma_console .content .console_message_container .message.failed').remove(); + $('#pma_console .content .console_message_container .message.expanded').find('.action.collapse').click(); }, /** * Used for show history messages @@ -567,6 +653,7 @@ var PMA_consoleMessages = { } // Generate an ID for each message, we can find them later var msgId = Math.round(Math.random()*(899999999999)+100000000000); + var now = new Date(); var $newMessage = $(''); - CodeMirror.runMode(msgString, - 'text/x-sql', $newMessage.children('.query')[0]); + if(PMA_consoleInput._codemirror) { + CodeMirror.runMode(msgString, + 'text/x-sql', $newMessage.children('.query')[0]); + } else { + $newMessage.children('.query').text(msgString); + } $newMessage.children('.action_content') .append(PMA_console.$consoleTemplates.children('.query_actions').html()); break; @@ -584,7 +675,9 @@ var PMA_consoleMessages = { $newMessage.append('' + msgString + ''); } PMA_consoleMessages._msgEventBinds($newMessage); - $newMessage.find('span.text.query_time span').text(Date()); + $newMessage.find('span.text.query_time span') + .text(now.getHours() + ':' + now.getMinutes() + ':' + now.getSeconds()) + .parent().attr('title', now); return {message_id: msgId, $message: $newMessage.appendTo('#pma_console .content .console_message_container')}; }, @@ -606,19 +699,21 @@ var PMA_consoleMessages = { targetMessage.$message.attr('targettable', queryData.table); targetMessage.$message.find('.text.targetdb span').text(queryData.db); } + if(PMA_console.isSelect(queryData.sql_query)) { + targetMessage.$message.addClass('select'); + } switch(state) { case 'failed': targetMessage.$message.addClass('failed'); break; case 'successed': - console.dir(targetMessage.$message); targetMessage.$message.addClass('successed'); break; default: case 'pending': targetMessage.$message.addClass('pending'); } - return targetMessage.message_id; + return targetMessage; }, _msgEventBinds: function($targetMessage) { // Leave unbinded elements, remove binded. @@ -636,7 +731,7 @@ var PMA_consoleMessages = { $(this).closest('.message').addClass('collapsed'); $(this).closest('.message').removeClass('expanded'); }); - $targetMessage.find('.action.reedit').click(function () { + $targetMessage.find('.action.edit').click(function () { PMA_consoleInput.setText($(this).parent().siblings('.query').text()); PMA_consoleInput.focus(); }); @@ -648,6 +743,53 @@ var PMA_consoleMessages = { PMA_console.execute(query, {db: $message.attr('targetdb'), table: $message.attr('targettable')}); } }); + $targetMessage.find('.action.bookmark').click(function () { + var query = $(this).parent().siblings('.query').text(); + var $message = $(this).closest('.message'); + PMA_consoleBookmarks.addBookmark(query, $message.attr('targetdb')); + PMA_console.showCard('#pma_bookmarks .card.add'); + }); + $targetMessage.find('.action.edit_bookmark').click(function () { + var query = $(this).parent().siblings('.query').text(); + var $message = $(this).closest('.message'); + var isShared = $message.find('span.bookmark_label').hasClass('shared'); + var label = $message.find('span.bookmark_label').text(); + PMA_consoleBookmarks.addBookmark(query, $message.attr('targetdb'), label, isShared); + PMA_console.showCard('#pma_bookmarks .card.add'); + }); + $targetMessage.find('.action.delete_bookmark').click(function () { + var $message = $(this).closest('.message'); + if(confirm(PMA_messages.strConsoleDeleteBookmarkConfirm + '\n' + $message.find('.bookmark_label').text())) { + $.post('import.php', + {token: PMA_commonParams.get('token'), + action_bookmark: 2, + ajax_request: true, + id_bookmark: $message.attr('bookmarkid')}, + function () { + PMA_consoleBookmarks.refresh(); + }); + } + }); + $targetMessage.find('.action.profiling').click(function () { + var $message = $(this).closest('.message'); + PMA_console.execute($(this).parent().siblings('.query').text(), + {db: $message.attr('targetdb'), + table: $message.attr('targettable'), + profiling: true}); + }); + $targetMessage.find('.action.explain').click(function () { + var $message = $(this).closest('.message'); + PMA_console.execute('EXPLAIN ' + $(this).parent().siblings('.query').text(), + {db: $message.attr('targetdb'), + table: $message.attr('targettable')}); + }); + if(PMA_consoleInput._codemirror) { + $targetMessage.find('.query:not(.highlighted)').each(function(index, elem) { + CodeMirror.runMode($(elem).text(), + 'text/x-sql', elem); + $(this).addClass('highlighted'); + }); + } }, msgAppend: function(msgId, msgString, msgType) { var $targetMessage = $('#pma_console .content .console_message_container .message[msgid=' + msgId +']'); @@ -666,7 +808,15 @@ var PMA_consoleMessages = { $targetMessage.addClass('successed'); if(queryData) { $targetMessage.children('.query').text(''); - CodeMirror.runMode(queryData.sql_query, 'text/x-sql', $targetMessage.children('.query')[0]); + $targetMessage.removeClass('select'); + if(PMA_console.isSelect(queryData.sql_query)) { + $targetMessage.addClass('select'); + } + if(PMA_consoleInput._codemirror) { + CodeMirror.runMode(queryData.sql_query, 'text/x-sql', $targetMessage.children('.query')[0]); + } else { + $targetMessage.children('.query').text(queryData.sql_query); + } $targetMessage.attr('targetdb', queryData.db); $targetMessage.attr('targettable', queryData.table); $targetMessage.find('.text.targetdb span').text(queryData.db); @@ -682,11 +832,6 @@ var PMA_consoleMessages = { */ initialize: function() { PMA_consoleMessages._msgEventBinds($('#pma_console .message:not(.binded)')); - $('#pma_console .message .query:not(.highlighted)').each(function(index, elem) { - CodeMirror.runMode(elem.innerHTML, - 'text/x-sql', elem); - $(this).addClass('highlighted'); - }); if(PMA_console.config.startHistory) { PMA_consoleMessages.showHistory(); } @@ -698,6 +843,37 @@ var PMA_consoleMessages = { * Console bookmarks card, and bookmarks items management object */ var PMA_consoleBookmarks = { + _bookmarks: [], + addBookmark: function (queryString, targetDb, label, isShared, id) { + $('#pma_bookmarks .add [name=shared]').prop('checked', false); + $('#pma_bookmarks .add [name=label]').val(''); + $('#pma_bookmarks .add [name=targetdb]').val(''); + $('#pma_bookmarks .add [name=id_bookmark]').val(''); + PMA_consoleInput.setText('', 'bookmark'); + + switch(arguments.length) { + case 4: + $('#pma_bookmarks .add [name=shared]').prop('checked', isShared); + case 3: + $('#pma_bookmarks .add [name=label]').val(label); + case 2: + $('#pma_bookmarks .add [name=targetdb]').val(targetDb); + case 1: + PMA_consoleInput.setText(queryString, 'bookmark'); + default: + break; + } + }, + refresh: function () { + $.get('import.php?console_bookmark_refresh=refresh&token=' + PMA_commonParams.get('token'), + {'ajax_request': true}, + function(data) { + if(data.console_message_bookmark) { + $('#pma_bookmarks .content.bookmark').html(data.console_message_bookmark); + PMA_consoleMessages._msgEventBinds($('#pma_bookmarks .message:not(.binded)')); + } + }); + }, /** * Used for console bookmarks initialize * message events are already binded by PMA_consoleMsg._msgEventBinds @@ -714,15 +890,30 @@ var PMA_consoleBookmarks = { $('#pma_bookmarks .button.add').click(function() { PMA_console.showCard('#pma_bookmarks .card.add'); }); - $('#pma_console .button.refresh').click(function() { - $.get('import.php?console_bookmark_refresh=refresh&token=' + PMA_commonParams.get('token'), - {'ajax_request': true}, - function(data) { - if(data.console_message_bookmark) { - $('#pma_bookmarks .content.bookmark').html(data.console_message_bookmark); - PMA_consoleMessages._msgEventBinds($('#pma_bookmarks .message:not(.binded)')); - } + $('#pma_bookmarks .card.add [name=submit]').click(function () { + if ($('#pma_bookmarks .card.add [name=label]').val().length === 0 + || PMA_consoleInput.getText('bookmark').length === 0) + { + alert(PMA_messages.strFormEmpty); + return; + } + $(this).prop('disabled', true); + $.post('import.php', + {token: PMA_commonParams.get('token'), + ajax_request: true, + console_bookmark_add: 'true', + label: $('#pma_bookmarks .card.add [name=label]').val(), + db: $('#pma_bookmarks .card.add [name=targetdb]').val(), + bookmark_query: PMA_consoleInput.getText('bookmark'), + shared: $('#pma_bookmarks .card.add [name=shared]').prop('checked')}, + function () { + PMA_consoleBookmarks.refresh(); + $('#pma_bookmarks .card.add [name=submit]').prop('disabled', false); + PMA_console.hideCard($('#pma_bookmarks .card.add')); }); }); + $('#pma_console .button.refresh').click(function() { + PMA_consoleBookmarks.refresh(); + }); } }; diff --git a/js/messages.php b/js/messages.php index d66589ff4d..1d3e5228c8 100644 --- a/js/messages.php +++ b/js/messages.php @@ -512,6 +512,7 @@ $js_messages['phpErrorsBeingSubmitted'] = '' . ''; $js_messages['strConsoleRequeryConfirm'] = __('Execute this query again?'); +$js_messages['strConsoleDeleteBookmarkConfirm'] = __('Do you really want to delete this bookmark?'); echo "var PMA_messages = new Array();\n"; foreach ($js_messages as $name => $js_message) { diff --git a/js/sql.js b/js/sql.js index 3a431c098c..012a69f66b 100644 --- a/js/sql.js +++ b/js/sql.js @@ -375,9 +375,6 @@ AJAX.registerOnload('sql.js', function () { } } } - if(PMA_console && PMA_console.isEnabled) { - PMA_console.ajaxCallback(data); - } } else if (data.success === false) { // show an error message that stays on screen $('#sqlqueryform').before(data.error); diff --git a/libraries/Console.class.php b/libraries/Console.class.php index 859b779aae..df3a125c01 100644 --- a/libraries/Console.class.php +++ b/libraries/Console.class.php @@ -93,8 +93,8 @@ class PMA_Console = '' . __('Collapse') . ' ' . '' . __('Expand') . ' ' . '' . __('Requery') . ' ' - . '' . __('Edit') . ' ' - // . '' . __('Delete') . ' ' + . '' . __('Edit') . ' ' + . '' . __('Delete') . ' ' . '' . __('Database') . ': %s'; $bookmarks = PMA_Bookmark_getList(); @@ -131,13 +131,13 @@ class PMA_Console $output .= ''; foreach ($bookmarks as $key => $val) { $output .= '' - . sprintf($tpl_bookmark_actions, $val['db']) + . sprintf($tpl_bookmark_actions, htmlspecialchars($val['db'])) . '' - . $val['label'] + . htmlspecialchars($val['label']) . ' ' - . $val['query'] + . htmlspecialchars($val['query']) . ''; } } @@ -155,9 +155,11 @@ class PMA_Console $output = ''; if ((! $this->_isAjax) && $this->_isEnabled) { $cfgBookmark = PMA_Bookmark_getParams(); - $this->_scripts->addFile('codemirror/lib/codemirror.js'); - $this->_scripts->addFile('codemirror/mode/sql/sql.js'); - $this->_scripts->addFile('codemirror/addon/runmode/runmode.js'); + 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'); + } $this->_scripts->addFile('console.js'); $output .= $this->_scripts->getDisplay(); $output .= ''; @@ -168,8 +170,10 @@ class PMA_Console $tpl_query_actions = '' . __('Collapse') . ' ' . '' . __('Expand') . ' ' . '' . __('Requery') . ' ' - . '' . __('Edit') . ' ' - // . ($cfgBookmark ? '' . __('Bookmark') . ' ' : '') + . '' . __('Edit') . ' ' + . '' . __('Explain') . ' ' + . '' . __('Profiling') . ' ' + . ($cfgBookmark ? '' . __('Bookmark') . ' ' : '') . '' . __('Query failed') . ' ' . '' . __('Database') . ': %s ' . '' . __('Queried time') . ': %s '; @@ -208,13 +212,16 @@ class PMA_Console $_sql_history = PMA_getHistory($GLOBALS['cfg']['Server']['user']); if ($_sql_history) { foreach (array_reverse($_sql_history) as $record) { - $output .= '' . sprintf( $tpl_query_actions, - $record['db'], + htmlspecialchars($record['db']), (isset($record['timevalue']) ? $record['timevalue'] : __('During current session') @@ -227,7 +234,7 @@ class PMA_Console } $output .= ''; // .console_message_container - $output .= '' + $output .= '' . ''; // Messages end // Dark the console while other cards cover it @@ -244,8 +251,8 @@ class PMA_Console $output .= '' . __('Refresh') . ''; - // $output .= '' - // . __('Add') . ''; + $output .= '' + . __('Add') . ''; $output .= ''; $output .= $this->getBookmarkContent(); @@ -256,11 +263,16 @@ class PMA_Console . '' . __('Add bookmark') . ''; $output .= '' - . ''. __('Label') . ': ' - . ''. __('Target database') . ': ' - . ''. __('Share this bookmark') . ''; + . '' + . ''. __('Label') . ': ' + . ''. __('Target database') . ': ' + . ''. __('Share this bookmark') . '' + . 'Ok' + . '' // .options + . ''; $output .= ''; - $output .= ''; // Bookmarks card + $output .= ''; // Add bookmark card + $output .= ''; // Bookmarks card } // Options card: @@ -273,7 +285,7 @@ class PMA_Console $output .= '' . '' - . __('Always expand queried messages') . '' + . __('Always expand query messages') . '' . '' . __('Show query history at start') . '' . '' diff --git a/libraries/Response.class.php b/libraries/Response.class.php index ca1fbdc0e1..7f60173e6f 100644 --- a/libraries/Response.class.php +++ b/libraries/Response.class.php @@ -296,7 +296,11 @@ class PMA_Response unset($this->_JSON['message']); } - if ($this->_isAjaxPage && $this->_isSuccess) { + if ($this->_isSuccess) { + // Note: the old judge sentence is: + // $this->_isAjaxPage && $this->_isSuccess + // Removal the first, because console need log all queries, if casued any + // bug, contact Edward Cheng $this->addJSON('_title', $this->getHeader()->getTitleTag()); $menuHash = $this->getHeader()->getMenu()->getHash(); @@ -326,7 +330,7 @@ class PMA_Response if (isset($GLOBALS['sql_query']) && strlen($GLOBALS['sql_query']) < $maxChars ) { - $query = PMA_escapeJsString($GLOBALS['sql_query']); + $query = $GLOBALS['sql_query']; } $this->addJSON( '_reloadQuerywindow', diff --git a/libraries/bookmark.lib.php b/libraries/bookmark.lib.php index 8830158961..1972d52688 100644 --- a/libraries/bookmark.lib.php +++ b/libraries/bookmark.lib.php @@ -218,7 +218,9 @@ function PMA_Bookmark_save($bkm_fields, $all_users = false) $cfgBookmark = PMA_Bookmark_getParams(); - if (empty($cfgBookmark)) { + if (! (isset($bkm_fields['bkm_sql_query']) && isset($bkm_fields['bkm_label']) + && strlen($bkm_fields['bkm_sql_query']) > 0 && strlen($bkm_fields['bkm_label']) > 0) ) + { return false; } diff --git a/libraries/relation.lib.php b/libraries/relation.lib.php index 8aa3016456..ffb8233216 100644 --- a/libraries/relation.lib.php +++ b/libraries/relation.lib.php @@ -966,13 +966,7 @@ function PMA_setHistory($db, $table, $username, $sqlquery) $_SESSION['sql_history'] = array(); } - $key = md5($sqlquery . $db . $table); - - if (isset($_SESSION['sql_history'][$key])) { - unset($_SESSION['sql_history'][$key]); - } - - $_SESSION['sql_history'][$key] = array( + $_SESSION['sql_history'][] = array( 'db' => $db, 'table' => $table, 'sqlquery' => $sqlquery, diff --git a/themes/original/css/common.css.php b/themes/original/css/common.css.php index 60cf1aa0da..2b665ac596 100644 --- a/themes/original/css/common.css.php +++ b/themes/original/css/common.css.php @@ -2798,6 +2798,11 @@ table.show_create td { #pma_console .query_input:before { top: -2px; } +#pma_console .query_input textarea { + width: 100%; + height: 4em; + resize: vertical; +} #pma_console .message:hover:before { color: #7cf; font-weight: bold; @@ -2831,9 +2836,13 @@ table.show_create td { #pma_console .message.collapsed .action.collapse, #pma_console .message.expanded .action.expand, #pma_console .message .action.requery, +#pma_console .message .action.profiling, +#pma_console .message .action.explain, #pma_console .message .action.bookmark { display: none; } +#pma_console .message.select .action.profiling, +#pma_console .message.select .action.explain, #pma_console .message.history .text.targetdb, #pma_console .message.successed .text.targetdb, #pma_console .message.history .action.requery, @@ -2928,6 +2937,16 @@ html.ie7 #pma_console .query_input { #pma_console_options .content { padding: 4px 6px; } +#pma_bookmarks .content.add_bookmark .options { + margin-: 1.4em; + padding-bottom: .4em; + margin-bottom: .4em; + border-bottom: solid 1px #ccc; +} +#pma_bookmarks .content.add_bookmark .options button { + margin: 0 7px; + vertical-align: bottom; +} #pma_bookmarks .content.add_bookmark input[type=text] { margin: 0; padding: 2px 4px; @@ -2951,11 +2970,16 @@ html.ie7 #pma_console .query_input { min-height: initial; max-height: initial; } +.firefox .cm-s-pma.CodeMirror { + font-size: 120%; +} .cm-s-pma .CodeMirror-scroll { padding-bottom: 2em; cursor: text; } +/* PMA drop-improt style */ + .pma_drop_handler { display: none; position: fixed; diff --git a/themes/pmahomme/css/common.css.php b/themes/pmahomme/css/common.css.php index 7bda864c71..a899293a85 100644 --- a/themes/pmahomme/css/common.css.php +++ b/themes/pmahomme/css/common.css.php @@ -312,6 +312,17 @@ input.button:active { text-shadow: none; } +input[type=submit]:disabled, +input[type=button]:disabled, +button[type=submit]:not(.mult_submit):disabled, +input[type=reset]:disabled, +input[name=submit_reset]:disabled, +input.button:disabled { + background: #ccc; + color: #666; + text-shadow: none; +} + textarea { overflow: visible; height: em; @@ -3099,6 +3110,11 @@ table.show_create td { #pma_console .query_input:before { top: -2px; } +#pma_console .query_input textarea { + width: 100%; + height: 4em; + resize: vertical; +} #pma_console .message:hover:before { color: #7cf; font-weight: bold; @@ -3132,9 +3148,13 @@ table.show_create td { #pma_console .message.collapsed .action.collapse, #pma_console .message.expanded .action.expand, #pma_console .message .action.requery, +#pma_console .message .action.profiling, +#pma_console .message .action.explain, #pma_console .message .action.bookmark { display: none; } +#pma_console .message.select .action.profiling, +#pma_console .message.select .action.explain, #pma_console .message.history .text.targetdb, #pma_console .message.successed .text.targetdb, #pma_console .message.history .action.requery, @@ -3229,6 +3249,16 @@ html.ie7 #pma_console .query_input { #pma_console_options .content { padding: 4px 6px; } +#pma_bookmarks .content.add_bookmark .options { + margin-: 1.4em; + padding-bottom: .4em; + margin-bottom: .4em; + border-bottom: solid 1px #ccc; +} +#pma_bookmarks .content.add_bookmark .options button { + margin: 0 7px; + vertical-align: bottom; +} #pma_bookmarks .content.add_bookmark input[type=text] { margin: 0; padding: 2px 4px; @@ -3252,11 +3282,16 @@ html.ie7 #pma_console .query_input { min-height: initial; max-height: initial; } +.firefox .cm-s-pma.CodeMirror { + font-size: 120%; +} .cm-s-pma .CodeMirror-scroll { padding-bottom: 2em; cursor: text; } +/* PMA drop-improt style */ + .pma_drop_handler { display: none; position: fixed; @@ -3387,4 +3422,4 @@ span.drag_icon { width: 1em; height: 3em; cursor: move; -} +} \ No newline at end of file