[Phpmyadmin-git] [SCM] phpMyAdmin branch, master, updated. RELEASE_3_4_1RC1-2061-g66e72d9

Marc Delisle lem9 at users.sourceforge.net
Sat May 28 12:49:57 CEST 2011


The branch, master has been updated
       via  66e72d9a0cec97ce0f52fd879b2c16e62446f26f (commit)
       via  e4ba1dc06605fd81718d1991ad509d8e47f159fc (commit)
       via  42800318aa89a5fa189bbbd2475041b30f2a4f7f (commit)
       via  a55873c9871bfb05bac8a3f42b6c30e23c88677d (commit)
       via  889a047fbc90d7dde5b3099fe0acc7cecabbe6b2 (commit)
       via  e98446c6c9f1098e7ffc147426dcb4bea0ac5b87 (commit)
       via  cc7eade6a5d4b17b67b0ec22ff5df0876d906d56 (commit)
       via  b7a4d0736c44fde5ea79f23ab9c7f29102d9a28b (commit)
       via  20f2e2011d9d732b3144f88c9ed894c0374fafc0 (commit)
       via  96a253bfccfbb48102d83998282537a759956842 (commit)
       via  c1cd10a14ff54d8d3d321b27c1a95a8fb7f410da (commit)
       via  07de5495c424bb1aa888d897ac02f4a201a979d5 (commit)
       via  81f95377787abe9ffbc901ad07adb24f4e9110e0 (commit)
       via  5bb9808ae272617e51c4c6043159b30911c23b7e (commit)
       via  be32b88ec0d30e79d5e523aa5d425d0187963a92 (commit)
       via  8f99ac7a286f5dc043d4e62d533e600fb864c665 (commit)
      from  ecc81cc23884fd2797bc19a2a1f36beea772ff68 (commit)


- Log -----------------------------------------------------------------
commit 66e72d9a0cec97ce0f52fd879b2c16e62446f26f
Merge: ecc81cc23884fd2797bc19a2a1f36beea772ff68 e4ba1dc06605fd81718d1991ad509d8e47f159fc
Author: Marc Delisle <marc at infomarc.info>
Date:   Sat May 28 06:46:27 2011 -0400

    Merge commit 'e4ba1dc06605fd81718d1991ad509d8e47f159fc'

commit e4ba1dc06605fd81718d1991ad509d8e47f159fc
Author: Aris Feryanto <aris_feryanto at yahoo.com>
Date:   Fri May 27 18:52:00 2011 +0700

    Add table pma_ui_prefs for remembering table sorting persistently

commit 42800318aa89a5fa189bbbd2475041b30f2a4f7f
Merge: a55873c9871bfb05bac8a3f42b6c30e23c88677d 434d233e5b710dc6d3ac82b6825cf726aac22cb3
Author: Aris Feryanto <aris_feryanto at yahoo.com>
Date:   Fri May 27 08:29:17 2011 +0700

    Merge remote-tracking branch 'origin/master' into browsemode

commit a55873c9871bfb05bac8a3f42b6c30e23c88677d
Author: Aris Feryanto <aris_feryanto at yahoo.com>
Date:   Wed May 25 20:01:16 2011 +0700

    Recent tables: Additional fix for frame_navigation.PMA_reloadRecentTable() not found

commit 889a047fbc90d7dde5b3099fe0acc7cecabbe6b2
Merge: e98446c6c9f1098e7ffc147426dcb4bea0ac5b87 6c938c0f7339b7c7263e0b0e7e055254827b0b1b
Author: Aris Feryanto <aris_feryanto at yahoo.com>
Date:   Wed May 25 19:58:17 2011 +0700

    Merge remote-tracking branch 'origin/master' into browsemode

commit e98446c6c9f1098e7ffc147426dcb4bea0ac5b87
Author: Aris Feryanto <aris_feryanto at yahoo.com>
Date:   Wed May 25 09:08:18 2011 +0700

    Recent tables: Fix for frame_navigation reference not found

