mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 19:04:27 +02:00
sync with EN
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<!-- EN-Revision: 1.5 Maintainer: yannick Status: ready -->
|
||||
<!-- EN-Revision: 1.6 Maintainer: yannick Status: ready -->
|
||||
|
||||
<sect1 id="advanced.features.objects">
|
||||
<title>Objets</title>
|
||||
<para>
|
||||
Smarty donne l'acc<63>s aux objets PHP <20> travers les templates. Il y
|
||||
a 2 moyens d'y avoir acc<63>s. Le premier consiste <20>
|
||||
Smarty donne l'acc<63>s aux <ulink url="&url.php-manual;object">objets</ulink>
|
||||
PHP <20> travers les templates. Il y a 2 moyens d'y avoir acc<63>s. Le premier consiste <20>
|
||||
<link linkend="api.register.object">allouer les objets</link>
|
||||
au template puis de les utiliser avec une syntaxe similaire a celles
|
||||
des fonctions personnalis<69>es. Le deuxi<78>me moyen consiste <20>
|
||||
<link linkend="api.assign">assigner des objets</link>
|
||||
des <link linkend="language.custom.functions">fonctions personnalis<69>es</link>.
|
||||
Le deuxi<78>me moyen consiste <20> <link linkend="api.assign">assigner</link> des objets
|
||||
aux templates et de les utiliser comme n'importe quelle
|
||||
variable. La premi<6D>re m<>thode a une syntaxe beaucoup plus sympathique.
|
||||
Elle est aussi plus s<>curis<69>e, puisqu'un objet allou<6F> ne peut avoir acc<63>s
|
||||
@@ -64,22 +65,22 @@
|
||||
|
||||
class My_Object() {
|
||||
function meth1($params, &$smarty_obj) {
|
||||
return "this is my meth1";
|
||||
return 'Ceci est ma methode 1';
|
||||
}
|
||||
}
|
||||
|
||||
$myobj = new My_Object;
|
||||
// enregistre l'objet
|
||||
$smarty->register_object("foobar",$myobj);
|
||||
$smarty->register_object('foobar',$myobj);
|
||||
// on restreint l'acc<63>s a certaines m<>thodes et propri<72>t<EFBFBD>s en les listant
|
||||
$smarty->register_object("foobar",$myobj,array('meth1','meth2','prop1'));
|
||||
$smarty->register_object('foobar',$myobj,array('meth1','meth2','prop1'));
|
||||
// pour utiliser le format habituel de param<61>tre objet, passez le bool<6F>en = false
|
||||
$smarty->register_object("foobar",$myobj,null,false);
|
||||
$smarty->register_object('foobar',$myobj,null,false);
|
||||
|
||||
// on peut aussi assigner des objets. Assignez par r<>f<EFBFBD>rence quand c'est possible
|
||||
$smarty->assign_by_ref("myobj", $myobj);
|
||||
$smarty->assign_by_ref('myobj', $myobj);
|
||||
|
||||
$smarty->display("index.tpl");
|
||||
$smarty->display('index.tpl');
|
||||
?>
|
||||
|
||||
?>
|
||||
@@ -102,6 +103,11 @@ the output was {$output)
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Voir aussi
|
||||
<link linkend="api.register.object">register_object()</link> et
|
||||
<link linkend="api.assign">assign()</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@@ -1,14 +1,15 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<!-- EN-Revision: 1.3 Maintainer: yannick Status: ready -->
|
||||
<!-- EN-Revision: 1.4 Maintainer: yannick Status: ready -->
|
||||
|
||||
<sect1 id="advanced.features.postfilters">
|
||||
<title>Filtres de post-compilation</title>
|
||||
<para>
|
||||
Les filtres de post-compilation sont des fonctions PHP que vos templates
|
||||
ex<65>cutent apr<70>s avoir <20>t<EFBFBD> compil<69>s. Les filtres de post-compilation peuvent
|
||||
<20>tre soit <link linkend="api.register.postfilter">d<EFBFBD>clar<EFBFBD>s</link>, soit charg<72>s
|
||||
depuis les r<EFBFBD>pertoires des plugins en utilisant la fonction
|
||||
<link linkend="api.load.filter">load_filter()</link> ou en r<>glant
|
||||
depuis les <link linkend="variable.plugins.dir">r<EFBFBD>pertoires des plugins</link>
|
||||
en utilisant la fonction <link linkend="api.load.filter">load_filter()</link> ou en r<>glant
|
||||
la variable <link linkend="variable.autoload.filters">$autoload_filters</link>.
|
||||
Smarty passera le template compil<69> en tant que premier param<61>tre et attendra
|
||||
de la fonction qu'elle retourne le r<>sultat de l'ex<65>cution.
|
||||
@@ -25,8 +26,8 @@ function add_header_comment($tpl_source, &$smarty)
|
||||
}
|
||||
|
||||
// enregistre le filtre de post-compilation
|
||||
$smarty->register_postfilter("add_header_comment");
|
||||
$smarty->display("index.tpl");
|
||||
$smarty->register_postfilter('add_header_comment');
|
||||
$smarty->display('index.tpl');
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
@@ -40,7 +41,14 @@ $smarty->display("index.tpl");
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
Voir aussi
|
||||
<link linkend="api.register.postfilter">register_postfilter()</link>,
|
||||
<link linkend="advanced.features.prefilters">les pr<70>-filtres</link> et
|
||||
<link linkend="api.load.filter">load_filter()</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
|
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<!-- EN-Revision: 1.9 Maintainer: yannick Status: ready -->
|
||||
<!-- EN-Revision: 1.10 Maintainer: yannick Status: ready -->
|
||||
|
||||
<chapter id="api.functions">
|
||||
<title>M<EFBFBD>thodes</title>
|
||||
&programmers.api-functions.api-append;
|
||||
|
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<!-- EN-Revision: 1.3 Maintainer: yannick Status: ready -->
|
||||
<!-- EN-Revision: 1.4 Maintainer: yannick Status: ready -->
|
||||
|
||||
<chapter id="api.variables">
|
||||
<title>Variables</title>
|
||||
|
||||
@@ -39,6 +40,7 @@
|
||||
&programmers.api-variables.variable-use-sub-dirs;
|
||||
&programmers.api-variables.variable-default-modifiers;
|
||||
&programmers.api-variables.variable-default-resource-type;
|
||||
|
||||
</chapter>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -1,35 +1,44 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<!-- EN-Revision: 1.4 Maintainer: yannick Status: ready -->
|
||||
<!-- EN-Revision: 1.7 Maintainer: yannick Status: ready -->
|
||||
|
||||
<chapter id="smarty.constants">
|
||||
<title>Constantes</title>
|
||||
|
||||
<sect1 id="constant.smarty.dir">
|
||||
<title>SMARTY_DIR</title>
|
||||
<para>
|
||||
Il doit s'agir du chemin complet du r<>pertoire o<>
|
||||
se trouvent les fichiers classes de Smarty.
|
||||
Il doit s'agir du <emphasis role="bold">chemin complet</emphasis>
|
||||
du r<>pertoire o<> se trouvent les fichiers classes de Smarty.
|
||||
S'il n'est pas d<>fini, Smarty essaiera alors d'en
|
||||
d<>terminer automatiquement la valeur.
|
||||
S'il est d<>fini, le chemin doit se terminer par un slash.
|
||||
S'il est d<>fini, le chemin <emphasis role="bold">doit se terminer par un slash</emphasis>.
|
||||
</para>
|
||||
<example>
|
||||
<title>SMARTY_DIR</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
// d<>finit le chemin du r<>pertoire de Smarty (sur un syst<73>me *nix)
|
||||
define('SMARTY_DIR','/usr/local/lib/php/Smarty/libs/');
|
||||
|
||||
// d<>finit le chemin du r<>pertoire de Smarty
|
||||
define("SMARTY_DIR","/usr/local/lib/php/Smarty/");
|
||||
// d<>finit le chemin du r<>pertoire de Smarty (sur un syst<73>me Windows)
|
||||
define('SMARTY_DIR','c:/webroot/libs/Smarty/libs/');
|
||||
|
||||
require_once(SMARTY_DIR."Smarty.class.php");
|
||||
// astuce (non recommend<6E>) qui fonctionne sous Windows et sous *nix
|
||||
// Smarty est suppos<6F> <20>tre dans le dossier 'include' du script courant
|
||||
define('SMARTY_DIR',str_replace("\\","/",getcwd()).'/includes/Smarty/libs/');
|
||||
|
||||
// inclut la classe Smarty. Notez le 'S' en majuscule
|
||||
require_once(SMARTY_DIR.'Smarty.class.php');
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Voir aussi
|
||||
<link linkend="language.variables.smarty.const">$smarty.const</link>.
|
||||
<link linkend="language.variables.smarty.const">$smarty.const</link> et
|
||||
<link linkend="variable.php.handling">$php_handling constants</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
<sect1 id="constant.smarty.core.dir">
|
||||
@@ -49,9 +58,10 @@ require_once(SMARTY_DIR."Smarty.class.php");
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
// chargement de core.get_microtime.php
|
||||
|
||||
require_once(SMARTY_CORE_DIR."core.get_microtime.php");
|
||||
// chargement de core.get_microtime.php
|
||||
require_once(SMARTY_CORE_DIR.'core.get_microtime.php');
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
Reference in New Issue
Block a user