Add a database size column to the all database list
authorxzilla <xzilla>
Fri, 6 Jan 2006 21:06:57 +0000 (21:06 +0000)
committerxzilla <xzilla>
Fri, 6 Jan 2006 21:06:57 +0000 (21:06 +0000)
Add a "prettysize" option to printVal for formatting sizes in translatable fasion. (based on pg_size_pretty in core)
English and Spanish language files updated

all_db.php
classes/Misc.php
classes/database/Postgres.php
classes/database/Postgres81.php
lang/english.php
lang/recoded/english.php
lang/recoded/spanish.php
lang/spanish.php

index 3b2aeb9316e47a799026936ee785eb6c72018019..39a341419507a245bfde116f9206b2ed9dea47a5 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Manage databases within a server
         *
-        * $Id: all_db.php,v 1.42 2005/11/25 08:49:08 jollytoad Exp $
+        * $Id: all_db.php,v 1.43 2006/01/06 21:06:57 xzilla Exp $
         */
 
        // Include application functions
                                'title' => $lang['strtablespace'],
                                'field' => 'tablespace',
                        ),
+                       'dbsize' => array(
+                               'title' => $lang['strsize'],
+                               'field' => 'dbsize',
+                               'type' => 'prettysize',
+                       ),
                        'actions' => array(
                                'title' => $lang['stractions'],
                        ),
                }
                
                if (!$data->hasTablespaces()) unset($columns['tablespace']);
+               if (!$data->hasServerAdminFuncs()) unset($columns['dbsize']);
                if (!isset($data->privlist['database'])) unset($actions['privileges']);
                
                $misc->printTable($databases, $columns, $actions, $lang['strnodatabases']);
index be37cffc5124b593f5e585df5eba7bdb048089aa..f7c1b92fe4a98f40d1a60cef76558e1b38a3756c 100644 (file)
@@ -2,7 +2,7 @@
        /**
         * Class to hold various commonly used functions
         *
-        * $Id: Misc.php,v 1.123 2005/12/07 08:55:36 jollytoad Exp $
+        * $Id: Misc.php,v 1.124 2006/01/06 21:06:57 xzilla Exp $
         */
         
        class Misc {
                                case 'callback':
                                        $out = $params['function']($str, $params);
                                        break;
+                               case 'prettysize':
+                                       $mult = 1;
+                                       $limit = 10 * 1024;
+
+                                       if ($str < $limit * $mult)
+                                               $out = $str.' '.$lang['strbytes'];
+                                       else
+                                       {
+                                               $mult *= 1024;
+                                               if ($str < $limit * $mult)
+                                                       $out = floor(($str + $mult / 2) / $mult).' '.$lang['strkb'];
+                                               else
+                                               {                                                       
+                                                       $mult *= 1024;
+                                                       if ($str < $limit * $mult)
+                                                               $out = floor(($str + $mult / 2) / $mult).' '.$lang['strmb'];
+                                                       else
+                                                       {                                                       
+                                                               $mult *= 1024;
+                                                               if ($str < $limit * $mult)
+                                                                       $out = floor(($str + $mult / 2) / $mult).' '.$lang['strgb'];
+                                                               else
+                                                               {                                                       
+                                                                       $mult *= 1024;
+                                                                       if ($str < $limit * $mult)
+                                                                               $out = floor(($str + $mult / 2) / $mult).' '.$lang['strtb'];
+                                                               }
+                                                       }
+                                               }
+                                       }
+                                       break;  
                                default:
                                        // If the string contains at least one instance of >1 space in a row, a tab
                                        // character, a space at the start of a line, or a space at the start of
index 35948121ec7d37e3fe724bcafad438f334700c95..d8d74cb540dd507ba4f34754554f4022aa6c9ea5 100755 (executable)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: Postgres.php,v 1.280 2006/01/04 02:45:50 chriskl Exp $
+ * $Id: Postgres.php,v 1.281 2006/01/06 21:06:57 xzilla Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -4512,6 +4512,7 @@ class Postgres extends ADODB_base {
        function hasCompositeTypes() { return false; }
        function hasReadOnlyQueries() { return false; }
        function hasFuncPrivs() { return false; }
+       function hasServerAdminFuncs() { return false; }
 
 }
 
index ab7081456c5542d953e09b7e64c325bae109ea21..3f4bac95f62eaaba095ce3f4f55523bac5224266 100644 (file)
@@ -3,7 +3,7 @@
 /**
  * PostgreSQL 8.1 support
  *
- * $Id: Postgres81.php,v 1.3 2005/09/07 08:09:21 chriskl Exp $
+ * $Id: Postgres81.php,v 1.4 2006/01/06 21:06:57 xzilla Exp $
  */
 
 include_once('./classes/database/Postgres80.php');
@@ -70,6 +70,50 @@ class Postgres81 extends Postgres80 {
                return $this->help_page;
        }
 
+       // Database Functions
+       /**
+        * Return all database available on the server
+        * @return A list of databases, sorted alphabetically
+        */
+       function getDatabases($currentdatabase = NULL) {
+               global $conf, $misc;
+               
+               $server_info = $misc->getServerInfo();
+               
+               if (isset($conf['owned_only']) && $conf['owned_only'] && !$this->isSuperUser($server_info['username'])) {
+                       $username = $server_info['username'];
+                       $this->clean($username);
+                       $clause = " AND pu.usename='{$username}'";
+               }
+               else $clause = '';
+
+               if ($currentdatabase != NULL)
+                       $orderby = "ORDER BY pdb.datname = '{$currentdatabase}' DESC, pdb.datname";
+               else
+                       $orderby = "ORDER BY pdb.datname";
+
+               if (!$conf['show_system'])
+                       $where = ' AND NOT pdb.datistemplate';
+               else
+                       $where = ' AND pdb.datallowconn';
+
+               $sql = "SELECT pdb.datname AS datname, pu.usename AS datowner, pg_encoding_to_char(encoding) AS datencoding,
+                               (SELECT description FROM pg_catalog.pg_description pd WHERE pdb.oid=pd.objoid) AS datcomment,
+                               (SELECT spcname FROM pg_catalog.pg_tablespace pt WHERE pt.oid=pdb.dattablespace) AS tablespace,
+                                                          pg_catalog.pg_database_size(oid) as dbsize 
+                        FROM pg_catalog.pg_database pdb, pg_catalog.pg_user pu
+                       WHERE pdb.datdba = pu.usesysid
+                       {$where}
+                       {$clause}
+                       {$orderby}";
+
+               return $this->selectSet($sql);
+       }
+
+
+       // Capabilities
+       function hasServerAdminFuncs() { return true; }
+
 }
 
 ?>
