diff --git a/js/makegrid.js b/js/makegrid.js index 82fe8684b6..bb998957da 100644 --- a/js/makegrid.js +++ b/js/makegrid.js @@ -9,7 +9,7 @@ alignment: 'horizontal', // 3 possibilities: vertical, horizontal, horizontalflipped actionSpan: 5, colOrder: new Array(), // array of column order - tableCreateTime: null, // table creation time + tableCreateTime: null, // table creation time, only available in "Browse tab" hintShown: false, // true if hint balloon is shown, used by updateHint() method reorderHint: '', // string, hint for column reordering sortHint: '', // string, hint for column sorting @@ -163,7 +163,9 @@ this.colMov.objLeft = objPos.left; this.colMov.n = this.colMov.newn; // send request to server to remember the column order - this.sendColOrder(); + if (this.tableCreateTime) { + this.sendColOrder(); + } this.refreshRestoreButton(); } @@ -293,8 +295,10 @@ this.shiftCol(i, j + 1); } } - // send request to server to remember the column order - this.sendColOrder(); + if (this.tableCreateTime) { + // send request to server to remember the column order + this.sendColOrder(); + } this.refreshRestoreButton(); }, @@ -427,6 +431,7 @@ } // assign table create time + // #table_create_time will only available if we are in "Browse" tab g.tableCreateTime = $('#table_create_time').val(); // assign column reorder & column sort hint diff --git a/libraries/Table.class.php b/libraries/Table.class.php index 712fa448c9..ae76194dd3 100644 --- a/libraries/Table.class.php +++ b/libraries/Table.class.php @@ -1375,12 +1375,14 @@ class PMA_Table if ($property == self::PROP_COLUMN_ORDER) { $curr_create_time = self::sGetStatusInfo($this->db_name, $this->name, 'CREATE_TIME'); if (isset($table_create_time) && - $table_create_time < $curr_create_time) { + $table_create_time > $curr_create_time) { + $this->uiprefs['CREATE_TIME'] = $curr_create_time; + } else { + // there is no $table_create_time, or // supplied $table_create_time is older than current create time, // so don't save return false; } - $this->uiprefs['CREATE_TIME'] = $curr_create_time; } // save the value $this->uiprefs[$property] = $value; diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php index aea4e4b7ba..d2fb33b724 100644 --- a/libraries/display_tbl.lib.php +++ b/libraries/display_tbl.lib.php @@ -184,6 +184,20 @@ function PMA_setDisplayMode(&$the_disp_mode, &$the_total) } // end of the 'PMA_setDisplayMode()' function +/** + * Return true if we are currently browsing a table from the browse tab + * + * @return boolean + */ +function PMA_isBrowsing() +{ + return basename($GLOBALS['PMA_PHP_SELF']) == 'sql.php' + && ! ($is_count || $is_export || $is_func || $is_analyse) + && isset($analyzed_sql[0]['queryflags']['select_from']) + && count($analyzed_sql[0]['table_ref']) == 1; +} + + /** * Displays a navigation button * @@ -377,15 +391,17 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, $id_for_di getUiProp(PMA_Table::PROP_COLUMN_ORDER); - if ($col_order) { - echo ''; + if (PMA_isBrowsing()) { + // generate the column order, if it is set + $pmatable = new PMA_Table($GLOBALS['table'], $GLOBALS['db']); + $col_order = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_ORDER); + if ($col_order) { + echo ''; + } + // generate table create time + echo ''; } - // generate table create time - echo ''; // generate text for draggable column hint echo ''; // generate text for sortable column hint @@ -753,9 +769,13 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $ } } - // prepare to get the column order, if there is - $pmatable = new PMA_Table($GLOBALS['table'], $GLOBALS['db']); - $col_order = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_ORDER); + if (PMA_isBrowsing()) { + // prepare to get the column order, if available + $pmatable = new PMA_Table($GLOBALS['table'], $GLOBALS['db']); + $col_order = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_ORDER); + } else { + $col_order = false; + } for ($j = 0; $j < $fields_cnt; $j++) { // assign $i with appropriate column order @@ -1315,9 +1335,13 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) { // 2. Displays the rows' values - // prepare to get the column order, if there is - $pmatable = new PMA_Table($GLOBALS['table'], $GLOBALS['db']); - $col_order = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_ORDER); + if (PMA_isBrowsing()) { + // prepare to get the column order, if available + $pmatable = new PMA_Table($GLOBALS['table'], $GLOBALS['db']); + $col_order = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_ORDER); + } else { + $col_order = false; + } for ($j = 0; $j < $fields_cnt; ++$j) { // assign $i with appropriate column order @@ -1689,9 +1713,13 @@ function PMA_displayVerticalTable() echo '' . "\n"; } // end if - // prepare to get the column order, if there is - $pmatable = new PMA_Table($GLOBALS['table'], $GLOBALS['db']); - $col_order = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_ORDER); + if (PMA_isBrowsing()) { + // prepare to get the column order, if available + $pmatable = new PMA_Table($GLOBALS['table'], $GLOBALS['db']); + $col_order = $pmatable->getUiProp(PMA_Table::PROP_COLUMN_ORDER); + } else { + $col_order = false; + } // Displays data foreach ($vertical_display['desc'] AS $j => $val) { diff --git a/sql.php b/sql.php index 17e0974ece..b1b3e242d0 100644 --- a/sql.php +++ b/sql.php @@ -153,6 +153,9 @@ if(isset($_REQUEST['get_set_values']) && $_REQUEST['get_set_values'] == true) { PMA_ajaxResponse(NULL, true, $extra_data); } +/** + * Check ajax request to set the column order + */ if(isset($_REQUEST['set_col_order']) && $_REQUEST['set_col_order'] == true) { $pmatable = new PMA_Table($table, $db); $retval = $pmatable->setUiProp(PMA_Table::PROP_COLUMN_ORDER, $_REQUEST['col_order'], $_REQUEST['table_create_time']);