mirror of
				https://github.com/smarty-php/smarty.git
				synced 2025-10-30 20:01:37 +01:00 
			
		
		
		
	sync with EN
This commit is contained in:
		| @@ -1,21 +1,22 @@ | ||||
| <?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 | ||||
|   qu'a certaines m<>thodes et propri<72>t<EFBFBD>s. N<>anmoins,  | ||||
|   qu'a certaines m<>thodes et propri<72>t<EFBFBD>s. N<>anmoins, | ||||
|   <emphasis role="bold">un objet allou<6F> ne peut pas avoir de lien sur lui-m<>me  | ||||
|   ou <20>tre mis dans un tableau d'objet</emphasis>, etc.  | ||||
|   ou <20>tre mis dans un tableau d'objet</emphasis>, etc. | ||||
|   Vous devez choisir la m<>thode qui correspond a vos | ||||
|   besoins, mais tGchez d'utiliser la premi<6D>re m<>thode autant que possible | ||||
|   afin de r<>duire la syntaxe des templates au minimum. | ||||
| @@ -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 | ||||
| @@ -60,4 +68,4 @@ $smarty->display("index.tpl"); | ||||
|  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