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/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..bd50a3ea3d 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('click', '.navigation .showAllRows'); $('body').off('click','a.browse_foreign'); $('body').off('click', '#simulate_dml'); $('body').off('keyup', '#sqlqueryform'); @@ -441,6 +442,26 @@ AJAX.registerOnload('sql.js', function () { }); // Filter row handling. --ENDS-- + // Prompt to confirm on Show All + $('body').on('click', '.navigation .showAllRows', function (e) { + e.preventDefault(); + $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 () { PMA_handleSimulateQueryButton(); }); diff --git a/libraries/DisplayResults.class.php b/libraries/DisplayResults.class.php index b3040d28d7..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,8 +845,9 @@ class PMA_DisplayResults * * @see _getTableNavigation() */ - private function _getShowAllButtonForTableNavigation($html_sql_query) - { + private function _getShowAllCheckboxForTableNavigation( + $showing_all, $html_sql_query + ) { return "\n" . '' . '
' @@ -853,10 +857,13 @@ class PMA_DisplayResults . '' . '' - . '' + . '' . '' - . '' + . '' + . '' . '
' . ''; } // end of the '_getShowAllButtonForTableNavigation()' function @@ -2925,7 +2932,7 @@ class PMA_DisplayResults false, $this->__get('table') ); - + $transform_url_params = array( 'db' => $this->__get('db'), 'table' => $this->__get('table'), 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) ) ); }