}
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];
#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;
use SL::Template::LaTeX;
use SL::Template::OpenDocument;
use SL::Template::PlainText;
+use SL::Template::ShellCommand;
use SL::Template::XML;
sub create {
--- /dev/null
+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;
-<!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
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.
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) 19yy <name of author>
+ <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
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
- <signature of Ty Coon>, 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
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>
-
######################################################################
-# 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
#
<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ändern</a></li>
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 <%if cp_phone2%><%cp_phone2%><%else%><%cp_phone1%><%end%></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ändern</a></h2>