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
/**
* 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']);
/**
* 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
* 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???
function hasCompositeTypes() { return false; }
function hasReadOnlyQueries() { return false; }
function hasFuncPrivs() { return false; }
+ function hasServerAdminFuncs() { return false; }
}
/**
* 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');
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; }
+
}
?>
* 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';
* 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';
* Spanish language file for phpPgAdmin.
* @maintainer Martín Marqué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
$lang['strfile'] = 'Archivo';
$lang['strfileimported'] = 'Archivo importado.';
$lang['strtrycred'] = 'Usar el mismo par usuario/contraseña para todos los servidores';
+ $lang['strsize'] = 'Tamaño';
+
// 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.';
* 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
$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.';