Added support for Composite types.
authorjollytoad <jollytoad>
Thu, 22 Jul 2004 13:29:19 +0000 (13:29 +0000)
committerjollytoad <jollytoad>
Thu, 22 Jul 2004 13:29:19 +0000 (13:29 +0000)
classes/database/Postgres73.php
lang/english.php
types.php

index ca25e24e4e3032739cd34956c2b75bc7ba38fef1..9e5a6eaf6cc65043c7d0c04f66e5d71215f2fce0 100644 (file)
@@ -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.132 2004/07/22 13:26:03 jollytoad Exp $
+ * $Id: Postgres73.php,v 1.133 2004/07/22 13:29:19 jollytoad Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -881,6 +881,7 @@ class Postgres73 extends Postgres72 {
                                t.typname AS basename,
                                pg_catalog.format_type(t.oid, NULL) AS typname,
                                pu.usename AS typowner,
+                               t.typtype,
                                pg_catalog.obj_description(t.oid, 'pg_type') AS typcomment
                        FROM (pg_catalog.pg_type t
                                LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace)
index 66bffaeaf248701204f4113e2e04b3bb2e35cc50..c5c3abc5560bb344c74a87be09a7c6f747abe936 100755 (executable)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.156 2004/07/22 04:52:50 chriskl Exp $
+        * $Id: english.php,v 1.157 2004/07/22 13:29:19 jollytoad Exp $
         */
 
        // Language and character set
        $lang['strconfdroptype'] = 'Are you sure you want to drop the type "%s"?';
        $lang['strtypedropped'] = 'Type dropped.';
        $lang['strtypedroppedbad'] = 'Type drop failed.';
+       $lang['strflavour'] = 'Flavour';
+       $lang['strbasetype'] = 'Base';
+       $lang['strcompositetype'] = 'Composite';
+       $lang['strpseudotype'] = 'Pseudo';
 
        // Schemas
        $lang['strschema'] = 'Schema';
index 5002f699de6463ba7f5c70a588207a69291335dc..6d16b03fe4973641f3e42d96ae773fdc64d257a7 100644 (file)
--- a/types.php
+++ b/types.php
@@ -3,7 +3,7 @@
        /**
         * Manage types in a database
         *
-        * $Id: types.php,v 1.19 2004/07/13 15:24:41 jollytoad Exp $
+        * $Id: types.php,v 1.20 2004/07/22 13:29:20 jollytoad Exp $
         */
 
        // Include application functions
                
                
                if ($typedata->recordCount() > 0) {
-                       $byval = $data->phpBool($typedata->f['typbyval']);
-                       echo "<table>\n";
-                       echo "<tr><th class=\"data left\">{$lang['strname']}</th>\n";
-                       echo "<td class=\"data1\">", $misc->printVal($typedata->f['typname']), "</td></tr>\n";
-                       echo "<tr><th class=\"data left\">{$lang['strinputfn']}</th>\n";
-                       echo "<td class=\"data1\">", $misc->printVal($typedata->f['typin']), "</td></tr>\n";
-                       echo "<tr><th class=\"data left\">{$lang['stroutputfn']}</th>\n";
-                       echo "<td class=\"data1\">", $misc->printVal($typedata->f['typout']), "</td></tr>\n";
-                       echo "<tr><th class=\"data left\">{$lang['strlength']}</th>\n";
-                       echo "<td class=\"data1\">", $misc->printVal($typedata->f['typlen']), "</td></tr>\n";
-                       echo "<tr><th class=\"data left\">{$lang['strpassbyval']}</th>\n";
-                       echo "<td class=\"data1\">", ($byval) ? $lang['stryes'] : $lang['strno'], "</td></tr>\n";
-                       echo "<tr><th class=\"data left\">{$lang['stralignment']}</th>\n";
-                       echo "<td class=\"data1\">", $misc->printVal($typedata->f['typalign']), "</td></tr>\n";
-                       echo "</table>\n";
+                       switch ($typedata->f['typtype']) {
+                       case 'c':
+                               function attPre(&$rowdata) {
+                                       global $data;
+                                       $rowdata->f['+type'] = $data->formatType($rowdata->f['type'], $rowdata->f['atttypmod']);
+                               }
+                               
+                               $attrs = &$data->getTableAttributes($_REQUEST['type']);
+                               
+                               $columns = array(
+                                       'field' => array(
+                                               'title' => $lang['strfield'],
+                                               'field' => 'attname',
+                                       ),
+                                       'type' => array(
+                                               'title' => $lang['strtype'],
+                                               'field' => '+type',
+                                       ),
+                               );
+                               
+                               $actions = array();
+                               
+                               $misc->printTable($attrs, $columns, $actions, null, 'attPre');
+                               
+                               break;
+
+                       default:
+                               $byval = $data->phpBool($typedata->f['typbyval']);
+                               echo "<table>\n";
+                               echo "<tr><th class=\"data left\">{$lang['strname']}</th>\n";
+                               echo "<td class=\"data1\">", $misc->printVal($typedata->f['typname']), "</td></tr>\n";
+                               echo "<tr><th class=\"data left\">{$lang['strinputfn']}</th>\n";
+                               echo "<td class=\"data1\">", $misc->printVal($typedata->f['typin']), "</td></tr>\n";
+                               echo "<tr><th class=\"data left\">{$lang['stroutputfn']}</th>\n";
+                               echo "<td class=\"data1\">", $misc->printVal($typedata->f['typout']), "</td></tr>\n";
+                               echo "<tr><th class=\"data left\">{$lang['strlength']}</th>\n";
+                               echo "<td class=\"data1\">", $misc->printVal($typedata->f['typlen']), "</td></tr>\n";
+                               echo "<tr><th class=\"data left\">{$lang['strpassbyval']}</th>\n";
+                               echo "<td class=\"data1\">", ($byval) ? $lang['stryes'] : $lang['strno'], "</td></tr>\n";
+                               echo "<tr><th class=\"data left\">{$lang['stralignment']}</th>\n";
+                               echo "<td class=\"data1\">", $misc->printVal($typedata->f['typalign']), "</td></tr>\n";
+                               echo "</table>\n";
+                       }
 
                        echo "<p><a class=\"navlink\" href=\"$PHP_SELF?{$misc->href}\">{$lang['strshowalltypes']}</a></p>\n";           }
                else
                                'title' => $lang['strowner'],
                                'field' => 'typowner',
                        ),
+                       'flavour' => array(
+                               'title' => $lang['strflavour'],
+                               'field' => 'typtype',
+                               'type'  => 'verbatim',
+                               'params'=> array(
+                                       'map' => array(
+                                               'b' => $lang['strbasetype'],
+                                               'c' => $lang['strcompositetype'],
+                                               'd' => $lang['strdomain'],
+                                               'p' => $lang['strpseudotype'],
+                                       ),
+                                       'align' => 'center',
+                               ),
+                       ),
                        'actions' => array(
                                'title' => $lang['stractions'],
                        ),
                                'field' => 'typcomment',
                        ),
                );
+               
+               if (!isset($types->f['typtype'])) unset($columns['flavour']);
 
                $actions = array(
                        'properties' => array(