From 72b60c630502ce6b6e07a5c934cae83aea4b100e Mon Sep 17 00:00:00 2001 From: ioguix Date: Wed, 3 Oct 2007 17:32:07 +0000 Subject: [PATCH] add support for Enum type creation --- HISTORY | 1 + classes/database/Postgres.php | 3 +- classes/database/Postgres83.php | 62 +++++++++++++- lang/english.php | 11 ++- lang/french.php | 64 +++++++++++++- lang/recoded/english.php | 11 ++- lang/recoded/french.php | 64 +++++++++++++- types.php | 144 +++++++++++++++++++++++++++++++- 8 files changed, 348 insertions(+), 12 deletions(-) diff --git a/HISTORY b/HISTORY index 69f2e0f1..eecb77be 100644 --- a/HISTORY +++ b/HISTORY @@ -18,6 +18,7 @@ Features * Add alter name, owner & comment on views (ioguix) * Add column about called procedure + links to their definition in the triggers properties page (ioguix) +* Add Support for Enum type creation (ioguix,xzilla) Bugs * Fix inability to assign a field type/domain of a different schema diff --git a/classes/database/Postgres.php b/classes/database/Postgres.php index cdbcc83b..9be55700 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.306 2007/10/02 21:36:35 ioguix Exp $ + * $Id: Postgres.php,v 1.307 2007/10/03 17:32:07 ioguix Exp $ */ // @@@ THOUGHT: What about inherits? ie. use of ONLY??? @@ -4722,6 +4722,7 @@ class Postgres extends ADODB_base { function hasNamedParams() { return false; } function hasUserAndDbVariables() { return false; } function hasCompositeTypes() { return false; } + function hasEnumTypes() {return false;} function hasReadOnlyQueries() { return false; } function hasFuncPrivs() { return false; } function hasServerAdminFuncs() { return false; } diff --git a/classes/database/Postgres83.php b/classes/database/Postgres83.php index 94aa521b..5e1bd8a3 100644 --- a/classes/database/Postgres83.php +++ b/classes/database/Postgres83.php @@ -3,7 +3,7 @@ /** * PostgreSQL 8.3 support * - * $Id: Postgres83.php,v 1.7 2007/09/25 09:53:11 ioguix Exp $ + * $Id: Postgres83.php,v 1.8 2007/10/03 17:32:07 ioguix Exp $ */ include_once('./classes/database/Postgres82.php'); @@ -619,10 +619,70 @@ class Postgres83 extends Postgres82 { $sql = "SELECT alias AS name, description FROM pg_catalog.ts_token_type({$cfg->fields['parser_id']}) ORDER BY name"; return $this->selectSet($sql); } + + // Type functions + + /** + * Creates a new enum type in the database + * @param $name The name of the type + * @param $values An array of values + * @param $typcomment Type comment + * @return 0 success + * @return -1 transaction error + * @return -2 no values supplied + */ + function createEnumType($name, $values, $typcomment) { + $this->fieldClean($name); + $this->clean($typcomment); + + if (empty($values)) return -2; + + $status = $this->beginTransaction(); + if ($status != 0) return -1; + + $values = array_unique($values); + + $nbval = count($values); + + for ($i = 0; $i < $nbval; $i++) + $this->clean($values[$i]); + + $sql = "CREATE TYPE \"{$name}\" AS ENUM ('"; + $sql.= implode("','", $values); + $sql .= "')"; + $status = $this->execute($sql); + if ($status) { + $this->rollbackTransaction(); + return -1; + } + + if ($typcomment != '') { + $status = $this->setComment('TYPE', $name, '', $typcomment, true); + if ($status) { + $this->rollbackTransaction(); + return -1; + } + } + + return $this->endTransaction(); + + } + + /** + * Get defined values for a given enum + * @return A recordset + */ + function getEnumValues($name) { + $this->fieldClean($name); + + $sql = "SELECT enumlabel AS enumval FROM pg_catalog.pg_type t JOIN pg_catalog.pg_enum e ON (t.oid=e.enumtypid) WHERE t.typname = '{$name}' ORDER BY e.oid"; + return $this->selectSet($sql); + } // Capabilities function hasCreateTableLikeWithIndexes() {return true;} function hasVirtualTransactionId() {return true;} + function hasEnumTypes() {return true;} } ?> diff --git a/lang/english.php b/lang/english.php index f9aaed30..2af9db83 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.218 2007/09/18 05:03:29 xzilla Exp $ + * $Id: english.php,v 1.219 2007/10/03 17:32:07 ioguix Exp $ */ // Language and character set @@ -562,8 +562,11 @@ $lang['strnotypes'] = 'No types found.'; $lang['strcreatetype'] = 'Create type'; $lang['strcreatecomptype'] = 'Create composite type'; + $lang['strcreateenumtype'] = 'Create enum type'; $lang['strtypeneedsfield'] = 'You must specify at least one field.'; - $lang['strtypeneedscols'] = 'You must specify a valid number of fields.'; + $lang['strtypeneedsvalue'] = 'You must specify at least one value.'; + $lang['strtypeneedscols'] = 'You must specify a valid number of fields.'; + $lang['strtypeneedsvals'] = 'You must specify a valid number of values.'; $lang['strtypename'] = 'Type name'; $lang['strinputfn'] = 'Input function'; $lang['stroutputfn'] = 'Output function'; @@ -573,7 +576,9 @@ $lang['strdelimiter'] = 'Delimiter'; $lang['strstorage'] = 'Storage'; $lang['strfield'] = 'Field'; + $lang['strvalue'] = 'Value'; $lang['strnumfields'] = 'Num. of fields'; + $lang['strnumvalues'] = 'Num. of values'; $lang['strtypeneedsname'] = 'You must give a name for your type.'; $lang['strtypeneedslen'] = 'You must give a length for your type.'; $lang['strtypecreated'] = 'Type created'; @@ -585,6 +590,8 @@ $lang['strbasetype'] = 'Base'; $lang['strcompositetype'] = 'Composite'; $lang['strpseudotype'] = 'Pseudo'; + $lang['strenum'] = 'Enum'; + $lang['strenumvalues'] = 'Enum Values'; // Schemas $lang['strschema'] = 'Schema'; diff --git a/lang/french.php b/lang/french.php index 56984a63..0d0c5d04 100644 --- a/lang/french.php +++ b/lang/french.php @@ -4,7 +4,7 @@ * French Language file for phpPgAdmin. * @maintainer Pascal PEYRE [pascal.peyre@cir.fr] * - * $Id: french.php,v 1.30 2007/09/13 14:53:41 ioguix Exp $ + * $Id: french.php,v 1.31 2007/10/03 17:32:07 ioguix Exp $ */ // Language and character set @@ -138,6 +138,7 @@ $lang['stractionsonmultiplelines'] = 'Actions sur plusieurs lignes'; $lang['strselectall'] = 'Sélectionner tout'; $lang['strunselectall'] = 'Desélectionner tout'; +$lang['strlocale'] = 'Locale'; // Database Sizes $lang['strsize'] = 'Taille'; @@ -563,8 +564,11 @@ $lang['strnotypes'] = 'Aucun type trouvé.'; $lang['strcreatetype'] = 'Créer un type'; $lang['strcreatecomptype'] = 'Créer un type composé'; + $lang['strcreateenumtype'] = 'Créer un type enum'; $lang['strtypeneedsfield'] = 'Vous devez spécifier au moins un champ.'; + $lang['strtypeneedsvalue'] = 'Vous devez spécifier au moins une valeur.'; $lang['strtypeneedscols'] = 'Vous devez spécifier un nombre valide de champs.'; + $lang['strtypeneedsvals'] = 'Vous devez spécifier un nombre valide de valeurs.'; $lang['strtypename'] = 'Nom du type'; $lang['strinputfn'] = 'Fonction d\'entrée'; $lang['stroutputfn'] = 'Fonction de sortie'; @@ -574,7 +578,9 @@ $lang['strdelimiter'] = 'Délimiteur'; $lang['strstorage'] = 'Stockage'; $lang['strfield'] = 'Champ'; + $lang['strvalue'] = 'Valeur'; $lang['strnumfields'] = 'Nombre de champs'; + $lang['strnumvalues'] = 'Nombre de valeurs'; $lang['strtypeneedsname'] = 'Vous devez indiquer un nom pour votre type.'; $lang['strtypeneedslen'] = 'Vous devez indiquer une longueur pour votre type.'; $lang['strtypecreated'] = 'Type créé'; @@ -586,6 +592,8 @@ $lang['strflavor'] = 'Flavor'; $lang['strbasetype'] = 'Base'; $lang['strcompositetype'] = 'Composite'; $lang['strpseudotype'] = 'Pseudo'; + $lang['strenum'] = 'Enum'; +$lang['strenumvalues'] = 'Enum Values'; // Schemas $lang['strschema'] = 'Schéma'; @@ -891,6 +899,7 @@ $lang['straggrstype'] = 'Data type for state value'; //Table-level Locks $lang['strlocks'] = 'Verrous'; $lang['strtransaction'] = 'ID de transaction'; +$lang['strvirtualtransaction'] = 'Virtual Transaction ID'; $lang['strprocessid'] = 'ID du processus'; $lang['strmode'] = 'Mode du verrou'; $lang['strislockheld'] = 'Verrou détenu ?'; @@ -899,4 +908,57 @@ $lang['straggrstype'] = 'Data type for state value'; $lang['strpreparedxacts'] = 'Transactions préparées'; $lang['strxactid'] = 'ID de transaction'; $lang['strgid'] = 'ID global'; + + // Fulltext search +$lang['strfulltext'] = 'Full Text Search'; +$lang['strftsconfig'] = 'FTS configuration'; +$lang['strftscreateconfig'] = 'Create FTS configuration'; +$lang['strftscreatedict'] = 'Create dictionary'; +$lang['strftscreatedicttemplate'] = 'Create dictionary template'; +$lang['strftscreateparser'] = 'Create parser'; +$lang['strftsnoconfigs'] = 'No FTS configuration found.'; +$lang['strftsconfigdropped'] = 'FTS configuration dropped.'; +$lang['strftsconfigdroppedbad'] = 'FTS configuration drop failed.'; +$lang['strconfdropftsconfig'] = 'Are you sure you want to drop the FTS configuration "%s"?'; +$lang['strconfdropftsdict'] = 'Are you sure you want to drop the FTS dictionary "%s"?'; +$lang['strconfdropftsmapping'] = 'Are you sure you want to drop mapping "%s" of FTS configuration "%s"?'; +$lang['strftstemplate'] = 'Template'; +$lang['strftsparser'] = 'Parser'; +$lang['strftsconfigneedsname'] = 'You must give a name for your FTS configuration.'; +$lang['strftsconfigcreated'] = 'FTS configuration created'; +$lang['strftsconfigcreatedbad'] = 'FTS configuration creation failed.'; +$lang['strftsmapping'] = 'Mapping'; +$lang['strftsdicts'] = 'Dictionaries'; +$lang['strftsdict'] = 'Dictionary'; +$lang['strftsemptymap'] = 'Empty FTS configuration map.'; +$lang['strftswithmap'] = 'With map'; +$lang['strftsmakedefault'] = 'Make default for given locale'; +$lang['strftsconfigaltered'] = 'FTS configuration altered.'; +$lang['strftsconfigalteredbad'] = 'FTS configuration alter failed.'; +$lang['strftsconfigmap'] = 'FTS configuration map'; +$lang['strftsparsers'] = 'FTS parsers'; +$lang['strftsnoparsers'] = 'No FTS parsers available.'; +$lang['strftsnodicts'] = 'No FTS dictionaries available.'; +$lang['strftsdictcreated'] = 'FTS dictionary created'; +$lang['strftsdictcreatedbad'] = 'FTS dictionary creation failed.'; +$lang['strftslexize'] = 'Lexize'; +$lang['strftsinit'] = 'Init'; +$lang['strftsoption'] = 'Option'; +$lang['strftsdictneedsname'] = 'You must give a name for your FTS dictionary.'; +$lang['strftsdictdropped'] = 'FTS dictionary dropped.'; +$lang['strftsdictdroppedbad'] = 'FTS dictionary drop failed.'; +$lang['strftsdictaltered'] = 'FTS dictionary altered.'; +$lang['strftsdictalteredbad'] = 'FTS dictionary alter failed.'; +$lang['strftsaddmapping'] = 'Add new mapping'; +$lang['strftsspecifymappingtodrop'] = 'You must specify at least one mapping to drop'; +$lang['strftsspecifyconfigtoalter'] = 'You must specify a FTS configuration to alter'; +$lang['strftsmappingdropped'] = 'FTS mapping dropped.'; +$lang['strftsmappingdroppedbad'] = 'FTS mapping drop failed.'; +$lang['strftsnodictionaries'] = 'No dictionaries found.'; +$lang['strftsmappingaltered'] = 'FTS mapping altered.'; +$lang['strftsmappingalteredbad'] = 'FTS mapping alter failed.'; +$lang['strftsmappingadded'] = 'FTS mapping added.'; +$lang['strftsmappingaddedbad'] = 'FTS mapping add failed.'; + + ?> diff --git a/lang/recoded/english.php b/lang/recoded/english.php index 82d6bcb0..dc7c7338 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.170 2007/09/18 05:03:29 xzilla Exp $ + * $Id: english.php,v 1.171 2007/10/03 17:32:07 ioguix Exp $ */ // Language and character set @@ -562,8 +562,11 @@ $lang['strnotypes'] = 'No types found.'; $lang['strcreatetype'] = 'Create type'; $lang['strcreatecomptype'] = 'Create composite type'; + $lang['strcreateenumtype'] = 'Create enum type'; $lang['strtypeneedsfield'] = 'You must specify at least one field.'; - $lang['strtypeneedscols'] = 'You must specify a valid number of fields.'; + $lang['strtypeneedsvalue'] = 'You must specify at least one value.'; + $lang['strtypeneedscols'] = 'You must specify a valid number of fields.'; + $lang['strtypeneedsvals'] = 'You must specify a valid number of values.'; $lang['strtypename'] = 'Type name'; $lang['strinputfn'] = 'Input function'; $lang['stroutputfn'] = 'Output function'; @@ -573,7 +576,9 @@ $lang['strdelimiter'] = 'Delimiter'; $lang['strstorage'] = 'Storage'; $lang['strfield'] = 'Field'; + $lang['strvalue'] = 'Value'; $lang['strnumfields'] = 'Num. of fields'; + $lang['strnumvalues'] = 'Num. of values'; $lang['strtypeneedsname'] = 'You must give a name for your type.'; $lang['strtypeneedslen'] = 'You must give a length for your type.'; $lang['strtypecreated'] = 'Type created'; @@ -585,6 +590,8 @@ $lang['strbasetype'] = 'Base'; $lang['strcompositetype'] = 'Composite'; $lang['strpseudotype'] = 'Pseudo'; + $lang['strenum'] = 'Enum'; + $lang['strenumvalues'] = 'Enum Values'; // Schemas $lang['strschema'] = 'Schema'; diff --git a/lang/recoded/french.php b/lang/recoded/french.php index 66cf035a..d146b6d9 100644 --- a/lang/recoded/french.php +++ b/lang/recoded/french.php @@ -4,7 +4,7 @@ * French Language file for phpPgAdmin. * @maintainer Pascal PEYRE [pascal.peyre@cir.fr] * - * $Id: french.php,v 1.29 2007/09/13 14:53:41 ioguix Exp $ + * $Id: french.php,v 1.30 2007/10/03 17:32:07 ioguix Exp $ */ // Language and character set @@ -138,6 +138,7 @@ $lang['stractionsonmultiplelines'] = 'Actions sur plusieurs lignes'; $lang['strselectall'] = 'Sélectionner tout'; $lang['strunselectall'] = 'Desélectionner tout'; +$lang['strlocale'] = 'Locale'; // Database Sizes $lang['strsize'] = 'Taille'; @@ -563,8 +564,11 @@ $lang['strnotypes'] = 'Aucun type trouvé.'; $lang['strcreatetype'] = 'Créer un type'; $lang['strcreatecomptype'] = 'Créer un type composé'; + $lang['strcreateenumtype'] = 'Créer un type enum'; $lang['strtypeneedsfield'] = 'Vous devez spécifier au moins un champ.'; + $lang['strtypeneedsvalue'] = 'Vous devez spécifier au moins une valeur.'; $lang['strtypeneedscols'] = 'Vous devez spécifier un nombre valide de champs.'; + $lang['strtypeneedsvals'] = 'Vous devez spécifier un nombre valide de valeurs.'; $lang['strtypename'] = 'Nom du type'; $lang['strinputfn'] = 'Fonction d\'entrée'; $lang['stroutputfn'] = 'Fonction de sortie'; @@ -574,7 +578,9 @@ $lang['strdelimiter'] = 'Délimiteur'; $lang['strstorage'] = 'Stockage'; $lang['strfield'] = 'Champ'; + $lang['strvalue'] = 'Valeur'; $lang['strnumfields'] = 'Nombre de champs'; + $lang['strnumvalues'] = 'Nombre de valeurs'; $lang['strtypeneedsname'] = 'Vous devez indiquer un nom pour votre type.'; $lang['strtypeneedslen'] = 'Vous devez indiquer une longueur pour votre type.'; $lang['strtypecreated'] = 'Type créé'; @@ -586,6 +592,8 @@ $lang['strflavor'] = 'Flavor'; $lang['strbasetype'] = 'Base'; $lang['strcompositetype'] = 'Composite'; $lang['strpseudotype'] = 'Pseudo'; + $lang['strenum'] = 'Enum'; +$lang['strenumvalues'] = 'Enum Values'; // Schemas $lang['strschema'] = 'Schéma'; @@ -891,6 +899,7 @@ $lang['straggrstype'] = 'Data type for state value'; //Table-level Locks $lang['strlocks'] = 'Verrous'; $lang['strtransaction'] = 'ID de transaction'; +$lang['strvirtualtransaction'] = 'Virtual Transaction ID'; $lang['strprocessid'] = 'ID du processus'; $lang['strmode'] = 'Mode du verrou'; $lang['strislockheld'] = 'Verrou détenu ?'; @@ -899,4 +908,57 @@ $lang['straggrstype'] = 'Data type for state value'; $lang['strpreparedxacts'] = 'Transactions préparées'; $lang['strxactid'] = 'ID de transaction'; $lang['strgid'] = 'ID global'; + + // Fulltext search +$lang['strfulltext'] = 'Full Text Search'; +$lang['strftsconfig'] = 'FTS configuration'; +$lang['strftscreateconfig'] = 'Create FTS configuration'; +$lang['strftscreatedict'] = 'Create dictionary'; +$lang['strftscreatedicttemplate'] = 'Create dictionary template'; +$lang['strftscreateparser'] = 'Create parser'; +$lang['strftsnoconfigs'] = 'No FTS configuration found.'; +$lang['strftsconfigdropped'] = 'FTS configuration dropped.'; +$lang['strftsconfigdroppedbad'] = 'FTS configuration drop failed.'; +$lang['strconfdropftsconfig'] = 'Are you sure you want to drop the FTS configuration "%s"?'; +$lang['strconfdropftsdict'] = 'Are you sure you want to drop the FTS dictionary "%s"?'; +$lang['strconfdropftsmapping'] = 'Are you sure you want to drop mapping "%s" of FTS configuration "%s"?'; +$lang['strftstemplate'] = 'Template'; +$lang['strftsparser'] = 'Parser'; +$lang['strftsconfigneedsname'] = 'You must give a name for your FTS configuration.'; +$lang['strftsconfigcreated'] = 'FTS configuration created'; +$lang['strftsconfigcreatedbad'] = 'FTS configuration creation failed.'; +$lang['strftsmapping'] = 'Mapping'; +$lang['strftsdicts'] = 'Dictionaries'; +$lang['strftsdict'] = 'Dictionary'; +$lang['strftsemptymap'] = 'Empty FTS configuration map.'; +$lang['strftswithmap'] = 'With map'; +$lang['strftsmakedefault'] = 'Make default for given locale'; +$lang['strftsconfigaltered'] = 'FTS configuration altered.'; +$lang['strftsconfigalteredbad'] = 'FTS configuration alter failed.'; +$lang['strftsconfigmap'] = 'FTS configuration map'; +$lang['strftsparsers'] = 'FTS parsers'; +$lang['strftsnoparsers'] = 'No FTS parsers available.'; +$lang['strftsnodicts'] = 'No FTS dictionaries available.'; +$lang['strftsdictcreated'] = 'FTS dictionary created'; +$lang['strftsdictcreatedbad'] = 'FTS dictionary creation failed.'; +$lang['strftslexize'] = 'Lexize'; +$lang['strftsinit'] = 'Init'; +$lang['strftsoption'] = 'Option'; +$lang['strftsdictneedsname'] = 'You must give a name for your FTS dictionary.'; +$lang['strftsdictdropped'] = 'FTS dictionary dropped.'; +$lang['strftsdictdroppedbad'] = 'FTS dictionary drop failed.'; +$lang['strftsdictaltered'] = 'FTS dictionary altered.'; +$lang['strftsdictalteredbad'] = 'FTS dictionary alter failed.'; +$lang['strftsaddmapping'] = 'Add new mapping'; +$lang['strftsspecifymappingtodrop'] = 'You must specify at least one mapping to drop'; +$lang['strftsspecifyconfigtoalter'] = 'You must specify a FTS configuration to alter'; +$lang['strftsmappingdropped'] = 'FTS mapping dropped.'; +$lang['strftsmappingdroppedbad'] = 'FTS mapping drop failed.'; +$lang['strftsnodictionaries'] = 'No dictionaries found.'; +$lang['strftsmappingaltered'] = 'FTS mapping altered.'; +$lang['strftsmappingalteredbad'] = 'FTS mapping alter failed.'; +$lang['strftsmappingadded'] = 'FTS mapping added.'; +$lang['strftsmappingaddedbad'] = 'FTS mapping add failed.'; + + ?> diff --git a/types.php b/types.php index 0135909a..f4787879 100644 --- a/types.php +++ b/types.php @@ -3,7 +3,7 @@ /** * Manage types in a database * - * $Id: types.php,v 1.40 2007/09/13 13:41:01 ioguix Exp $ + * $Id: types.php,v 1.41 2007/10/03 17:32:07 ioguix Exp $ */ // Include application functions @@ -32,6 +32,7 @@ } if ($typedata->recordCount() > 0) { + $vals = false; switch ($typedata->fields['typtype']) { case 'c': $attrs = $data->getTableAttributes($_REQUEST['type']); @@ -56,7 +57,8 @@ $misc->printTable($attrs, $columns, $actions, null, 'attPre'); break; - + case 'e': + $vals = $data->getEnumValues($typedata->fields['typname']); default: $byval = $data->phpBool($typedata->fields['typbyval']); echo "\n"; @@ -72,6 +74,14 @@ echo "\n"; echo "\n"; echo "\n"; + if ($data->hasEnumTypes() && $vals) { + $vals = $vals->getArray(); + $nbVals = count($vals); + echo "\n\t\n"; + echo "\n"; + for ($i=1; $i < $nbVals; $i++) + echo "\n"; + } echo "
", ($byval) ? $lang['stryes'] : $lang['strno'], "
{$lang['stralignment']}", $misc->printVal($typedata->fields['typalign']), "
{$lang['strenumvalues']}{$vals[0]['enumval']}
{$vals[$i]['enumval']}
\n"; } @@ -262,7 +272,127 @@ echo "

