From bec8208b033df3371a1e569a10ddd67ad407a4a8 Mon Sep 17 00:00:00 2001 From: chriskl Date: Mon, 27 Oct 2003 05:43:18 +0000 Subject: [PATCH] show languages --- BUGS | 2 +- HISTORY | 1 + TODO | 4 ++- browser.php | 16 +++++++++- casts.php | 21 +------------ classes/database/Postgres.php | 54 ++++++++++++++++++++------------- classes/database/Postgres73.php | 32 ++++++++++++++++++- functions.php | 4 +-- lang/english.php | 7 ++++- lang/recoded/english.php | 7 ++++- schema.php | 3 +- 11 files changed, 101 insertions(+), 50 deletions(-) diff --git a/BUGS b/BUGS index 652adc9d..51b7da89 100644 --- a/BUGS +++ b/BUGS @@ -3,5 +3,5 @@ fix getIndexes() and getConstraints() for < 7.3 to know about index type (eg. constraints can only be btree indexes) re-enable help system all DROP and ALTER commands MUST be fully schema-qualified otherwise you can accidentally drop stuff in pg_catalog :( -need icons for Casts and Conversions +need icons for Casts and Conversions and Languages diff --git a/HISTORY b/HISTORY index 42992cf1..bc9c2d15 100644 --- a/HISTORY +++ b/HISTORY @@ -17,6 +17,7 @@ Features * Removed any trace of MySQL support * Show casts * Show conversions +* Show languages Bugs * Added legal DOCTYPE diff --git a/TODO b/TODO index 51d529fe..2f61f76e 100644 --- a/TODO +++ b/TODO @@ -97,7 +97,9 @@ Aggregates Languages --------- -* Unimplemented +* -Display (chriskl) +* Drop +* Create Domains (7.3) ------------- diff --git a/browser.php b/browser.php index 21f6f2c8..ab5c00d0 100644 --- a/browser.php +++ b/browser.php @@ -5,7 +5,7 @@ * if you click on a database it shows a list of database objects in that * database. * - * $Id: browser.php,v 1.21 2003/10/27 03:49:19 chriskl Exp $ + * $Id: browser.php,v 1.22 2003/10/27 05:43:18 chriskl Exp $ */ // Include application functions @@ -223,6 +223,20 @@ addNodes($db_node, $querystr); } + // Languages + if ($data->hasLanguages()) { + $lang_node = &new HTML_TreeNode(array( + 'text' => addslashes($lang['strlanguages']), + 'link' => addslashes(htmlspecialchars("languages.php?{$querystr}")), + 'icon' => "../../../images/themes/{$conf['theme']}/types.png", + 'expandedIcon' => "../../../images/themes/{$conf['theme']}/types.png", + 'expanded' => false, + 'linkTarget' => 'detail')); + + // Add folder to database + $db_node->addItem($lang_node); + } + // Casts if ($data->hasCasts()) { $cast_node = &new HTML_TreeNode(array( diff --git a/casts.php b/casts.php index 061b2721..6cb8cbf6 100644 --- a/casts.php +++ b/casts.php @@ -3,7 +3,7 @@ /** * Manage casts in a database * - * $Id: casts.php,v 1.1 2003/10/26 12:12:28 chriskl Exp $ + * $Id: casts.php,v 1.2 2003/10/27 05:43:18 chriskl Exp $ */ // Include application functions @@ -46,31 +46,12 @@ else { echo "

{$lang['strnocasts']}

\n"; } - -// echo "

href}\">{$lang['strcreatecast']}

