From 021e81165360a6762a24be3a99f9da4f480d07ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 8 Aug 2011 15:23:20 +0200 Subject: [PATCH 1/9] Use standard way for passing messages --- js/makegrid.js | 12 ++++++------ js/messages.php | 7 +++++++ libraries/display_tbl.lib.php | 6 ------ 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/js/makegrid.js b/js/makegrid.js index 00d839f9ce..7755d1ece1 100644 --- a/js/makegrid.js +++ b/js/makegrid.js @@ -489,12 +489,12 @@ g.tableCreateTime = $('#table_create_time').val(); // assign column reorder & column sort hint - g.reorderHint = $('#col_order_hint').val(); - g.sortHint = $('#sort_hint').val(); - g.markHint = $('#col_mark_hint').val(); - g.colVisibHint = $('#col_visib_hint').val(); - g.showAllColText = $('#show_all_col_text').val(); - + g.reorderHint = PMA_messages['strColOrderHint']; + g.sortHint = PMA_messages['strSortHint']; + g.markHint = PMA_messages['strMarkHint']; + g.colVisibHint = PMA_messages['strVisibHint']; + g.showAllColText = PMA_messages['strShowAll']; + // initialize column order $col_order = $('#col_order'); if ($col_order.length > 0) { diff --git a/js/messages.php b/js/messages.php index d5565ac09a..72d5f04ea3 100644 --- a/js/messages.php +++ b/js/messages.php @@ -268,6 +268,13 @@ $js_messages['strNewerVersion'] = __('A newer version of phpMyAdmin is available $js_messages['strLatestAvailable'] = __(', latest stable version:'); $js_messages['strUpToDate'] = __('up to date'); +/* Browsing grid */ +$js_messages['strColOrderHint'] = __('Drag to reorder'); +$js_messages['strSortHint'] = __('Click to sort'); +$js_messages['strMarkHint'] = __('Click to mark/unmark'); +$js_messages['strVisibHint'] = __('Click the drop-down arrow
to toggle column\'s visibility'); +$js_messages['strShowAll'] = __('Show all'); + echo "var PMA_messages = new Array();\n"; foreach ($js_messages as $name => $js_message) { PMA_printJsValue("PMA_messages['" . $name . "']", $js_message); diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php index 2f95f11c2b..711998d18e 100644 --- a/libraries/display_tbl.lib.php +++ b/libraries/display_tbl.lib.php @@ -419,12 +419,6 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, $id_for_di PMA_Table::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], 'Create_time') . '" />'; } } - // generate hints - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; ?> From f16efa15ddfa22852a9195d40c3cc39d8b26cd4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 8 Aug 2011 15:23:27 +0200 Subject: [PATCH 2/9] Whitespace cleanup --- js/makegrid.js | 108 ++++++++++++++++++++++++------------------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/js/makegrid.js b/js/makegrid.js index 7755d1ece1..13fcc37a4c 100644 --- a/js/makegrid.js +++ b/js/makegrid.js @@ -4,7 +4,7 @@ var g = { // constant minColWidth: 15, - + // variables, assigned with default value, changed later actionSpan: 5, colOrder: new Array(), // array of column order @@ -21,7 +21,7 @@ showColVisibHint: false, showAllColText: '', // string, text for "show all" button under column visibility list visibleHeadersCount: 0, // number of visible data headers - + // functions dragStartRsz: function(e, obj) { // start column resize var n = $(this.cRsz).find('div').index(obj); @@ -35,7 +35,7 @@ $('body').css('cursor', 'col-resize'); $('body').noSelect(); }, - + dragStartMove: function(e, obj) { // start column move // prepare the cCpy and cPointer from the dragged column $(this.cCpy).text($(obj).text()); @@ -49,10 +49,10 @@ $(this.cPointer).css({ top: objPos.top }); - + // get the column index, zero-based var n = this.getHeaderIdx(obj); - + this.colMov = { x0: e.pageX, y0: e.pageY, @@ -66,7 +66,7 @@ $('body').css('cursor', 'move'); $('body').noSelect(); }, - + dragMove: function(e) { if (this.colRsz) { var dx = e.pageX - this.colRsz.x0; @@ -79,7 +79,7 @@ $(this.cCpy) .css('left', this.colMov.objLeft + dx) .show(); - + // pointer animation var hoveredCol = this.getHoveredCol(e); if (hoveredCol) { @@ -103,7 +103,7 @@ } } }, - + dragEnd: function(e) { if (this.colRsz) { var dx = e.pageX - this.colRsz.x0; @@ -114,7 +114,7 @@ var n = this.colRsz.n; // do the resizing this.resize(n, nw); - + $('body').css('cursor', 'default'); this.reposRsz(); this.reposDrop(); @@ -134,7 +134,7 @@ } this.refreshRestoreButton(); } - + // animate new column position $(this.cCpy).stop(true, true) .animate({ @@ -149,7 +149,7 @@ $('body').css('cursor', 'default'); $('body').noSelect(false); }, - + /** * Resize column n to new width "nw" */ @@ -160,7 +160,7 @@ .css('width', nw); }); }, - + /** * Reposition column resize bars. */ @@ -175,7 +175,7 @@ } $(this.cRsz).css('height', $(this.t).height()); }, - + /** * Shift column from index oldn to newn. */ @@ -195,7 +195,7 @@ }); // reposition the column resize bars this.reposRsz(); - + // adjust the column visibility list if (newn < oldn) { $(g.cList).find('.lDiv div:eq(' + newn + ')') @@ -213,7 +213,7 @@ this.colVisib.splice(oldn, 1); this.colVisib.splice(newn, 0, tmp); }, - + /** * Find currently hovered table column's header (excluding actions column). * @return the hovered column's th object or undefined if no hovered column found. @@ -230,14 +230,14 @@ }); return hoveredCol; }, - + /** * Get a zero-based index from a tag in a table. */ getHeaderIdx: function(obj) { return $(obj).parents('tr').find('th.draggable').index(obj); }, - + /** * Reposition the table back to normal order. */ @@ -259,7 +259,7 @@ } this.refreshRestoreButton(); }, - + /** * Send column preferences (column order and visibility) to the server. */ @@ -276,7 +276,7 @@ table_create_time: this.tableCreateTime }); }, - + /** * Refresh restore button state. * Make restore button disabled if the table is similar with initial state. @@ -299,7 +299,7 @@ $('.restore_column').show(); } }, - + /** * Update current hint using the boolean values (showReorderHint, showSortHint, etc.). * It will hide the hint if all the boolean values is false. @@ -324,16 +324,16 @@ text += text.length > 0 ? '
' : ''; text += this.colVisibHint; } - + // hide the hint if no text this.qtip.disable(!text && e.type == 'mouseenter'); - + this.qtip.updateContent(text, false); } else { this.qtip.disable(true); } }, - + /** * Toggle column's visibility. * After calling this function and it returns true, afterToggleCol() must be called. @@ -367,7 +367,7 @@ } return true; }, - + /** * This must be called after calling toggleCol() and the return value is true. * @@ -379,12 +379,12 @@ this.reposRsz(); this.reposDrop(); this.sendColPrefs(); - + // check visible first row headers count this.visibleHeadersCount = $(this.t).find('tr:first th.draggable:visible').length; this.refreshRestoreButton(); }, - + /** * Show columns' visibility list. */ @@ -404,7 +404,7 @@ $(obj).addClass('coldrop-hover'); } }, - + /** * Hide columns' visibility list. */ @@ -412,7 +412,7 @@ $(this.cList).hide(); $(g.cDrop).find('.coldrop-hover').removeClass('coldrop-hover'); }, - + /** * Reposition the column visibility drop-down arrow. */ @@ -427,7 +427,7 @@ }); } }, - + /** * Show all hidden columns. */ @@ -440,54 +440,54 @@ this.afterToggleCol(); } } - + // wrap all data cells, except actions cell, with span $(t).find('th, td:not(:has(span))') .wrapInner(''); - + g.gDiv = document.createElement('div'); // create global div g.cRsz = document.createElement('div'); // column resizer g.cCpy = document.createElement('div'); // column copy, to store copy of dragged column header g.cPointer = document.createElement('div'); // column pointer, used when reordering column g.cDrop = document.createElement('div'); // column drop-down arrows g.cList = document.createElement('div'); // column visibility list - + // adjust g.cCpy g.cCpy.className = 'cCpy'; $(g.cCpy).hide(); - + // adjust g.cPoint g.cPointer.className = 'cPointer'; $(g.cPointer).css('visibility', 'hidden'); - + // adjust g.cDrop g.cDrop.className = 'cDrop'; - + // adjust g.cList g.cList.className = 'cList'; $(g.cList).hide(); - + // chain table and grid together t.grid = g; g.t = t; - + // get first row data columns var $firstRowCols = $(t).find('tr:first th.draggable'); - + // initialize g.visibleHeadersCount g.visibleHeadersCount = $firstRowCols.filter(':visible').length; - + // assign first column (actions) span if (! $(t).find('tr:first th:first').hasClass('draggable')) { // action header exist g.actionSpan = $(t).find('tr:first th:first').prop('colspan'); } else { g.actionSpan = 0; } - + // assign table create time // #table_create_time will only available if we are in "Browse" tab g.tableCreateTime = $('#table_create_time').val(); - + // assign column reorder & column sort hint g.reorderHint = PMA_messages['strColOrderHint']; g.sortHint = PMA_messages['strSortHint']; @@ -508,7 +508,7 @@ g.colOrder.push(i); } } - + // initialize column visibility $col_visib = $('#col_visib'); if ($col_visib.length > 0) { @@ -522,7 +522,7 @@ g.colVisib.push(1); } } - + if ($firstRowCols.length > 1) { // create column drop-down arrow(s) $(t).find('th:not(.draggable)').each(function() { @@ -542,7 +542,7 @@ }); $(g.cDrop).append(cd); }); - + // add column visibility control g.cList.innerHTML = '
'; var $listDiv = $(g.cList).find('div'); @@ -576,7 +576,7 @@ }); } } - + // create column borders $firstRowCols.each(function() { $this = $(this); @@ -588,15 +588,15 @@ $(g.cRsz).append(cb); }); g.reposRsz(); - + // bind event to update currently hovered qtip API $(t).find('th').mouseenter(function(e) { g.qtip = $(this).qtip('api'); }); - + // create qtip for each with draggable class PMA_createqTip($(t).find('th.draggable')); - + // register events if (g.reorderHint) { // make sure columns is reorderable $(t).find('th.draggable') @@ -621,7 +621,7 @@ } if ($firstRowCols.length > 1) { var $colVisibTh = $(t).find('th:not(.draggable)'); - + PMA_createqTip($colVisibTh); $colVisibTh.mouseenter(function(e) { g.showColVisibHint = true; @@ -663,10 +663,10 @@ $(t).find('td, th.draggable').mouseenter(function() { g.hideColList(); }); - + // add table class $(t).addClass('pma_table'); - + // link all divs $(t).before(g.gDiv); $(g.gDiv).append(t); @@ -686,13 +686,13 @@ return false; }); }; - + // document ready checking var docready = false; $(document).ready(function() { docready = true; }); - + // Additional jQuery functions /** * Make resizable, reorderable grid. @@ -732,6 +732,6 @@ } }); } - + })(jQuery); From 0fc55bb503fdb18dc701bc9a6a84374aad1ecc0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 8 Aug 2011 15:43:34 +0200 Subject: [PATCH 3/9] Remove debugging code --- js/common.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/js/common.js b/js/common.js index 9b5dcf6d31..47fd3bf4d5 100644 --- a/js/common.js +++ b/js/common.js @@ -180,7 +180,6 @@ function markDbTable(db, table) */ function setAll( new_lang, new_collation_connection, new_server, new_db, new_table, new_token ) { - //alert('setAll( ' + new_lang + ', ' + new_collation_connection + ', ' + new_server + ', ' + new_db + ', ' + new_table + ', ' + new_token + ' )'); if (new_server != server || new_lang != lang || new_collation_connection != collation_connection) { // something important has changed @@ -240,7 +239,6 @@ function focus_querywindow(sql_query) if ( !querywindow || querywindow.closed || !querywindow.location) { // we need first to open the window and cannot pass the query with it // as we dont know if the query exceeds max url length - /* url = 'querywindow.php?' + common_query + '&db=' + db + '&table=' + table + '&sql_query=SELECT * FROM'; */ query_to_load = sql_query; open_querywindow(); insertQuery(0); From 21afd1786006ebd1045123446a4a87c592359dcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 8 Aug 2011 15:45:47 +0200 Subject: [PATCH 4/9] Wrap long line --- libraries/common.lib.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraries/common.lib.php b/libraries/common.lib.php index c3a9d69d15..4475943c5e 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -253,7 +253,10 @@ function PMA_unQuote($quoted_string, $quote = null) && substr($quoted_string, -1, 1) === $quote) { $unquoted_string = substr($quoted_string, 1, -1); // replace escaped quotes - $unquoted_string = str_replace($quote . $quote, $quote, $unquoted_string); + $unquoted_string = str_replace( + $quote . $quote, + $quote, + $unquoted_string); return $unquoted_string; } } From dae7d3bd4a2f1c36f5a928fad015c5d099aeec9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 8 Aug 2011 15:46:05 +0200 Subject: [PATCH 5/9] Improve code readability --- libraries/common.lib.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 4475943c5e..89c1dc27ed 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -293,9 +293,13 @@ function PMA_formatSql($parsed_sql, $unparsed_sql = '') if (! is_array($parsed_sql)) { // We don't so just return the input directly // This is intended to be used for when the SQL Parser is turned off - $formatted_sql = '
' . "\n"
-                        . (($cfg['SQP']['fmtType'] == 'none' && $unparsed_sql != '') ? $unparsed_sql : $parsed_sql) . "\n"
-                        . '
'; + $formatted_sql = '
' . "\n";
+        if ($cfg['SQP']['fmtType'] == 'none' && $unparsed_sql != '') {
+            $formatted_sql .= $unparsed_sql;
+        } else {
+            $formatted_sql .= $parsed_sql;
+        }
+        $formatted_sql .= '
'; return $formatted_sql; } From b9e17020b889bfe5e10de3e8ab8b5ab23ea81126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 8 Aug 2011 15:46:18 +0200 Subject: [PATCH 6/9] Whitespace cleanup --- libraries/common.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 89c1dc27ed..5ee05d201e 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -1709,7 +1709,7 @@ function PMA_linkOrButton($url, $message, $tag_params = array(), if (stristr($message, ''; } - + // Suhosin: Check that each query parameter is not above maximum $in_suhosin_limits = true; if ($url_length <= $GLOBALS['cfg']['LinkLengthLimit']) { @@ -1739,12 +1739,12 @@ function PMA_linkOrButton($url, $message, $tag_params = array(), if (empty($tag_params['class'])) { $tag_params['class'] = 'link'; } - + if (! isset($query_parts)) { $query_parts = PMA_splitURLQuery($url); } $url_parts = parse_url($url); - + if ($new_form) { $ret = '