From e6db29ed88b603289d601aa137447e4527df7eca Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Sat, 26 Jul 2008 15:18:59 +0000 Subject: [PATCH] headwords for sorted column --- ChangeLog | 1 + libraries/dbi/mysql.dbi.lib.php | 13 ++++++++ libraries/dbi/mysqli.dbi.lib.php | 13 ++++++++ libraries/display_tbl.lib.php | 68 ++++++++++++++++++++++++++++++---------- 4 files changed, 78 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4d46ebdd1d..ee292301d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -68,6 +68,7 @@ danbarry + rfe #1692928 [transformation] Option to disable browser transformations + [import] Speed optimization to be able to import the sakila database + [doc] Documentation for distributing phpMyAdmin in README.VENDOR. ++ [display] headwords for sorted column 2.11.8.0 (not yet released) - patch #1987593 [interface] Table list pagination in navi, diff --git a/libraries/dbi/mysql.dbi.lib.php b/libraries/dbi/mysql.dbi.lib.php index a723039a2b..92d9424b18 100644 --- a/libraries/dbi/mysql.dbi.lib.php +++ b/libraries/dbi/mysql.dbi.lib.php @@ -187,6 +187,19 @@ function PMA_DBI_fetch_row($result) return mysql_fetch_array($result, MYSQL_NUM); } +/* + * Adjusts the result pointer to an arbitrary row in the result + * + * @uses mysql_data_seek() + * @param $result + * @param $offset + * @return boolean true on success, false on failure + */ +function PMA_DBI_data_seek($result, $offset) +{ + return mysql_data_seek($result, $offset); +} + /** * Frees the memory associated with the results * diff --git a/libraries/dbi/mysqli.dbi.lib.php b/libraries/dbi/mysqli.dbi.lib.php index 41a816b8ee..ec47b82e7f 100644 --- a/libraries/dbi/mysqli.dbi.lib.php +++ b/libraries/dbi/mysqli.dbi.lib.php @@ -240,6 +240,19 @@ function PMA_DBI_fetch_row($result) return mysqli_fetch_array($result, MYSQLI_NUM); } +/* + * Adjusts the result pointer to an arbitrary row in the result + * + * @uses mysqli_data_seek() + * @param $result + * @param $offset + * @return boolean true on success, false on failure + */ +function PMA_DBI_data_seek($result, $offset) +{ + return mysqli_data_seek($result, $offset); +} + /** * Frees the memory associated with the results * diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php index 3cb381a679..1c99d14c41 100644 --- a/libraries/display_tbl.lib.php +++ b/libraries/display_tbl.lib.php @@ -448,7 +448,7 @@ onsubmit="return (checkFormElementInRange(this, 'session_max_rows', ' $meta) { + if ($meta->table == $sort_table && $meta->name == $sort_column) { + $sorted_column_index = $key; + break; + } + } + if ($sorted_column_index !== false) { + // fetch first row of the result set + $row = PMA_DBI_fetch_row($dt_result); + $column_for_first_row = $row[$sorted_column_index]; + // fetch last row of the result set + PMA_DBI_data_seek($dt_result, $num_rows - 1); + $row = PMA_DBI_fetch_row($dt_result); + $column_for_last_row = $row[$sorted_column_index]; + // reset to first row for the loop in PMA_displayTableBody() + PMA_DBI_data_seek($dt_result, 0); + // we could also use here $sort_expression_nodirection + $sorted_column_message = ' [' . $sort_column . ': ' . $column_for_first_row . ' - ' . $column_for_last_row . ']'; + unset($row, $column_for_first_row, $column_for_last_row); + } + unset($sorted_column_index, $sort_table, $sort_column); + } + // 2. ----- Displays the top of the page ----- // 2.1 Displays a messages with position informations @@ -1800,6 +1832,8 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql) $message->addMessage($messagge_qt, ''); $message->addMessage(')', ''); + $message->addMessage(isset($sorted_column_message) ? htmlspecialchars($sorted_column_message) : '', ''); + PMA_showMessage($message, $sql_query, 'success'); } elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') { @@ -1861,7 +1895,7 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql) // end 2b // 3. ----- Displays the results table ----- - PMA_displayTableHeaders($is_display, $fields_meta, $fields_cnt, $analyzed_sql); + PMA_displayTableHeaders($is_display, $fields_meta, $fields_cnt, $analyzed_sql, $sort_expression, $sort_expression_nodirection); $url_query = ''; echo '' . "\n"; PMA_displayTableBody($dt_result, $is_display, $map, $analyzed_sql); -- 2.11.4.GIT