#!/usr/local/bin/perl # edit_field.cgi # Display a form for editing an existing field or creating a new one require './postgresql-lib.pl'; &ReadParse(); &can_edit_db($in{'db'}) || &error($text{'dbase_ecannot'}); $desc = &text('field_in', "$in{'table'}", "$in{'db'}"); if ($in{'type'}) { # Creating a new field &ui_print_header($desc, $text{'field_title1'}, "", "create_field"); $type = $in{'type'}; } else { # Editing an existing field &ui_print_header($desc, $text{'field_title2'}, "", "edit_field"); @desc = &table_structure($in{'db'}, $in{'table'}); $f = $desc[$in{'idx'}]; $type = $f->{'type'}; } print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
$text{'field_header'}
\n"; print "\n"; print "\n"; print "\n" if (!$in{'type'}); if ($type =~ /^(\S+)\((.*)\)/) { $type = $1; $size = $2; } print "\n"; print "\n"; print "\n"; if ($type eq 'char' || $type eq 'varchar' || $type eq 'numeric' || $type eq 'bit') { if ($in{'type'}) { # Type has a size print "\n"; print "\n"; } else { # Type cannot be edited print "\n"; print "\n"; } } print "\n"; if (!$in{'type'}) { # Display nulls print "\n"; print "\n"; } print "
$text{'field_name'}
$text{'field_type'}$type
$text{'field_size'}
$text{'field_size'}$size
$text{'field_arr'} \n"; if ($in{'type'}) { # Ask if this is an array print " $text{'yes'}\n"; print " $text{'no'}\n"; } else { # Display if array or not print $f->{'arr'} eq 'YES' ? $text{'yes'} : $text{'no'}; } print "
$text{'field_null'}",$f->{'null'} eq 'YES' ? $text{'yes'} : $text{'no'},"
\n"; if ($in{'type'}) { print "\n"; } else { print "\n"; if (&can_drop_fields() && @desc > 1) { print "\n"; } } print "
\n"; &ui_print_footer("edit_table.cgi?db=$in{'db'}&table=$in{'table'}",$text{'table_return'}, "edit_dbase.cgi?db=$in{'db'}", $text{'dbase_return'}, "", $text{'index_return'});