added a optionnal "show all" button in display mode
This commit is contained in:
@@ -475,6 +475,13 @@
|
|||||||
<br /><br />
|
<br /><br />
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
|
<dt><b>$cfgShowAll </b>boolean</dt>
|
||||||
|
<dd>
|
||||||
|
Defines whether an user should be displayed a "show all (records)"
|
||||||
|
button in browse mode or not.
|
||||||
|
<br /><br />
|
||||||
|
</dd>
|
||||||
|
|
||||||
<dt><b>$cfgMaxRows </b>integer</dt>
|
<dt><b>$cfgMaxRows </b>integer</dt>
|
||||||
<dd>
|
<dd>
|
||||||
Number of rows displayed when browsing a resultset. If the resultset
|
Number of rows displayed when browsing a resultset. If the resultset
|
||||||
|
@@ -106,6 +106,7 @@ $cfgAllowUserDropDatabase = FALSE; // disallow users to delete their own databa
|
|||||||
$cfgShowSQL = TRUE; // show SQL queries as run
|
$cfgShowSQL = TRUE; // show SQL queries as run
|
||||||
$cfgSkipLockedTables = FALSE; // mark used tables, make possible to show
|
$cfgSkipLockedTables = FALSE; // mark used tables, make possible to show
|
||||||
// locked tables (since MySQL 3.23.30)
|
// 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
|
$cfgMaxRows = 30; // maximum number of rows to display in browse mode
|
||||||
$cfgOrder = 'ASC'; // default for 'ORDER BY' clause (valid
|
$cfgOrder = 'ASC'; // default for 'ORDER BY' clause (valid
|
||||||
// values are 'ASC', 'DESC' or 'SMART' -ie
|
// values are 'ASC', 'DESC' or 'SMART' -ie
|
||||||
|
@@ -176,7 +176,7 @@ if (!defined('__LIB_DISPLAY_TBL__')){
|
|||||||
* @global integer the total number of rows returned by the sql query
|
* @global integer the total number of rows returned by the sql query
|
||||||
* without any programmatically appended "LIMIT" clause
|
* without any programmatically appended "LIMIT" clause
|
||||||
* @global integer the current position in results
|
* @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
|
* @global boolean whether to limit the number of displayed characters of
|
||||||
* text type fields or not
|
* text type fields or not
|
||||||
*
|
*
|
||||||
@@ -197,7 +197,7 @@ if (!defined('__LIB_DISPLAY_TBL__')){
|
|||||||
<tr>
|
<tr>
|
||||||
<?php
|
<?php
|
||||||
// Move to the beginning or to the previous page
|
// Move to the beginning or to the previous page
|
||||||
if ($pos > 0) {
|
if ($pos > 0 && $sessionMaxRows != 'all') {
|
||||||
?>
|
?>
|
||||||
<td>
|
<td>
|
||||||
<form action="sql.php3" method="post">
|
<form action="sql.php3" method="post">
|
||||||
@@ -245,7 +245,7 @@ if (!defined('__LIB_DISPLAY_TBL__')){
|
|||||||
<input type="hidden" name="goto" value="<?php echo $goto; ?>" />
|
<input type="hidden" name="goto" value="<?php echo $goto; ?>" />
|
||||||
<input type="hidden" name="dontlimitchars" value="<?php echo $dontlimitchars; ?>" />
|
<input type="hidden" name="dontlimitchars" value="<?php echo $dontlimitchars; ?>" />
|
||||||
<input type="submit" name="navig" value="<?php echo $GLOBALS['strShow']; ?> :" />
|
<input type="submit" name="navig" value="<?php echo $GLOBALS['strShow']; ?> :" />
|
||||||
<input type="text" name="sessionMaxRows" size="3" value="<?php echo $sessionMaxRows; ?>" />
|
<input type="text" name="sessionMaxRows" size="3" value="<?php echo (($sessionMaxRows != 'all') ? $sessionMaxRows : $GLOBALS['cfgMaxRows']); ?>" />
|
||||||
<?php echo $GLOBALS['strRowsFrom'] . "\n"; ?>
|
<?php echo $GLOBALS['strRowsFrom'] . "\n"; ?>
|
||||||
<input type="text" name="pos" size="3" value="<?php echo (($pos_next >= $unlim_num_rows) ? 0 : $pos_next); ?>" />
|
<input type="text" name="pos" size="3" value="<?php echo (($pos_next >= $unlim_num_rows) ? 0 : $pos_next); ?>" />
|
||||||
</form>
|
</form>
|
||||||
@@ -255,7 +255,8 @@ if (!defined('__LIB_DISPLAY_TBL__')){
|
|||||||
</td>
|
</td>
|
||||||
<?php
|
<?php
|
||||||
// Move to the next page or to the last one
|
// Move to the next page or to the last one
|
||||||
if (($pos + $sessionMaxRows < $unlim_num_rows) && $num_rows >= $sessionMaxRows) {
|
if (($pos + $sessionMaxRows < $unlim_num_rows) && $num_rows >= $sessionMaxRows
|
||||||
|
&& $sessionMaxRows != 'all') {
|
||||||
echo "\n";
|
echo "\n";
|
||||||
?>
|
?>
|
||||||
<td>
|
<td>
|
||||||
@@ -289,6 +290,30 @@ if (!defined('__LIB_DISPLAY_TBL__')){
|
|||||||
</td>
|
</td>
|
||||||
<?php
|
<?php
|
||||||
} // end move toward
|
} // end move toward
|
||||||
|
|
||||||
|
// Show all the records if allowed
|
||||||
|
if ($GLOBALS['cfgShowAll'] && ($num_rows < $unlim_num_rows)) {
|
||||||
|
echo "\n";
|
||||||
|
?>
|
||||||
|
<td>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<form action="sql.php3" method="post">
|
||||||
|
<input type="hidden" name="lang" value="<?php echo $lang; ?>" />
|
||||||
|
<input type="hidden" name="server" value="<?php echo $server; ?>" />
|
||||||
|
<input type="hidden" name="db" value="<?php echo $db; ?>" />
|
||||||
|
<input type="hidden" name="table" value="<?php echo $table; ?>" />
|
||||||
|
<input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
|
||||||
|
<input type="hidden" name="pos" value="0" />
|
||||||
|
<input type="hidden" name="sessionMaxRows" value="all" />
|
||||||
|
<input type="hidden" name="goto" value="<?php echo $goto; ?>" />
|
||||||
|
<input type="hidden" name="dontlimitchars" value="<?php echo $dontlimitchars; ?>" />
|
||||||
|
<input type="submit" name="navig" value="<?php echo $GLOBALS['strShowAll']; ?>" />
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
<?php
|
||||||
|
} // end show all
|
||||||
echo "\n";
|
echo "\n";
|
||||||
?>
|
?>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -811,14 +836,7 @@ if (!defined('__LIB_DISPLAY_TBL__')){
|
|||||||
|
|
||||||
// 1. ----- Prepares the work -----
|
// 1. ----- Prepares the work -----
|
||||||
|
|
||||||
// 1.1 Gets the number of rows per page
|
// 1.1 Gets the informations about which functionnalities should be
|
||||||
if (isset($GLOBALS['sessionMaxRows'])) {
|
|
||||||
$GLOBALS['cfgMaxRows'] = $GLOBALS['sessionMaxRows'];
|
|
||||||
} else {
|
|
||||||
$GLOBALS['sessionMaxRows'] = $GLOBALS['cfgMaxRows'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// 1.2 Gets the informations about which functionnalities should be
|
|
||||||
// displayed
|
// displayed
|
||||||
$total = '';
|
$total = '';
|
||||||
$is_display = set_display_mode($the_disp_mode, $total);
|
$is_display = set_display_mode($the_disp_mode, $total);
|
||||||
@@ -826,19 +844,24 @@ if (!defined('__LIB_DISPLAY_TBL__')){
|
|||||||
unset($total);
|
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 ($is_display['nav_bar'] == '1') {
|
||||||
if (!isset($pos)) {
|
if (!isset($pos)) {
|
||||||
$pos = 0;
|
$pos = 0;
|
||||||
}
|
}
|
||||||
$pos_next = $pos + $GLOBALS['cfgMaxRows'];
|
if ($GLOBALS['sessionMaxRows'] == 'all') {
|
||||||
$pos_prev = $pos - $GLOBALS['cfgMaxRows'];
|
$pos_next = 0;
|
||||||
if ($pos_prev < 0) {
|
$pos_prev = 0;
|
||||||
$pos_prev = 0;
|
} else {
|
||||||
|
$pos_next = $pos + $GLOBALS['cfgMaxRows'];
|
||||||
|
$pos_prev = $pos - $GLOBALS['cfgMaxRows'];
|
||||||
|
if ($pos_prev < 0) {
|
||||||
|
$pos_prev = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} // end if
|
} // 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'
|
// will be stripslashed in 'sql.php3' if the 'magic_quotes_gpc'
|
||||||
// directive is set to 'on')
|
// directive is set to 'on')
|
||||||
if (get_magic_quotes_gpc()) {
|
if (get_magic_quotes_gpc()) {
|
||||||
@@ -856,7 +879,9 @@ if (!defined('__LIB_DISPLAY_TBL__')){
|
|||||||
} else {
|
} else {
|
||||||
$selectstring = '';
|
$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 . ')');
|
show_message($GLOBALS['strShowingRecords'] . " $pos - $last_shown_rec ($total " . $GLOBALS['strTotal'] . $selectstring . ')');
|
||||||
} else {
|
} else {
|
||||||
show_message($GLOBALS['strSQLQuery']);
|
show_message($GLOBALS['strSQLQuery']);
|
||||||
|
6
sql.php3
6
sql.php3
@@ -148,7 +148,10 @@ else {
|
|||||||
&& eregi('^CREATE TABLE (.*)', $sql_query)) {
|
&& eregi('^CREATE TABLE (.*)', $sql_query)) {
|
||||||
$reload = 1;
|
$reload = 1;
|
||||||
}
|
}
|
||||||
if (isset($sessionMaxRows)) {
|
// Gets the number of rows per page
|
||||||
|
if (!isset($sessionMaxRows)){
|
||||||
|
$sessionMaxRows = $cfgMaxRows;
|
||||||
|
} else if ($sessionMaxRows != 'all') {
|
||||||
$cfgMaxRows = $sessionMaxRows;
|
$cfgMaxRows = $sessionMaxRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,6 +177,7 @@ else {
|
|||||||
|
|
||||||
// Do append a "LIMIT" clause?
|
// Do append a "LIMIT" clause?
|
||||||
if (isset($pos)
|
if (isset($pos)
|
||||||
|
&& (!$cfgShowAll || $sessionMaxRows != 'all')
|
||||||
&& ($is_select && !$is_count && eregi(' FROM ', $sql_query))
|
&& ($is_select && !$is_count && eregi(' FROM ', $sql_query))
|
||||||
&& !eregi(' LIMIT[ 0-9,]+$', $sql_query)) {
|
&& !eregi(' LIMIT[ 0-9,]+$', $sql_query)) {
|
||||||
$sql_limit_to_append = " LIMIT $pos, $cfgMaxRows";
|
$sql_limit_to_append = " LIMIT $pos, $cfgMaxRows";
|
||||||
|
Reference in New Issue
Block a user