]> wagnertech.de Git - kivitendo-erp.git/commitdiff
Merge branch 'master' of vc.linet-services.de:public/lx-office-erp
authorSven Schöling <s.schoeling@linet-services.de>
Tue, 10 Jan 2012 10:57:29 +0000 (11:57 +0100)
committerSven Schöling <s.schoeling@linet-services.de>
Tue, 10 Jan 2012 10:57:29 +0000 (11:57 +0100)
SL/Form.pm
SL/Template.pm
SL/Template/ShellCommand.pm [new file with mode: 0644]
doc/COPYING
doc/copyright
doc/dbschema.dia [deleted file]
doc/dokumentenvorlagen-und-variablen.html

index 58b1973aacfc53e5045b70a89052143ab886bd77..529426ec2cd9277b322bb01771b2172cc39970f2 100644 (file)
@@ -1113,8 +1113,13 @@ sub parse_template {
   }
 
   my $result;
+  my $command_formatter = sub {
+    my ($out_mode, $out) = @_;
+    return $out_mode eq '|-' ? SL::Template::create(type => 'ShellCommand', form => $self)->parse($out) : $out;
+  };
 
   if ($self->{OUT}) {
+    $self->{OUT} = $command_formatter->($self->{OUT_MODE}, $self->{OUT});
     open(OUT, $self->{OUT_MODE}, $self->{OUT}) or $self->error("error on opening $self->{OUT} with mode $self->{OUT_MODE} : $!");
   } else {
     *OUT = ($::dispatcher->get_standard_filehandles)[1];
@@ -1199,6 +1204,8 @@ sub parse_template {
       #print(STDERR "OUT $self->{OUT}\n");
       for my $i (1 .. $self->{copies}) {
         if ($self->{OUT}) {
+          $self->{OUT} = $command_formatter->($self->{OUT_MODE}, $self->{OUT});
+
           open  OUT, $self->{OUT_MODE}, $self->{OUT} or $self->error($self->cleanup . "$self->{OUT} : $!");
           print OUT $_ while <IN>;
           close OUT;
index df18e706ea971878862c71463bed22d76973ba84..ab499e99d289e43ae600ff1701f2848d9adc26c1 100644 (file)
@@ -16,6 +16,7 @@ use SL::Template::HTML;
 use SL::Template::LaTeX;
 use SL::Template::OpenDocument;
 use SL::Template::PlainText;
+use SL::Template::ShellCommand;
 use SL::Template::XML;
 
 sub create {
diff --git a/SL/Template/ShellCommand.pm b/SL/Template/ShellCommand.pm
new file mode 100644 (file)
index 0000000..0824129
--- /dev/null
@@ -0,0 +1,51 @@
+package SL::Template::ShellCommand;
+
+use parent qw(SL::Template::LaTeX);
+
+use strict;
+
+use String::ShellQuote;
+
+sub new {
+  my $type = shift;
+
+  return $type->SUPER::new(@_);
+}
+
+sub substitute_vars {
+  my ($self, $text, @indices) = @_;
+
+  my $form = $self->{"form"};
+
+  while ($text =~ /$self->{substitute_vars_re}/) {
+    my ($tag_pos, $tag_len) = ($-[0], $+[0] - $-[0]);
+    my ($var, @option_list) = split(/\s+/, $1);
+    my %options             = map { ($_ => 1) } @option_list;
+
+    my $value               = $self->_get_loop_variable($var, 0, @indices);
+    $value                  = $form->parse_amount({ numberformat => $::myconfig{output_numberformat} || $::myconfig{numberformat} }, $value) if $options{NOFORMAT};
+    $value                  = $self->format_string($value); # Don't allow NOESCAPE for arguments passed to shell commands.
+
+    substr($text, $tag_pos, $tag_len, $value);
+  }
+
+  return $text;
+}
+
+sub format_string {
+  my ($self, $variable) = @_;
+
+  return shell_quote_best_effort($variable);
+}
+
+sub get_mime_type {
+  return "text/plain";
+}
+
+sub parse {
+  my ($self, $text) = @_;
+
+  return $self->parse_block($text);
+}
+
+1;
index 083bb4150a6301e20dd3e0e8fa17932c2e97e794..7edebd1ea41d6baa58aa5088507dfe8b768a96ab 100644 (file)
@@ -1,13 +1,3 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
-<HTML>
-<HEAD>
-<TITLE>GNU General Public License</TITLE>
-</HEAD>
-
-<BODY BGCOLOR=ffffff>
-
-
-<pre>
                     GNU GENERAL PUBLIC LICENSE
                        Version 2, June 1991
 
@@ -301,8 +291,8 @@ to attach them to the start of each source file to most effectively
 convey the exclusion of warranty; and each file should have at least
 the "copyright" line and a pointer to where the full notice is found.
 
-    &lt;one line to give the program's name and a brief idea of what it does.&gt;
-    Copyright (C) 19yy  &lt;name of author&gt;
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) 19yy  <name of author>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -340,7 +330,7 @@ necessary.  Here is a sample; alter the names:
   Yoyodyne, Inc., hereby disclaims all copyright interest in the program
   `Gnomovision' (which makes passes at compilers) written by James Hacker.
 
-  &lt;signature of Ty Coon&gt;, 1 April 1989
+  <signature of Ty Coon>, 1 April 1989
   Ty Coon, President of Vice
 
 This General Public License does not permit incorporating your program into
@@ -348,8 +338,3 @@ proprietary programs.  If your program is a subroutine library, you may
 consider it more useful to permit linking proprietary applications with the
 library.  If this is what you want to do, use the GNU Library General
 Public License instead of this License.
-
-
-</BODY>
-</HTML>
-
index 70cdbabcf48683bcf3b25a8065f9806d2473b062..3b87ce78a27a37f59fa612cac94364dfe61c441b 100644 (file)
@@ -1,6 +1,6 @@
 ######################################################################
-# Lx-Office ERP                                                  
-# distributed from Linet Services GbR - Braunschweig
+# Lx-Office ERP
+# distributed from Linet Services GmbH - Braunschweig
 #
 # based von SQL-Ledger - Author: Dieter Simander
 #
diff --git a/doc/dbschema.dia b/doc/dbschema.dia
deleted file mode 100644 (file)
index 7d6eb07..0000000
Binary files a/doc/dbschema.dia and /dev/null differ
index 1009f31ffe3a3c19827cadb5c5ca8c6ba63103f5..e1dac111be62efa5429a829f9ed122474fcf2c84 100644 (file)
@@ -51,6 +51,9 @@ td {
   <li><a href="#variablen_ausgeben">Variablen ausgeben</a>
   </li>
 
+  <li><a href="#verwendung_in_druckbefehlen">Verwendung in Druckbefehlen</a>
+  </li>
+
   <li><a href="dokumentenvorlagen-und-variablen.html#tag_style">
     Anfang und Ende der Tags ver&auml;ndern</a></li>
 
@@ -229,6 +232,31 @@ td {
    zum Inhaltsverzeichnis</a></small><br>
  <hr>
 
+ <h2><a name="verwendung_in_druckbefehlen">Verwendung in Druckbefehlen</a></h2>
+
+ <p>
+  In der Admininstration können Drucker definiert werden. Auch im dort
+  eingebbaren Druckbefehl können die hier aufgelisteten Variablen und
+  Kontrollstrukturen verwendet werden. Ihr Inhalt wird dabei nach den
+  Regeln der gängigen Shells formatiert, sodass Sonderzeichen
+  wie <code>`...`</code> nicht zu unerwünschtem Verhalten führen.
+ </p>
+
+ <p>
+  Dies erlaubt z.B. die Definition eines Faxes als Druckerbefehl, für
+  das die Telefonnummer eines Ansprechpartners als Teil der
+  Kommandozeile verwendet wird. Für ein fiktives Kommando könnte das
+  z.B. wie folgt aussehen:
+ </p>
+
+ <p>
+  <code>send_fax --number &lt;%if cp_phone2%&gt;&lt;%cp_phone2%&gt;&lt;%else%&gt;&lt;%cp_phone1%&gt;&lt;%end%&gt;</code>
+ </p>
+
+ <small><a href="dokumentenvorlagen-und-variablen.html#inhaltsverzeichnis">
+   zum Inhaltsverzeichnis</a></small><br>
+ <hr>
+
  <h2><a name="tag_style">
    Anfang und Ende der Tags ver&auml;ndern</a></h2>