[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb: [1819] trunk



Revision: 1819
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=1819&view=rev
Author:   tetragon
Date:     2007-10-24 17:36:53 -0700 (Wed, 24 Oct 2007)

Log Message:
-----------
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

Modified Paths:
--------------
    trunk/bin/am.pl

Added Paths:
-----------
    trunk/UI/am-display-template.html
    trunk/UI/am-edit-template.html

Added: trunk/UI/am-display-template.html
===================================================================
--- trunk/UI/am-display-template.html	                        (rev 0)
+++ trunk/UI/am-display-template.html	2007-10-25 00:36:53 UTC (rev 1819)
@@ -0,0 +1,20 @@
+<?lsmb INCLUDE 'ui-header.html' ?> 
+<?lsmb PROCESS elements.html ?> 
+<body>
+<?lsmb IF !form.file.match('\.html$'); #Pre-enclose non-HTML templates ?>
+<pre><?lsmb form.body ?></pre><?lsmb 
+ELSE;
+    form.body;
+END ?>
+<form method="post" action="<?lsmb form.script ?>">
+<?lsmb FOREACH hidden IN hiddens.keys;
+	PROCESS input element_data={
+		type => 'hidden',
+		name => hidden,
+		value => hiddens.item(hidden)
+		}; END ?>
+<?lsmb FOREACH button IN buttons; PROCESS button element_data=button; END ?>
+</form>
+</body>
+</html>
+

Added: trunk/UI/am-edit-template.html
===================================================================
--- trunk/UI/am-edit-template.html	                        (rev 0)
+++ trunk/UI/am-edit-template.html	2007-10-25 00:36:53 UTC (rev 1819)
@@ -0,0 +1,22 @@
+<?lsmb INCLUDE 'ui-header.html' ?> 
+<?lsmb PROCESS elements.html ?> 
+<body>
+<form method="post" action="<?lsmb form.script ?>">
+  <?lsmb PROCESS textarea element_data={
+  name => 'body',
+  rows => 25,
+  cols => 70,
+  text => form.body,
+  } ?>
+<br />
+<?lsmb FOREACH hidden IN hiddens.keys;
+	PROCESS input element_data={
+		type => 'hidden',
+		name => hidden,
+		value => hiddens.item(hidden)
+		}; END ?>
+<?lsmb FOREACH button IN buttons; PROCESS button element_data=button; END ?>
+</form>
+</body>
+</html>
+

Modified: trunk/bin/am.pl
===================================================================
--- trunk/bin/am.pl	2007-10-25 00:14:07 UTC (rev 1818)
+++ trunk/bin/am.pl	2007-10-25 00:36:53 UTC (rev 1819)
@@ -180,50 +180,6 @@
 ##    }
 }
 
-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|
-</form>
-
-</body>
-</html>
-|;
-
-}
-
 sub save_account {
 
     $form->isblank( "accno",    $locale->text('Account Number missing!') );
@@ -1427,6 +1383,7 @@
 
 sub display_form {
 
+    my %hiddens;
     AM->load_template( \%myconfig, \%$form );
 
     $form->{title} = $form->{file};
@@ -1434,91 +1391,65 @@
     $form->{body} =~
 s/<%include (.*?)%>/<a href=$form->{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} = "<pre>\n$form->{body}\n</pre>";
-    }
-
-    $form->header;
-
-    print qq|
-<body>
-
-$form->{body}
-
-<form method=post action=$form->{script}>
-|;
-
     $form->{type} = "template";
+    $hiddens{$_} = $form->{$_} foreach qw(file type path login sessionid);
 
-    $form->hide_form(qw(file type path login sessionid));
+##SC: Temporary commenting
+##    if ( $form->{lynx} ) {
+##        require "bin/menu.pl";
+##        &menubar;
+##    }
 
-    print qq|
-<button name="action" type="submit" class="submit" value="edit">|
-      . $locale->text('Edit')
-      . qq|</button>|;
-
-    if ( $form->{lynx} ) {
-        require "bin/menu.pl";
-        &menubar;
-    }
-
-    print qq|
-  </form>
-
-</body>
-</html>
-|;
-
+    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 => ..hidden..,
+	hiddens => \%hiddens,
+    });
 }
 
 sub edit_template {
 
     AM->load_template( \%myconfig, \%$form );
+    my %hiddens;
 
     $form->{title} = $locale->text('Edit Template');
 
     # convert &nbsp to &amp;nbsp;
     $form->{body} =~ s/&nbsp;/&amp;nbsp;/gi;
 
-    $form->header;
+    $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}|;
 
-    print qq|
-<body>
+##SC: Temporary commenting
+##    if ( $form->{lynx} ) {
+##        require "bin/menu.pl";
+##        &menubar;
+##    }
 
-<form method=post action=$form->{script}>
-
-<input name=file type=hidden value=$form->{file}>
-<input name=type type=hidden value=template>
-
-<input type=hidden name=path value=$form->{path}>
-<input type=hidden name=login value=$form->{login}>
-<input type=hidden name=sessionid value=$form->{sessionid}>
-
-<input name=callback type=hidden value="$form->{script}?action=display_form&file=$form->{file}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}">
-
-<textarea name=body rows=25 cols=70>
-$form->{body}
-</textarea>
-
-<br>
-<button type="submit" class="submit" name="action" value="save">|
-      . $locale->text('Save')
-      . qq|</button>|;
-
-    if ( $form->{lynx} ) {
-        require "bin/menu.pl";
-        &menubar;
-    }
-
-    print q|
-  </form>
-
-
-</body>
-</html>
-|;
-
+    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 => ..hidden..,
+	hiddens => \%hiddens,
+    });
 }
 
 sub save_template {


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.