{$lang['strinvalidparam']}

\n"; } } - + + /** + * Displays a screen where they can enter a new enum type + */ + function doCreateEnum($msg = '') { + global $data, $misc; + global $lang; + + if (!isset($_REQUEST['stage'])) $_REQUEST['stage'] = 1; + if (!isset($_REQUEST['name'])) $_REQUEST['name'] = ''; + if (!isset($_REQUEST['values'])) $_REQUEST['values'] = ''; + if (!isset($_REQUEST['typcomment'])) $_REQUEST['typcomment'] = ''; + + switch ($_REQUEST['stage']) { + case 1: + $misc->printTrail('type'); + $misc->printTitle($lang['strcreateenumtype'], 'pg.type.create'); + $misc->printMsg($msg); + + echo "
\n"; + echo "\n"; + echo "\t\n\t\t\n"; + echo "\t\t\n\t\n"; + echo "\t\n\t\t\n"; + echo "\t\t\n\t\n"; + + echo "\t\n\t\t\n"; + echo "\t\t\n\t\n"; + + echo "
{$lang['strname']}_maxNameLen}\" value=\"", + htmlspecialchars($_REQUEST['name']), "\" />
{$lang['strnumvalues']}_maxNameLen}\" value=\"", + htmlspecialchars($_REQUEST['values']), "\" />
{$lang['strcomment']}
\n"; + echo "

