From 149ed7b949ab0c8464f3c2f52aa44b7f6dff93b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Chapeaux?= Date: Thu, 13 Sep 2001 18:25:59 +0000 Subject: [PATCH] added a optionnal "show all" button in display mode --- Documentation.html | 7 ++++ config.inc.php3 | 1 + libraries/display_tbl.lib.php3 | 65 +++++++++++++++++++++++----------- sql.php3 | 6 +++- 4 files changed, 58 insertions(+), 21 deletions(-) diff --git a/Documentation.html b/Documentation.html index 754b044f2..580123135 100755 --- a/Documentation.html +++ b/Documentation.html @@ -475,6 +475,13 @@

+
$cfgShowAll boolean
+
+ Defines whether an user should be displayed a "show all (records)" + button in browse mode or not. +

+
+
$cfgMaxRows integer
Number of rows displayed when browsing a resultset. If the resultset diff --git a/config.inc.php3 b/config.inc.php3 index 770138cc3..f5e6aec6e 100755 --- a/config.inc.php3 +++ b/config.inc.php3 @@ -106,6 +106,7 @@ $cfgAllowUserDropDatabase = FALSE; // disallow users to delete their own databa $cfgShowSQL = TRUE; // show SQL queries as run $cfgSkipLockedTables = FALSE; // mark used tables, make possible to show // locked tables (since MySQL 3.23.30) +$cfgShowAll = FALSE; // allows to display all the rows in browse mode $cfgMaxRows = 30; // maximum number of rows to display in browse mode $cfgOrder = 'ASC'; // default for 'ORDER BY' clause (valid // values are 'ASC', 'DESC' or 'SMART' -ie diff --git a/libraries/display_tbl.lib.php3 b/libraries/display_tbl.lib.php3 index 50c7c9b91..a89d1fc91 100644 --- a/libraries/display_tbl.lib.php3 +++ b/libraries/display_tbl.lib.php3 @@ -176,7 +176,7 @@ if (!defined('__LIB_DISPLAY_TBL__')){ * @global integer the total number of rows returned by the sql query * without any programmatically appended "LIMIT" clause * @global integer the current position in results - * @global integer the maximum number of rows per page + * @global mixed the maximum number of rows per page ('all' = no limit) * @global boolean whether to limit the number of displayed characters of * text type fields or not * @@ -197,7 +197,7 @@ if (!defined('__LIB_DISPLAY_TBL__')){ 0) { + if ($pos > 0 && $sessionMaxRows != 'all') { ?>
@@ -245,7 +245,7 @@ if (!defined('__LIB_DISPLAY_TBL__')){ - +
@@ -255,7 +255,8 @@ if (!defined('__LIB_DISPLAY_TBL__')){ = $sessionMaxRows) { + if (($pos + $sessionMaxRows < $unlim_num_rows) && $num_rows >= $sessionMaxRows + && $sessionMaxRows != 'all') { echo "\n"; ?> @@ -289,6 +290,30 @@ if (!defined('__LIB_DISPLAY_TBL__')){ + +     + + +
+ + + + + + + + + + +
+ + @@ -811,14 +836,7 @@ if (!defined('__LIB_DISPLAY_TBL__')){ // 1. ----- Prepares the work ----- - // 1.1 Gets the number of rows per page - if (isset($GLOBALS['sessionMaxRows'])) { - $GLOBALS['cfgMaxRows'] = $GLOBALS['sessionMaxRows']; - } else { - $GLOBALS['sessionMaxRows'] = $GLOBALS['cfgMaxRows']; - } - - // 1.2 Gets the informations about which functionnalities should be + // 1.1 Gets the informations about which functionnalities should be // displayed $total = ''; $is_display = set_display_mode($the_disp_mode, $total); @@ -826,19 +844,24 @@ if (!defined('__LIB_DISPLAY_TBL__')){ unset($total); } - // 1.3 Defines offsets for the next and previous pages + // 1.2 Defines offsets for the next and previous pages if ($is_display['nav_bar'] == '1') { if (!isset($pos)) { - $pos = 0; + $pos = 0; } - $pos_next = $pos + $GLOBALS['cfgMaxRows']; - $pos_prev = $pos - $GLOBALS['cfgMaxRows']; - if ($pos_prev < 0) { - $pos_prev = 0; + if ($GLOBALS['sessionMaxRows'] == 'all') { + $pos_next = 0; + $pos_prev = 0; + } else { + $pos_next = $pos + $GLOBALS['cfgMaxRows']; + $pos_prev = $pos - $GLOBALS['cfgMaxRows']; + if ($pos_prev < 0) { + $pos_prev = 0; + } } } // end if - // 1.4 Urlencodes the query to use in input form fields ($sql_query + // 1.3 Urlencodes the query to use in input form fields ($sql_query // will be stripslashed in 'sql.php3' if the 'magic_quotes_gpc' // directive is set to 'on') if (get_magic_quotes_gpc()) { @@ -856,7 +879,9 @@ if (!defined('__LIB_DISPLAY_TBL__')){ } else { $selectstring = ''; } - $last_shown_rec = ($pos_next > $total) ? $total : $pos_next; + $last_shown_rec = ($GLOBALS['sessionMaxRows'] == 'all' || $pos_next > $total) + ? $total + : $pos_next; show_message($GLOBALS['strShowingRecords'] . " $pos - $last_shown_rec ($total " . $GLOBALS['strTotal'] . $selectstring . ')'); } else { show_message($GLOBALS['strSQLQuery']); diff --git a/sql.php3 b/sql.php3 index 28d829298..34b8f9e70 100755 --- a/sql.php3 +++ b/sql.php3 @@ -148,7 +148,10 @@ else { && eregi('^CREATE TABLE (.*)', $sql_query)) { $reload = 1; } - if (isset($sessionMaxRows)) { + // Gets the number of rows per page + if (!isset($sessionMaxRows)){ + $sessionMaxRows = $cfgMaxRows; + } else if ($sessionMaxRows != 'all') { $cfgMaxRows = $sessionMaxRows; } @@ -174,6 +177,7 @@ else { // Do append a "LIMIT" clause? if (isset($pos) + && (!$cfgShowAll || $sessionMaxRows != 'all') && ($is_select && !$is_count && eregi(' FROM ', $sql_query)) && !eregi(' LIMIT[ 0-9,]+$', $sql_query)) { $sql_limit_to_append = " LIMIT $pos, $cfgMaxRows";