Auslagern des HTML-Codes aus login.pl in HTML-Vorlagen.
authorMoritz Bunkus <m.bunkus@linet-services.de>
Thu, 1 Nov 2007 16:58:51 +0000 (16:58 +0000)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Thu, 1 Nov 2007 16:58:51 +0000 (16:58 +0000)
SL/Template/Plugin/LxERP.pm
bin/mozilla/login.pl
locale/de/all
locale/de/login
templates/webpages/login/company_logo_de.html [new file with mode: 0644]
templates/webpages/login/company_logo_master.html [new file with mode: 0644]
templates/webpages/login/login_screen_de.html [new file with mode: 0644]
templates/webpages/login/login_screen_master.html [new file with mode: 0644]

index a97344a..ed2287b 100644 (file)
@@ -23,5 +23,14 @@ sub format_percent {
   return $self->format_amount($var * 100, $places, $skip_zero);
 }
 
+sub escape_br {
+  my ($self, $var) = @_;
+
+  $var =~ s/\r//g;
+  $var =~ s/\n/<br>/g;
+
+  return $var;
+}
+
 1;
 
index 7623bff..b9a29c3 100644 (file)
@@ -50,14 +50,14 @@ if (-f "bin/mozilla/$form->{login}_$form->{script}") {
 }
 
 # window title bar, user info
-$form->{titlebar} =
-  "Lx-Office " . $locale->text('Version') . " $form->{version}";
+$form->{titlebar} = "Lx-Office " . $locale->text('Version') . " $form->{version}";
 
 if ($form->{action}) {
   $form->{titlebar} .= " - $myconfig{name} - $myconfig{dbname}";
   call_sub($locale->findsub($form->{action}));
+
 } else {
-  &login_screen;
+  login_screen();
 }
 
 1;
@@ -72,59 +72,7 @@ sub login_screen {
   $form->{fokus} = "loginscreen.login";
   $form->header;
 
-  print qq|
-
-
-<body class=login onLoad="fokus()">
-
-<pre>
-
-</pre>
-
-<center>
-<table class=login border=3 cellpadding=20>
-  <tr>
-    <td class=login align=center><a href="http://www.lx-office.org" target=_top><img src="image/lx-office-erp.png" border=0></a>
-<h1 class=login align=center>|
-    . $locale->text('Version') . qq| $form->{version}
-</h1>
-
-<p>
-
-<form method=post name=loginscreen action=$form->{script}>
-
-  <input type="hidden" name="show_dbupdate_warning" value="1">
-
-      <table width=100%>
-       <tr>
-         <td align=center>
-           <table>
-             <tr>
-               <th align=right>| . $locale->text('Login Name') . qq|</th>
-               <td><input class=login name=login size=30 tabindex="1"></td>
-             </tr>
-             <tr>
-               <th align=right>| . $locale->text('Password') . qq|</th>
-               <td><input class=login type=password name=password size=30 tabindex="2"></td>
-             </tr>
-           </table>
-
-           <br>
-           <input type=submit name=action value="| . $locale->text('Login') . qq|" tabindex="3">
-
-         </td>
-       </tr>
-      </table>
-
-</form>
-
-    </td>
-  </tr>
-</table>
-
-</body>
-</html>
-|;
+  print $form->parse_html_template('login/login_screen');
 
   $lxdebug->leave_sub();
 }
