* A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: Postgres.php,v 1.295 2007/03/03 14:25:14 xzilla Exp $
+ * $Id: Postgres.php,v 1.296 2007/04/01 16:02:07 xzilla Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
        function hasDisableTriggers() { return false; }
        function hasAlterAggregate() { return false; }
        function hasSharedComments() {return false;}
+       function hasAnalyze() {return false;}
 }
 
 ?>
 
  * A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: Postgres72.php,v 1.88 2007/01/10 02:01:17 soranzo Exp $
+ * $Id: Postgres72.php,v 1.89 2007/04/01 16:02:07 xzilla Exp $
  */
 
 
        function hasProcesses() { return true; }
        function hasStatsCollector() { return true; }
        function hasFullVacuum() { return true; }
+       function hasAnalyze() { return true; }
 
 }
 
 
        /**
         * Manage schemas within a database
         *
-        * $Id: database.php,v 1.89 2007/03/25 16:16:21 xzilla Exp $
+        * $Id: database.php,v 1.90 2007/04/01 16:02:07 xzilla Exp $
         */
 
        // Include application functions
                                echo "<th class=\"data\">";
                                $misc->printHelp($lang['strvacuum'],'pg.admin.vacuum')."</th>\n";
                                echo "</th>";
-                               echo "<th class=\"data\">";
-                               $misc->printHelp($lang['stranalyze'],'pg.admin.analyze');
-                               echo "</th>";
+                               if ($data->hasAnalyze()){
+                                       echo "<th class=\"data\">";
+                                       $misc->printHelp($lang['stranalyze'],'pg.admin.analyze');
+                                       echo "</th>";
+                               }
                                if ($data->hasRecluster()){
                                        echo "<th class=\"data\">";
                                        $misc->printHelp($lang['strclusterindex'],'pg.index.cluster');
                                echo "</td>\n";
 
                                // Analyze
-                               echo "<td class=\"data1\" align=\"center\" valign=\"bottom\">\n";
-                               echo "<form name=\"adminfrm\" id=\"adminfrm\" action=\"{$PHP_SELF}\" method=\"post\">\n";
-                               echo "<input type=\"submit\" value=\"{$lang['stranalyze']}\" />\n";
-                               echo "<input type=\"hidden\" name=\"action\" value=\"analyze\" />\n";
-                               echo $misc->form;
-                               echo "</form>\n";
-                               echo "</td>\n";
+                               if ($data->hasAnalyze()) {
+                                       echo "<td class=\"data1\" align=\"center\" valign=\"bottom\">\n";
+                                       echo "<form name=\"adminfrm\" id=\"adminfrm\" action=\"{$PHP_SELF}\" method=\"post\">\n";
+                                       echo "<input type=\"submit\" value=\"{$lang['stranalyze']}\" />\n";
+                                       echo "<input type=\"hidden\" name=\"action\" value=\"analyze\" />\n";
+                                       echo $misc->form;
+                                       echo "</form>\n";
+                                       echo "</td>\n";
+                               }
                                
                                // Recluster
                                if ($data->hasRecluster()){
 
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.201 2007/03/03 20:00:48 xzilla Exp $
+        * $Id: english.php,v 1.202 2007/04/01 16:02:07 xzilla Exp $
         */
 
        // Language and character set
        $lang['strtabbed'] = 'Tabbed';
        $lang['strauto'] = 'Auto';
        $lang['strconfvacuumtable'] = 'Are you sure you want to vacuum "%s"?';
+       $lang['strconfanalyzetable'] = 'Are you sure you want to analyze "%s"?';
        $lang['strestimatedrowcount'] = 'Estimated row count';
 
        // Columns
 
      * French Language file for phpPgAdmin. 
      * @maintainer Pascal PEYRE [pascal.peyre@cir.fr]
      *
-     * $Id: french.php,v 1.21 2007/03/13 02:39:22 xzilla Exp $
+     * $Id: french.php,v 1.22 2007/04/01 16:02:07 xzilla Exp $
      */
 
     // Language and character set
     $lang['strfile']  =  'Fichier';
     $lang['strfileimported']  =  'Fichier importé.';
     $lang['strtrycred']  =  'Utilisez ces identifiants pour tous les serveurs';
-       $lang['stractionsonmultiplelines']  =  'Actions sur plusieurs lignes';
-       $lang['strcheckall']  =  'Sélectionner tout';
-       $lang['struncheckall']  =  'Desélectionner tout';
+               $lang['stractionsonmultiplelines']  =  'Actions sur plusieurs lignes';
+               $lang['strcheckall']  =  'Sélectionner tout';
+               $lang['struncheckall']  =  'Desélectionner tout';
 
     // Database Sizes
     $lang['strsize']  =  'Taille';
     $lang['strstructureanddata']  =  'Structure et données';
     $lang['strtabbed']  =  'Tabulé';
     $lang['strauto']  =  'Auto';
-    $lang['strconfvacuumtable']  =  'Êtes-vous sur de vouloir faire un vacuum de « %s » ?';
+    $lang['strconfvacuumtable']  =  'Êtes-vous sûr de vouloir faire un vacuum de « %s » ?';
+               $lang['strconfanalyzetable']  =  'Êtes-vous sûr de vouloir éffectuer un ANALYZE sur « %s » ?';
     $lang['strestimatedrowcount']  =  'Nombre d\'enregistrements estimés';
 
        // Columns
 
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.153 2007/03/03 20:00:48 xzilla Exp $
+        * $Id: english.php,v 1.154 2007/04/01 16:02:06 xzilla Exp $
         */
 
        // Language and character set
        $lang['strtabbed'] = 'Tabbed';
        $lang['strauto'] = 'Auto';
        $lang['strconfvacuumtable'] = 'Are you sure you want to vacuum "%s"?';
+       $lang['strconfanalyzetable'] = 'Are you sure you want to analyze "%s"?';
        $lang['strestimatedrowcount'] = 'Estimated row count';
 
        // Columns
 
      * French Language file for phpPgAdmin. 
      * @maintainer Pascal PEYRE [pascal.peyre@cir.fr]
      *
-     * $Id: french.php,v 1.20 2007/03/13 02:39:22 xzilla Exp $
+     * $Id: french.php,v 1.21 2007/04/01 16:02:06 xzilla Exp $
      */
 
     // Language and character set
     $lang['strfile']  =  'Fichier';
     $lang['strfileimported']  =  'Fichier importé.';
     $lang['strtrycred']  =  'Utilisez ces identifiants pour tous les serveurs';
-       $lang['stractionsonmultiplelines']  =  'Actions sur plusieurs lignes';
-       $lang['strcheckall']  =  'Sélectionner tout';
-       $lang['struncheckall']  =  'Desélectionner tout';
+               $lang['stractionsonmultiplelines']  =  'Actions sur plusieurs lignes';
+               $lang['strcheckall']  =  'Sélectionner tout';
+               $lang['struncheckall']  =  'Desélectionner tout';
 
     // Database Sizes
     $lang['strsize']  =  'Taille';
     $lang['strstructureanddata']  =  'Structure et données';
     $lang['strtabbed']  =  'Tabulé';
     $lang['strauto']  =  'Auto';
-    $lang['strconfvacuumtable']  =  'Êtes-vous sur de vouloir faire un vacuum de « %s » ?';
+    $lang['strconfvacuumtable']  =  'Êtes-vous sûr de vouloir faire un vacuum de « %s » ?';
+               $lang['strconfanalyzetable']  =  'Êtes-vous sûr de vouloir éffectuer un ANALYZE sur « %s » ?';
     $lang['strestimatedrowcount']  =  'Nombre d\'enregistrements estimés';
 
        // Columns
 
        /**
         * List tables in a database
         *
-        * $Id: tables.php,v 1.87 2007/03/03 20:00:48 xzilla Exp $
+        * $Id: tables.php,v 1.88 2007/04/01 16:02:07 xzilla Exp $
         */
 
        // Include application functions
                }
        }
 