\n"; } $misc->printHeader($lang['strcasts']); $misc->printBody(); switch ($action) { - case 'save_create': - if (isset($_POST['cancel'])) doDefault(); - else doSaveCreate(); - break; - case 'create': - doCreate(); - break; - case 'drop': - if (isset($_POST['cancel'])) doDefault(); - else doDrop(false); - break; - case 'confirm_drop': - doDrop(true); - break; - case 'properties': - doProperties(); - break; default: doDefault(); break; diff --git a/classes/database/Postgres.php b/classes/database/Postgres.php index f98031b8..542367ca 100755 --- a/classes/database/Postgres.php +++ b/classes/database/Postgres.php @@ -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.159 2003/10/26 10:59:16 chriskl Exp $ + * $Id: Postgres.php,v 1.160 2003/10/27 05:43:18 chriskl Exp $ */ // @@@ THOUGHT: What about inherits? ie. use of ONLY??? @@ -922,26 +922,6 @@ class Postgres extends BaseDB { } } - /** - * Return all database available on the server - * @return A list of databases, sorted alphabetically - */ - function &getLanguages() { - $sql = "SELECT lanname, lanispl, lanpltrusted FROM pg_language ORDER BY lanname"; - return $this->selectSet($sql); - } - - /** - * Return all information about a particular database - * @param $database The name of the database to retrieve - * @return The database info - */ - function &getLanguage($database) { - $this->clean($database); - $sql = "SELECT * FROM pg_database WHERE datname='{$database}'"; - return $this->selectRow($sql); - } - /** * Creates a database * @param $database The name of the database to create @@ -3339,6 +3319,38 @@ class Postgres extends BaseDB { return $this->selectSet($sql); } + // Language functions + + /** + * Gets all languages + * @param $all True to get all languages, regardless of show_system + * @return A recordset + */ + function &getLanguages($all = false) { + global $conf; + + if ($conf['show_system'] || $all) + $where = ''; + else + $where = 'AND lanispl'; + + $sql = " + SELECT + pl.lanname, + pl.lanpltrusted, + pp.proname AS lanplcallf + FROM + pg_language pl, pg_proc pp + WHERE + pl.lanplcallfoid = pp.oid + {$where} + ORDER BY + lanname + "; + + return $this->selectSet($sql); + } + // Type conversion routines /** diff --git a/classes/database/Postgres73.php b/classes/database/Postgres73.php index c366ee16..a95bf063 100644 --- a/classes/database/Postgres73.php +++ b/classes/database/Postgres73.php @@ -4,7 +4,7 @@ * A class that implements the DB interface for Postgres * Note: This class uses ADODB and returns RecordSets. * - * $Id: Postgres73.php,v 1.74 2003/10/27 03:49:19 chriskl Exp $ + * $Id: Postgres73.php,v 1.75 2003/10/27 05:43:18 chriskl Exp $ */ // @@@ THOUGHT: What about inherits? ie. use of ONLY??? @@ -1288,6 +1288,36 @@ class Postgres73 extends Postgres72 { ORDER BY 1; "; + return $this->selectSet($sql); + } + + // Language functions + + /** + * Gets all languages + * @param $all True to get all languages, regardless of show_system + * @return A recordset + */ + function &getLanguages($all = false) { + global $conf; + + if ($conf['show_system'] || $all) + $where = ''; + else + $where = 'WHERE lanispl'; + + $sql = " + SELECT + lanname, + lanpltrusted, + lanplcallfoid::pg_catalog.regproc AS lanplcallf + FROM + pg_catalog.pg_language + {$where} + ORDER BY + lanname + "; + return $this->selectSet($sql); } diff --git a/functions.php b/functions.php index fe39893a..760bb6b9 100644 --- a/functions.php +++ b/functions.php @@ -3,7 +3,7 @@ /** * Manage functions in a database * - * $Id: functions.php,v 1.21 2003/09/17 17:04:11 soranzo Exp $ + * $Id: functions.php,v 1.22 2003/10/27 05:43:18 chriskl Exp $ */ // Include application functions @@ -211,7 +211,7 @@ if (!isset($_POST['formSetOf'])) $_POST['formSetOf'] = ''; $types = &$localData->getTypes(true); - $langs = &$localData->getLanguages(); + $langs = &$localData->getLanguages(true); echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strfunctions']}: {$lang['strcreatefunction']}

\n"; $misc->printMsg($msg); diff --git a/lang/english.php b/lang/english.php index 6e11b951..d8227872 100755 --- a/lang/english.php +++ b/lang/english.php @@ -4,7 +4,7 @@ * English language file for phpPgAdmin. Use this as a basis * for new translations. * - * $Id: english.php,v 1.118 2003/10/27 03:49:19 chriskl Exp $ + * $Id: english.php,v 1.119 2003/10/27 05:43:18 chriskl Exp $ */ // Language and character set @@ -521,6 +521,11 @@ $lang['strsourceencoding'] = 'Source encoding'; $lang['strtargetencoding'] = 'Target encoding'; + // Languages + $lang['strlanguages'] = 'Languages'; + $lang['strnolanguages'] = 'No languages found.'; + $lang['strtrusted'] = 'Trusted'; + // Info $lang['strnoinfo'] = 'No information available.'; $lang['strreferringtables'] = 'Referring tables'; diff --git a/lang/recoded/english.php b/lang/recoded/english.php index 8058b785..f8641b20 100644 --- a/lang/recoded/english.php +++ b/lang/recoded/english.php @@ -4,7 +4,7 @@ * English language file for phpPgAdmin. Use this as a basis * for new translations. * - * $Id: english.php,v 1.70 2003/10/27 03:49:20 chriskl Exp $ + * $Id: english.php,v 1.71 2003/10/27 05:43:18 chriskl Exp $ */ // Language and character set @@ -521,6 +521,11 @@ $lang['strsourceencoding'] = 'Source encoding'; $lang['strtargetencoding'] = 'Target encoding'; + // Languages + $lang['strlanguages'] = 'Languages'; + $lang['strnolanguages'] = 'No languages found.'; + $lang['strtrusted'] = 'Trusted'; + // Info $lang['strnoinfo'] = 'No information available.'; $lang['strreferringtables'] = 'Referring tables'; diff --git a/schema.php b/schema.php index cf69b1d9..77a4ebba 100755 --- a/schema.php +++ b/schema.php @@ -3,7 +3,7 @@ /** * Display properties of a schema * - * $Id: schema.php,v 1.8 2003/10/26 10:59:16 chriskl Exp $ + * $Id: schema.php,v 1.9 2003/10/27 05:43:18 chriskl Exp $ */ // Include application functions @@ -32,6 +32,7 @@ echo "\n"; echo "\n"; } -- 2.39.5