commit cc7eade6a5d4b17b67b0ec22ff5df0876d906d56
Author: Aris Feryanto <aris_feryanto at yahoo.com>
Date:   Wed May 25 09:01:07 2011 +0700

    Remember table sorting: Fix for table_ref error

commit b7a4d0736c44fde5ea79f23ab9c7f29102d9a28b
Merge: 20f2e2011d9d732b3144f88c9ed894c0374fafc0 8f2a040f41f2cd03e359bcadeb8d9f24c23290fa
Author: Aris Feryanto <aris_feryanto at yahoo.com>
Date:   Tue May 24 19:35:08 2011 +0700

    Merge remote-tracking branch 'origin/master' into browsemode

commit 20f2e2011d9d732b3144f88c9ed894c0374fafc0
Author: Aris Feryanto <aris_feryanto at yahoo.com>
Date:   Tue May 24 16:57:01 2011 +0700

    Change default value for RememberSorting to true, for testing in the demo server

commit 96a253bfccfbb48102d83998282537a759956842
Author: Aris Feryanto <aris_feryanto at yahoo.com>
Date:   Tue May 24 16:51:30 2011 +0700

    Remove debugging message

commit c1cd10a14ff54d8d3d321b27c1a95a8fb7f410da
Author: Aris Feryanto <aris_feryanto at yahoo.com>
Date:   Tue May 24 16:41:51 2011 +0700

    Only remember sorting in Browse tab, modify the  so SQL pretty printer works

commit 07de5495c424bb1aa888d897ac02f4a201a979d5
Author: Aris Feryanto <aris_feryanto at yahoo.com>
Date:   Tue May 24 15:11:39 2011 +0700

    RememberSorting: add some checking before retrieving/remembering sorting

commit 81f95377787abe9ffbc901ad07adb24f4e9110e0
Author: Aris Feryanto <aris_feryanto at yahoo.com>
Date:   Tue May 24 14:50:47 2011 +0700

    Add new configuration field for RememberSorting

commit 5bb9808ae272617e51c4c6043159b30911c23b7e
Merge: be32b88ec0d30e79d5e523aa5d425d0187963a92 4b3780760ce251cdcb351ba51a5374f1529951ad
Author: Aris Feryanto <aris_feryanto at yahoo.com>
Date:   Tue May 24 14:21:16 2011 +0700

    Merge remote-tracking branch 'origin/master' into browsemode

commit be32b88ec0d30e79d5e523aa5d425d0187963a92
Author: Aris Feryanto <aris_feryanto at yahoo.com>
Date:   Tue May 24 13:49:00 2011 +0700

    Remember table sorting in session variable

commit 8f99ac7a286f5dc043d4e62d533e600fb864c665
Merge: ab6d16ed2f4728c9f066353a851621a352ef969f e6026f6fafb40081bb8014dd25c8102c8d97a746
Author: Aris Feryanto <aris_feryanto at yahoo.com>
Date:   Tue May 24 08:42:32 2011 +0700

    Merge remote-tracking branch 'origin/master' into browsemode

-----------------------------------------------------------------------

Summary of changes:
 Documentation.html                          |   22 ++++
 config.sample.inc.php                       |    1 +
 libraries/Table.class.php                   |  146 +++++++++++++++++++++++++++
 libraries/config.default.php                |   14 +++
 libraries/config/messages.inc.php           |    4 +
 libraries/config/setup.forms.php            |    4 +-
 libraries/config/user_preferences.forms.php |    3 +-
 libraries/relation.lib.php                  |   19 +++-
 scripts/create_tables.sql                   |   15 +++
 sql.php                                     |   25 +++++
 10 files changed, 248 insertions(+), 5 deletions(-)

diff --git a/Documentation.html b/Documentation.html
index 3bbb832..2ff0881 100644
--- a/Documentation.html
+++ b/Documentation.html
@@ -1077,6 +1077,25 @@ ALTER TABLE `pma_column_comments`
         </ul>
     </dd>
 
