[set page_title]Edit Page[/set] [set ui_class]Content[/set] [set help_name]page.main[/set] [set icon_name]admin/icon_pages.gif[/set] @_UI_STD_HEAD_@
[perl tables="__UI_META_TABLE__"] my $ref; my $ref_in_page; my $t_name = ''; my @filters = grep /^ui_filter:/, keys %$CGI; foreach my $key (@filters) { my $val = delete $CGI->{$key}; $key =~ s/ui_filter://; next unless $val; next unless defined $CGI->{$key}; $CGI->{$key} = $Tag->filter($val, $CGI->{$key}, $key); } if($CGI->{ui_template}) { #Log("reading template=$CGI->{ui_template}"); $CGI->{ui_template} = $Tag->filter('filesafe', $CGI->{ui_template}); my ($ary) = $Tag->read_ui_template($CGI->{ui_template}); $ref = shift @$ary || {}; $t_name = $CGI->{ui_template}; $t_desc = $ref->{ui_template_description} || 'none'; } #Log("t_name=$t_name"); my @choices = split /\s*\0\s*/, $CGI->{ui_page}; my $page; for(@choices) { next if ! $_; $page = $_; $page .= $Config->{HTMLsuffix} if $page !~ /$Config->{HTMLsuffix}$/; $page = "pages/$page" if $page !~ m(^pages/); last; } my $ary; my $current = $Tag->file($page); delete $CGI->{save_in_page}; # This call returns an array of hashes if exists if(! $ref and $current) { # Force array context for return value (wantarray test) ($ary) = $Tag->read_ui_template($page); if(ref $ary) { my $refp = shift (@$ary); if($refp->{ui_template_name} and ! $refp->{ui_template_layout}) { # Force array context for return value (wantarray test) ($ary) = $Tag->read_ui_template("templates/$refp->{ui_template_name}"); if(ref $ary) { $ref = shift @$ary || {}; } else { $ref = $refp; } } else { $ref = $refp; $CGI->{save_in_page} = 'CHECKED'; } } } $ref = {} if ! $ref; length($current) and $current !~ m{\n(.*)\n}is and $current = "$current"; $t_name = $ref->{ui_template_name} || 'None' if ! $t_name; $t_desc = $ref->{ui_template_description} || 'n/a' if ! $t_desc; my @def; my $def_string = $ref->{ui_definition}; $def_string =~ s/"/"/g; my $short_def = "ui_template: Yes\nui_template_name: $ref->{ui_template_name}"; my $r; #Log("ui_control_element=$ref->{ui_control_element}"); if ($r = $ref->{ui_control_element} and ref($r)) { my $widget; my @order; if($ref->{ui_display_order}) { @order = @{$ref->{ui_display_order}}; } else { @order = sort keys %$r; } for(@order) { my ($set) = $current =~ m{\[set\s+$_\](.*?)\[/set\]}; my $t_set = $r->{$_}; my $wtype = $ref->{ui_control_widget}{$_} || ''; if($wtype eq 'break') { push @controls, ['break']; next; } my $options = $ref->{ui_control_options}{$_} || $t_set || '=No,1=Yes'; #Log("r key $_ set='$set' options=$options value=$Values->{qq!ui_control_$_!}"); my $help = $ref->{ui_control_help}{$_} || ''; if($wtype) { $widget = $Tag->widget( { name => "ui_control_$_", type => $wtype, passed => $options, rows => $ref->{ui_control_height}{$_}, cols => $ref->{ui_control_width}{$_}, set => $set, filter => $ref->{ui_control_filter}{$_}, pre_filter => $ref->{ui_control_prefilter}{$_}, }); } else { my $val = $set || $t_set; $val =~ s/"/"/g; $widget = qq{}; } my $desc = $ref->{ui_control_description}{$_} || $_; $desc .= "
$help" if $help; push @controls, [ $desc, $widget ]; } } my $out = ''; my $imgpath = $Tag->var('UI_IMG', 1) || $Variable->{UI_IMG} || ''; #Log("t_name=$t_name"); $out .= < EOF if($CGI->{ui_show_description}) { $out .= < EOF } else { $out .= <[0] eq 'break') { $out .= < EOF next; } $out .= qq{}; } my $content_input; my $isfile = $Tag->value_extended( { name => 'ui_upload_content', test => 'isfile', } ); #Log("upload_content=$Values->{ui_upload_content} isfile=$isfile"); if( $Values->{ui_upload_content} and $Tag->value_extended( { name => 'ui_upload_content', test => 'isfile', } ) ) { #Log("content from upload."); $content_input = $Tag->value_extended( { name => 'ui_upload_content', file_contents => 1, }); #Log("content from upload is:\n$content_input"); $content_input =~ s{()([^\n])}{$1\n$2}is; $content_input =~ s{([^\n])()}{$1\n$2}is; } $content = $content_input || $current || ''; $content =~ m{\n(.*)\n}is and $content = $1; $content =~ s/\&/\&/g; $content =~ s/\[/[/g; $content =~ s/{ui_template_layout} = 'UI_CONTENT' if ! $ref->{ui_template_layout}; $out .= < [comment] [/comment] EOF $out .= < EOF return $out; [/perl]
Page file $page
Template
Template description $t_desc
Template sequence
$ref->{ui_template_layout}
UI_CONTENT is the content portion(s), all others refer to Knar elements.
$_->[0]$_->[1]
Content

download $pagedownload content
(will not reflect changes below unless saved)

[button text="Upload content portion from file"] mv_todo=return [js]onclick="this.form.target='_self'"[/js] mv_nextpage=@@MV_PAGE@@ [/button]
or input below:
[set Preview] mv_nextpage=__UI_BASE__/page_preview mv_action=back [/set] [set Save] mv_nextpage=__UI_BASE__/page_save [/set] [set Cancel] mv_nextpage=__UI_BASE__/page mv_todo=back [/set]
Save template in page
@_UI_STD_FOOTER_@