index 46731b5b6dcde23f21a78f12997f4ba6a5e2318a..364436233749a97879a7a2e9168858d9fca53675 100755 (executable)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.183 2005/10/09 09:05:16 chriskl Exp $
+        * $Id: english.php,v 1.184 2006/01/06 21:06:57 xzilla Exp $
         */
 
        // Language and character set
        $lang['strfileimported'] = 'File imported.';
        $lang['strtrycred'] = 'Use these credentials for all servers';
 
+       // Database Sizes
+       $lang['strsize'] = 'Size';
+       $lang['strbytes'] = 'bytes';
+       $lang['strkb'] = 'kB';
+       $lang['strmb'] = 'MB';
+       $lang['strgb'] = 'GB';
+       $lang['strtb'] = 'TB';
+
        // Error handling
        $lang['strnoframes'] = 'This application works best with a frames-enabled browser, but can be used without frames by following the link below.';
        $lang['strnoframeslink'] = 'Use without frames';
index 8020de087446a5f64b73e0b9bce004bef6018563..d6a64cec6453c109b3f1dbcda061c53dc5ee0288 100644 (file)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.136 2005/11/19 09:40:25 chriskl Exp $
+        * $Id: english.php,v 1.137 2006/01/06 21:06:58 xzilla Exp $
         */
 
        // Language and character set
        $lang['strfileimported'] = 'File imported.';
        $lang['strtrycred'] = 'Use these credentials for all servers';
 
+       // Database Sizes
+       $lang['strsize'] = 'Size';
+       $lang['strbytes'] = 'bytes';
+       $lang['strkb'] = 'kB';
+       $lang['strmb'] = 'MB';
+       $lang['strgb'] = 'GB';
+       $lang['strtb'] = 'TB';
+
        // Error handling
        $lang['strnoframes'] = 'This application works best with a frames-enabled browser, but can be used without frames by following the link below.';
        $lang['strnoframeslink'] = 'Use without frames';
index a508359e51f14539b1f32d7cc0f518d189a034a7..d713994208d9cca821a856ed26b5cc7682d660cf 100644 (file)
@@ -4,7 +4,7 @@
         * Spanish language file for phpPgAdmin.
         * @maintainer Mart&#237;n Marqu&#233;s (martin@bugs.unl.edu.ar)
         *
-        * $Id: spanish.php,v 1.32 2005/11/19 09:40:25 chriskl Exp $
+        * $Id: spanish.php,v 1.33 2006/01/06 21:06:58 xzilla Exp $
         */
 
        // Language and character set
@@ -135,6 +135,8 @@ $lang['strnull']  =  'NULL (The word)';
        $lang['strfile'] = 'Archivo';
        $lang['strfileimported'] = 'Archivo importado.';
         $lang['strtrycred']  =  'Usar el mismo par usuario/contrase&#241;a para todos los servidores';
+       $lang['strsize'] = 'Tama&#241;o';
+
 
        // Error handling
         $lang['strnoframes']  =  'Esta aplicaci&#243;n funciona mejor con un navegador con soporte para marcos, pero puede usarse sin marcos siguiendo el link de abajo.';
index e7615fe771161a17b5886423e3574406ac07ac6c..20a3a7e175ddd0a5a4618ebd83c85d7c9f44edad 100644 (file)
@@ -4,7 +4,7 @@
         * Spanish language file for phpPgAdmin.
         * @maintainer Martín Marqués (martin@bugs.unl.edu.ar)
         *
-        * $Id: spanish.php,v 1.31 2005/10/28 01:57:53 chriskl Exp $
+        * $Id: spanish.php,v 1.32 2006/01/06 21:06:57 xzilla Exp $
         */
 
        // Language and character set
@@ -134,7 +134,15 @@ $lang['strnull']  =  'NULL (The word)';
        $lang['strstarttime'] = 'Hora de comienzo';
        $lang['strfile'] = 'Archivo';
        $lang['strfileimported'] = 'Archivo importado.';
-        $lang['strtrycred']  =  'Usar el mismo par usuario/contraseña para todos los servidores';
+    $lang['strtrycred']  =  'Usar el mismo par usuario/contraseña para todos los servidores';
+
+       // Database Sizes
+       $lang['strsize'] = 'Tamaño';
+       $lang['strbytes'] = 'bytes';
+       $lang['strkb'] = 'kB';
+       $lang['strmb'] = 'MB';
+       $lang['strgb'] = 'GB';
+       $lang['strtb'] = 'TB';
 
        // Error handling
         $lang['strnoframes']  =  'Esta aplicación funciona mejor con un navegador con soporte para marcos, pero puede usarse sin marcos siguiendo el link de abajo.';