From 52596698a722e1732371a3be7dfdeaf8fa2c5d4f Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Thu, 13 Nov 2014 10:53:29 +0530 Subject: [PATCH 1/3] Prompt to confirm on Show All Signed-off-by: Madhura Jayaratne --- js/messages.php | 1 + js/sql.js | 12 ++++++++++++ libraries/DisplayResults.class.php | 4 ++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/js/messages.php b/js/messages.php index 7dd4c35c3a..58c0abe566 100644 --- a/js/messages.php +++ b/js/messages.php @@ -430,6 +430,7 @@ $js_messages['strColVisibHint'] = __( $js_messages['strShowAllCol'] = __('Show all'); $js_messages['strAlertNonUnique'] = __('This table does not contain a unique column. Features related to the grid edit, checkbox, Edit, Copy and Delete links may not work after saving.'); $js_messages['strEnterValidHex'] = __('Please enter a valid hexadecimal string. Valid characters are 0-9, A-F.'); +$js_messages['strShowAllRowsWarning'] = __('Do you really want to see all rows? For a big table this could crash the browser.'); /** Drag & Drop sql import messages */ $js_messages['dropImportMessageCancel'] = __('cancel'); diff --git a/js/sql.js b/js/sql.js index 394984a8a5..937261f7b6 100644 --- a/js/sql.js +++ b/js/sql.js @@ -100,6 +100,7 @@ AJAX.registerTeardown('sql.js', function () { $('th.column_heading.marker').die('click'); $(window).unbind('scroll'); $(".filter_rows").die("keyup"); + $('body').off('submit', '.navigation .showAllRows'); $('body').off('click','a.browse_foreign'); $('body').off('click', '#simulate_dml'); $('body').off('keyup', '#sqlqueryform'); @@ -441,6 +442,17 @@ AJAX.registerOnload('sql.js', function () { }); // Filter row handling. --ENDS-- + // Prompt to confirm on Show All + $('body').on('submit', '.navigation .showAllRows', function (e) { + e.preventDefault(); + $form = $(this); + $form.PMA_confirm(PMA_messages.strShowAllRowsWarning, $form.attr('action'), function (url) { + var submitData = $form.serialize() + '&ajax_request=true&ajax_page_request=true'; + PMA_ajaxShowMessage(); + $.post($form.attr('action'), submitData, AJAX.responseHandler); + }); + }); + $('body').on('keyup', '#sqlqueryform', function () { PMA_handleSimulateQueryButton(); }); diff --git a/libraries/DisplayResults.class.php b/libraries/DisplayResults.class.php index b3040d28d7..798248ba43 100644 --- a/libraries/DisplayResults.class.php +++ b/libraries/DisplayResults.class.php @@ -846,7 +846,7 @@ class PMA_DisplayResults { return "\n" . '' - . '
' + . '' . PMA_URL_getHiddenInputs( $this->__get('db'), $this->__get('table') ) @@ -2925,7 +2925,7 @@ class PMA_DisplayResults false, $this->__get('table') ); - + $transform_url_params = array( 'db' => $this->__get('db'), 'table' => $this->__get('table'), From 183aae0c3f0b9a5736083bb7972afd4efcf4efc2 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Thu, 13 Nov 2014 12:42:16 +0530 Subject: [PATCH 2/3] rfe #1556 Disabling Show all Signed-off-by: Madhura Jayaratne --- ChangeLog | 1 + js/sql.js | 19 +++++++++---- libraries/DisplayResults.class.php | 43 +++++++++++++++++------------- 3 files changed, 40 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index d939629e5c..6f56742cd8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -59,6 +59,7 @@ phpMyAdmin - ChangeLog - bug #4495 Comment lines in multiquery - bug #4535 Loads of Warnings/Notices in PMA_getServerSlaveStatus on replication slave - bug #4585 Multi query results not shown +- rfe #1556 Disabling Show all 4.2.12.0 (not yet released) - bug #4574 Blank/white page when JavaScript disabled diff --git a/js/sql.js b/js/sql.js index 937261f7b6..bd50a3ea3d 100644 --- a/js/sql.js +++ b/js/sql.js @@ -100,7 +100,7 @@ AJAX.registerTeardown('sql.js', function () { $('th.column_heading.marker').die('click'); $(window).unbind('scroll'); $(".filter_rows").die("keyup"); - $('body').off('submit', '.navigation .showAllRows'); + $('body').off('click', '.navigation .showAllRows'); $('body').off('click','a.browse_foreign'); $('body').off('click', '#simulate_dml'); $('body').off('keyup', '#sqlqueryform'); @@ -443,14 +443,23 @@ AJAX.registerOnload('sql.js', function () { // Filter row handling. --ENDS-- // Prompt to confirm on Show All - $('body').on('submit', '.navigation .showAllRows', function (e) { + $('body').on('click', '.navigation .showAllRows', function (e) { e.preventDefault(); - $form = $(this); - $form.PMA_confirm(PMA_messages.strShowAllRowsWarning, $form.attr('action'), function (url) { + $form = $(this).parents('form'); + + if (! $(this).is(':checked')) { // already showing all rows + submitShowAllForm(); + } else { + $form.PMA_confirm(PMA_messages.strShowAllRowsWarning, $form.attr('action'), function (url) { + submitShowAllForm(); + }); + } + + function submitShowAllForm() { var submitData = $form.serialize() + '&ajax_request=true&ajax_page_request=true'; PMA_ajaxShowMessage(); $.post($form.attr('action'), submitData, AJAX.responseHandler); - }); + } }); $('body').on('keyup', '#sqlqueryform', function () { diff --git a/libraries/DisplayResults.class.php b/libraries/DisplayResults.class.php index 798248ba43..759e1b8f7e 100644 --- a/libraries/DisplayResults.class.php +++ b/libraries/DisplayResults.class.php @@ -703,17 +703,10 @@ class PMA_DisplayResults } //_if2 } //_if1 - // Display the "Show all" button if allowed - if (($this->__get('num_rows') < $this->__get('unlim_num_rows')) - && ($GLOBALS['cfg']['ShowAll'] - || ($this->__get('unlim_num_rows') <= 500)) - ) { - - $table_navigation_html .= $this->_getShowAllButtonForTableNavigation( - $html_sql_query - ); - - } // end show all + $showing_all = false; + if ($_SESSION['tmpval']['max_rows'] == self::ALL_ROWS) { + $showing_all = true; + } // Move to the next page or to the last one $endpos = $_SESSION['tmpval']['pos'] @@ -731,8 +724,17 @@ class PMA_DisplayResults } // end move toward + // Display the "Show all" button if allowed + if ($GLOBALS['cfg']['ShowAll'] || ($this->__get('unlim_num_rows') <= 500) ) { + + $table_navigation_html .= $this->_getShowAllCheckboxForTableNavigation( + $showing_all, $html_sql_query + ); + + } // end show all + // show separator if pagination happen - if ($nbTotalPage > 1) { + if ($nbTotalPage > 1 || $showing_all) { $table_navigation_html .= ''; } @@ -832,8 +834,9 @@ class PMA_DisplayResults /** - * Prepare Show All button for table navigation + * Prepare Show All checkbox for table navigation * + * @param bool $showing_all whether all rows are shown currently * @param string $html_sql_query the sql encoded by html special characters * * @return string html content @@ -842,21 +845,25 @@ class PMA_DisplayResults * * @see _getTableNavigation() */ - private function _getShowAllButtonForTableNavigation($html_sql_query) - { + private function _getShowAllCheckboxForTableNavigation( + $showing_all, $html_sql_query + ) { return "\n" . '' - . '' + . '' . PMA_URL_getHiddenInputs( $this->__get('db'), $this->__get('table') ) . '' . '' - . '' + . '' . '' - . '' + . '' + . '' . '' . ''; } // end of the '_getShowAllButtonForTableNavigation()' function From 3e1455a5db6c184830b09ebf0b100447b97794d8 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Thu, 13 Nov 2014 14:02:08 +0530 Subject: [PATCH 3/3] Fix failing tests Signed-off-by: Madhura Jayaratne --- test/classes/PMA_DisplayResults_test.php | 30 +++++++++++++----------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/test/classes/PMA_DisplayResults_test.php b/test/classes/PMA_DisplayResults_test.php index d4485c22d6..f690f7345b 100644 --- a/test/classes/PMA_DisplayResults_test.php +++ b/test/classes/PMA_DisplayResults_test.php @@ -1601,7 +1601,7 @@ class PMA_DisplayResults_Test extends PHPUnit_Framework_TestCase * * @return array parameters and output */ - public function dataProviderForTestGetShowAllButtonForTableNavigation() + public function dataProviderForTestGetShowAllCheckboxForTableNavigation() { return array( array( @@ -1610,15 +1610,17 @@ class PMA_DisplayResults_Test extends PHPUnit_Framework_TestCase 'tbl_structure.php', 'SELECT * FROM `user`', "\n" - . '
' - . '
' + . '
' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '' + . '
' ) ); } @@ -1635,9 +1637,9 @@ class PMA_DisplayResults_Test extends PHPUnit_Framework_TestCase * * @return void * - * @dataProvider dataProviderForTestGetShowAllButtonForTableNavigation + * @dataProvider dataProviderForTestGetShowAllCheckboxForTableNavigation */ - public function testGetShowAllButtonForTableNavigation( + public function testGetShowAllCheckboxForTableNavigation( $db, $table, $goto, $html_sql_query, $output ) { $this->object->__set('db', $db); @@ -1647,8 +1649,8 @@ class PMA_DisplayResults_Test extends PHPUnit_Framework_TestCase $this->assertEquals( $output, $this->_callPrivateFunction( - '_getShowAllButtonForTableNavigation', - array($html_sql_query) + '_getShowAllCheckboxForTableNavigation', + array(false, $html_sql_query) ) ); }