store browse state in session per query

This commit is contained in:
Sebastian Mendel
2007-05-15 11:16:10 +00:00
parent 4b368f8b42
commit fa30ac8c33
9 changed files with 238 additions and 318 deletions

View File

@@ -59,6 +59,7 @@ $HeadURL: https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyA
+ RFE #1704779 [gui] link documentation from login page
+ RFE #1513345 [setup] check control user connection during setup
+ [structure] TRIGGERS: display/edit/drop/SQL export
+ [browse] store browse state in session per query
2.10.2.0 (not yet released)

View File

@@ -407,13 +407,6 @@ if (isset($my_die)) {
}
if ($go_sql) {
if (isset($_GET['pos'])) {
// comes from the Refresh link
$pos = $_GET['pos'];
} else {
// Set pos to zero to possibly append limit
$pos = 0;
}
require './sql.php';
} else {
$active_page = $goto;

View File

@@ -1200,7 +1200,6 @@ function PMA_showMessage($message, $sql_query = null)
$refresh_link = 'import.php'
. $url_qpart
. '&show_query=1'
. (isset($_GET['pos']) ? '&pos=' . $_GET['pos'] : '')
. '&sql_query=' . urlencode($sql_query);
$refresh_link = ' [' . PMA_linkOrButton($refresh_link, $GLOBALS['strRefresh']) . ']';
} else {

View File

@@ -14,16 +14,6 @@ require_once './libraries/Table.class.php';
* Set of functions used to display the records returned by a SQL query
*/
/**
* Avoids undefined variables
*/
if (!isset($pos)) {
$pos = 0;
} else {
/* We need this to be a integer */
$pos = (int)$pos;
}
/**
* Defines the display mode to use for the results of a SQL query
*
@@ -197,6 +187,10 @@ function PMA_setDisplayMode(&$the_disp_mode, &$the_total)
/**
* Displays a navigation bar to browse among the results of a SQL query
*
* @uses $_SESSION['userconf']['disp_direction']
* @uses $_SESSION['userconf']['repeat_cells']
* @uses $_SESSION['userconf']['max_rows']
* @uses $_SESSION['userconf']['pos']
* @param integer the offset for the "next" page
* @param integer the offset for the "previous" page
* @param string the URL-encoded query
@@ -204,19 +198,10 @@ function PMA_setDisplayMode(&$the_disp_mode, &$the_total)
* @global string $db the database name
* @global string $table the table name
* @global string $goto the URL to go back in case of errors
* @global boolean $dontlimitchars whether to limit the number of displayed
* characters of text type fields or not
* @global integer $num_rows the total number of rows returned by the
* SQL query
* @global integer $unlim_num_rows the total number of rows returned by the
* SQL any programmatically appended "LIMIT" clause
* @global integer $pos the current position in results
* @global mixed $session_max_rows the maximum number of rows per page
* ('all' = no limit)
* @global string $disp_direction the display mode
* (horizontal / vertical / horizontalflipped)
* @global integer $repeat_cells the number of row to display between two
* table headers
* @global boolean $is_innodb whether its InnoDB or not
* @global array $showtable table definitions
*
@@ -226,9 +211,8 @@ function PMA_setDisplayMode(&$the_disp_mode, &$the_total)
*/
function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query)
{
global $db, $table, $goto, $dontlimitchars;
global $num_rows, $unlim_num_rows, $pos, $session_max_rows;
global $disp_direction, $repeat_cells;
global $db, $table, $goto;
global $num_rows, $unlim_num_rows;
global $is_innodb;
global $showtable;
@@ -247,7 +231,7 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query)
<tr>
<?php
// Move to the beginning or to the previous page
if ($pos > 0 && $session_max_rows != 'all') {
if ($_SESSION['userconf']['pos'] && $_SESSION['userconf']['max_rows'] != 'all') {
// loic1: patch #474210 from Gosha Sakovich - part 1
if ($GLOBALS['cfg']['NavigationBarIconic']) {
$caption1 = '&lt;&lt;';
@@ -266,11 +250,7 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query)
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
<input type="hidden" name="sql_query" value="<?php echo $html_sql_query; ?>" />
<input type="hidden" name="pos" value="0" />
<input type="hidden" name="session_max_rows" value="<?php echo $session_max_rows; ?>" />
<input type="hidden" name="disp_direction" value="<?php echo $disp_direction; ?>" />
<input type="hidden" name="repeat_cells" value="<?php echo $repeat_cells; ?>" />
<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 $caption1; ?>"<?php echo $title1; ?> />
</form>
</td>
@@ -279,11 +259,7 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query)
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
<input type="hidden" name="sql_query" value="<?php echo $html_sql_query; ?>" />
<input type="hidden" name="pos" value="<?php echo $pos_prev; ?>" />
<input type="hidden" name="session_max_rows" value="<?php echo $session_max_rows; ?>" />
<input type="hidden" name="disp_direction" value="<?php echo $disp_direction; ?>" />
<input type="hidden" name="repeat_cells" value="<?php echo $repeat_cells; ?>" />
<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 $caption2; ?>"<?php echo $title2; ?> />
</form>
</td>
@@ -299,21 +275,20 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query)
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
<input type="hidden" name="sql_query" value="<?php echo $html_sql_query; ?>" />
<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['strShow']; ?> :" />
<input type="text" name="session_max_rows" size="3" value="<?php echo (($session_max_rows != 'all') ? $session_max_rows : $GLOBALS['cfg']['MaxRows']); ?>" class="textfield" onfocus="this.select()" />
<input type="text" name="session_max_rows" size="3" value="<?php echo (($_SESSION['userconf']['max_rows'] != 'all') ? $_SESSION['userconf']['max_rows'] : $GLOBALS['cfg']['MaxRows']); ?>" class="textfield" onfocus="this.select()" />
<?php echo $GLOBALS['strRowsFrom'] . "\n"; ?>
<input type="text" name="pos" size="6" value="<?php echo (($pos_next >= $unlim_num_rows) ? 0 : $pos_next); ?>" class="textfield" onfocus="this.select()" />
<br />
<?php
// Display mode (horizontal/vertical and repeat headers)
$param1 = ' <select name="disp_direction">' . "\n"
. ' <option value="horizontal"' . (($disp_direction == 'horizontal') ? ' selected="selected"': '') . '>' . $GLOBALS['strRowsModeHorizontal'] . '</option>' . "\n"
. ' <option value="horizontalflipped"' . (($disp_direction == 'horizontalflipped') ? ' selected="selected"': '') . '>' . $GLOBALS['strRowsModeFlippedHorizontal'] . '</option>' . "\n"
. ' <option value="vertical"' . (($disp_direction == 'vertical') ? ' selected="selected"': '') . '>' . $GLOBALS['strRowsModeVertical'] . '</option>' . "\n"
. ' <option value="horizontal"' . (($_SESSION['userconf']['disp_direction'] == 'horizontal') ? ' selected="selected"': '') . '>' . $GLOBALS['strRowsModeHorizontal'] . '</option>' . "\n"
. ' <option value="horizontalflipped"' . (($_SESSION['userconf']['disp_direction'] == 'horizontalflipped') ? ' selected="selected"': '') . '>' . $GLOBALS['strRowsModeFlippedHorizontal'] . '</option>' . "\n"
. ' <option value="vertical"' . (($_SESSION['userconf']['disp_direction'] == 'vertical') ? ' selected="selected"': '') . '>' . $GLOBALS['strRowsModeVertical'] . '</option>' . "\n"
. ' </select>' . "\n"
. ' ';
$param2 = ' <input type="text" size="3" name="repeat_cells" value="' . $repeat_cells . '" class="textfield" />' . "\n"
$param2 = ' <input type="text" size="3" name="repeat_cells" value="' . $_SESSION['userconf']['repeat_cells'] . '" class="textfield" />' . "\n"
. ' ';
echo ' ' . sprintf($GLOBALS['strRowsModeOptions'], "\n" . $param1, "\n" . $param2) . "\n";
?>
@@ -324,8 +299,8 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query)
</td>
<?php
// Move to the next page or to the last one
if (($pos + $session_max_rows < $unlim_num_rows) && $num_rows >= $session_max_rows
&& $session_max_rows != 'all') {
if (($_SESSION['userconf']['pos'] + $_SESSION['userconf']['max_rows'] < $unlim_num_rows) && $num_rows >= $_SESSION['userconf']['max_rows']
&& $_SESSION['userconf']['max_rows'] != 'all') {
// loic1: patch #474210 from Gosha Sakovich - part 2
if ($GLOBALS['cfg']['NavigationBarIconic']) {
$caption3 = ' &gt; ';
@@ -345,20 +320,16 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query)
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
<input type="hidden" name="sql_query" value="<?php echo $html_sql_query; ?>" />
<input type="hidden" name="pos" value="<?php echo $pos_next; ?>" />
<input type="hidden" name="session_max_rows" value="<?php echo $session_max_rows; ?>" />
<input type="hidden" name="disp_direction" value="<?php echo $disp_direction; ?>" />
<input type="hidden" name="repeat_cells" value="<?php echo $repeat_cells; ?>" />
<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 $caption3; ?>"<?php echo $title3; ?> />
</form>
</td>
<td>
<form action="sql.php" method="post"
onsubmit="return <?php echo (($pos + $session_max_rows < $unlim_num_rows && $num_rows >= $session_max_rows) ? 'true' : 'false'); ?>">
onsubmit="return <?php echo (($_SESSION['userconf']['pos'] + $_SESSION['userconf']['max_rows'] < $unlim_num_rows && $num_rows >= $_SESSION['userconf']['max_rows']) ? 'true' : 'false'); ?>">
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
<input type="hidden" name="sql_query" value="<?php echo $html_sql_query; ?>" />
<input type="hidden" name="pos" value="<?php echo @((ceil($unlim_num_rows / $session_max_rows)- 1) * $session_max_rows); ?>" />
<input type="hidden" name="pos" value="<?php echo @((ceil($unlim_num_rows / $_SESSION['userconf']['max_rows'])- 1) * $_SESSION['userconf']['max_rows']); ?>" />
<?php
if ($is_innodb && $unlim_num_rows > $GLOBALS['cfg']['MaxExactCount']) {
echo '<input type="hidden" name="find_real_end" value="1" />' . "\n";
@@ -366,11 +337,7 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query)
$onclick = ' onclick="return confirmAction(\'' . PMA_jsFormat($GLOBALS['strLongOperation'], false) . '\')"';
}
?>
<input type="hidden" name="session_max_rows" value="<?php echo $session_max_rows; ?>" />
<input type="hidden" name="disp_direction" value="<?php echo $disp_direction; ?>" />
<input type="hidden" name="repeat_cells" value="<?php echo $repeat_cells; ?>" />
<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 $caption4; ?>"<?php echo $title4; ?> <?php echo (empty($onclick) ? '' : $onclick); ?>/>
</form>
</td>
@@ -379,8 +346,8 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query)
//page redirection
$pageNow = @floor($pos / $session_max_rows) + 1;
$nbTotalPage = @ceil($unlim_num_rows / $session_max_rows);
$pageNow = @floor($_SESSION['userconf']['pos'] / $_SESSION['userconf']['max_rows']) + 1;
$nbTotalPage = @ceil($unlim_num_rows / $_SESSION['userconf']['max_rows']);
if ($nbTotalPage > 1){ //if1
?>
@@ -392,14 +359,10 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query)
<form action="none">
<?php echo PMA_pageselector(
'sql.php?sql_query=' . urlencode($sql_query) .
'&amp;session_max_rows=' . $session_max_rows .
'&amp;disp_direction=' . $disp_direction .
'&amp;repeat_cells=' . $repeat_cells .
'&amp;goto=' . $goto .
'&amp;dontlimitchars=' . $dontlimitchars .
'&amp;' . PMA_generate_common_url($db, $table) .
'&amp;goto=' . $goto .
'&amp;' . PMA_generate_common_url($db, $table) .
'&amp;',
$session_max_rows,
$_SESSION['userconf']['max_rows'],
$pageNow,
$nbTotalPage
);
@@ -423,10 +386,7 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query)
<input type="hidden" name="sql_query" value="<?php echo $html_sql_query; ?>" />
<input type="hidden" name="pos" value="0" />
<input type="hidden" name="session_max_rows" value="all" />
<input type="hidden" name="disp_direction" value="<?php echo $disp_direction; ?>" />
<input type="hidden" name="repeat_cells" value="<?php echo $repeat_cells; ?>" />
<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>
@@ -444,6 +404,10 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query)
/**
* Displays the headers of the results table
*
* @uses $_SESSION['userconf']['disp_direction']
* @uses $_SESSION['userconf']['repeat_cells']
* @uses $_SESSION['userconf']['max_rows']
* @uses $_SESSION['userconf']['dontlimitchars']
* @param array which elements to display
* @param array the list of fields properties
* @param integer the total number of fields returned by the SQL query
@@ -454,19 +418,11 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query)
* @global string $db the database name
* @global string $table the table name
* @global string $goto the URL to go back in case of errors
* @global boolean $dontlimitchars whether to limit the number of displayed
* characters of text type fields or not
* @global string $sql_query the sql query
* @global string $sql_query the SQL query
* @global integer $num_rows the total number of rows returned by the
* SQL query
* @global integer $pos the current position in results
* @global integer $session_max_rows the maximum number of rows per page
* @global array $vertical_display informations used with vertical display
* mode
* @global string $disp_direction the display mode
* (horizontal/vertical/horizontalflipped)
* @global integer $repeat_cellsthe number of row to display between two
* table headers
*
* @access private
*
@@ -474,9 +430,9 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query)
*/
function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $analyzed_sql = '')
{
global $db, $table, $goto, $dontlimitchars;
global $sql_query, $num_rows, $pos, $session_max_rows;
global $vertical_display, $disp_direction, $repeat_cells, $highlight_columns;
global $db, $table, $goto;
global $sql_query, $num_rows;
global $vertical_display, $highlight_columns;
if ($analyzed_sql == '') {
$analyzed_sql = array();
@@ -544,7 +500,8 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
// do we have any index?
if (isset($indexes_data)) {
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
if ($_SESSION['userconf']['disp_direction'] == 'horizontal'
|| $_SESSION['userconf']['disp_direction'] == 'horizontalflipped') {
$span = $fields_cnt;
if ($is_display['edit_lnk'] != 'nn') {
$span++;
@@ -556,16 +513,11 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
$span++;
}
} else {
$span = $num_rows + floor($num_rows/$repeat_cells) + 1;
$span = $num_rows + floor($num_rows/$_SESSION['userconf']['repeat_cells']) + 1;
}
echo '<form action="sql.php" method="post">' . "\n";
echo PMA_generate_common_hidden_inputs($db, $table, 5);
echo '<input type="hidden" name="pos" value="' . $pos . '" />' . "\n";
echo '<input type="hidden" name="session_max_rows" value="' . $session_max_rows . '" />' . "\n";
echo '<input type="hidden" name="disp_direction" value="' . $disp_direction . '" />' . "\n";
echo '<input type="hidden" name="repeat_cells" value="' . $repeat_cells . '" />' . "\n";
echo '<input type="hidden" name="dontlimitchars" value="' . $dontlimitchars . '" />' . "\n";
echo $GLOBALS['strSortByKey'] . ': <select name="sql_query" onchange="this.form.submit();">' . "\n";
$used_index = false;
$local_order = (isset($sort_expression) ? $sort_expression : '');
@@ -605,21 +557,18 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
if ($is_display['del_lnk'] == 'dr' || $is_display['del_lnk'] == 'kp') {
echo '<form method="post" action="tbl_row_action.php" name="rowsDeleteForm" id="rowsDeleteForm">' . "\n";
echo PMA_generate_common_hidden_inputs($db, $table, 1);
echo '<input type="hidden" name="disp_direction" value="' . $disp_direction . '" />' . "\n";
echo '<input type="hidden" name="repeat_cells" value="' . $repeat_cells . '" />' . "\n";
echo '<input type="hidden" name="dontlimitchars" value="' . $dontlimitchars . '" />' . "\n";
echo '<input type="hidden" name="pos" value="' . $pos . '" />' . "\n";
echo '<input type="hidden" name="session_max_rows" value="' . $session_max_rows . '" />' . "\n";
echo '<input type="hidden" name="goto" value="sql.php" />' . "\n";
}
echo '<table id="table_results" class="data">' . "\n";
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
if ($_SESSION['userconf']['disp_direction'] == 'horizontal'
|| $_SESSION['userconf']['disp_direction'] == 'horizontalflipped') {
echo '<thead><tr>' . "\n";
}
// 1. Displays the full/partial text button (part 1)...
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
if ($_SESSION['userconf']['disp_direction'] == 'horizontal'
|| $_SESSION['userconf']['disp_direction'] == 'horizontalflipped') {
$colspan = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn')
? ' colspan="3"'
: '';
@@ -631,20 +580,22 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
$text_url = 'sql.php?'
. PMA_generate_common_url($db, $table)
. '&amp;sql_query=' . urlencode($sql_query)
. '&amp;session_max_rows=' . $session_max_rows
. '&amp;pos=' . $pos
. '&amp;disp_direction=' . $disp_direction
. '&amp;repeat_cells=' . $repeat_cells
. '&amp;goto=' . $goto
. '&amp;dontlimitchars=' . (($dontlimitchars) ? 0 : 1);
$text_message = '<img class="fulltext" src="' . $GLOBALS['pmaThemeImage'] . 's_'.($dontlimitchars ? 'partialtext' : 'fulltext') . '.png" width="50" height="20" alt="' . ($dontlimitchars ? $GLOBALS['strPartialText'] : $GLOBALS['strFullText']) . '" title="' . ($dontlimitchars ? $GLOBALS['strPartialText'] : $GLOBALS['strFullText']) . '" />';
. '&amp;goto=' . $goto;
$text_message = '<img class="fulltext" src="' . $GLOBALS['pmaThemeImage']
. 's_'
. ($_SESSION['userconf']['dontlimitchars'] ? 'partialtext' : 'fulltext')
. '.png" width="50" height="20" alt="'
. ($_SESSION['userconf']['dontlimitchars'] ? $GLOBALS['strPartialText'] : $GLOBALS['strFullText'])
. '" title="'
. ($_SESSION['userconf']['dontlimitchars'] ? $GLOBALS['strPartialText'] : $GLOBALS['strFullText']) . '" />';
$text_link = PMA_linkOrButton($text_url, $text_message, array(), false);
// ... before the result table
if (($is_display['edit_lnk'] == 'nn' && $is_display['del_lnk'] == 'nn')
&& $is_display['text_btn'] == '1') {
$vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 3 : 0;
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
if ($_SESSION['userconf']['disp_direction'] == 'horizontal'
|| $_SESSION['userconf']['disp_direction'] == 'horizontalflipped') {
?>
<th colspan="<?php echo $fields_cnt; ?>"><?php echo $text_link; ?></th>
</tr>
@@ -654,7 +605,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
else {
?>
<tr>
<th colspan="<?php echo $num_rows + floor($num_rows/$repeat_cells) + 1; ?>">
<th colspan="<?php echo $num_rows + floor($num_rows/$_SESSION['userconf']['repeat_cells']) + 1; ?>">
<?php echo $text_link; ?></th>
</tr>
<?php
@@ -665,7 +616,8 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
// and required
elseif ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && $is_display['text_btn'] == '1') {
$vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 3 : 0;
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
if ($_SESSION['userconf']['disp_direction'] == 'horizontal'
|| $_SESSION['userconf']['disp_direction'] == 'horizontalflipped') {
?>
<th <?php echo $colspan; ?>><?php echo $text_link; ?></th>
<?php
@@ -681,7 +633,8 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
elseif ($GLOBALS['cfg']['ModifyDeleteAtLeft']
&& ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn')) {
$vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 3 : 0;
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
if ($_SESSION['userconf']['disp_direction'] == 'horizontal'
|| $_SESSION['userconf']['disp_direction'] == 'horizontalflipped') {
?>
<td<?php echo $colspan; ?>></td>
<?php
@@ -697,7 +650,10 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
// 2.0.1 Prepare Display column comments if enabled ($GLOBALS['cfg']['ShowBrowseComments']).
// Do not show comments, if using horizontalflipped mode, because of space usage
if ($GLOBALS['cfg']['ShowBrowseComments'] && ($GLOBALS['cfgRelation']['commwork'] || PMA_MYSQL_INT_VERSION >= 40100) && $disp_direction != 'horizontalflipped') {
if ($GLOBALS['cfg']['ShowBrowseComments']
&& ($GLOBALS['cfgRelation']['commwork']
|| PMA_MYSQL_INT_VERSION >= 40100)
&& $_SESSION['userconf']['disp_direction'] != 'horizontalflipped') {
$comments_map = array();
if (isset($analyzed_sql[0]) && is_array($analyzed_sql[0])) {
foreach ($analyzed_sql[0]['table_ref'] as $tbl) {
@@ -824,11 +780,6 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
$sorted_sql_query = $unsorted_sql_query . $sort_order;
}
$url_query = PMA_generate_common_url($db, $table)
. '&amp;pos=' . $pos
. '&amp;session_max_rows=' . $session_max_rows
. '&amp;disp_direction=' . $disp_direction
. '&amp;repeat_cells=' . $repeat_cells
. '&amp;dontlimitchars=' . $dontlimitchars
. '&amp;sql_query=' . urlencode($sorted_sql_query);
$order_url = 'sql.php?' . $url_query;
@@ -845,20 +796,21 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
$order_link_params['onmouseout'] = 'if(document.getElementById(\'soimg' . $i . '\')){ document.getElementById(\'soimg' . $i . '\').src=\'' . $GLOBALS['pmaThemeImage'] . 's_desc.png\'; }';
}
}
if ($disp_direction == 'horizontalflipped'
&& $GLOBALS['cfg']['HeaderFlipType'] == 'css') {
if ($_SESSION['userconf']['disp_direction'] == 'horizontalflipped'
&& $GLOBALS['cfg']['HeaderFlipType'] == 'css') {
$order_link_params['style'] = 'direction: ltr; writing-mode: tb-rl;';
}
$order_link_params['title'] = $GLOBALS['strSort'];
$order_link_content = ($disp_direction == 'horizontalflipped' && $GLOBALS['cfg']['HeaderFlipType'] == 'fake' ? PMA_flipstring(htmlspecialchars($fields_meta[$i]->name), "<br />\n") : htmlspecialchars($fields_meta[$i]->name));
$order_link_content = ($_SESSION['userconf']['disp_direction'] == 'horizontalflipped' && $GLOBALS['cfg']['HeaderFlipType'] == 'fake' ? PMA_flipstring(htmlspecialchars($fields_meta[$i]->name), "<br />\n") : htmlspecialchars($fields_meta[$i]->name));
$order_link = PMA_linkOrButton($order_url, $order_link_content . $order_img, $order_link_params, false, true);
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
if ($_SESSION['userconf']['disp_direction'] == 'horizontal'
|| $_SESSION['userconf']['disp_direction'] == 'horizontalflipped') {
echo '<th';
if ($condition_field) {
echo ' class="condition"';
}
if ($disp_direction == 'horizontalflipped') {
if ($_SESSION['userconf']['disp_direction'] == 'horizontalflipped') {
echo ' valign="bottom"';
}
echo '>' . $order_link . $comments . '</th>';
@@ -870,20 +822,21 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
// 2.2 Results can't be sorted
else {
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
if ($_SESSION['userconf']['disp_direction'] == 'horizontal'
|| $_SESSION['userconf']['disp_direction'] == 'horizontalflipped') {
echo '<th';
if ($condition_field) {
echo ' class="condition"';
}
if ($disp_direction == 'horizontalflipped') {
if ($_SESSION['userconf']['disp_direction'] == 'horizontalflipped') {
echo ' valign="bottom"';
}
if ($disp_direction == 'horizontalflipped'
if ($_SESSION['userconf']['disp_direction'] == 'horizontalflipped'
&& $GLOBALS['cfg']['HeaderFlipType'] == 'css') {
echo ' style="direction: ltr; writing-mode: tb-rl;"';
}
echo '>';
if ($disp_direction == 'horizontalflipped'
if ($_SESSION['userconf']['disp_direction'] == 'horizontalflipped'
&& $GLOBALS['cfg']['HeaderFlipType'] == 'fake') {
echo PMA_flipstring(htmlspecialchars($fields_meta[$i]->name), '<br />');
} else {
@@ -904,7 +857,8 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
&& ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn')
&& $is_display['text_btn'] == '1') {
$vertical_display['emptyafter'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 3 : 1;
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
if ($_SESSION['userconf']['disp_direction'] == 'horizontal'
|| $_SESSION['userconf']['disp_direction'] == 'horizontalflipped') {
echo "\n";
?>
<th <?php echo $colspan; ?>>
@@ -925,7 +879,8 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
&& ($is_display['edit_lnk'] == 'nn' && $is_display['del_lnk'] == 'nn')
&& (!$GLOBALS['is_header_sent'])) {
$vertical_display['emptyafter'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ? 3 : 1;
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
if ($_SESSION['userconf']['disp_direction'] == 'horizontal'
|| $_SESSION['userconf']['disp_direction'] == 'horizontalflipped') {
echo "\n";
?>
<td<?php echo $colspan; ?>></td>
@@ -936,7 +891,8 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
} // end vertical mode
}
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
if ($_SESSION['userconf']['disp_direction'] == 'horizontal'
|| $_SESSION['userconf']['disp_direction'] == 'horizontalflipped') {
?>
</tr>
</thead>
@@ -951,6 +907,10 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
/**
* Displays the body of the results table
*
* @uses $_SESSION['userconf']['disp_direction']
* @uses $_SESSION['userconf']['repeat_cells']
* @uses $_SESSION['userconf']['max_rows']
* @uses $_SESSION['userconf']['dontlimitchars']
* @param integer the link id associated to the query which results have
* to be displayed
* @param array which elements to display
@@ -962,31 +922,23 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
* @global string $db the database name
* @global string $table the table name
* @global string $goto the URL to go back in case of errors
* @global boolean $dontlimitchars whether to limit the number of displayed
* characters of text type fields or not
* @global string $sql_query the SQL query
* @global integer $pos the current position in results
* @global integer $session_max_rows the maximum number of rows per page
* @global array $fields_meta the list of fields properties
* @global integer $fields_cnt the total number of fields returned by
* the SQL query
* @global array $vertical_display informations used with vertical display
* mode
* @global string $disp_direction the display mode
* (horizontal/vertical/horizontalflipped)
* @global integer $repeat_cells the number of row to display between two
* table headers
* @global array $highlight_columns collumn names to highlight
* @gloabl array $row current row data
* @global array $highlight_columns column names to highlight
* @global array $row current row data
*
* @access private
*
* @see PMA_displayTable()
*/
function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
global $db, $table, $goto, $dontlimitchars;
global $sql_query, $pos, $session_max_rows, $fields_meta, $fields_cnt;
global $vertical_display, $disp_direction, $repeat_cells, $highlight_columns;
global $db, $table, $goto;
global $sql_query, $fields_meta, $fields_cnt;
global $vertical_display, $highlight_columns;
global $row; // mostly because of browser transformations, to make the row-data accessible in a plugin
$url_sql_query = $sql_query;
@@ -1041,9 +993,9 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
$odd_row = true;
while ($row = PMA_DBI_fetch_row($dt_result)) {
// lem9: "vertical display" mode stuff
if ($row_no != 0 && $repeat_cells != 0 && !($row_no % $repeat_cells)
&& ($disp_direction == 'horizontal'
|| $disp_direction == 'horizontalflipped'))
if ($row_no != 0 && $_SESSION['userconf']['repeat_cells'] != 0 && !($row_no % $_SESSION['userconf']['repeat_cells'])
&& ($_SESSION['userconf']['disp_direction'] == 'horizontal'
|| $_SESSION['userconf']['disp_direction'] == 'horizontalflipped'))
{
echo '<tr>' . "\n";
if ($vertical_display['emptypre'] > 0) {
@@ -1064,7 +1016,8 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
$class = $odd_row ? 'odd' : 'even';
$odd_row = ! $odd_row;
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
if ($_SESSION['userconf']['disp_direction'] == 'horizontal'
|| $_SESSION['userconf']['disp_direction'] == 'horizontalflipped') {
// loic1: pointer code part
echo ' <tr class="' . $class . '">' . "\n";
$class = '';
@@ -1082,12 +1035,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
$unique_condition = urlencode(PMA_getUniqueCondition($dt_result, $fields_cnt, $fields_meta, $row));
// 1.2 Defines the URLs for the modify/delete link(s)
$url_query = PMA_generate_common_url($db, $table)
. '&amp;pos=' . $pos
. '&amp;session_max_rows=' . $session_max_rows
. '&amp;disp_direction=' . $disp_direction
. '&amp;repeat_cells=' . $repeat_cells
. '&amp;dontlimitchars=' . $dontlimitchars;
$url_query = PMA_generate_common_url($db, $table);
if ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn') {
// We need to copy the value or else the == 'both' check will always return true
@@ -1187,7 +1135,8 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
// 1.3 Displays the links at left if required
if ($GLOBALS['cfg']['ModifyDeleteAtLeft']
&& ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped')) {
&& ($_SESSION['userconf']['disp_direction'] == 'horizontal'
|| $_SESSION['userconf']['disp_direction'] == 'horizontalflipped')) {
$doWriteModifyAt = 'left';
require './libraries/display_tbl_links.lib.php';
} // end if (1.3)
@@ -1209,7 +1158,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
}
$mouse_events = '';
if ($disp_direction == 'vertical' && (!isset($GLOBALS['printview']) || ($GLOBALS['printview'] != '1'))) {
if ($_SESSION['userconf']['disp_direction'] == 'vertical' && (!isset($GLOBALS['printview']) || ($GLOBALS['printview'] != '1'))) {
if ($GLOBALS['cfg']['BrowsePointerEnable'] == true) {
$mouse_events .= ' onmouseover="setVerticalPointer(this, ' . $row_no . ', \'over\', \'odd\', \'even\', \'hover\', \'marked\');"'
. ' onmouseout="setVerticalPointer(this, ' . $row_no . ', \'out\', \'odd\', \'even\', \'hover\', \'marked\');" ';
@@ -1310,7 +1259,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
$vertical_display['data'][$row_no][$i] .= '<a href="sql.php?'
. PMA_generate_common_url($map[$meta->name][3], $map[$meta->name][0])
. '&amp;pos=0&amp;session_max_rows=' . $session_max_rows . '&amp;dontlimitchars=' . $dontlimitchars
. '&amp;pos=0'
. '&amp;sql_query=' . urlencode('SELECT * FROM ' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' = ' . $row[$i]) . '"' . $title . '>'
. ($transform_function != $default_function ? $transform_function($row[$i], $transform_options, $meta) : $transform_function($row[$i], array(), $meta)) . '</a>';
}
@@ -1357,7 +1306,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
$vertical_display['data'][$row_no][$i] = ' <td' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . '"><i>NULL</i></td>' . "\n";
} elseif ($row[$i] != '') {
// garvin: if a transform function for blob is set, none of these replacements will be made
if (PMA_strlen($row[$i]) > $GLOBALS['cfg']['LimitChars'] && ($dontlimitchars != 1)) {
if (PMA_strlen($row[$i]) > $GLOBALS['cfg']['LimitChars'] && ! $_SESSION['userconf']['dontlimitchars']) {
$row[$i] = PMA_substr($row[$i], 0, $GLOBALS['cfg']['LimitChars']) . '...';
}
// loic1: displays all space characters, 4 space
@@ -1378,7 +1327,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
// nijel: Cut all fields to $GLOBALS['cfg']['LimitChars']
// lem9: (unless it's a link-type transformation)
if (PMA_strlen($row[$i]) > $GLOBALS['cfg']['LimitChars'] && ($dontlimitchars != 1) && !strpos($transform_function, 'link') === true) {
if (PMA_strlen($row[$i]) > $GLOBALS['cfg']['LimitChars'] && ! $_SESSION['userconf']['dontlimitchars'] && !strpos($transform_function, 'link') === true) {
$row[$i] = PMA_substr($row[$i], 0, $GLOBALS['cfg']['LimitChars']) . '...';
}
@@ -1446,7 +1395,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
$vertical_display['data'][$row_no][$i] .= '<a href="sql.php?'
. PMA_generate_common_url($map[$meta->name][3], $map[$meta->name][0])
. '&amp;pos=0&amp;session_max_rows=' . $session_max_rows . '&amp;dontlimitchars=' . $dontlimitchars
. '&amp;pos=0'
. '&amp;sql_query=' . urlencode('SELECT * FROM ' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' = \'' . PMA_sqlAddslashes($relation_id) . '\'') . '"' . $title . '>'
. $row[$i] . '</a>';
} else {
@@ -1459,7 +1408,8 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
}
// lem9: output stored cell
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
if ($_SESSION['userconf']['disp_direction'] == 'horizontal'
|| $_SESSION['userconf']['disp_direction'] == 'horizontalflipped') {
echo $vertical_display['data'][$row_no][$i];
}
@@ -1472,12 +1422,14 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
// 3. Displays the modify/delete links on the right if required
if ($GLOBALS['cfg']['ModifyDeleteAtRight']
&& ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped')) {
&& ($_SESSION['userconf']['disp_direction'] == 'horizontal'
|| $_SESSION['userconf']['disp_direction'] == 'horizontalflipped')) {
$doWriteModifyAt = 'right';
require './libraries/display_tbl_links.lib.php';
} // end if (3)
if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') {
if ($_SESSION['userconf']['disp_direction'] == 'horizontal'
|| $_SESSION['userconf']['disp_direction'] == 'horizontalflipped') {
?>
</tr>
<?php
@@ -1528,7 +1480,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
unset($vertical_display['delete'][$row_no]);
}
echo (($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') ? "\n" : '');
echo (($_SESSION['userconf']['disp_direction'] == 'horizontal' || $_SESSION['userconf']['disp_direction'] == 'horizontalflipped') ? "\n" : '');
$row_no++;
} // end while
@@ -1546,9 +1498,8 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
*
* @return boolean always true
*
* @uses $_SESSION['userconf']['repeat_cells']
* @global array $vertical_display the information to display
* @global integer $repeat_cells the number of row to display between two
* table headers
*
* @access private
*
@@ -1556,7 +1507,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
*/
function PMA_displayVerticalTable()
{
global $vertical_display, $repeat_cells;
global $vertical_display;
// Displays "multi row delete" link at top if required
if ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && is_array($vertical_display['row_delete']) && (count($vertical_display['row_delete']) > 0 || !empty($vertical_display['textbtn']))) {
@@ -1564,7 +1515,7 @@ function PMA_displayVerticalTable()
echo $vertical_display['textbtn'];
$foo_counter = 0;
foreach ($vertical_display['row_delete'] as $val) {
if (($foo_counter != 0) && ($repeat_cells != 0) && !($foo_counter % $repeat_cells)) {
if (($foo_counter != 0) && ($_SESSION['userconf']['repeat_cells'] != 0) && !($foo_counter % $_SESSION['userconf']['repeat_cells'])) {
echo '<th>&nbsp;</th>' . "\n";
}
@@ -1582,7 +1533,7 @@ function PMA_displayVerticalTable()
}
$foo_counter = 0;
foreach ($vertical_display['edit'] as $val) {
if (($foo_counter != 0) && ($repeat_cells != 0) && !($foo_counter % $repeat_cells)) {
if (($foo_counter != 0) && ($_SESSION['userconf']['repeat_cells'] != 0) && !($foo_counter % $_SESSION['userconf']['repeat_cells'])) {
echo ' <th>&nbsp;</th>' . "\n";
}
@@ -1600,7 +1551,7 @@ function PMA_displayVerticalTable()
}
$foo_counter = 0;
foreach ($vertical_display['delete'] as $val) {
if (($foo_counter != 0) && ($repeat_cells != 0) && !($foo_counter % $repeat_cells)) {
if (($foo_counter != 0) && ($_SESSION['userconf']['repeat_cells'] != 0) && !($foo_counter % $_SESSION['userconf']['repeat_cells'])) {
echo '<th>&nbsp;</th>' . "\n";
}
@@ -1618,7 +1569,7 @@ function PMA_displayVerticalTable()
$foo_counter = 0;
foreach ($vertical_display['rowdata'][$key] as $subval) {
if (($foo_counter != 0) && ($repeat_cells != 0) and !($foo_counter % $repeat_cells)) {
if (($foo_counter != 0) && ($_SESSION['userconf']['repeat_cells'] != 0) and !($foo_counter % $_SESSION['userconf']['repeat_cells'])) {
echo $val;
}
@@ -1635,7 +1586,7 @@ function PMA_displayVerticalTable()
echo $vertical_display['textbtn'];
$foo_counter = 0;
foreach ($vertical_display['row_delete'] as $val) {
if (($foo_counter != 0) && ($repeat_cells != 0) && !($foo_counter % $repeat_cells)) {
if (($foo_counter != 0) && ($_SESSION['userconf']['repeat_cells'] != 0) && !($foo_counter % $_SESSION['userconf']['repeat_cells'])) {
echo '<th>&nbsp;</th>' . "\n";
}
@@ -1653,7 +1604,7 @@ function PMA_displayVerticalTable()
}
$foo_counter = 0;
foreach ($vertical_display['edit'] as $val) {
if (($foo_counter != 0) && ($repeat_cells != 0) && !($foo_counter % $repeat_cells)) {
if (($foo_counter != 0) && ($_SESSION['userconf']['repeat_cells'] != 0) && !($foo_counter % $_SESSION['userconf']['repeat_cells'])) {
echo '<th>&nbsp;</th>' . "\n";
}
@@ -1671,7 +1622,7 @@ function PMA_displayVerticalTable()
}
$foo_counter = 0;
foreach ($vertical_display['delete'] as $val) {
if (($foo_counter != 0) && ($repeat_cells != 0) && !($foo_counter % $repeat_cells)) {
if (($foo_counter != 0) && ($_SESSION['userconf']['repeat_cells'] != 0) && !($foo_counter % $_SESSION['userconf']['repeat_cells'])) {
echo '<th>&nbsp;</th>' . "\n";
}
@@ -1684,6 +1635,96 @@ function PMA_displayVerticalTable()
return true;
} // end of the 'PMA_displayVerticalTable' function
/**
*
* @uses $_SESSION['userconf']['disp_direction']
* @uses $_REQUEST['disp_direction']
* @uses $GLOBALS['cfg']['DefaultDisplay']
* @uses $_SESSION['userconf']['repeat_cells']
* @uses $_REQUEST['repeat_cells']
* @uses $GLOBALS['cfg']['RepeatCells']
* @uses $_SESSION['userconf']['max_rows']
* @uses $_REQUEST['session_max_rows']
* @uses $GLOBALS['cfg']['MaxRows']
* @uses $_SESSION['userconf']['pos']
* @uses $_REQUEST['pos']
* @uses $_SESSION['userconf']['dontlimitchars']
* @uses $_REQUEST['dontlimitchars']
* @uses PMA_isValid()
* @uses $GLOBALS['sql_query']
* @todo make maximum remembered queries configurable
* @todo move/split into SQL class!?
* @todo currently this is called twice unnecessary
* @todo ignore LIMIT and ORDER in query!?
*/
function PMA_displayTable_checkConfigParams()
{
$sql_key = md5($GLOBALS['sql_query']);
$_SESSION['userconf']['query'][$sql_key]['sql'] = $GLOBALS['sql_query'];
if (PMA_isValid($_REQUEST['disp_direction'], array('horizontal', 'vertical', 'horizontalflipped'))) {
$_SESSION['userconf']['query'][$sql_key]['disp_direction'] = $_REQUEST['disp_direction'];
unset($_REQUEST['disp_direction']);
} elseif (empty($_SESSION['userconf']['query'][$sql_key]['disp_direction'])) {
$_SESSION['userconf']['query'][$sql_key]['disp_direction'] = $GLOBALS['cfg']['DefaultDisplay'];
}
if (PMA_isValid($_REQUEST['repeat_cells'], 'numeric')) {
$_SESSION['userconf']['query'][$sql_key]['repeat_cells'] = $_REQUEST['repeat_cells'];
unset($_REQUEST['repeat_cells']);
} elseif (empty($_SESSION['userconf']['query'][$sql_key]['repeat_cells'])) {
$_SESSION['userconf']['query'][$sql_key]['repeat_cells'] = $GLOBALS['cfg']['RepeatCells'];
}
if (PMA_isValid($_REQUEST['session_max_rows'], 'numeric')) {
$_SESSION['userconf']['query'][$sql_key]['max_rows'] = $_REQUEST['session_max_rows'];
unset($_REQUEST['session_max_rows']);
} elseif (empty($_SESSION['userconf']['query'][$sql_key]['max_rows'])) {
$_SESSION['userconf']['query'][$sql_key]['max_rows'] = $GLOBALS['cfg']['MaxRows'];
}
if (PMA_isValid($_REQUEST['pos'], 'numeric')) {
$_SESSION['userconf']['query'][$sql_key]['pos'] = $_REQUEST['pos'];
unset($_REQUEST['pos']);
} elseif (empty($_SESSION['userconf']['query'][$sql_key]['pos'])) {
$_SESSION['userconf']['query'][$sql_key]['pos'] = 0;
}
if (PMA_isValid($_REQUEST['dontlimitchars'], array('0', '1'))) {
$_SESSION['userconf']['query'][$sql_key]['dontlimitchars'] = (int) $_REQUEST['dontlimitchars'];
unset($_REQUEST['dontlimitchars']);
} elseif (empty($_SESSION['userconf']['query'][$sql_key]['dontlimitchars'])) {
$_SESSION['userconf']['query'][$sql_key]['dontlimitchars'] = 0;
}
// move current query to the last position, to be removed last
// so only least executed query will be removed if maximum remembered queries
// limit is reached
$tmp = $_SESSION['userconf']['query'][$sql_key];
unset($_SESSION['userconf']['query'][$sql_key]);
$_SESSION['userconf']['query'][$sql_key] = $tmp;
// do not exceed a maximum number of queries to remember
if (count($_SESSION['userconf']['query']) > 10) {
array_shift($_SESSION['userconf']['query']);
echo 'deleting one element ...';
}
// populate query configuration
$_SESSION['userconf']['dontlimitchars'] = $_SESSION['userconf']['query'][$sql_key]['dontlimitchars'];
$_SESSION['userconf']['pos'] = $_SESSION['userconf']['query'][$sql_key]['pos'];
$_SESSION['userconf']['max_rows'] = $_SESSION['userconf']['query'][$sql_key]['max_rows'];
$_SESSION['userconf']['repeat_cells'] = $_SESSION['userconf']['query'][$sql_key]['repeat_cells'];
$_SESSION['userconf']['disp_direction'] = $_SESSION['userconf']['query'][$sql_key]['disp_direction'];
/*
* debugging
echo '<pre>';
var_dump($_SESSION['userconf']);
echo '</pre>';
*/
}
/**
* Displays a table of results returned by a SQL query.
@@ -1694,29 +1735,22 @@ function PMA_displayVerticalTable()
* @param array the display mode
* @param array the analyzed query
*
* @uses $_SESSION['userconf']['pos']
* @global string $db the database name
* @global string $table the table name
* @global string $goto the URL to go back in case of errors
* @global boolean $dontlimitchars whether to limit the number of displayed
* characters of text type fields or not
* @global string $sql_query the current sql query
* @global string $sql_query the current SQL query
* @global integer $num_rows the total number of rows returned by the
* SQL query
* @global integer $unlim_num_rows the total number of rows returned by the
* SQL query without any programmatically
* appended "LIMIT" clause
* @global integer $pos the current postion of the first record
* to be displayed
* @global array $fields_meta the list of fields properties
* @global integer $fields_cnt the total number of fields returned by
* the SQL query
* @global array $vertical_display informations used with vertical display
* mode
* @global string $disp_direction the display mode
* (horizontal/vertical/horizontalflipped)
* @global integer $repeat_cells the number of row to display between two
* table headers
* @global array $highlight_columns collumn names to highlight
* @global array $highlight_columns column names to highlight
* @global array $cfgRelation the relation settings
*
* @access private
@@ -1727,12 +1761,14 @@ function PMA_displayVerticalTable()
*/
function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
{
global $db, $table, $goto, $dontlimitchars;
global $sql_query, $num_rows, $unlim_num_rows, $pos, $fields_meta, $fields_cnt;
global $vertical_display, $disp_direction, $repeat_cells, $highlight_columns;
global $db, $table, $goto;
global $sql_query, $num_rows, $unlim_num_rows, $fields_meta, $fields_cnt;
global $vertical_display, $highlight_columns;
global $cfgRelation;
global $showtable;
PMA_displayTable_checkConfigParams();
/**
* @todo move this to a central place
* @todo for other future table types
@@ -1766,15 +1802,12 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
// 1.2 Defines offsets for the next and previous pages
if ($is_display['nav_bar'] == '1') {
if (!isset($pos)) {
$pos = 0;
}
if ($GLOBALS['session_max_rows'] == 'all') {
if ($_SESSION['userconf']['max_rows'] == 'all') {
$pos_next = 0;
$pos_prev = 0;
} else {
$pos_next = $pos + $GLOBALS['cfg']['MaxRows'];
$pos_prev = $pos - $GLOBALS['cfg']['MaxRows'];
$pos_next = $_SESSION['userconf']['pos'] + $_SESSION['userconf']['max_rows'];
$pos_prev = $_SESSION['userconf']['pos'] - $_SESSION['userconf']['max_rows'];
if ($pos_prev < 0) {
$pos_prev = 0;
}
@@ -1793,10 +1826,10 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
} else {
$selectstring = '';
}
$last_shown_rec = ($GLOBALS['session_max_rows'] == 'all' || $pos_next > $total)
$last_shown_rec = ($_SESSION['userconf']['max_rows'] == 'all' || $pos_next > $total)
? $total - 1
: $pos_next - 1;
PMA_showMessage($GLOBALS['strShowingRecords'] . " $pos - $last_shown_rec (" . $pre_count . PMA_formatNumber($total, 0) . $after_count . ' ' . $GLOBALS['strTotal'] . $selectstring . ', ' . sprintf($GLOBALS['strQueryTime'], $GLOBALS['querytime']) . ')');
PMA_showMessage($GLOBALS['strShowingRecords'] . ' ' . $_SESSION['userconf']['pos'] . ' - ' . $last_shown_rec . ' (' . $pre_count . PMA_formatNumber($total, 0) . $after_count . ' ' . $GLOBALS['strTotal'] . $selectstring . ', ' . sprintf($GLOBALS['strQueryTime'], $GLOBALS['querytime']) . ')');
if (PMA_Table::isView($db, $table) && $total == $GLOBALS['cfg']['MaxExactCount']) {
echo '<div class="notice">' . "\n";
@@ -1876,7 +1909,7 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
PMA_displayTableBody($dt_result, $is_display, $map, $analyzed_sql);
echo '</tbody>' . "\n";
// vertical output case
if ($disp_direction == 'vertical') {
if ($_SESSION['userconf']['disp_direction'] == 'vertical') {
PMA_displayVerticalTable();
} // end if
unset($vertical_display);
@@ -1893,16 +1926,10 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
$uncheckall_url = 'sql.php?'
. PMA_generate_common_url($db, $table)
. '&amp;sql_query=' . urlencode($sql_query)
. '&amp;pos=' . $pos
. '&amp;session_max_rows=' . $GLOBALS['session_max_rows']
. '&amp;pos=' . $pos
. '&amp;disp_direction=' . $disp_direction
. '&amp;repeat_cells=' . $repeat_cells
. '&amp;goto=' . $goto
. '&amp;dontlimitchars=' . $dontlimitchars;
. '&amp;goto=' . $goto;
$checkall_url = $uncheckall_url . '&amp;checkall=1';
if ($disp_direction == 'vertical') {
if ($_SESSION['userconf']['disp_direction'] == 'vertical') {
$checkall_params['onclick'] = 'if (setCheckboxes(\'rowsDeleteForm\', true)) return false;';
$uncheckall_params['onclick'] = 'if (setCheckboxes(\'rowsDeleteForm\', false)) return false;';
} else {
@@ -1911,7 +1938,7 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
}
$checkall_link = PMA_linkOrButton($checkall_url, $GLOBALS['strCheckAll'], $checkall_params, false);
$uncheckall_link = PMA_linkOrButton($uncheckall_url, $GLOBALS['strUncheckAll'], $uncheckall_params, false);
if ($disp_direction != 'vertical') {
if ($_SESSION['userconf']['disp_direction'] != 'vertical') {
echo '<img class="selectallarrow" width="38" height="22"'
.' src="' . $GLOBALS['pmaThemeImage'] . 'arrow_' . $GLOBALS['text_dir'] . '.png' . '"'
.' alt="' . $GLOBALS['strWithChecked'] . '" />';
@@ -1947,7 +1974,6 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
}
echo '<input type="hidden" name="sql_query"'
.' value="' . htmlspecialchars($sql_query) . '" />' . "\n";
echo '<input type="hidden" name="pos" value="' . $pos . '" />' . "\n";
echo '<input type="hidden" name="url_query"'
.' value="' . $GLOBALS['url_query'] . '" />' . "\n";
echo '</form>' . "\n";
@@ -1978,20 +2004,14 @@ function default_function($buffer) {
* @param array the display mode
* @param array the analyzed query
*
* @uses $_SESSION['userconf']['pos']
* @uses $_SESSION['userconf']['dontlimitchars']
* @global string $db the database name
* @global string $table the table name
* @global boolean $dontlimitchars whether to limit the number of displayed
* characters of text type fields or not
* @global integer $pos the current postion of the first record
* to be displayed
* @global string $sql_query the current SQL query
* @global integer $unlim_num_rows the total number of rows returned by the
* SQL query without any programmatically
* appended "LIMIT" clause
* @global string $disp_direction the display mode
* (horizontal/vertical/horizontalflipped)
* @global integer $repeat_cells the number of row to display between two
* table headers
*
* @access private
*
@@ -2000,7 +2020,7 @@ function default_function($buffer) {
* PMA_displayTableBody(), PMA_displayResultsOperations()
*/
function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql) {
global $db, $table, $dontlimitchars, $pos, $sql_query, $unlim_num_rows, $disp_direction, $repeat_cells;
global $db, $table, $sql_query, $unlim_num_rows;
$header_shown = FALSE;
$header = '<fieldset><legend>' . $GLOBALS['strQueryResultsOperations'] . '</legend>';
@@ -2016,19 +2036,15 @@ function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql) {
$url_query = '?'
. PMA_generate_common_url($db, $table)
. '&amp;pos=' . $pos
. '&amp;session_max_rows=' . $GLOBALS['session_max_rows']
. '&amp;disp_direction=' . $disp_direction
. '&amp;repeat_cells=' . $repeat_cells
. '&amp;printview=1'
. '&amp;sql_query=' . urlencode($sql_query);
echo ' <!-- Print view -->' . "\n";
echo PMA_linkOrButton(
'sql.php' . $url_query . ((isset($dontlimitchars) && $dontlimitchars == '1') ? '&amp;dontlimitchars=1' : ''),
'sql.php' . $url_query,
($GLOBALS['cfg']['PropertiesIconic'] ? '<img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_print.png" height="16" width="16" alt="' . $GLOBALS['strPrintView'] . '"/>' : '') . $GLOBALS['strPrintView'],
'', true, true, 'print_view') . "\n";
if (!$dontlimitchars) {
if (! $_SESSION['userconf']['dontlimitchars']) {
echo ' &nbsp;&nbsp;' . "\n";
echo PMA_linkOrButton(
'sql.php' . $url_query . '&amp;dontlimitchars=1',

View File

@@ -241,7 +241,7 @@ if (!empty($submit_mult) && !empty($what)) {
?>
<input type="hidden" name="reload" value="<?php echo isset($reload) ? PMA_sanitize($reload) : 0; ?>" />
<?php
foreach ($selected AS $idx => $sval) {
foreach ($selected as $idx => $sval) {
echo '<input type="hidden" name="selected[]" value="' . htmlspecialchars($sval) . '" />' . "\n";
}
if ($what == 'drop_tbl' && !empty($views)) {
@@ -253,11 +253,6 @@ if (!empty($submit_mult) && !empty($what)) {
echo '<input type="hidden" name="original_sql_query" value="' . htmlspecialchars($original_sql_query) . '" />' . "\n";
echo '<input type="hidden" name="original_pos" value="' . $original_pos . '" />' . "\n";
echo '<input type="hidden" name="original_url_query" value="' . htmlspecialchars($original_url_query) . '" />' . "\n";
echo '<input type="hidden" name="disp_direction" value="' . $disp_direction . '" />' . "\n";
echo '<input type="hidden" name="repeat_cells" value="' . $repeat_cells . '" />' . "\n";
echo '<input type="hidden" name="dontlimitchars" value="' . $dontlimitchars . '" />' . "\n";
echo '<input type="hidden" name="pos" value="' . (isset($pos) ? $pos : 0) . '" />' . "\n";
echo '<input type="hidden" name="session_max_rows" value="' . $session_max_rows . '" />' . "\n";
}
?>
<fieldset class="confirmation">

61
sql.php
View File

@@ -15,13 +15,6 @@ require_once './libraries/tbl_indexes.lib.php';
require_once './libraries/check_user_privileges.lib.php';
require_once './libraries/bookmark.lib.php';
/**
* Could be coming from a subform ("T" column expander)
*/
if (isset($_REQUEST['dontlimitchars'])) {
$dontlimitchars = $_REQUEST['dontlimitchars'];
}
/**
* Defines the url to return to in case of error in a sql statement
*/
@@ -89,32 +82,25 @@ $is_drop_database = preg_match('/DROP[[:space:]]+(DATABASE|SCHEMA)[[:space:]]+/i
* into account this case.
*/
if (!defined('PMA_CHK_DROP')
&& !$cfg['AllowUserDropDatabase']
&& $is_drop_database
&& !$is_superuser) {
&& !$cfg['AllowUserDropDatabase']
&& $is_drop_database
&& !$is_superuser) {
require_once './libraries/header.inc.php';
PMA_mysqlDie($strNoDropDatabases, '', '', $err_url);
} // end if
require_once './libraries/display_tbl.lib.php';
PMA_displayTable_checkConfigParams();
/**
* Need to find the real end of rows?
*/
if (isset($find_real_end) && $find_real_end) {
$unlim_num_rows = PMA_Table::countRecords($db, $table, true, true);
$pos = @((ceil($unlim_num_rows / $session_max_rows) - 1) * $session_max_rows);
}
/**
* Avoids undefined variables
*/
elseif (!isset($pos)) {
$pos = 0;
} else {
/* We need this to be a integer */
$pos = (int)$pos;
$_SESSION['userconf']['pos'] = @((ceil($unlim_num_rows / $_SESSION['userconf']['max_rows']) - 1) * $_SESSION['userconf']['max_rows']);
}
/**
* Bookmark add
*/
@@ -145,7 +131,6 @@ if ($goto == 'sql.php') {
$is_gotofile = false;
$goto = 'sql.php?'
. PMA_generate_common_url($db, $table)
. '&amp;pos=' . $pos
. '&amp;sql_query=' . urlencode($sql_query);
} // end if
@@ -238,19 +223,6 @@ if (empty($reload)
&& preg_match('/^(CREATE|ALTER|DROP)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i', $sql_query)) {
$reload = 1;
}
// Gets the number of rows per page
if (empty($session_max_rows)) {
$session_max_rows = $cfg['MaxRows'];
} elseif ($session_max_rows != 'all') {
$cfg['MaxRows'] = $session_max_rows;
}
// Defines the display mode (horizontal/vertical) and header "frequency"
if (empty($disp_direction)) {
$disp_direction = $cfg['DefaultDisplay'];
}
if (empty($repeat_cells)) {
$repeat_cells = $cfg['RepeatCells'];
}
// SK -- Patch: $is_group added for use in calculation of total number of
// rows.
@@ -290,13 +262,13 @@ if ($is_select) { // see line 141
}
// Do append a "LIMIT" clause?
if (isset($pos)
&& (!$cfg['ShowAll'] || $session_max_rows != 'all')
if ((!$cfg['ShowAll'] || $_SESSION['userconf']['max_rows'] != 'all')
&& !($is_count || $is_export || $is_func || $is_analyse)
&& isset($analyzed_sql[0]['queryflags']['select_from'])
&& !isset($analyzed_sql[0]['queryflags']['offset'])
&& !preg_match('@[[:space:]]LIMIT[[:space:]0-9,-]+(;)?$@i', $sql_query)) {
$sql_limit_to_append = " LIMIT $pos, ".$cfg['MaxRows'] . " ";
&& !preg_match('@[[:space:]]LIMIT[[:space:]0-9,-]+(;)?$@i', $sql_query)
) {
$sql_limit_to_append = ' LIMIT ' . $_SESSION['userconf']['pos'] . ', ' . $_SESSION['userconf']['max_rows'] . " ";
$full_sql_query = $analyzed_sql[0]['section_before_limit'] . "\n" . $sql_limit_to_append . $analyzed_sql[0]['section_after_limit'];
/**
@@ -401,7 +373,7 @@ if (isset($GLOBALS['show_as_php']) || !empty($GLOBALS['validatequery'])) {
$unlim_num_rows = $num_rows;
// if we did not append a limit, set this to get a correct
// "Showing rows..." message
$GLOBALS['session_max_rows'] = 'all';
//$_SESSION['userconf']['max_rows'] = 'all';
} elseif ($is_select) {
// c o u n t q u e r y
@@ -696,15 +668,11 @@ else {
}
// Displays the results in a table
require_once './libraries/display_tbl.lib.php';
if (empty($disp_mode)) {
// see the "PMA_setDisplayMode()" function in
// libraries/display_tbl.lib.php
$disp_mode = 'urdr111101';
}
if (!isset($dontlimitchars)) {
$dontlimitchars = 0;
}
// hide edit and delete links for information_schema
if (PMA_MYSQL_INT_VERSION >= 50002 && $db == 'information_schema') {
@@ -739,11 +707,6 @@ else {
$goto = 'sql.php?'
. PMA_generate_common_url($db, $table)
. '&amp;pos=' . $pos
. '&amp;session_max_rows=' . $session_max_rows
. '&amp;disp_direction=' . $disp_direction
. '&amp;repeat_cells=' . $repeat_cells
. '&amp;dontlimitchars=' . $dontlimitchars
. '&amp;sql_query=' . urlencode($sql_query)
. '&amp;id_bookmark=1';

View File

@@ -15,21 +15,6 @@ require_once './libraries/common.inc.php';
* Here it's better to use a if, instead of the '?' operator
* to avoid setting a variable to '' when it's not present in $_REQUEST
*/
if (isset($_REQUEST['pos'])) {
$pos = $_REQUEST['pos'];
}
if (isset($_REQUEST['session_max_rows'])) {
$session_max_rows = $_REQUEST['session_max_rows'];
}
if (isset($_REQUEST['disp_direction'])) {
$disp_direction = $_REQUEST['disp_direction'];
}
if (isset($_REQUEST['repeat_cells'])) {
$repeat_cells = $_REQUEST['repeat_cells'];
}
if (isset($_REQUEST['dontlimitchars'])) {
$dontlimitchars = $_REQUEST['dontlimitchars'];
}
/**
* @todo this one is badly named, it's really a WHERE condition
* and exists even for tables not having a primary key or unique key
@@ -203,11 +188,6 @@ document.onkeydown = onKeyDownArrowsHandler;
<form method="post" action="tbl_replace.php" name="insertForm" <?php if ($is_upload) { echo ' enctype="multipart/form-data"'; } ?>>
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
<input type="hidden" name="goto" value="<?php echo htmlspecialchars($goto); ?>" />
<input type="hidden" name="pos" value="<?php echo isset($pos) ? $pos : 0; ?>" />
<input type="hidden" name="session_max_rows" value="<?php echo isset($session_max_rows) ? $session_max_rows : ''; ?>" />
<input type="hidden" name="disp_direction" value="<?php echo isset($disp_direction) ? $disp_direction : ''; ?>" />
<input type="hidden" name="repeat_cells" value="<?php echo isset($repeat_cells) ? $repeat_cells : ''; ?>" />
<input type="hidden" name="dontlimitchars" value="<?php echo (isset($dontlimitchars) ? $dontlimitchars : 0); ?>" />
<input type="hidden" name="err_url" value="<?php echo htmlspecialchars($err_url); ?>" />
<input type="hidden" name="sql_query" value="<?php echo htmlspecialchars($sql_query); ?>" />
<?php

View File

@@ -64,21 +64,6 @@ PMA_DBI_select_db($GLOBALS['db']);
*/
$goto_include = false;
if (isset($_REQUEST['dontlimitchars'])) {
$url_params['dontlimitchars'] = $_REQUEST['dontlimitchars'];
}
if (isset($_REQUEST['pos'])) {
$url_params['pos'] = (int) $_REQUEST['pos'];
}
if (isset($_REQUEST['session_max_rows'])) {
$url_params['session_max_rows'] = (int) $_REQUEST['session_max_rows'];
}
if (isset($_REQUEST['disp_direction'])) {
$url_params['disp_direction'] = $_REQUEST['disp_direction'];
}
if (isset($_REQUEST['repeat_cells'])) {
$url_params['repeat_cells'] = (int) $_REQUEST['repeat_cells'];
}
if (isset($_REQUEST['insert_rows']) && is_numeric($_REQUEST['insert_rows']) && $_REQUEST['insert_rows'] != $cfg['InsertRows']) {
$cfg['InsertRows'] = $_REQUEST['insert_rows'];
require_once './libraries/header.inc.php';

View File

@@ -11,13 +11,6 @@
require_once './libraries/common.inc.php';
require_once './libraries/mysql_charsets.lib.php';
/**
* Avoids undefined variables
*/
if (!isset($pos)) {
$pos = 0;
}
/**
* No rows were selected => show again the query and tell that user.
*/
@@ -113,10 +106,9 @@ if (!empty($submit_mult)) {
default:
$action = 'tbl_row_action.php';
$err_url = 'tbl_row_action.php?' . PMA_generate_common_url($db, $table);
if (!isset($mult_btn)) {
if (! isset($mult_btn)) {
$original_sql_query = $sql_query;
$original_url_query = $url_query;
$original_pos = $pos;
}
require './libraries/mult_submits.inc.php';
$url_query = PMA_generate_common_url($db, $table)
@@ -140,10 +132,6 @@ if (!empty($submit_mult)) {
$url_query = $original_url_query;
}
if (isset($original_pos)) {
$pos = $original_pos;
}
// this is because sql.php could call tbl_structure
// which would think it needs to call mult_submits.inc.php:
unset($submit_mult);