\n"; + echo "\n"; + echo $misc->form; + echo "\n"; + echo "

\n"; + echo "
\n"; + break; + case 2: + global $lang; + + // Check inputs + $values = trim($_REQUEST['values']); + if (trim($_REQUEST['name']) == '') { + $_REQUEST['stage'] = 1; + doCreateEnum($lang['strtypeneedsname']); + return; + } + elseif ($values == '' || !is_numeric($values) || $values != (int)$values || $values < 1) { + $_REQUEST['stage'] = 1; + doCreateEnum($lang['strtypeneedsvals']); + return; + } + + $misc->printTrail('schema'); + $misc->printTitle($lang['strcreateenumtype'], 'pg.type.create'); + $misc->printMsg($msg); + + echo "
\n"; + + // Output table header + echo "\n"; + echo "\t\n"; + + for ($i = 0; $i < $_REQUEST['values']; $i++) { + if (!isset($_REQUEST['value'][$i])) $_REQUEST['value'][$i] = ''; + + echo "\t\n\t\t\n"; + echo "\t\t\n\t\n"; + } + echo "
{$lang['strvalue']}
", $i + 1, ". _maxNameLen}\" value=\"", + htmlspecialchars($_REQUEST['value'][$i]), "\" />
\n"; + echo "

\n"; + echo "\n"; + echo $misc->form; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "

