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

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



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

Log Message:
-----------
Convert language forms to templates

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

Added Paths:
-----------
    trunk/UI/am-language-form.html

Added: trunk/UI/am-language-form.html
===================================================================
--- trunk/UI/am-language-form.html	                        (rev 0)
+++ trunk/UI/am-language-form.html	2007-10-24 21:36:16 UTC (rev 1813)
@@ -0,0 +1,33 @@
+<?lsmb INCLUDE 'ui-header.html' ?> 
+<?lsmb PROCESS elements.html ?> 
+<body>
+<form method="post" action="<?lsmb form.script ?>">
+<table width="100%">
+  <tr><th class="listtop"><?lsmb form.title ?></th></tr>
+  <tr><td> </td></tr>
+  <tr>
+    <td>
+      <table>
+        <tr>
+          <th align="right"><?lsmb text('Code') ?></th>
+	  <td><?lsmb PROCESS input element_data={name => 'code', size => 10, value => form.code} ?></td>
+        </tr>
+        <tr>
+          <th align="right"><?lsmb text('Description') ?></th>
+          <td><?lsmb PROCESS input element_data={name => 'description', size => 60, value => form.description} ?></td>
+        </tr>
+      </table>
+    </td>
+  </tr>
+  <tr><td colspan="2"><hr size="3" noshade="noshade" /></td></tr>
+</table>
+<?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-24 20:47:25 UTC (rev 1812)
+++ trunk/bin/am.pl	2007-10-24 21:36:16 UTC (rev 1813)
@@ -1135,9 +1135,21 @@
 "$form->{script}?action=add_language&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"
       unless $form->{callback};
 
-    &language_header;
-    &form_footer;
+    my %hiddens;
+    my @buttons;
+    &language_header(\%hiddens);
+    &form_footer_buttons(\%hiddens, ..hidden..);
 
+    my $template = LedgerSMB::Template->new_UI(
+        user => \%myconfig, 
+        locale => $locale,
+        template => 'am-language-form');
+    $template->render({
+        form => $form,
+        buttons => ..hidden..,
+        hiddens => \%hiddens,
+    });
+
 }
 
 sub edit_language {
@@ -1149,11 +1161,22 @@
 
     AM->get_language( \%myconfig, \%$form );
     $form->{id} = $form->{code};
+    $form->{orphaned} = 1;
 
-    &language_header;
+    my %hiddens;
+    my @buttons;
+    &language_header(\%hiddens);
+    &form_footer_buttons(\%hiddens, ..hidden..);
 
-    $form->{orphaned} = 1;
-    &form_footer;
+    my $template = LedgerSMB::Template->new_UI(
+        user => \%myconfig, 
+        locale => $locale,
+        template => 'am-language-form');
+    $template->render({
+        form => $form,
+        buttons => ..hidden..,
+        hiddens => \%hiddens,
+    });
 
 }
 
@@ -1233,6 +1256,7 @@
 }
 
 sub language_header {
+    my $hiddens = shift;
 
     $form->{title} = $locale->text("$form->{title} Language");
 
@@ -1241,34 +1265,8 @@
 
     for (qw(code description)) { $form->{$_} = $form->quote( $form->{$_} ) }
 
-    $form->header;
-
-    print qq|
-<body>
-
-<form method=post action=$form->{script}>
-
-<input type=hidden name=type value=language>
-<input type=hidden name=id value="$form->{code}">
-
-<table width=100%>
-  <tr>
-    <th class=listtop colspan=2>$form->{title}</th>
-  </tr>
-  <tr height="5"></tr>
-  <tr>
-    <th align="right">| . $locale->text('Code') . qq|</th>
-    <td><input name=code size=10 value="$form->{code}"></td>
-  <tr>
-  <tr>
-    <th align="right">| . $locale->text('Description') . qq|</th>
-    <td><input name=description size=60 value="$form->{description}"></td>
-  </tr>
-    <td colspan=2><hr size=3 noshade></td>
-  </tr>
-</table>
-|;
-
+    $hiddens->{type} = 'language';
+    $hiddens->{id} = $form->{code};
 }
 
 sub save_language {
@@ -1322,40 +1320,27 @@
 sub delete_language {
 
     $form->{title} = $locale->text('Confirm!');
-
-    $form->header;
-
-    print qq|
-<body>
-
-<form method=post action=$form->{script}>
-|;
-
     for (qw(action nextsub)) { delete $form->{$_} }
 
-    $form->hide_form;
-
-    print qq|
-<h2 class=confirm>$form->{title}</h2>
-
-<h4>|
-      . $locale->text(
+    my %hiddens;
+    $hiddens{$_} = $form->{$_} foreach keys %$form;
+    my @buttons = ({
+        name => 'action',
+        value => 'yes_delete_language',
+        text => $locale->text('Delete Language'),
+        });
+    my $template = LedgerSMB::Template->new_UI(
+        user => \%myconfig, 
+        locale => $locale,
+        template => 'form-confirmation');
+    $template->render({
+        form => $form,
+        buttons => ..hidden..,
+        hiddens => \%hiddens,
+        query => $locale->text(
 'Deleting a language will also delete the templates for the language [_1]',
-        $form->{invnumber}
-      )
-      . qq|</h4>
-
-<input type=hidden name=action value=continue>
-<input type=hidden name=nextsub value=yes_delete_language>
-<button name="action" class="submit" type="submit" value="continue">|
-      . $locale->text('Continue')
-      . qq|</button>
-</form>
-
-</body>
-</html>
-|;
-
+            $form->{id}),
+    });
 }
 
 sub yes_delete_language {


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