mirror of
				https://github.com/smarty-php/smarty.git
				synced 2025-11-04 06:11:37 +01:00 
			
		
		
		
	- updates for new build system - added missing files - corrections from users - revcheck comments for all files - big up to didou and nuno, brilliant work - make test: ok - make: ok
		
			
				
	
	
		
			116 lines
		
	
	
		
			3.4 KiB
		
	
	
	
		
			XML
		
	
	
	
	
	
			
		
		
	
	
			116 lines
		
	
	
		
			3.4 KiB
		
	
	
	
		
			XML
		
	
	
	
	
	
<?xml version="1.0" encoding="iso-8859-1"?>
 | 
						|
<!-- $Revision$ -->
 | 
						|
<!-- EN-Revision: 1.2 Maintainer: andreas Status: ready -->
 | 
						|
  <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>
 | 
						|
<![CDATA[
 | 
						|
<?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>
 | 
						|
<![CDATA[
 | 
						|
<?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
 | 
						|
-->
 |