\n"; + echo "
\n"; + + break; + case 3: + global $data, $lang; + + // Check inputs + $values = trim($_REQUEST['values']); + if (trim($_REQUEST['name']) == '') { + $_REQUEST['stage'] = 1; + doCreateEnum($lang['strtypeneedsname']); + return; + } + elseif ($values == '' || !is_numeric($values) || $values != (int)$values || $values <= 0) { + $_REQUEST['stage'] = 1; + doCreateEnum($lang['strtypeneedsvals']); + return; + } + + $status = $data->createEnumType($_REQUEST['name'], $_REQUEST['value'], $_REQUEST['typcomment']); + + if ($status == 0) + doDefault($lang['strtypecreated']); + elseif ($status == -1) { + $_REQUEST['stage'] = 2; + doCreateEnum($lang['strtypeneedsvalue']); + return; + } + else { + $_REQUEST['stage'] = 2; + doCreateEnum($lang['strtypecreatedbad']); + return; + } + break; + default: + echo "

{$lang['strinvalidparam']}

\n"; + } + } + /** * Displays a screen where they can enter a new type */ @@ -422,6 +552,7 @@ 'c' => $lang['strcompositetype'], 'd' => $lang['strdomain'], 'p' => $lang['strpseudotype'], + 'e' => $lang['strenum'], ), 'align' => 'center', ), @@ -450,8 +581,9 @@ echo "\n"; - } /** @@ -491,6 +623,10 @@ if (isset($_POST['cancel'])) doDefault(); else doCreateComposite(); break; + case 'create_enum': + if (isset($_POST['cancel'])) doDefault(); + else doCreateEnum(); + break; case 'save_create': if (isset($_POST['cancel'])) doDefault(); else doSaveCreate(); -- 2.39.5