[if !cgi item_id] [bounce page="__UI_BASE__/gentable"] [/if] [calc] delete $Scratch->{ui_meta_option_col}; my $location = $CGI->{item_id}; my @parts = split /::/, $location; ($m_table, $m_col, $m_key) = @parts; $Scratch->{ui_meta_option_col} = $m_col; my $string = "Add field option: "; $string .= "table=$m_table column=$m_col"; $string .= " key=$m_key" if $m_key; $Scratch->{page_title} = $string; $string = <Add field option   
table: $m_table
column: $m_col
EOF $Scratch->{page_banner} = $string; $CGI->{mv_data_table} = $m_table; return; [/calc] [if-mm function="!tables" name="[cgi mv_data_table]=c"] [seti ui_error]Not allowed to set options for that table ([cgi mv_data_table]), sorry.[/seti] [bounce page="__UI_BASE__/error"] [/if-mm] [if-mm function="!columns" name="[scratch ui_meta_option_col]"] [seti ui_error]Not allowed to set options for that column ([scratch ui_meta_option_col]), sorry.[/seti] [bounce page="__UI_BASE__/error"] [/if-mm] [calc] $CGI->{ui_meta_view} = 'optadd'; $Scratch->{ui_override_table} = $CGI->{mv_data_table} = '__UI_META_TABLE__'; $CGI->{ui_hide_key} = 1; $CGI->{ui_data_fields} = 'code options'; return; [/calc] [comment] BEGIN former UI_STD_DBEDIT_HEAD [/comment] [if cgi mv_data_table] [value name=mv_data_table set="[cgi mv_data_table]" hide=1] [else] [value name=mv_data_table set="[calc]$Config->{ProductFiles}[0][/calc]" hide=1] [/else] [/if] [if-mm !tables] [calc] delete $Scratch->{no_bounce}; my $tmp = delete $Scratch->{ui_override_table}; if($tmp eq $Values->{mv_data_table}) { $Scratch->{no_bounce} = 1; } return; [/calc] [if scratch no_bounce] [set no_bounce][/set] [else] [seti ui_error]Not authorized for table [value mv_data_table].[/seti] [bounce page="__UI_BASE__/error"] [/else] [/if] [/if-mm] [if-mm function=keys name="[cgi item_id]"] [else][bounce href="[area admin/special/key_violation]"][/else] [/if-mm] [perl tables="[value mv_data_table] __UI_META_TABLE__"] my $table = $Values->{mv_data_table}; my $db = $Db{$table}; my $mdb = $Db{__UI_META_TABLE__}; if(! $db) { $Scratch->{ui_error} = "Bad table '$table'."; $Tag->bounce( { page => '__UI_BASE__/error' } ); } $Values->{ui_data_key_name} = $db->config('KEY'); ############################################################### # Get the field display information including breaks and labels ############################################################### if( $mdb and ! $CGI->{ui_data_fields} and ! $CGI->{ui_data_fields_all} and $mdb->record_exists($table) ) { $CGI->{ui_data_fields} = $mdb->field($table, 'options'); $CGI->{ui_data_fields} =~ s/\r\n/\n/g; $CGI->{ui_data_fields} =~ s/\r/\n/g; if($CGI->{ui_data_fields} =~ /\n\n/) { my @breaks; my @break_labels; while ($CGI->{ui_data_fields} =~ s/\n+(?:\n=(.*)\n)?\n+(\w+)/\n$2/) { push @breaks, $2; push @break_labels, "$2=$1" if $1; } $CGI->{ui_break_before} = join " ", @breaks; $CGI->{ui_break_before_label} = join ",", @break_labels; } $CGI->{ui_data_fields} =~ s/^\s+//; $CGI->{ui_data_fields} =~ s/\s+$//; } $Values->{ui_data_fields} = $CGI->{ui_data_fields} || $CGI->{mv_data_fields} || $Values->{"$table:ui_data_fields"} || (join " ", $db->columns()); #Log("data fields: '$Values->{ui_data_fields}' cgi='$CGI->{ui_data_fields}'"); $Values->{ui_data_fields} =~ s/[,\0\s]+/ /g; ############################################################### my @cols = split /[,\0\s]/, $Values->{ui_data_fields}; @cols = grep /:/ || $db->column_exists($_), @cols; $Values->{ui_data_fields} = $CGI->{ui_data_fields} = join " ", @cols; return; [/perl] [comment] END former UI_STD_DBEDIT_HEAD [/comment] [set ui_class]Admin[/set] [set help_name]meta.edit[/set] [set icon_name][/set] [set enable_it] [tmp mv_data_enable]1[/tmp] [/set] @_UI_STD_HEAD_@ [if scratch ui_failure] Failed: [scratch ui_failure][set ui_failure][/set]
[/if]
[calc] unless ($CGI->{ui_return_to}) { $CGI->{ui_return_to} = "[var MV_PAGE global]\0item_id=$CGI->{item_id}"; } @inst = split /\0/, $CGI->{ui_return_to}; my $out; for(@inst) { s/"/"/g; $out .= < EOF } return $out; [/calc] [if-key-exists table="[value mv_data_table]" key="[cgi item_id]"] [else] [/else] [/if-key-exists]
[comment] Display an extra Ok/Cancel button pair if there are more than 4 rows of input, so user doesn't have to scroll to bottom of page. [/comment] [perl] my $linecount = (split / /, $CGI->{ui_data_fields}) - 1; my $out = ''; $out .= <<'EOF' if $linecount > 4; EOF [/perl] [mvasp tables="[list-databases] __UI_META_TABLE__ __UI_ACCESS_TABLE__"] <% my $table = $Values->{mv_data_table}; my $mtable = qq{__UI_META_TABLE__} || 'mv_metadata'; my $db = $Db{$table}; my $mdb = $Db{__UI_META_TABLE__}; my %break; my %break_label; if($CGI->{ui_break_before}) { my @tmp = grep /\S/, split /[\s,\0]+/, $CGI->{ui_break_before}; @break{@tmp} = @tmp; if($CGI->{ui_break_before_label}) { @tmp = grep /\S/, split /\s*[,\0]\s*/, $CGI->{ui_break_before_label}; for(@tmp) { my ($br, $lab) = split /\s*=\s*/, $_; $break_label{$br} = $lab; } } } if(!$db) { return ""; } my %display_only; if($CGI->{ui_display_only}) { my @do = split /[\0,\s]+/, $CGI->{ui_display_only}; for(@do) { $display_only{$_} = 1; $CGI->{ui_data_fields} =~ s/\b$_\b//; } } my $key = $CGI->{item_id}; my $keycol = $db->config('KEY'); my $passed_fields = $Values->{ui_data_fields}; my @extra_cols; my %ok_col; while($passed_fields =~ s/(\w+:+\S+)//) { push @extra_cols, $1; } my (@cols) = split /\s+/, $Tag->db_columns( { name => $table, columns => $passed_fields, passed_order => 1, }); if($Values->{ui_data_fields}) { for(@cols, @extra_cols) { unless (/^(\w+):+(\S+)/) { $ok_col{$_} = 1; next; } my $t = $1; my $c = $2; next unless $Tag->db_columns( { name => $t, columns => $c, }); $ok_col{$_} = 1; } @cols = grep $ok_col{$_}, split /\s+/, $Values->{ui_data_fields}; } my $super = $Tag->if_mm('super'); my $refkey = $key; if($db->record_exists($key)) { #Log("Should work. key=$key table=$table"); } elsif($db->config('_Auto_number')) { $CGI->{$Values->{ui_data_key_name}} = ''; undef $key; } else { $CGI->{$Values->{ui_data_key_name}} = $key; undef $key; } foreach my $col (@cols) { if($CGI->{ui_hide_key} and $col eq $keycol) { my $k = defined $key && length($key) ? $key : $refkey; $Document->write(< EOF next; } my $do = $display_only{$col}; my $currval; if($col =~ /(\w+):+(\S+)/) { $t = $1; $c = $2; $Scratch->{mv_data_enable} .= " $t " unless $do or $Scratch->{mv_data_enable} =~ /\b$t\b/; } else { $t = $table; $c = $col; } my $type; if($do) { my $k = defined $key ? $key : $refkey; $currval = tag_data($t, $c, $k); $type = 'value'; #Log("hit display_only for $col, t=$t, c=$c, k=$k, currval=$currval"); } elsif($CGI->{$col} and !defined($key) || !tag_data($t, $c, $key) ) { $currval = $CGI->{$col}; } else { $currval = delete $Scratch->{"ui_preload:$t:$c"} || undef; } my $meta = ''; my $display = $Tag->display({ table => $t, column => $c, name => $col, key => $key, type => $type, default => $currval, arbitrary => $CGI->{ui_meta_view}, fallback => 1, template => q( ), }); if($super and ($Variable->{UI_META_LINK} || $Values->{ui_meta_force}) ) { $meta .= '
'; # Get global variables my $base = $Tag->var('UI_BASE', 1); my $page = $Tag->var('MV_PAGE', 1); $meta .= $Tag->page( { href => "$base/meta_editor", form => qq{ item_id=${t}::$c ui_return_to=$page ui_return_to=item_id=$CGI->{item_id} ui_return_to=mv_return_table=$t } }); $meta .= 'meta'; $meta .= '
' . $Tag->page( { href => "$base/meta_editor", form => qq{ item_id=${t}::${c}::$key mv_data_table=$mtable ui_hide_key=1 ui_meta_view=metaconfig ui_return_to=$page ui_return_to=item_id=$CGI->{item_id} ui_return_to=mv_return_table=$t } }) . 'item-specific meta
' if $CGI->{ui_meta_specific}; $meta .= ''; } #unless ($label) { #$Document->write ($display); #next; #} $Document->write(< EOF $display =~ s/\~META\~/$meta/g; $Document->write($display); } %> [/mvasp]
x
   
x
Broken table '$table'
$LABEL$~META~
$WIDGET$ $HELP${HELPURL}
help{/HELPURL}
$break_label{$col}x
x
  [button text="Ok"] [return-to click] mv_todo=set mv_data_table=[cgi mv_data_table] [/button]     [if-mm tables =x]           [if !value ui_too_large] [if-mm super] Auto-export [else] [/else] [/if-mm] [/if] [/if-mm]
x
@_UI_STD_FOOTER_@