[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] @_UI_STD_DBEDIT_HEAD_@ [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] $ui_img = q{@_UI_IMG_@}; unless ($CGI->{ui_return_to}) { $CGI->{ui_return_to} = "[var MV_PAGE global]\0item_id=$Scratch->{arg}"; } @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="[scratch arg]"] [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 $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) { $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=$Scratch->{arg} ui_return_to=ui_return_table=$t } }); $meta .= 'meta'; $meta .= '
' . $Tag->page( { href => "$base/meta_editor", form => qq{ item_id=${t}::${c}::$key mv_data_table=mv_metadata ui_hide_key=1 ui_meta_view=metaconfig ui_return_to=$page ui_return_to=item_id=$Scratch->{arg} ui_return_to=ui_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]     [button text="Cancel"] mv_todo=return [return-to click] [/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_@