+    <dt id="table_uiprefs">
+        <span id="cfg_Servers_table_uiprefs">$cfg['Servers'][$i]['table_uiprefs']</span> string
+    </dt>
+    <dd>
+        Since release 3.5.0 phpMyAdmin can be configured to remember several things
+        (table sorting
+        <a href="#cfg_RememberSorting" class="configrule">$cfg['RememberSorting']</a>
+        , etc.) for browsing tables.
+        Without configuring the storage, these features still can be used,
+        but the values will disappear after you logout.<br/><br/>
+
+        To allow the usage of these functionality persistently:
+
+        <ul>
+            <li>set up <a href="#pmadb">pmadb</a> and the phpMyAdmin configuration storage</li>
+            <li>put the table name in <tt>$cfg['Servers'][$i]['table_uiprefs']</tt> (e.g. 'pma_table_uiprefs')</li>
+        </ul>
+    </dd>
+
     <dt id="tracking">
         <span id="cfg_Servers_tracking">$cfg['Servers'][$i]['tracking']</span> string
     </dt>
@@ -1934,6 +1953,9 @@ $cfg['TrustedProxies'] =
         each row on a vertical lineup.
     </dd>
 
+    <dt id="cfg_RememberSorting">$cfg['RememberSorting'] boolean</dt>
+    <dd>If enabled, when browsing tables, the sorting of each table is remembered.</dd>
+
     <dt id="cfg_HeaderFlipType">$cfg['HeaderFlipType'] string</dt>
     <dd>
         The HeaderFlipType can be set to 'auto', 'css' or 'fake'. When using
diff --git a/config.sample.inc.php b/config.sample.inc.php
index 95d3a1a..edffd03 100644
--- a/config.sample.inc.php
+++ b/config.sample.inc.php
@@ -53,6 +53,7 @@ $cfg['Servers'][$i]['AllowNoPassword'] = false;
 // $cfg['Servers'][$i]['column_info'] = 'pma_column_info';
 // $cfg['Servers'][$i]['history'] = 'pma_history';
 // $cfg['Servers'][$i]['recent'] = 'pma_recent';
+// $cfg['Servers'][$i]['table_uiprefs'] = 'pma_table_uiprefs';
 // $cfg['Servers'][$i]['tracking'] = 'pma_tracking';
 // $cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords';
 // $cfg['Servers'][$i]['userconfig'] = 'pma_userconfig';
diff --git a/libraries/Table.class.php b/libraries/Table.class.php
index d41eadc..c73eb31 100644
--- a/libraries/Table.class.php
+++ b/libraries/Table.class.php
@@ -11,6 +11,10 @@
  */
 class PMA_Table
 {
+    /**
+     * UI preferences property: sorted column
+     */
+    const PROP_SORTED_COLUMN = 'sorted_col';
 
     static $cache = array();
 
@@ -40,6 +44,11 @@ class PMA_Table
     var $settings = array();
 
     /**
+     * @var array UI preferences
+     */
+    var $uiprefs;
+
+    /**
      * @var array errors occured
      */
     var $errors = array();
@@ -1185,5 +1194,142 @@ class PMA_Table
 
         return $return;
     }