@@ -132,39 +80,30 @@ sub login_screen {
 sub login {
   $lxdebug->enter_sub();
 
-  $form->error($locale->text('You did not enter a name!'))
-    unless ($form->{login});
+  $form->error($locale->text('You did not enter a name!')) unless ($form->{login});
 
   $user = new User $memberfile, $form->{login};
 
   # if we get an error back, bale out
-  if (($errno = $user->login(\%$form, $userspath)) <= -1) {
-    $errno *= -1;
-    $err[1] = $err[3] = $locale->text('Incorrect username or password!');
-
-    if ($errno == 2) {
+  if (($result = $user->login(\%$form, $userspath)) <= -1) {
+    if ($result == -2) {
       exit;
     }
 
-    $form->error($err[$errno]);
+    $form->error($locale->text('Incorrect username or password!'));
   }
 
+  my %style_to_script_map = ( 'v3'  => 'v3',
+                              'neu' => 'new',
+                              'xml' => 'XML',
+    );
+
+  my $menu_script = $style_to_script_map{$user->{menustyle}} || '';
+
   # made it this far, execute the menu
-  if ($user->{menustyle} eq "v3") {
-    $form->{callback} =
-      "menuv3.pl?login=$form->{login}&password=$form->{password}&action=display";
-  } elsif ($user->{menustyle} eq "neu") {
-    $form->{callback} =
-      "menunew.pl?login=$form->{login}&password=$form->{password}&action=display";
-  } elsif ($user->{menustyle} eq "xml") {
-    $form->{callback} =
-      "menuXML.pl?login=$form->{login}&password=$form->{password}&action=display";
-  } else {
-    $form->{callback} =
-      "menu.pl?login=$form->{login}&password=$form->{password}&action=display";
-  }
+  $form->{callback} = build_std_url("script=menu${menu_script}.pl", 'action=display');
 
-  $form->redirect;
+  $form->redirect();
 
   $lxdebug->leave_sub();
 }
@@ -185,64 +124,16 @@ sub company_logo {
   $lxdebug->enter_sub();
 
   require "$userspath/$form->{login}.conf";
-  $locale = new Locale $myconfig{countrycode}, "login"
-    unless ($language eq $myconfig{countrycode});
 
-  $myconfig{address} =~ s/\\n/<br>/g;
-  $myconfig{dbhost} = $locale->text('localhost') unless $myconfig{dbhost};
+  $locale             =  new Locale $myconfig{countrycode}, "login" if ($language ne $myconfig{countrycode});
 
-  $form->{stylesheet} = $myconfig{stylesheet};
-
-  $form->{title} = $locale->text('About');
+  $form->{stylesheet} =  $myconfig{stylesheet};
+  $form->{title}      =  $locale->text('About');
 
   # create the logo screen
-  $form->header unless $form->{noheader};
-
-  print qq|
-<body>
-<center>
-<a href="http://www.lx-office.org" target=_top><img src="image/lx-office-erp.png" border=0></a>
-<h2 class=login>| . $locale->text('Version') . qq| $form->{version}</h2>
-
-| . $locale->text('Licensed to') . qq|
-<p>
-<b>
-$myconfig{company}
-<br>$myconfig{address}
-</b>
-
-
-<br>
-<table border=0>
-  <tr>
-    <th align=left>| . $locale->text('User') . qq|</th>
-    <td>$myconfig{name}</td>
-  </tr>
-  <tr>
-    <th align=left>| . $locale->text('Dataset') . qq|</th>
-    <td>$myconfig{dbname}</td>
-  </tr>
-  <tr>
-    <th align=left>| . $locale->text('Database Host') . qq|</th>
-    <td>$myconfig{dbhost}</td>
-  </tr>
-  <tr>
-  </tr>
-  <tr>
-  </tr>
-  <tr>
-    <th colspan="2" align="center"><a href="http://lx-office.org" target="blank">http://lx-office.org</a></th>
-  </tr>
-  <tr>
-    <th colspan="2" align="center"><a href="mailto:info&#064;lx-office.org" target="blank">info&#064;lx-office.org</a></th>
-  </tr>
-</table>
-
-</center>
-
-</body>
-</html>
-|;
+  $form->header() unless $form->{noheader};
+
+  print $form->parse_html_template('login/company_logo');
 
   $lxdebug->leave_sub();
 }
index 1e3c86c..a5c3409 100644 (file)
@@ -1341,7 +1341,6 @@ aktualisieren wollen?',
   'list_of_payments'            => 'zahlungsausgaenge',
   'list_of_receipts'            => 'zahlungseingaenge',
   'list_of_transactions'        => 'buchungsliste',
-  'localhost'                   => 'lokaler Rechner',
   'logout'                      => 'abmelden',
   'mark as paid'                => 'als bezahlt markieren',
   'month'                       => 'Monatliche Abgabe',
index 369113a..cbcfd02 100644 (file)
@@ -13,8 +13,6 @@ $self->{texts} = {
   'Customer details'            => 'Kundendetails',
   'DELETED'                     => 'Gelöscht',
   'DUNNING STARTED'             => 'Mahnprozess gestartet',
-  'Database Host'               => 'Datenbankcomputer',
-  'Dataset'                     => 'Datenbank',
   'Dataset upgrade'             => 'Datenbankaktualisierung',
   'Date'                        => 'Datum',
   'Dependency loop detected:'   => 'Schleife in den Abh&auml;ngigkeiten entdeckt:',
@@ -26,9 +24,6 @@ $self->{texts} = {
   'History'                     => 'Historie',
   'Incorrect username or password!' => 'Ungültiger Benutzername oder falsches Passwort!',
   'Invoice'                     => 'Rechnung',
-  'Licensed to'                 => 'Lizensiert für',
-  'Login'                       => 'Anmeldung',
-  'Login Name'                  => 'Benutzername',
   'MAILED'                      => 'Gesendet',
   'Mark as paid?'               => 'Als bezahlt markieren?',
   'Marked as paid'              => 'Als bezahlt markiert',
@@ -52,7 +47,6 @@ $self->{texts} = {
   'Packing List'                => 'Lieferschein',
   'Part Number'                 => 'Artikelnummer',
   'Part description'            => 'Artikelbeschreibung',
-  'Password'                    => 'Passwort',
   'Pick List'                   => 'Sammelliste',
   'Please enter values'         => 'Bitte Werte eingeben',
   'Proforma Invoice'            => 'Proformarechnung',
@@ -76,7 +70,6 @@ $self->{texts} = {
   'Trying to call a sub without a name' => 'Es wurde versucht, eine Unterfunktion ohne Namen aufzurufen.',
   'Unit'                        => 'Einheit',
   'Unknown dependency \'%s\'.'  => 'Unbekannte Abh&auml;ngigkeit \'%s\'.',
-  'User'                        => 'Benutzer',
   'Value'                       => 'Wert',
   'Variable'                    => 'Variable',
   'Vendor details'              => 'Lieferantendetails',
@@ -86,7 +79,6 @@ $self->{texts} = {
   '[email]'                     => '[email]',
   'bin_list'                    => 'Lagerliste',
   'invoice'                     => 'Rechnung',
-  'localhost'                   => 'lokaler Rechner',
   'no'                          => 'nein',
   'packing_list'                => 'Versandliste',
   'pick_list'                   => 'Entnahmeliste',
diff --git a/templates/webpages/login/company_logo_de.html b/templates/webpages/login/company_logo_de.html
new file mode 100644 (file)
index 0000000..6934db9
--- /dev/null
@@ -0,0 +1,48 @@
+[% USE HTML %][% USE LxERP %]<body>
+ [%- DEFAULT myconfig_dbhost = 'localhost' %]
+
+ <center>
+  <a href="http://www.lx-office.org" target="_top"><img src="image/lx-office-erp.png" border="0"></a>
+
+  <h2 class="login">Version [% version %]</h2>
+
+  <p>Lizensiert für</p>
+
+  <p>
+   <b>
+    [% HTML.escape(myconfig_company) %]
+    <br>
+    [% HTML.escape(myconfig_address).replace('\\\\n', '<br>') %]
+   </b>
+
+   <br>
+
+   <table border="0">
+    <tr>
+     <th align="left">Benutzer</th>
+     <td>[% HTML.escape(myconfig_name) %]</td>
+    </tr>
+    <tr>
+     <th align="left">Datenbank</th>
+     <td>[% HTML.escape(myconfig_dbname) %]</td>
+    </tr>
+    <tr>
+     <th align="left">Datenbankcomputer</th>
+     <td>[% HTML.escape(myconfig_dbhost) %]</td>
+    </tr>
+    <tr>
+    </tr>
+    <tr>
+    </tr>
+    <tr>
+     <th colspan="2" align="center"><a href="http://lx-office.org" target="blank">http://lx-office.org</a></th>
+    </tr>
+    <tr>
+     <th colspan="2" align="center"><a href="mailto:info&#064;lx-office.org" target="blank">info&#064;lx-office.org</a></th>
+    </tr>
+   </table>
+
+ </center>
+
+</body>
+</html>
diff --git a/templates/webpages/login/company_logo_master.html b/templates/webpages/login/company_logo_master.html
new file mode 100644 (file)
index 0000000..4af1057
--- /dev/null
@@ -0,0 +1,48 @@
+[% USE HTML %][% USE LxERP %]<body>
+ [%- DEFAULT myconfig_dbhost = 'localhost' %]
+
+ <center>
+  <a href="http://www.lx-office.org" target="_top"><img src="image/lx-office-erp.png" border="0"></a>
+
+  <h2 class="login"><translate>Version</translate> [% version %]</h2>
+
+  <p><translate>Licensed to</translate></p>
+
+  <p>
+   <b>
+    [% HTML.escape(myconfig_company) %]
+    <br>
+    [% HTML.escape(myconfig_address).replace('\\\\n', '<br>') %]
+   </b>
+
+   <br>
+
+   <table border="0">
+    <tr>
+     <th align="left"><translate>User</translate></th>
+     <td>[% HTML.escape(myconfig_name) %]</td>
+    </tr>
+    <tr>
+     <th align="left"><translate>Dataset</translate></th>
+     <td>[% HTML.escape(myconfig_dbname) %]</td>
+    </tr>
+    <tr>
+     <th align="left"><translate>Database Host</translate></th>
+     <td>[% HTML.escape(myconfig_dbhost) %]</td>
+    </tr>
+    <tr>
+    </tr>
+    <tr>
+    </tr>
+    <tr>
+     <th colspan="2" align="center"><a href="http://lx-office.org" target="blank">http://lx-office.org</a></th>
+    </tr>
+    <tr>
+     <th colspan="2" align="center"><a href="mailto:info&#064;lx-office.org" target="blank">info&#064;lx-office.org</a></th>
+    </tr>
+   </table>
+
+ </center>
+
+</body>
+</html>
diff --git a/templates/webpages/login/login_screen_de.html b/templates/webpages/login/login_screen_de.html
new file mode 100644 (file)
index 0000000..4000362
--- /dev/null
@@ -0,0 +1,44 @@
+[% USE HTML %]<body class="login" onLoad="fokus()">
+
+ <center>
+  <table class="login" border="3" cellpadding="20">
+   <tr>
+    <td class="login" align="center">
+     <a href="http://www.lx-office.org" target="_top"><img src="image/lx-office-erp.png" border="0"></a>
+     <h1 class="login" align="center">Version [% version %]</h1>
+
+     <p>
+
+      <form method="post" name="loginscreen" action="login.pl">
+
+       <input type="hidden" name="show_dbupdate_warning" value="1">
+
+       <table width="100%">
+        <tr>
+         <td align="center">
+          <table>
+           <tr>
+            <th align="right">Benutzername</th>
+            <td><input class="login" name="login" size="30" tabindex="1"></td>
+           </tr>
+           <tr>
+            <th align="right">Passwort</th>
+            <td><input class="login" type="password" name="password" size="30" tabindex="2"></td>
+           </tr>
+          </table>
+
+          <br>
+          <input type="submit" name="action" value="Anmeldung" tabindex="3">
+
+         </td>
+        </tr>
+       </table>
+
+      </form>
+
+    </td>
+   </tr>
+  </table>
+
+</body>
+</html>
diff --git a/templates/webpages/login/login_screen_master.html b/templates/webpages/login/login_screen_master.html
new file mode 100644 (file)
index 0000000..db6eb83
--- /dev/null
@@ -0,0 +1,44 @@
+[% USE HTML %]<body class="login" onLoad="fokus()">
+
+ <center>
+  <table class="login" border="3" cellpadding="20">
+   <tr>
+    <td class="login" align="center">
+     <a href="http://www.lx-office.org" target="_top"><img src="image/lx-office-erp.png" border="0"></a>
+     <h1 class="login" align="center"><translate>Version</translate> [% version %]</h1>
+
+     <p>
+
+      <form method="post" name="loginscreen" action="login.pl">
+
+       <input type="hidden" name="show_dbupdate_warning" value="1">
+
+       <table width="100%">
+        <tr>
+         <td align="center">
+          <table>
+           <tr>
+            <th align="right"><translate>Login Name</translate></th>
+            <td><input class="login" name="login" size="30" tabindex="1"></td>
+           </tr>
+           <tr>
+            <th align="right"><translate>Password</translate></th>
+            <td><input class="login" type="password" name="password" size="30" tabindex="2"></td>
+           </tr>
+          </table>
+
+          <br>
+          <input type="submit" name="action" value="<translate>Login</translate>" tabindex="3">
+
+         </td>
+        </tr>
+       </table>
+
+      </form>
+
+    </td>
+   </tr>
+  </table>
+
+</body>
+</html>