From b76b9b5f62567fc10377ef2be47972f79f1a2147 Mon Sep 17 00:00:00 2001 From: tetragon Date: Thu, 25 Oct 2007 00:36:53 +0000 Subject: Convert old template editor to templates Remove now-unused form_footer bin/am.pl now has all functions using templates or form functions for output git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1819 4979c152-3d1c-0410-bac9-87ea11338e46 --- UI/am-display-template.html | 20 ++++++ UI/am-edit-template.html | 22 +++++++ bin/am.pl | 157 +++++++++++++------------------------------- 3 files changed, 86 insertions(+), 113 deletions(-) create mode 100644 UI/am-display-template.html create mode 100644 UI/am-edit-template.html diff --git a/UI/am-display-template.html b/UI/am-display-template.html new file mode 100644 index 00000000..62a6a871 --- /dev/null +++ b/UI/am-display-template.html @@ -0,0 +1,20 @@ + + + + +
+
+ 'hidden', + name => hidden, + value => hiddens.item(hidden) + }; END ?> + +
+ + + diff --git a/UI/am-edit-template.html b/UI/am-edit-template.html new file mode 100644 index 00000000..8d596098 --- /dev/null +++ b/UI/am-edit-template.html @@ -0,0 +1,22 @@ + + + +
+ 'body', + rows => 25, + cols => 70, + text => form.body, + } ?> +
+ 'hidden', + name => hidden, + value => hiddens.item(hidden) + }; END ?> + +
+ + + diff --git a/bin/am.pl b/bin/am.pl index 581a19a0..0eab19c5 100644 --- a/bin/am.pl +++ b/bin/am.pl @@ -180,50 +180,6 @@ sub form_footer_buttons { ## } } -sub form_footer { - - $form->hide_form(qw(callback path login sessionid)); - - # type=submit $locale->text('Save') - # type=submit $locale->text('Save as new') - # type=submit $locale->text('Delete') - - %button = (); - - if ( $form->{id} ) { - $button{'save'} = - { ndx => 3, key => 'S', value => $locale->text('Save') }; - $button{'save_as_new'} = - { ndx => 7, key => 'N', value => $locale->text('Save as new') }; - - if ( $form->{orphaned} ) { - $button{'delete'} = - { ndx => 16, key => 'D', value => $locale->text('Delete') }; - } - } - else { - $button{'save'} = - { ndx => 3, key => 'S', value => $locale->text('Save') }; - } - - for ( sort { $button{$a}->{ndx} <=> $button{$b}->{ndx} } keys %button ) { - $form->print_button( \%button, $_ ); - } - - if ( $form->{lynx} ) { - require "bin/menu.pl"; - &menubar; - } - - print qq| - - - - -|; - -} - sub save_account { $form->isblank( "accno", $locale->text('Account Number missing!') ); @@ -1427,6 +1383,7 @@ sub list_templates { sub display_form { + my %hiddens; AM->load_template( \%myconfig, \%$form ); $form->{title} = $form->{file}; @@ -1434,91 +1391,65 @@ sub display_form { $form->{body} =~ s/<%include (.*?)%>/{script}\?action=display_form&file=$myconfig{templates}\/$form->{code}\/$1&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}>$1<\/a>/g; - # if it is anything but html - if ( $form->{file} !~ /\.html$/ ) { - $form->{body} = "
\n$form->{body}\n
"; - } - - $form->header; - - print qq| - - -$form->{body} - -
{script}> -|; - $form->{type} = "template"; + $hiddens{$_} = $form->{$_} foreach qw(file type path login sessionid); - $form->hide_form(qw(file type path login sessionid)); - - print qq| -|; - - if ( $form->{lynx} ) { - require "bin/menu.pl"; - &menubar; - } - - print qq| -
- - - -|; +##SC: Temporary commenting +## if ( $form->{lynx} ) { +## require "bin/menu.pl"; +## &menubar; +## } + my @buttons = ({ + name => 'action', + value => 'edit', + text => $locale->text('Edit Template'), + }); + my $template = LedgerSMB::Template->new_UI( + user => \%myconfig, + locale => $locale, + template => 'am-display-template'); + $template->render({ + form => $form, + buttons => \@buttons, + hiddens => \%hiddens, + }); } sub edit_template { AM->load_template( \%myconfig, \%$form ); + my %hiddens; $form->{title} = $locale->text('Edit Template'); # convert   to &nbsp; $form->{body} =~ s/ /&nbsp;/gi; - $form->header; - - print qq| - - -
{script}> - -{file}> - - -{path}> -{login}> -{sessionid}> - - + $hiddens{type} = 'template'; + $hiddens{$_} = $form->{$_} foreach qw(file path login sessionid); + $hiddens{callback} = qq|$form->{script}?action=display_form&file=$form->{file}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}|; - - -
-|; - - if ( $form->{lynx} ) { - require "bin/menu.pl"; - &menubar; - } - - print q| -
- - - - -|; +##SC: Temporary commenting +## if ( $form->{lynx} ) { +## require "bin/menu.pl"; +## &menubar; +## } + my @buttons = ({ + name => 'action', + value => 'save', + text => $locale->text('Save Template'), + }); + my $template = LedgerSMB::Template->new_UI( + user => \%myconfig, + locale => $locale, + template => 'am-edit-template'); + $template->render({ + form => $form, + buttons => \@buttons, + hiddens => \%hiddens, + }); } sub save_template { -- cgit v1.2.3