mirror of
https://github.com/smarty-php/smarty.git
synced 2025-11-02 13:21:36 +01:00
banana split
This commit is contained in:
105
docs/de/programmers/plugins/plugins-block-functions.xml
Normal file
105
docs/de/programmers/plugins/plugins-block-functions.xml
Normal file
@@ -0,0 +1,105 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="plugins.block.functions"><title>Block-Funktionen</title>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>void <function>smarty_function_<replaceable>name</replaceable></function></funcdef>
|
||||
<paramdef>array <parameter>$params</parameter></paramdef>
|
||||
<paramdef>mixed <parameter>$content</parameter></paramdef>
|
||||
<paramdef>object <parameter>&$smarty</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Block-Funktionen sind Funktionen, die in der Form {func} .. {/func} notiert
|
||||
werden. Mit anderen Worten umschliessen sie einen Template-Abschnitt und
|
||||
arbeiten danach auf dessen Inhalt. Eine Block-Funktion {func} .. {/func}
|
||||
kann nicht mir einer gleichnamigen Template-Funktion {func}
|
||||
überschrieben werden.
|
||||
</para>
|
||||
<para>
|
||||
Ihre Funktions-Implementation wird von Smarty zweimal
|
||||
aufgerufen: einmal für das öffnende und einmal
|
||||
für das schliessende Tag. (konsultieren Sie den Abschnitt zu <literal>&$repeat</literal>
|
||||
um zu erfahren wie Sie dies ändern können.)
|
||||
</para>
|
||||
<para>
|
||||
Nur das Öffnungs-Tag kann Attribute enthalten. Alle so übergebenen Attribute
|
||||
werden als assoziatives Array <parameter>$params</parameter> der Template-Funktion
|
||||
übergeben. Sie können auf die Werte entweder direkt mit <varname>$params['start']</varname>
|
||||
zugreifen oder sie mit <varname>extract($params)</varname> in die Symbol-Tabelle
|
||||
importieren. Die Attribute aus dem Öffnungs-Tag stehen auch beim Aufruf für das
|
||||
schliessende Tag zur Verfügung.
|
||||
</para>
|
||||
<para>
|
||||
Der Inhalt der <parameter>$content</parameter> Variable hängt davon
|
||||
ab, ob die Funktion für das öffnende Tag oder für das schliessende
|
||||
Tag aufgerufen wird. Für das öffnende Tag ist der Wert <literal>null</literal>,
|
||||
für das schliessende Tag ist es der Inhalt des Template-Abschnitts.
|
||||
Achtung: Der Template-Abschnitt den Sie erhalten, wurde bereits von
|
||||
Smarty bearbeitet. Sie erhalten also die Template-Ausgabe, nicht den Template-Quelltext.
|
||||
</para>
|
||||
<para>
|
||||
Der Parameter <parameter>&$repeat</parameter> wird als Referenz übergeben und
|
||||
kontrolliert wie oft ein Block dargestellt werden soll. Standardwert von <parameter>$repeat</parameter>
|
||||
ist beim ersten Aufruf (für das öffnende Tag) <literal>true</literal>, danach immer
|
||||
<literal>false</literal>.
|
||||
Jedes Mal wenn eine Funktion für <parameter>&$repeat</parameter> TRUE zurück gibt,
|
||||
wird der Inhalt zwischen {func} .. {/func} erneut mit dem veränderten
|
||||
Inhalt als <parameter>$content</parameter> Parameter aufgerufen.
|
||||
</para>
|
||||
<para>
|
||||
Wenn Sie verschachtelte Block-Funktionen haben, können Sie
|
||||
die Eltern-Block-Funktion mit der <varname>$smarty->_tag_stack</varname> Variable
|
||||
herausfinden. Lassen Sie sich ihren Inhalt mit 'var_dump()' ausgeben.
|
||||
Die Struktur sollte selbsterklärend sein.
|
||||
</para>
|
||||
<para>
|
||||
|
||||
Sehen Sie dazu:
|
||||
<link linkend="api.register.block">register_block()</link>,
|
||||
<link linkend="api.unregister.block">unregister_block()</link>.
|
||||
</para>
|
||||
<example>
|
||||
<title>Block-Funktionen</title>
|
||||
<programlisting>
|
||||
<?php
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
* File: block.translate.php
|
||||
* Type: block
|
||||
* Name: translate
|
||||
* Purpose: translate a block of text
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
function smarty_block_translate($params, $content, &$smarty)
|
||||
{
|
||||
if (isset($content)) {
|
||||
$lang = $params['lang'];
|
||||
|
||||
// den $content irgendwie intelligent übersetzuen
|
||||
return $translation;
|
||||
}
|
||||
}</programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
indent-tabs-mode:nil
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"../../../../manual.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:nil
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
-->
|
||||
86
docs/de/programmers/plugins/plugins-compiler-functions.xml
Normal file
86
docs/de/programmers/plugins/plugins-compiler-functions.xml
Normal file
@@ -0,0 +1,86 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="plugins.compiler.functions"><title>Compiler-Funktionen</title>
|
||||
<para>
|
||||
Compiler-Funktionen werden während der Kompilierung des Template
|
||||
aufgerufen. Das ist nützlich, um PHP-Code oder zeitkritische statische
|
||||
Inhalte in ein Template einzufügen. Sind eine Compiler-Funktion und
|
||||
eine eigene Funktion unter dem selben Namen registriert, wird die
|
||||
Compiler-Funktion ausgeführt.
|
||||
</para>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>mixed <function>smarty_compiler_<replaceable>name</replaceable></function></funcdef>
|
||||
<paramdef>string <parameter>$tag_arg</parameter></paramdef>
|
||||
<paramdef>object <parameter>&$smarty</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Die Compiler-Funktion erhält zwei Parameter: die Tag-Argument Zeichenkette
|
||||
- also alles ab dem Funktionsnamen bis zum schliessenden Trennzeichen - und
|
||||
das Smarty Objekt. Gibt den PHP-Code zurück, der in das Template eingefügt werden
|
||||
soll.
|
||||
</para>
|
||||
<para>
|
||||
|
||||
Sehen Sie dazu:
|
||||
<link linkend="api.register.compiler.function">register_compiler_function()</link>,
|
||||
<link linkend="api.unregister.compiler.function">unregister_compiler_function()</link>.
|
||||
</para>
|
||||
<example>
|
||||
<title>Einfache Compiler-Funktionen</title>
|
||||
<programlisting>
|
||||
<?php
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
* File: compiler.tplheader.php
|
||||
* Type: compiler
|
||||
* Name: tplheader
|
||||
* Purpose: Output header containing the source file name and
|
||||
* the time it was compiled.
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
function smarty_compiler_tplheader($tag_arg, &$smarty)
|
||||
{
|
||||
return "\necho '" . $smarty->_current_file . " compiled at " . date('Y-m-d H:M'). "';";
|
||||
}
|
||||
?></programlisting>
|
||||
<para>
|
||||
|
||||
Diese Funktion kann aus dem Template wie folgt aufgerufen werden:
|
||||
</para>
|
||||
<programlisting>
|
||||
|
||||
{* diese Funktion wird nur zum Kompilier-Zeitpunkt ausgeführt *}
|
||||
{tplheader}</programlisting>
|
||||
<para>
|
||||
|
||||
Der resultierende PHP-Code würde ungefähr so aussehen:
|
||||
</para>
|
||||
<programlisting>
|
||||
<php
|
||||
echo 'index.tpl compiled at 2002-02-20 20:02';
|
||||
?></programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
indent-tabs-mode:nil
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"../../../../manual.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:nil
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
-->
|
||||
123
docs/de/programmers/plugins/plugins-functions.xml
Normal file
123
docs/de/programmers/plugins/plugins-functions.xml
Normal file
@@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="plugins.functions"><title>Template-Funktionen</title>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>void <function>smarty_function_<replaceable>name</replaceable></function></funcdef>
|
||||
<paramdef>array <parameter>$params</parameter></paramdef>
|
||||
<paramdef>object <parameter>&$smarty</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Alle einer Funktion übergebenen Parameter werden in der Variable
|
||||
<parameter>$params</parameter> als assoziatives Array abgelegt. Sie können
|
||||
auf diese Werte entweder direkt mit <varname>$params['start']</varname> zugreifen
|
||||
oder sie mit <varname>extract($params)</varname> in die Symbol-Tabelle importieren.
|
||||
</para>
|
||||
<para>
|
||||
Die Ausgabe der Funktion wird verwendet, um das Funktions-Tag im Template
|
||||
(<function>fetch</function> Funktion, zum Beispiel) zu ersetzen.
|
||||
Alternativ kann sie auch etwas tun, ohne eine Ausgabe zurückzuliefern
|
||||
(<function>assign</function> Funktion, zum Beispiel).
|
||||
</para>
|
||||
<para>
|
||||
Falls die Funktion dem Template Variablen zuweisen oder
|
||||
auf eine andere Smarty-Funktionalität zugreifen möchte, kann dazu das
|
||||
übergebene <parameter>$smarty</parameter> Objekt verwendet werden.
|
||||
</para>
|
||||
<para>
|
||||
|
||||
Sehen Sie dazu:
|
||||
<link linkend="api.register.function">register_function()</link>,
|
||||
<link linkend="api.unregister.function">unregister_function()</link>.
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title>Funktionsplugin mit Ausgabe</title>
|
||||
<programlisting>
|
||||
<?php
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
* File: function.eightball.php
|
||||
* Type: function
|
||||
* Name: eightball
|
||||
* Purpose: outputs a random magic answer
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
function smarty_function_eightball($params, &$smarty)
|
||||
{
|
||||
$answers = array('Yes',
|
||||
'No',
|
||||
'No way',
|
||||
'Outlook not so good',
|
||||
'Ask again soon',
|
||||
'Maybe in your reality');
|
||||
|
||||
$result = array_rand($answers);
|
||||
echo $answers[$result];
|
||||
}
|
||||
?></programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
|
||||
Es kann im Template wie folgt angewendet werden:
|
||||
</para>
|
||||
<programlisting>
|
||||
Question: Will we ever have time travel?
|
||||
Answer: {eightball}.</programlisting>
|
||||
<para>
|
||||
<example>
|
||||
<title>Funktionsplugin ohne Ausgabe</title>
|
||||
<programlisting>
|
||||
<?php
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
* File: function.assign.php
|
||||
* Type: function
|
||||
* Name: assign
|
||||
* Purpose: assign a value to a template variable
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
function smarty_function_assign($params, &$smarty)
|
||||
{
|
||||
extract($params);
|
||||
|
||||
if (empty($var)) {
|
||||
$smarty->trigger_error("assign: missing 'var' parameter");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!in_array('value', array_keys($params))) {
|
||||
$smarty->trigger_error("assign: missing 'value' parameter");
|
||||
return;
|
||||
}
|
||||
|
||||
$smarty->assign($var, $value);
|
||||
}
|
||||
?></programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
indent-tabs-mode:nil
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"../../../../manual.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:nil
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
-->
|
||||
42
docs/de/programmers/plugins/plugins-howto.xml
Normal file
42
docs/de/programmers/plugins/plugins-howto.xml
Normal file
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="plugins.howto">
|
||||
<title>Wie Plugins funktionieren</title>
|
||||
<para>
|
||||
Plugins werden immer erst bei Bedarf geladen. Nur die im Template
|
||||
verwendeten Funktionen, Ressourcen, Variablen-Modifikatoren, etc. werden geladen.
|
||||
Des weiteren wird jedes Plugin nur einmal geladen, selbst wenn mehrere Smarty-Instanzen
|
||||
im selben Request erzeugt werden.
|
||||
</para>
|
||||
<para>
|
||||
'pre'/'post'-Filter machen die Ausnahme. Da sie in den Templates nicht direkt
|
||||
erwähnt werden, müssen sie zu Beginn der Ausführung explizit via API geladen oder
|
||||
registriert werden. Die Reihenfolge der Anwendung mehrerer Filter desselben Typs
|
||||
entspricht der Reihenfolge in der sie geladen/registriert wurden.
|
||||
</para>
|
||||
<para>
|
||||
Die <link linkend="variable.plugins.dir">plugins directory</link> Variable kann eine Zeichenkette,
|
||||
oder ein Array mit Verzeichnisnamen sein. Um einen Plugin zu installieren können Sie ihn einfach
|
||||
in einem der Verzeichnisse ablegen.
|
||||
</para>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
indent-tabs-mode:nil
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"../../../../manual.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:nil
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
-->
|
||||
70
docs/de/programmers/plugins/plugins-inserts.xml
Normal file
70
docs/de/programmers/plugins/plugins-inserts.xml
Normal file
@@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="plugins.inserts"><title>Inserts</title>
|
||||
<para>
|
||||
Insert-Plugins werden verwendet, um Funktionen zu implementieren, die
|
||||
via <link linkend="language.function.insert"><command>insert</command></link> aufgerufen werden.
|
||||
</para>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>string <function>smarty_insert_<replaceable>name</replaceable></function></funcdef>
|
||||
<paramdef>array <parameter>$params</parameter></paramdef>
|
||||
<paramdef>object <parameter>&$smarty</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Als erster Parameter wird der Funktion ein assoziatives Array aller Attribute
|
||||
übergeben, die im Insert-Tag notiert wurden. Sie können
|
||||
auf diese Werte entweder direkt mit <varname>$params['start']</varname> zugreifen
|
||||
oder sie mit <varname>extract($params)</varname> importieren.
|
||||
</para>
|
||||
<para>
|
||||
Als Rückgabewert muss das Resultat der Ausführung geliefert werden,
|
||||
das danach den Platz des <command>insert</command>-Tags im Template einnimmt.
|
||||
</para>
|
||||
<example>
|
||||
<title>Insert-Plugin</title>
|
||||
<programlisting>
|
||||
<?php
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
* File: insert.time.php
|
||||
* Type: time
|
||||
* Name: time
|
||||
* Purpose: Inserts current date/time according to format
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
function smarty_insert_time($params, &$smarty)
|
||||
{
|
||||
if (empty($params['format'])) {
|
||||
$smarty->trigger_error("insert time: missing 'format' parameter");
|
||||
return;
|
||||
}
|
||||
|
||||
$datetime = strftime($params['format']);
|
||||
return $datetime;
|
||||
}
|
||||
?></programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
indent-tabs-mode:nil
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"../../../../manual.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:nil
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
-->
|
||||
108
docs/de/programmers/plugins/plugins-modifiers.xml
Normal file
108
docs/de/programmers/plugins/plugins-modifiers.xml
Normal file
@@ -0,0 +1,108 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="plugins.modifiers"><title>Variablen-Modifikatoren</title>
|
||||
<para>
|
||||
Variablen-Modifikatoren sind kleine Funktionen, die auf eine Variable angewendet
|
||||
werden, bevor sie ausgegeben oder weiterverwendet wird. Variablen-Modifikatoren können
|
||||
aneinadergereiht werden.
|
||||
</para>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>mixed <function>smarty_modifier_<replaceable>name</replaceable></function></funcdef>
|
||||
<paramdef>mixed <parameter>$value</parameter></paramdef>
|
||||
<paramdef>[mixed <parameter>$param1</parameter>, ...]</paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Der erste an das Modifikator-Plugin übergebene Parameter ist der
|
||||
Wert mit welchem er arbeiten soll. Die restlichen Parameter sind optional
|
||||
und hängen von den durchzuführenden Operationen ab.
|
||||
</para>
|
||||
<para>
|
||||
|
||||
Der Modifikator muss das Resultat seiner Verarbeitung zurückgeben.
|
||||
</para>
|
||||
<para>
|
||||
Sehen Sie dazu:
|
||||
<link linkend="api.register.modifier">register_modifier()</link>,
|
||||
<link linkend="api.unregister.modifier">unregister_modifier()</link>.
|
||||
</para>
|
||||
<example>
|
||||
<title>Einfaches Modifikator-Plugin</title>
|
||||
<para>
|
||||
Dieses Plugin dient als Alias einer PHP-Funktion und erwartet keine
|
||||
zusätzlichen Parameter.
|
||||
</para>
|
||||
<programlisting>
|
||||
<?php
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
* File: modifier.capitalize.php
|
||||
* Type: modifier
|
||||
* Name: capitalize
|
||||
* Purpose: capitalize words in the string
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
function smarty_modifier_capitalize($string)
|
||||
{
|
||||
return ucwords($string);
|
||||
}
|
||||
?></programlisting>
|
||||
</example>
|
||||
<para></para>
|
||||
<example>
|
||||
<title>Komplexes Modifikator-Plugin</title>
|
||||
<programlisting>
|
||||
<?php
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
* File: modifier.truncate.php
|
||||
* Type: modifier
|
||||
* Name: truncate
|
||||
* Purpose: Truncate a string to a certain length if necessary,
|
||||
* optionally splitting in the middle of a word, and
|
||||
* appending the $etc string.
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
function smarty_modifier_truncate($string, $length = 80, $etc = '...',
|
||||
$break_words = false)
|
||||
{
|
||||
if ($length == 0)
|
||||
return '';
|
||||
|
||||
if (strlen($string) > $length) {
|
||||
$length -= strlen($etc);
|
||||
$fragment = substr($string, 0, $length+1);
|
||||
if ($break_words)
|
||||
$fragment = substr($fragment, 0, -1);
|
||||
else
|
||||
$fragment = preg_replace('/\s+(\S+)?$/', '', $fragment);
|
||||
return $fragment.$etc;
|
||||
} else
|
||||
return $string;
|
||||
}
|
||||
?></programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
indent-tabs-mode:nil
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"../../../../manual.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:nil
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
-->
|
||||
80
docs/de/programmers/plugins/plugins-naming-conventions.xml
Normal file
80
docs/de/programmers/plugins/plugins-naming-conventions.xml
Normal file
@@ -0,0 +1,80 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="plugins.naming.conventions">
|
||||
<title>Namenskonvention</title>
|
||||
<para>
|
||||
Plugin-Dateien müssen einer klaren Namenskonvention gehorchen,
|
||||
um von Smarty erkannt zu werden.
|
||||
</para>
|
||||
<para>
|
||||
|
||||
Die Plugin-Dateien müssen wie folgt benannt werden:
|
||||
<blockquote>
|
||||
<para>
|
||||
<filename>
|
||||
<replaceable>type</replaceable>.<replaceable>name</replaceable>.php
|
||||
</filename>
|
||||
</para>
|
||||
</blockquote>
|
||||
</para>
|
||||
<para>
|
||||
|
||||
Wobei <literal>Typ</literal> einen der folgenden Werte haben kann:
|
||||
<itemizedlist spacing="compact">
|
||||
<listitem><simpara>function</simpara></listitem>
|
||||
<listitem><simpara>modifier</simpara></listitem>
|
||||
<listitem><simpara>block</simpara></listitem>
|
||||
<listitem><simpara>compiler</simpara></listitem>
|
||||
<listitem><simpara>prefilter</simpara></listitem>
|
||||
<listitem><simpara>postfilter</simpara></listitem>
|
||||
<listitem><simpara>outputfilter</simpara></listitem>
|
||||
<listitem><simpara>resource</simpara></listitem>
|
||||
<listitem><simpara>insert</simpara></listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
<para>
|
||||
und <literal>Name</literal> ein erlaubter Identifikator (bestehend
|
||||
aus Buchstaben, Zahlen und Unterstrichen) ist.
|
||||
</para>
|
||||
<para>
|
||||
Ein paar Beispiele: <literal>function.html_select_date.php</literal>,
|
||||
<literal>resource.db.php</literal>,
|
||||
<literal>modifier.spacify.php</literal>.
|
||||
</para>
|
||||
<para>
|
||||
|
||||
Die Plugin-Funktion innerhalb das Plugin-Datei muss wie folgt benannt werden:
|
||||
<blockquote>
|
||||
<para>
|
||||
<function>smarty_<replaceable>type</replaceable>_<replaceable>name</replaceable></function>
|
||||
</para>
|
||||
</blockquote>
|
||||
</para>
|
||||
<para>
|
||||
<literal>type</literal> und <literal>name</literal> haben die selbe Bedeutung wie bei den Plugin-Dateien.
|
||||
</para>
|
||||
<para>
|
||||
Smarty gibt Fehlermeldungen aus, falls ein aufgerufenes Plugin nicht existiert,
|
||||
oder eine Datei mit falscher Namensgebung im Verzeichnis gefunden wurde.
|
||||
</para>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
indent-tabs-mode:nil
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"../../../../manual.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:nil
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
-->
|
||||
60
docs/de/programmers/plugins/plugins-outputfilters.xml
Normal file
60
docs/de/programmers/plugins/plugins-outputfilters.xml
Normal file
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="plugins.outputfilters"><title>Ausgabefilter</title>
|
||||
<para>
|
||||
Ausgabefilter werden auf das Template direkt vor der Ausgabe angewendet,
|
||||
nachdem es geladen und ausgeführt wurde.
|
||||
</para>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>string <function>smarty_outputfilter_<replaceable>name</replaceable></function></funcdef>
|
||||
<paramdef>string <parameter>$template_output</parameter></paramdef>
|
||||
<paramdef>object <parameter>&$smarty</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Als erster Parameter wird die Template-Ausgabe übergeben, welche
|
||||
verarbeitet werden soll und als zweiter Parameter das Smarty-Objekt.
|
||||
Das Plugin muss danach die verarbeitete Template-Ausgabe zurückgeben.
|
||||
</para>
|
||||
<example>
|
||||
<title>Ausgabefilter Plugin</title>
|
||||
<programlisting>
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
* File: outputfilter.protect_email.php
|
||||
* Type: outputfilter
|
||||
* Name: protect_email
|
||||
* Purpose: Converts @ sign in email addresses to %40 as
|
||||
* a simple protection against spambots
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
function smarty_outputfilter_protect_email($output, &$smarty)
|
||||
{
|
||||
return preg_replace('!(\S+)@([a-zA-Z0-9\.\-]+\.([a-zA-Z]{2,3}|[0-9]{1,3}))!',
|
||||
'$1%40$2', $output);
|
||||
}
|
||||
</programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
indent-tabs-mode:nil
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"../../../../manual.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:nil
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
-->
|
||||
@@ -0,0 +1,97 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="plugins.prefilters.postfilters">
|
||||
<title>'pre'/'post'-Filter</title>
|
||||
<para>
|
||||
'pre'-Filter und 'post'-Filter folgen demselben Konzept. Der
|
||||
einzige Unterschied ist der Zeitpunkt der Ausführung.
|
||||
</para>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>string <function>smarty_prefilter_<replaceable>name</replaceable></function></funcdef>
|
||||
<paramdef>string <parameter>$source</parameter></paramdef>
|
||||
<paramdef>object <parameter>&$smarty</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
'pre'-Filter werden verwendet, um die Quellen eines Templates direkt
|
||||
vor der Kompilierung zu verarbeiten. Als erster Parameter wird die
|
||||
Template-Quelle, die möglicherweise bereits durch eine weiteren 'pre'-Filter
|
||||
bearbeitet wurden, übergeben. Das Plugin muss den resultierenden Wert
|
||||
zurückgeben. Achtung: Diese Werte werden nicht gespeichert und nur
|
||||
zum Kompilier-Zeitpunkt verwendet.
|
||||
</para>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>string <function>smarty_postfilter_<replaceable>name</replaceable></function></funcdef>
|
||||
<paramdef>string <parameter>$compiled</parameter></paramdef>
|
||||
<paramdef>object <parameter>&$smarty</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
'post'-Filter werden auf die kompilierte Ausgabe direkt vor dem Speichern
|
||||
angewendet. Als erster Parameter wird der kompilierte Template-Code
|
||||
übergeben, der möglicherweise zuvor von anderen 'post'-Filtern
|
||||
bearbeitet wurde. Das Plugin muss den veränderten Template-Code zurückgeben.
|
||||
</para>
|
||||
<example>
|
||||
<title>'pre'-Filter Plugin</title>
|
||||
<programlisting>
|
||||
<?php
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
* File: prefilter.pre01.php
|
||||
* Type: prefilter
|
||||
* Name: pre01
|
||||
* Purpose: Convert html tags to be lowercase.
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
function smarty_prefilter_pre01($source, &$smarty)
|
||||
{
|
||||
return preg_replace('!<(\w+)[^>]+>!e', 'strtolower("$1")', $source);
|
||||
}
|
||||
?></programlisting>
|
||||
</example>
|
||||
<para></para>
|
||||
<example>
|
||||
<title>'post'-Filter Plugin</title>
|
||||
<programlisting>
|
||||
<?php
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
* File: postfilter.post01.php
|
||||
* Type: postfilter
|
||||
* Name: post01
|
||||
* Purpose: Output code that lists all current template vars.
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
function smarty_postfilter_post01($compiled, &$smarty)
|
||||
{
|
||||
$compiled = "<pre>\n<?php print_r(\$this->get_template_vars()); ?>\n</pre>" . $compiled;
|
||||
return $compiled;
|
||||
}
|
||||
?></programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
indent-tabs-mode:nil
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"../../../../manual.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:nil
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
-->
|
||||
154
docs/de/programmers/plugins/plugins-resources.xml
Normal file
154
docs/de/programmers/plugins/plugins-resources.xml
Normal file
@@ -0,0 +1,154 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="plugins.resources"><title>Ressourcen</title>
|
||||
<para>
|
||||
Ressourcen-Plugins stellen einen generischen Weg dar, um Smarty mit
|
||||
Template-Quellen oder PHP-Skripten zu versorgen. Einige Beispiele von Ressourcen:
|
||||
Datenbanken, LDAP, shared Memory, Sockets, usw.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Für jeden Ressource-Typ müssen 4 Funktionen registriert werden. Jede dieser
|
||||
Funktionen erhält die verlangte Ressource als ersten Parameter und das Smarty Objekt
|
||||
als letzten. Die restlichen Parameter hängen von der Funktion ab.
|
||||
</para>
|
||||
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>bool <function>smarty_resource_<replaceable>name</replaceable>_source</function></funcdef>
|
||||
<paramdef>string <parameter>$rsrc_name</parameter></paramdef>
|
||||
<paramdef>string <parameter>&$source</parameter></paramdef>
|
||||
<paramdef>object <parameter>&$smarty</parameter></paramdef>
|
||||
</funcprototype>
|
||||
<funcprototype>
|
||||
<funcdef>bool <function>smarty_resource_<replaceable>name</replaceable>_timestamp</function></funcdef>
|
||||
<paramdef>string <parameter>$rsrc_name</parameter></paramdef>
|
||||
<paramdef>int <parameter>&$timestamp</parameter></paramdef>
|
||||
<paramdef>object <parameter>&$smarty</parameter></paramdef>
|
||||
</funcprototype>
|
||||
<funcprototype>
|
||||
<funcdef>bool <function>smarty_resource_<replaceable>name</replaceable>_secure</function></funcdef>
|
||||
<paramdef>string <parameter>$rsrc_name</parameter></paramdef>
|
||||
<paramdef>object <parameter>&$smarty</parameter></paramdef>
|
||||
</funcprototype>
|
||||
<funcprototype>
|
||||
<funcdef>bool <function>smarty_resource_<replaceable>name</replaceable>_trusted</function></funcdef>
|
||||
<paramdef>string <parameter>$rsrc_name</parameter></paramdef>
|
||||
<paramdef>object <parameter>&$smarty</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
|
||||
<para>
|
||||
Die erste Funktion wird verwendet, um die Ressource zu laden. Der
|
||||
zweite Parameter ist eine Variable, die via Referenz übergeben
|
||||
wird und in der das Resultat gespeichert werden soll. Die Funktion
|
||||
gibt <literal>true</literal> zurück, wenn der Ladevorgang erfolgreich war -
|
||||
andernfalls <literal>false</literal>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Die zweite Funktion fragt das letzte Änderungsdatum der angeforderten
|
||||
Ressource (als Unix-Timestamp) ab. Der zweite Parameter ist die Variable,
|
||||
welche via Referenz übergeben wird und in der das Resultat gespeichert werden soll.
|
||||
Gibt <literal>true</literal> zurück, wenn das Änderungsdatum ermittelt
|
||||
werden konnte und <literal>false</literal> wenn nicht.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Die dritte Funktion gibt <literal>true</literal> oder <literal>false</literal>
|
||||
zurück, je nachdem ob die angeforderte Ressource als sicher bezeichnet wird
|
||||
oder nicht. Diese Funktion wird nur für Template-Ressourcen verwendet,
|
||||
sollte aber in jedem Fall definiert werden.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Die vierte Funktion gibt <literal>true</literal> oder <literal>false</literal>
|
||||
zurück, je nachdem ob die angeforderte Ressource als vertrauenswürdig angesehen wird
|
||||
oder nicht. Diese Funktion wird nur verwendet, wenn PHP-Skripte via <command>include_php</command>
|
||||
oder <command>insert</command> eingebunden werden sollen und ein 'src' Attribut übergeben wurde.
|
||||
Die Funktion sollte aber in jedem Fall definiert werden.
|
||||
</para>
|
||||
<para>
|
||||
Sehen Sie dazu:
|
||||
<link linkend="api.register.resource">register_resource()</link>,
|
||||
<link linkend="api.unregister.resource">unregister_resource()</link>.
|
||||
</para>
|
||||
<example>
|
||||
<title>Ressourcen Plugin</title>
|
||||
<programlisting>
|
||||
<?php
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
* File: resource.db.php
|
||||
* Type: resource
|
||||
* Name: db
|
||||
* Purpose: Fetches templates from a database
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
function smarty_resource_db_source($tpl_name, &$tpl_source, &$smarty)
|
||||
{
|
||||
// Datenbankabfragen machen, um '$tpl_source' das template zuzuweisen
|
||||
$sql = new SQL;
|
||||
$sql->query("select tpl_source
|
||||
from my_table
|
||||
where tpl_name='$tpl_name'");
|
||||
if ($sql->num_rows) {
|
||||
$tpl_source = $sql->record['tpl_source'];
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function smarty_resource_db_timestamp($tpl_name, &$tpl_timestamp, &$smarty)
|
||||
{
|
||||
|
||||
// Datenbankabfragen durchführen um '$tpl_timestamp' zuzuweisen
|
||||
$sql = new SQL;
|
||||
$sql->query("select tpl_timestamp
|
||||
from my_table
|
||||
where tpl_name='$tpl_name'");
|
||||
if ($sql->num_rows) {
|
||||
$tpl_timestamp = $sql->record['tpl_timestamp'];
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function smarty_resource_db_secure($tpl_name, &$smarty)
|
||||
{
|
||||
|
||||
// angenommen alle Templates seien sicher...
|
||||
return true;
|
||||
}
|
||||
|
||||
function smarty_resource_db_trusted($tpl_name, &$smarty)
|
||||
{
|
||||
|
||||
// wird für Templates nicht verwendet
|
||||
}
|
||||
?></programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
indent-tabs-mode:nil
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"../../../../manual.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:nil
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
-->
|
||||
47
docs/de/programmers/plugins/plugins-writing.xml
Normal file
47
docs/de/programmers/plugins/plugins-writing.xml
Normal file
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="plugins.writing">
|
||||
<title>Plugins schreiben</title>
|
||||
<para>
|
||||
Plugins können von Smarty automatisch geladen oder
|
||||
zur Laufzeit dynamisch mit den register_* API-Funktionen
|
||||
registriert werden. Um registrierte Plugins wieder zu entfernen,
|
||||
können die unregister_* API-Funktionen verwendet werden.
|
||||
</para>
|
||||
<para>
|
||||
Bei Plugins, die zur Laufzeit geladen werden, müssen keine Namenskonventionen
|
||||
beachtet werden.
|
||||
</para>
|
||||
<para>
|
||||
Wenn ein Plugin auf die Funktionalität eines anderen Plugins angewiesen
|
||||
ist (wie dies bei manchen Smarty Standard-Plugins der Fall ist), sollte
|
||||
folgender Weg gewählt werden, um das benötigte Plugin zu laden:
|
||||
</para>
|
||||
<programlisting>
|
||||
require_once $smarty->_get_plugin_filepath('function', 'html_options');</programlisting>
|
||||
<para>
|
||||
Das Smarty Objekt wird jedem Plugin immer als letzter Parameter
|
||||
übergeben (ausser bei Variablen-Modifikatoren und bei Blücken wird
|
||||
<parameter>&$repeat</parameter> nach dem Smarty Objekt übergeben um Rückwärtskompatibel zu bleiben).
|
||||
</para>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
indent-tabs-mode:nil
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"../../../../manual.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:nil
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
-->
|
||||
Reference in New Issue
Block a user