+
+    /**
+     * Return UI preferences for this table from phpMyAdmin database.
+     *
+     * @uses PMA_query_as_controluser()
+     * @uses PMA_DBI_fetch_array()
+     * @uses json_decode()
+     *
+     * @return array
+     */
+    protected function getUiPrefsFromDb()
+    {
+        $pma_table = PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) .".".
+                     PMA_backquote($GLOBALS['cfg']['Server']['table_uiprefs']);
+
+        // Read from phpMyAdmin database
+        $sql_query =
+        " SELECT `prefs` FROM " . $pma_table .
+        " WHERE `username` = '" . $GLOBALS['cfg']['Server']['user'] . "'" .
+        " AND `db_name` = '" . $this->db_name . "'" .
+        " AND `table_name` = '" . $this->name . "'";
+
+        $row = PMA_DBI_fetch_array(PMA_query_as_controluser($sql_query));
+        if (isset($row[0])) {
+            return json_decode($row[0], true);
+        } else {
+            return array();
+        }
+    }
+
+    /**
+     * Save this table's UI preferences into phpMyAdmin database.
+     *
+     * @uses PMA_DBI_try_query()
+     * @uses json_decode()
+     * @uses PMA_Message
+     *
+     * @return true|PMA_Message
+     */
+    protected function saveUiPrefsToDb()
+    {
+        $pma_table = PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) .".".
+                     PMA_backquote($GLOBALS['cfg']['Server']['table_uiprefs']);
+
+        $username = $GLOBALS['cfg']['Server']['user'];
+        $sql_query =
+        " REPLACE INTO " . $pma_table .
+        " VALUES ('" . $username . "', '" . $this->db_name . "', '" .
+                       $this->name . "', '" . PMA_sqlAddslashes(json_encode($this->uiprefs)) . "')";
+
+        $success = PMA_DBI_try_query($sql_query, $GLOBALS['controllink']);
+
+        if (!$success) {
+            $message = PMA_Message::error(__('Could not save table UI preferences'));
+            $message->addMessage('<br /><br />');
+            $message->addMessage(PMA_Message::rawError(PMA_DBI_getError($GLOBALS['controllink'])));
+            return $message;
+        }
+        return true;
+    }
+
+    /**
+     * Loads the UI preferences for this table.
+     * If pmadb and table_uiprefs is set, it will load the UI preferences from
+     * phpMyAdmin database.
+     *
+     * @uses getUiPrefsFromDb()
+     */
+    protected function loadUiPrefs()
+    {
+        // set session variable if it's still undefined
+        if (! isset($_SESSION['tmp_user_values']['table_uiprefs'][$this->db_name][$this->name])) {
+            $_SESSION['tmp_user_values']['table_uiprefs'][$this->db_name][$this->name] =
+                    // check whether we can get from pmadb
+                    (strlen($GLOBALS['cfg']['Server']['pmadb'])
+                     && strlen($GLOBALS['cfg']['Server']['table_uiprefs'])) ?
+                    $this->getUiPrefsFromDb() : array();
+        }
+        $this->uiprefs =& $_SESSION['tmp_user_values']['table_uiprefs'][$this->db_name][$this->name];
+    }
+
+    /**
+     * Get UI preferences array for this table.
+     * If pmadb and table_uiprefs is set, it will get the UI preferences from
+     * phpMyAdmin database.
+     *
+     * @return array
+     */
+    public function getUiPrefs()
+    {
+        if (! isset($this->uiprefs)) {
+            $this->loadUiPrefs();
+        }
+        return $this->uiprefs;
+    }
+
+    /**
+     * Get a property from UI preferences.
+     * Return false if the property is not found.
+     * Available property:
+     * - PROP_SORTED_COLUMN
+     *
+     * @uses loadUiPrefs()
+     *
+     * @param string $property
+     * @return mixed
+     */
+    public function getUiProp($property)
+    {
+        if (! isset($this->uiprefs)) {
+            $this->loadUiPrefs();
+        }
+        return isset($this->uiprefs[$property]) ? $this->uiprefs[$property] : false;
+    }
+
+    /**
+     * Set a property from UI preferences.
+     * If pmadb and table_uiprefs is set, it will save the UI preferences to
+     * phpMyAdmin database.
+     *
+     * @param string $property
+     * @param mixed $value
+     * @return true|PMA_Message
+     */
+    public function setUiProp($property, $value)
+    {
+        if (! isset($this->uiprefs)) {
+            $this->loadUiPrefs();
+        }
+        $this->uiprefs[$property] = $value;
+        // check if pmadb is set
+        if (strlen($GLOBALS['cfg']['Server']['pmadb'])
+                && strlen($GLOBALS['cfg']['Server']['table_uiprefs'])) {
+            return $this->saveUiprefsToDb();
+        }
+        return true;
+    }
 }
 ?>