+       /**
+        * Show confirmation of analyze and perform analyze
+        */
+       function doAnalyze($confirm) {
+               global $data, $misc;
+               global $lang, $_reload_browser;
+               global $PHP_SELF;
+
+               if (empty($_REQUEST['table']) && empty($_REQUEST['ma'])) {
+                       doDefault('No table(s) given to analyze...'); //TODO i18n
+                       exit();
+               }
+               if ($confirm) {
+                       if (isset($_REQUEST['ma'])) {
+                               $misc->printTrail('schema');
+                               $misc->printTitle($lang['stranalyze'], 'pg.analyze'); //TODO
+
+                               echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
+                               foreach($_REQUEST['ma'] as $v) {
+                                       $a = unserialize(html_entity_decode($v));
+                                       echo "<p>", sprintf($lang['strconfanalyzetable'], $misc->printVal($a['table'])), "</p>\n";
+                                       echo "<input type=\"hidden\" name=\"table[]\" value=\"", htmlspecialchars($a['table']), "\" />\n";
+                               }
+                       } // END if multi analyze
+                       else {
+                               $misc->printTrail('table');
+                               $misc->printTitle($lang['stranalyze'], 'pg.analyze'); //TODO
+
+                               echo "<p>", sprintf($lang['strconfanalyzetable'], $misc->printVal($_REQUEST['table'])), "</p>\n";
+
+                               echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
+                               echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($_REQUEST['table']), "\" />\n";
+                       }
+                       echo "<input type=\"hidden\" name=\"action\" value=\"analyze\" />\n";
+                       echo $misc->form;
+
+                       echo "<input type=\"submit\" name=\"analyze\" value=\"{$lang['stranalyze']}\" />\n"; //TODO
+                       echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
+                       echo "</form>\n";
+               } // END single analyze
+               else {
+                       //If multi drop
+                       if (is_array($_REQUEST['table'])) {
+                               $msg='';
+                               foreach($_REQUEST['table'] as $t) {
+                                       $status = $data->analyzeDB($t);
+                                       if ($status == 0)
+                                               $msg.= sprintf('%s: %s<br />', $t, $lang['stranalyzegood']);
+                                       else {
+                                               doDefault(sprintf('%s%s: %s<br />', $msg, $t, $lang['stranalyzebad']));
+                                               return;
+                                       }
+                               }
+                                // Everything went fine, back to the Default page....
+                                $_reload_browser = true;
+                                doDefault($msg);
+                       }
+                       else {
+                               $status = $data->analyzeDB($_POST['table']);
+                               if ($status == 0) {
+                                       $_reload_browser = true;
+                                       doDefault($lang['stranalyzegood']);
+                               }
+                               else
+                                       doDefault($lang['stranalyzebad']);
+                       }
+               }
+       }
+
        /**
         * Show default list of tables in the database
         */
                                'vacuum' => array(
                                        'action' => 'confirm_vacuum',
                                        'title' => $lang['strvacuum'],
+                               ),
+                               'analyze' => array(
+                                       'action' => 'confirm_analyze',
+                                       'title' => $lang['stranalyze'],
                                )
                        )
                );
                                'url'   => "{$PHP_SELF}?action=confirm_vacuum&{$misc->href}&",
                                'vars'  => array('table' => 'relname'),
                        ),
+                       'analyze' => array(
+                               'title' => $lang['stranalyze'],
+                               'url'   => "{$PHP_SELF}?action=confirm_analyze&{$misc->href}&",
+                               'vars'  => array('table' => 'relname'),
+                       ),
                );
                
+               if (!$data->hasAnalyze()) unset($actions['analyze'], $multiactions['actions']['analyze']);
                if (!$data->hasTablespaces()) unset($columns['tablespace']);
 
                $misc->printTable($tables, $columns, $actions, $lang['strnotables'], null, $multiactions);
                case 'confirm_vacuum':
                        doVacuum(true);
                        break;
+               case 'analyze':
+                       if (isset($_POST['analyze'])) doAnalyze(false);
+                       else doDefault();
+                       break;
+               case 'confirm_analyze':
+                       doAnalyze(true);
+                       break;
                default:
                        doDefault();
                        break;