diff --git a/libraries/config.default.php b/libraries/config.default.php
index 5c0b1b2..aa883d2 100644
--- a/libraries/config.default.php
+++ b/libraries/config.default.php
@@ -346,6 +346,13 @@ $cfg['Servers'][$i]['designer_coords'] = '';
 $cfg['Servers'][$i]['recent'] = '';
 
 /**
+ * table to store UI preferences for tables
+ *   - leave blank for no "persistent" UI preferences
+ *     SUGGESTED: 'pma_table_uiprefs'
+ */
+$cfg['Servers'][$i]['table_uiprefs'] = '';
+
+/**
  * table to store SQL tracking
  *   - leave blank for no SQL tracking
  *     SUGGESTED: 'pma_tracking'
@@ -2265,6 +2272,13 @@ $cfg['ModifyDeleteAtRight'] = false;
 $cfg['DefaultDisplay'] = 'horizontal';
 
 /**
+ * remember the last way a table sorted
+ *
+ * @global string $cfg['RememberSorting']
+ */
+$cfg['RememberSorting'] = true;
+
+/**
  * default display direction for altering/creating columns (tbl_properties)
  * (horizontal|vertical|<number>)
  * number indicates maximum number for which vertical model is used
diff --git a/libraries/config/messages.inc.php b/libraries/config/messages.inc.php
index e8ce0df..034214c 100644
--- a/libraries/config/messages.inc.php
+++ b/libraries/config/messages.inc.php
@@ -346,6 +346,8 @@ $strConfigQueryWindowWidth_desc = __('Query window width (in pixels)');
 $strConfigQueryWindowWidth_name = __('Query window width');
 $strConfigRecodingEngine_desc = __('Select which functions will be used for character set conversion');
 $strConfigRecodingEngine_name = __('Recoding engine');
+$strConfigRememberSorting_desc = __('When browsing tables, the sorting of each table is remembered');
+$strConfigRememberSorting_name = __('Remember table\'s sorting');
 $strConfigRepeatCells_desc = __('Repeat the headers every X cells, [kbd]0[/kbd] deactivates this feature');
 $strConfigRepeatCells_name = __('Repeat headers');
 $strConfigReplaceHelpImg_desc = __('Show help button instead of Documentation text');
@@ -420,6 +422,8 @@ $strConfigServers_table_coords_desc = __('Leave blank for no PDF schema support,
 $strConfigServers_table_coords_name = __('PDF schema: table coordinates');
 $strConfigServers_table_info_desc = __('Table to describe the display columns, leave blank for no support; suggested: [kbd]pma_table_info[/kbd]');
 $strConfigServers_table_info_name = __('Display columns table');
+$strConfigServers_table_uiprefs_desc = __('Leave blank for no "persistent" tables\'UI preferences across sessions, suggested: [kbd]pma_table_uiprefs[/kbd]');
+$strConfigServers_table_uiprefs_name = __('UI preferences table');
 $strConfigServers_tracking_add_drop_database_desc = __('Whether a DROP DATABASE IF EXISTS statement will be added as first line to the log when creating a database.');
 $strConfigServers_tracking_add_drop_database_name = __('Add DROP DATABASE');
 $strConfigServers_tracking_add_drop_table_desc = __('Whether a DROP TABLE IF EXISTS statement will be added as first line to the log when creating a table.');
diff --git a/libraries/config/setup.forms.php b/libraries/config/setup.forms.php
index 7269823..5cf5111 100644
--- a/libraries/config/setup.forms.php
+++ b/libraries/config/setup.forms.php
@@ -74,6 +74,7 @@ $forms['Servers']['Server_pmadb'] = array('Servers' => array(1 => array(
     'column_info' => 'pma_column_info',
     'history' => 'pma_history',
     'recent' => 'pma_recent',
+    'table_uiprefs' => 'pma_table_uiprefs',
     'tracking' => 'pma_tracking',
     'table_coords' => 'pma_table_coords',
     'pdf_pages' => 'pma_pdf_pages',
@@ -200,7 +201,8 @@ $forms['Main_frame']['Browse'] = array(
     'LimitChars',
     'ModifyDeleteAtLeft',
     'ModifyDeleteAtRight',
-    'DefaultDisplay');
+    'DefaultDisplay',
+    'RememberSorting');
 $forms['Main_frame']['Edit'] = array(
     'ProtectBinary',
     'ShowFunctionFields',
diff --git a/libraries/config/user_preferences.forms.php b/libraries/config/user_preferences.forms.php
index ffe0366..68619c9 100644
--- a/libraries/config/user_preferences.forms.php
+++ b/libraries/config/user_preferences.forms.php
@@ -111,7 +111,8 @@ $forms['Main_frame']['Browse'] = array(
     'LimitChars',
     'ModifyDeleteAtLeft',
     'ModifyDeleteAtRight',
-    'DefaultDisplay');
+    'DefaultDisplay',
+    'RememberSorting');
 $forms['Main_frame']['Edit'] = array(
     'ProtectBinary',
     'ShowFunctionFields',
diff --git a/libraries/relation.lib.php b/libraries/relation.lib.php
index 87521a9..20ddf97 100644
--- a/libraries/relation.lib.php
+++ b/libraries/relation.lib.php
@@ -142,6 +142,10 @@ function PMA_printRelationsParamDiagnostic($cfgRelation)
 
     PMA_printDiagMessageForFeature(__('Persistent recently used tables'), 'recentwork', $messages);
 
+    PMA_printDiagMessageForParameter('table_uiprefs', isset($cfgRelation['table_uiprefs']), $messages, 'table_uiprefs');
+
+    PMA_printDiagMessageForFeature(__('Persistent tables\' UI preferences'), 'uiprefswork', $messages);
+
     PMA_printDiagMessageForParameter('tracking', isset($cfgRelation['tracking']), $messages, 'tracking');
 
     PMA_printDiagMessageForFeature(__('Tracking'), 'trackingwork', $messages);
@@ -225,6 +229,7 @@ function PMA__getRelationsParam()
     $cfgRelation['mimework']    = false;
     $cfgRelation['historywork'] = false;
     $cfgRelation['recentwork']  = false;
+    $cfgRelation['uiprefswork'] = false;
     $cfgRelation['trackingwork'] = false;
     $cfgRelation['designerwork'] = false;
     $cfgRelation['userconfigwork'] = false;
@@ -278,6 +283,8 @@ function PMA__getRelationsParam()
             $cfgRelation['history'] = $curr_table[0];
         } elseif ($curr_table[0] == $GLOBALS['cfg']['Server']['recent']) {
             $cfgRelation['recent'] = $curr_table[0];
+        } elseif ($curr_table[0] == $GLOBALS['cfg']['Server']['table_uiprefs']) {
+            $cfgRelation['table_uiprefs'] = $curr_table[0];
         } elseif ($curr_table[0] == $GLOBALS['cfg']['Server']['tracking']) {
             $cfgRelation['tracking'] = $curr_table[0];
         } elseif ($curr_table[0] == $GLOBALS['cfg']['Server']['userconfig']) {
@@ -292,9 +299,11 @@ function PMA__getRelationsParam()
                 $cfgRelation['displaywork'] = true;
         }
     }
+    
     if (isset($cfgRelation['table_coords']) && isset($cfgRelation['pdf_pages'])) {
         $cfgRelation['pdfwork']     = true;
     }
+
     if (isset($cfgRelation['column_info'])) {
         $cfgRelation['commwork']    = true;
 
@@ -336,6 +345,10 @@ function PMA__getRelationsParam()
         $cfgRelation['recentwork']      = true;
     }
 
+    if (isset($cfgRelation['table_uiprefs'])) {
+        $cfgRelation['uiprefswork']     = true;
+    }
+
     if (isset($cfgRelation['tracking'])) {
         $cfgRelation['trackingwork']     = true;
     }
@@ -357,9 +370,9 @@ function PMA__getRelationsParam()
     if ($cfgRelation['relwork'] && $cfgRelation['displaywork']
      && $cfgRelation['pdfwork'] && $cfgRelation['commwork']
      && $cfgRelation['mimework'] && $cfgRelation['historywork']
-     && $cfgRelation['recentwork'] && $cfgRelation['trackingwork']
-     && $cfgRelation['userconfigwork'] && $cfgRelation['bookmarkwork']
-     && $cfgRelation['designerwork']) {
+     && $cfgRelation['recentwork'] && $cfgRelation['uiprefswork']
+     && $cfgRelation['trackingwork'] && $cfgRelation['userconfigwork']
+     && $cfgRelation['bookmarkwork'] && $cfgRelation['designerwork']) {
         $cfgRelation['allworks'] = true;
     }
 
diff --git a/scripts/create_tables.sql b/scripts/create_tables.sql
index 2d6cb56..a537462 100644
--- a/scripts/create_tables.sql
+++ b/scripts/create_tables.sql
@@ -117,6 +117,21 @@ CREATE TABLE IF NOT EXISTS `pma_recent` (
 
 -- --------------------------------------------------------
 
+--
+-- Table structure for table `pma_table_uiprefs`
+--
+
+CREATE TABLE IF NOT EXISTS `pma_table_uiprefs` (
+  `username` varchar(64) COLLATE utf8_bin NOT NULL,
+  `db_name` varchar(64) COLLATE utf8_bin NOT NULL,
+  `table_name` varchar(64) COLLATE utf8_bin NOT NULL,
+  `prefs` blob NOT NULL,
+  PRIMARY KEY (`username`,`db_name`,`table_name`)
+) ENGINE=MyISAM COMMENT='tables'' UI preferences'
+  DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
+
+-- --------------------------------------------------------
+
 -- 
 -- Table structure for table `pma_relation`
 -- 
diff --git a/sql.php b/sql.php
index d07022b..1053a9d 100644
--- a/sql.php
+++ b/sql.php
@@ -356,6 +356,31 @@ if ($is_select) { // see line 141
     $is_maint    = true;
 }
 
+// Handle remembered sorting order, only for single table query
+if ($GLOBALS['cfg']['RememberSorting']
+ && 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
+ ) {
+    $pmatable = new PMA_Table($table, $db);
+    if (empty($analyzed_sql[0]['order_by_clause'])) {
+        $sorted_col = $pmatable->getUiProp(PMA_Table::PROP_SORTED_COLUMN);
+        if ($sorted_col) {
+            // retrieve the remembered sorting order for current table
+            $sql_order_to_append = ' ORDER BY ' . $sorted_col . ' ';
+            $sql_query = $analyzed_sql[0]['section_before_limit'] . $sql_order_to_append . $analyzed_sql[0]['section_after_limit'];
+
+            // update the $analyzed_sql
+            $analyzed_sql[0]['section_before_limit'] .= $sql_order_to_append;
+            $analyzed_sql[0]['order_by_clause'] = $sorted_col;
+        }
+    } else {
+        // store the remembered table into session
+        $pmatable->setUiProp(PMA_Table::PROP_SORTED_COLUMN, $analyzed_sql[0]['order_by_clause']);
+    }
+}
+
 // Do append a "LIMIT" clause?
 if ((! $cfg['ShowAll'] || $_SESSION['tmp_user_values']['max_rows'] != 'all')
  && ! ($is_count || $is_export || $is_func || $is_analyse)


hooks/post-receive
-- 
phpMyAdmin




More information about the Git mailing list