sync with EN

This commit is contained in:
yannick
2005-12-10 22:09:38 +00:00
parent 5f92fc42fb
commit 5d7687ca04
8 changed files with 588 additions and 366 deletions

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="iso-8859-1"?> <?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ --> <!-- $Revision$ -->
<!-- EN-Revision: 1.7 Maintainer: gerald Status: ready --> <!-- EN-Revision: 1.8 Maintainer: yannick Status: ready -->
<sect1 id="language.function.if"> <sect1 id="language.function.if">
<title>{if},{elseif},{else}</title> <title>{if},{elseif},{else}</title>
@@ -16,6 +16,11 @@
<emphasis>&amp;&amp;</emphasis>, <emphasis>and</emphasis>, <emphasis>&amp;&amp;</emphasis>, <emphasis>and</emphasis>,
<emphasis>is_array()</emphasis>, etc. <emphasis>is_array()</emphasis>, etc.
</para> </para>
<para>
Si <link linkend="variable.security">$security</link> est actif,
alors le tableau <emphasis>IF_FUNCS</emphasis> dans le tableau
<link linkend="variable.security.settings">$security_settings</link> (?!).
</para>
<para> <para>
La liste suivante pr<70>sente les op<6F>rateurs reconnus, qui doivent <20>tre entour<75>s d'espaces. La liste suivante pr<70>sente les op<6F>rateurs reconnus, qui doivent <20>tre entour<75>s d'espaces.
Remarquez que les <20>l<EFBFBD>ments list<73>s entre [crochets] sont optionnels. Les <20>quivalents Remarquez que les <20>l<EFBFBD>ments list<73>s entre [crochets] sont optionnels. Les <20>quivalents
@@ -162,13 +167,6 @@
... ...
{/if} {/if}
{* l'exemple suivant NE fonctionne PAS, les op<6F>rateurs
doivent <20>tre entour<75>s d'espaces. *}
{if $name=="Fred" || $name=="Wilma"}
...
{/if}
{* les parenth<74>ses sont autoris<69>es *} {* les parenth<74>ses sont autoris<69>es *}
{if ( $amount < 0 or $amount > 1000 ) and $volume >= #minVolAmt#} {if ( $amount < 0 or $amount > 1000 ) and $volume >= #minVolAmt#}
... ...
@@ -179,6 +177,16 @@ doivent
... ...
{/if} {/if}
{* V<>rifie si c'est un tableau. *}
{if is_array($foo) }
.....
{/if}
{* V<>rifie si la variable est nulle. *}
{if isset($foo) }
.....
{/if}
{* teste si les valeurs sont paires(even) ou impaires(odd) *} {* teste si les valeurs sont paires(even) ou impaires(odd) *}
{if $var is even} {if $var is even}
... ...
@@ -206,17 +214,6 @@ doivent
... ...
{/if} {/if}
{* ------- if avec des fonctions PHP ------- *}
{* check for array. *}
{if is_array($foo) }
.....
{/if}
{* v<>rification du tableau. *}
{if isset($foo) }
.....
{/if}
]]> ]]>
</programlisting> </programlisting>
</example> </example>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="iso-8859-1"?> <?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ --> <!-- $Revision$ -->
<!-- EN-Revision: 1.9 Maintainer: gerald Status: ready --> <!-- EN-Revision: 1.10 Maintainer: yannick Status: ready -->
<sect1 id="language.function.include"> <sect1 id="language.function.include">
<title>{include}</title> <title>{include}</title>
@@ -17,6 +17,13 @@
qui d<>finit une variable de template dans laquelle la sortie de qui d<>finit une variable de template dans laquelle la sortie de
{include} sera stock<63>e plut<75>t qu'affich<63>e. {include} sera stock<63>e plut<75>t qu'affich<63>e.
</para> </para>
<para>
Toutes les valeurs des variables assign<67>es sont restaur<75>es lorsque
le template inclus est termin<69>. Ceci signifie que vous pouvez utiliser
toutes les variables d'un template inclus dans le template qui l'inclut.
Mais les modifications des variables dans le template inclus ne sont pas
visibles dans le template qui l'inclut apr<70>s l'instruction {include}.
</para>
<informaltable frame="all"> <informaltable frame="all">
<tgroup cols="5"> <tgroup cols="5">

View File

@@ -1,8 +1,26 @@
<?xml version="1.0" encoding="iso-8859-1"?> <?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ --> <!-- $Revision$ -->
<!-- EN-Revision: 1.8 Maintainer: gerald Status: ready --> <!-- EN-Revision: 1.14 Maintainer: yannick Status: ready -->
<sect1 id="language.function.section"> <sect1 id="language.function.section">
<title>section, sectionelse</title> <title>{section},{sectionelse}</title>
<para>
Les balises <emphasis>section</emphasis> sont utilis<69>es pour
parcourir un <emphasis role="bold">tableau de donn<6E>es</emphasis>
(tout comme <link linkend="language.function.foreach">{foreach}</link>).
Toutes les balises <emphasis>{section}</emphasis> doivent <20>tre utilis<69>es
de paire avec les balises <emphasis>{/section}</emphasis>. Les param<61>tres
requis sont <emphasis>name</emphasis> et <emphasis>loop</emphasis>.
Le nom de la {section} est, selon votre choix, compos<6F> de lettres,
chiffres et underscores. Les sections peuvent <20>tre imbriqu<71>es,
mais leurs noms doivent <20>tre uniques. La variable de parcours
(g<>n<EFBFBD>ralement un tableau de donn<6E>es) d<>termine le nombre de fois
que la section sera parcourue. Lorsque l'on affiche une variable
dans une section, le nom de la section doit pr<70>c<EFBFBD>der
la variable entre crochets []. <emphasis>{sectionelse}</emphasis>
est ex<65>cut<75> lorsqu'aucune valeur n'est trouv<75>e dans la variable <20>
parcourir.
</para>
<informaltable frame="all"> <informaltable frame="all">
<tgroup cols="5"> <tgroup cols="5">
<colspec colname="param" align="center" /> <colspec colname="param" align="center" />
@@ -76,29 +94,30 @@
</tbody> </tbody>
</tgroup> </tgroup>
</informaltable> </informaltable>
<para>
Les balises <emphasis>section</emphasis> sont utilis<69>es pour
parcourir un tableau de donn<6E>es. Toutes les balises
<emphasis>{section}</emphasis> doivent <20>tre utilis<69>es de paire avec
les balises <emphasis>{/section}</emphasis>. Les param<61>tres requis
sont <emphasis>name</emphasis> et <emphasis>loop</emphasis>.
Le nom de la {section} est, selon votre choix, compos<6F> de lettres,
chiffres et underscores. Les sections peuvent <20>tre imbriqu<71>es,
mais leurs noms doivent <20>tre uniques. La variable de parcours
(g<>n<EFBFBD>ralement un tableau de donn<6E>es) d<>termine le nombre de fois
que la section sera parcourue. Lorsque l'on affiche une variable
dans une section, le nom de la section doit pr<70>c<EFBFBD>der
la variable entre crochets. <emphasis>{sectionelse}</emphasis>
est ex<65>cut<75> lorsqu'aucune valeur n'est trouv<75>e dans la variable <20>
parcourir.
</para>
<example> <example>
<title>section</title> <title>{section}</title>
<programlisting role="php">
<![CDATA[
<?php
$data = array(1000,1001,1002);
$smarty->assign('custid',$data);
?>
]]>
</programlisting>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
{* Cet exemple va afficher toutes les valeurs du tableau $idClient *} {* Cet exemple affiche toutes les valeurs du tableau $custid *}
{section name=client loop=$idClient} {section name=customer loop=$custid}
id: {$idClient[client]}<br /> id: {$custid[customer]}<br />
{/section}
<hr />
{* Affiche toutes les valeurs du tableau $custid dans le sens inverse *}
{section name=foo loop=$custid step=-1}
{$custid[foo]}<br />
{/section} {/section}
]]> ]]>
</programlisting> </programlisting>
@@ -110,23 +129,69 @@
id: 1000<br /> id: 1000<br />
id: 1001<br /> id: 1001<br />
id: 1002<br /> id: 1002<br />
<hr />
id: 1002<br />
id: 1001<br />
id: 1000<br />
]]>
</screen>
<para>
Voici d'autres exemples sans tableaux assign<67>s.
</para>
<programlisting>
<![CDATA[
{section name=foo start=10 loop=20 step=2}
{$smarty.section.foo.index}
{/section}
<hr />
{section name=bar loop=21 max=6 step=-2}
{$smarty.section.bar.index}
{/section}
]]>
</programlisting>
<para>
L'exemple ci-dessus affichera :
</para>
<screen>
<![CDATA[
10 12 14 16 18
<hr />
20 18 16 14 12 10
]]> ]]>
</screen> </screen>
</example> </example>
<example> <example>
<title>section, variable de parcours</title> <title>{section}, variable de parcours</title>
<programlisting role="php">
<![CDATA[
<?php
$id = array(1001,1002,1003);
$smarty->assign('custid',$id);
$fullnames = array('John Smith','Jack Jones','Jane Munson');
$smarty->assign('name',$fullnames);
$addr = array('253 N 45th', '417 Mulberry ln', '5605 apple st');
$smarty->assign('address',$addr);
?>
]]>
</programlisting>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
{* La variable de parcours d<>termine uniquement le nombre de fois que nous allons {*
La variable de parcours d<>termine uniquement le nombre de fois que nous allons
rentrer dans la boucle. Vous pouvez acc<63>der <20> toutes les variables du template rentrer dans la boucle. Vous pouvez acc<63>der <20> toutes les variables du template
lorsque vous <20>tes dans une section. Cet exemple part du principe que lorsque vous <20>tes dans une section. Cet exemple part du principe que
$idClient, $noms et $adresses sont tous des tableaux qui contiennent $idClient, $noms et $adresses sont tous des tableaux qui contiennent
autant de valeurs les uns que les autres.*} autant de valeurs les uns que les autres.
*}
{section name=client loop=$idClient} {section name=client loop=$idClient}
id: {$idClient[client]}<br /> id : {$custid[customer]}<br />
nom: {$noms[client]}<br /> nom : {$name[customer]}<br />
addresse: {$addresses[client]}<br /> addresse : {$address[customer]}<br />
<p> <p>
{/section} {/section}
]]> ]]>
@@ -136,33 +201,39 @@ id: 1002<br />
</para> </para>
<screen> <screen>
<![CDATA[ <![CDATA[
id: 1000<br />
nom: John Smith<br />
addresse: 253 N 45th<br />
<p> <p>
id: 1001<br /> id : 1000<br />
nom: Jack Jones<br /> nom : John Smith<br />
addresse: 417 Mulberry ln<br /> addresse : 253 N 45th
</p>
<p> <p>
id: 1002<br /> id : 1001<br />
nom: Jane Munson<br /> nom : Jack Jones<br />
addresse: 5605 apple st<br /> addresse : 417 Mulberry ln
</p>
<p> <p>
id : 1002<br />
nom : Jane Munson<br />
addresse : 5605 apple st
</p>
]]> ]]>
</screen> </screen>
</example> </example>
<example> <example>
<title>nom de section</title> <title>nom de {section}</title>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
{* Le nom de la section peut <20>tre ce que vous voulez, {*
et est utilis<69> pour r<>f<EFBFBD>rencer les donn<6E>es depuis la section. *} Le nom de la section peut <20>tre ce que vous voulez,
et est utilis<69> pour r<>f<EFBFBD>rencer les donn<6E>es depuis la section.
*}
{section name=monTableau loop=$idClient} {section name=monTableau loop=$idClient}
<p>
id: {$idCLient[monTableau]}<br /> id: {$idCLient[monTableau]}<br />
name: {$noms[monTableau]}<br /> name: {$noms[monTableau]}<br />
address: {$addresses[monTableau]}<br /> address: {$addresses[monTableau]}
<p> </p>
{/section} {/section}
]]> ]]>
</programlisting> </programlisting>
@@ -170,21 +241,53 @@ addresse: 5605 apple st<br />
<example> <example>
<title>sections imbriqu<71>es</title> <title>sections imbriqu<71>es</title>
<programlisting role="php">
<![CDATA[
<?php
$id = array(1001,1002,1003);
$smarty->assign('custid',$id);
$fullnames = array('John Smith','Jack Jones','Jane Munson');
$smarty->assign('name',$fullnames);
$addr = array('253 N 45th', '417 Mulberry ln', '5605 apple st');
$smarty->assign('address',$addr);
$types = array(
array( 'home phone', 'cell phone', 'e-mail'),
array( 'home phone', 'web'),
array( 'cell phone')
);
$smarty->assign('contact_type', $types);
$info = array(
array('555-555-5555', '666-555-5555', 'john@myexample.com'),
array( '123-456-4', 'www.example.com'),
array( '0457878')
);
$smarty->assign('contact_info', $info);
?>
]]>
</programlisting>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
{* Les sections peuvent <20>tre imbriqu<71>es <20> un nombre de niveaux illimit<69>. {*
Les sections peuvent <20>tre imbriqu<71>es <20> un nombre de niveaux illimit<69>.
Gr<47>ce aux sections imbriqu<71>es, vous pouvez acc<63>der <20> des structures de donn<6E>es Gr<47>ce aux sections imbriqu<71>es, vous pouvez acc<63>der <20> des structures de donn<6E>es
complexes, comme des tableaux multi-dimentionnels. Dans cet exemple, complexes, comme des tableaux multi-dimentionnels. Dans cet exemple,
$type_contact[client] est un tableau de type de contact pour le client $type_contact[client] est un tableau de type de contact pour le client
courant. *} courant.
*}
{section name=client loop=$idClient} {section name=client loop=$idClient}
<hr />
id: {$idClient[client]}<br /> id: {$idClient[client]}<br />
nom: {$nom[client]}<br /> nom: {$nom[client]}<br />
addresse: {$addresse[client]}<br /> addresse: {$addresse[client]}<br />
{section name=contact loop=$type_contact[client]} {section name=contact loop=$type_contact[client]}
{$type_contact[client][contact]}: {$info_contact[client][contact]}<br /> {$type_contact[client][contact]}: {$info_contact[client][contact]}<br />
{/section} {/section}
<p>
{/section} {/section}
]]> ]]>
</programlisting> </programlisting>
@@ -193,41 +296,63 @@ addresse: 5605 apple st<br />
</para> </para>
<screen> <screen>
<![CDATA[ <![CDATA[
<hr />
id: 1000<br /> id: 1000<br />
nom: John Smith<br /> nom: John Smith<br />
addresse: 253 N 45th<br /> addresse: 253 N 45th<br />
telephone: 555-555-5555<br /> telephone: 555-555-5555<br />
telephone portable: 555-555-5555<br /> telephone portable: 555-555-5555<br />
e-mail: john@myexample.com<br /> e-mail: john@myexample.com<br />
<p> <hr />
id: 1001<br /> id: 1001<br />
nom: Jack Jones<br /> nom: Jack Jones<br />
addresse: 417 Mulberry ln<br /> addresse: 417 Mulberry ln<br />
telephone: 555-555-5555<br /> telephone: 555-555-5555<br />
telephone portable: 555-555-5555<br /> telephone portable: 555-555-5555<br />
e-mail: jack@myexample.com<br /> e-mail: jack@myexample.com<br />
<p> <hr />
id: 1002<br /> id: 1002<br />
nom: Jane Munson<br /> nom: Jane Munson<br />
addresse: 5605 apple st<br /> addresse: 5605 apple st<br />
telephone: 555-555-5555<br /> telephone: 555-555-5555<br />
telephone portable: 555-555-5555<br /> telephone portable: 555-555-5555<br />
e-mail: jane@myexample.com<br /> e-mail: jane@myexample.com<br />
<p> <hr />
]]> ]]>
</screen> </screen>
</example> </example>
<example> <example>
<title>Sections et tableaux associatifs</title> <title>Sections et tableaux associatifs</title>
<programlisting role="php">
<![CDATA[
<?php
$data = array(
array('name' => 'John Smith', 'home' => '555-555-5555',
'cell' => '666-555-5555', 'email' => 'john@myexample.com'),
array('name' => 'Jack Jones', 'home' => '777-555-5555',
'cell' => '888-555-5555', 'email' => 'jack@myexample.com'),
array('name' => 'Jane Munson', 'home' => '000-555-5555',
'cell' => '123456', 'email' => 'jane@myexample.com')
);
$smarty->assign('contacts',$data);
?>
]]>
</programlisting>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
{* Exemple d'affichage d'un tableau associatif dans une section *} {*
Exemple d'affichage d'un tableau associatif dans une section
*}
{section name=client loop=$contacts} {section name=client loop=$contacts}
<p>
nom: {$contacts[client].name}<br /> nom: {$contacts[client].name}<br />
telephone: {$contacts[client].home}<br /> telephone: {$contacts[client].home}<br />
portable: {$contacts[client].cell}<br /> portable: {$contacts[client].cell}<br />
e-mail: {$contacts[client].email}<p> e-mail: {$contacts[client].email}
</p>
{/section} {/section}
]]> ]]>
</programlisting> </programlisting>
@@ -236,24 +361,62 @@ e-mail: jane@myexample.com<br />
</para> </para>
<screen> <screen>
<![CDATA[ <![CDATA[
<p>
nom: John Smith<br /> nom: John Smith<br />
telephone: 555-555-5555<br /> telephone: 555-555-5555<br />
portable: 555-555-5555<br /> portable: 555-555-5555<br />
e-mail: john@myexample.com<p> e-mail: john@myexample.com
</p>
<p>
nom: Jack Jones<br /> nom: Jack Jones<br />
telephone: 555-555-5555<br /> telephone: 555-555-5555<br />
portable: 555-555-5555<br /> portable: 555-555-5555<br />
e-mail: jack@myexample.com<p> e-mail: jack@myexample.com
</p>
<p>
nom: Jane Munson<br /> nom: Jane Munson<br />
telephone: 555-555-5555<br /> telephone: 555-555-5555<br />
portable: 555-555-5555<br /> portable: 555-555-5555<br />
e-mail: jane@myexample.com<p> e-mail: jane@myexample.com<p>
</p>
]]> ]]>
</screen> </screen>
</example> </example>
<para>Exemple avec une base de donn<6E>es (eg. en utilisant Pear ou Adodb)</para>
<programlisting role="php">
<![CDATA[
<?php
$sql = 'select id, name, home, cell, email from contacts';
$smarty->assign('contacts',$db->getAll($sql) );
?>
]]>
</programlisting>
<programlisting>
<![CDATA[
{*
Affiche le r<>sultat de la base de donn<6E>es dans un tableau
*}
<table>
<tr><th>&nbsp;</th><th>Name></th><th>Home</th><th>Cell</th><th>Email</th></tr>
{section name=co loop=$contacts}
<tr>
<td><a href="view.php?id={$contacts[co].id}">view<a></td>
<td>{$contacts[co].name}</td>
<td>{$contacts[co].home}</td>
<td>{$contacts[co].cell}</td>
<td>{$contacts[co].email}</td>
<tr>
{/section}
</table>
]]>
</programlisting>
<example> <example>
<title>sectionelse</title> <title>{sectionelse}</title>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
{* sectionelse est ex<65>cut<75> s'il n'existe aucune valeur dans idClient *} {* sectionelse est ex<65>cut<75> s'il n'existe aucune valeur dans idClient *}
@@ -271,34 +434,37 @@ e-mail: jane@myexample.com<p>
<link linkend="language.variables.smarty.loops">{$smarty.section.sectionname.varname}</link> <link linkend="language.variables.smarty.loops">{$smarty.section.sectionname.varname}</link>
</para> </para>
<para> <para>
NOTE: Depuis Smarty 1.5.0, la syntaxe pour les propi<70>t<EFBFBD>s des sections Depuis Smarty 1.5.0, la syntaxe pour les propri<EFBFBD>t<EFBFBD>s des sections
a <20>t<EFBFBD> chang<6E>e de {%sectionname.varname%} <20> a <20>t<EFBFBD> chang<6E>e de {%sectionname.varname%} <20>
{$smarty.section.nomSection.nomVariable}. L'ancienne syntaxe est toujours {$smarty.section.nomSection.nomVariable}. L'ancienne syntaxe est toujours
support<72>e, mais vous ne verrez que des exemples avec la nouvelle syntaxe support<72>e, mais vous ne verrez que des exemples avec la nouvelle syntaxe
dans le manuel. dans le manuel.
</para> </para>
<sect2 id="section.property.index"> <sect2 id="section.property.index">
<title>index</title> <title>index</title>
<para> <para>
Index est utilis<69> pour afficher l'index de parcours courant, commence par Index est utilis<69> pour afficher l'index de parcours courant, commence par
0 (ou l'attribut start), et s'incr<63>mente de 1 (ou de la valeur 0 (ou l'attribut start s'il est fourni), et s'incr<63>mente de 1 (ou de la valeur
de l'attribut step). de l'attribut step s'il est fourni).
</para> </para>
<note> <note>
<title>Note technique</title> <title>Note technique</title>
<para> <para>
Si les attributs step et start ne sont pas modifi<66>s, alors index Si les attributs step et start ne sont pas modifi<66>s, alors index
fonctionne de la m<>me fa<66>on que <link fonctionne de la m<>me fa<66>on que <link
linkend="section.property.iteration">iteration</link>, <20> l'exception qu'il commence linkend="section.property.iteration">iteration</link>, <20> l'exception qu'il commence
par 0 plut<75>t que par 1. par 0 plut<75>t que par 1.
</para> </para>
</note> </note>
<example> <example>
<title>propri<EFBFBD>t<EFBFBD> de section index</title> <title>propri<EFBFBD>t<EFBFBD> de {section} index</title>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
{* FYI, $custid[customer.index] et $custid[customer] sont identiques *}
{section name=client loop=$idClient} {section name=client loop=$idClient}
{$smarty.section.client.index} id: {$idClient[client]}<br /> {$smarty.section.client.index} id: {$idClient[client]}<br />
{/section} {/section}
]]> ]]>
</programlisting> </programlisting>
@@ -307,47 +473,22 @@ e-mail: jane@myexample.com<p>
</para> </para>
<screen> <screen>
<![CDATA[ <![CDATA[
0 id: 1000<br /> 0 id: 1000<br />
1 id: 1001<br /> 1 id: 1001<br />
2 id: 1002<br /> 2 id: 1002<br />
]]> ]]>
</screen> </screen>
</example> </example>
</sect2> </sect2>
<sect2 id="section.property.index.prev"> <sect2 id="section.property.index.prev">
<title>index_prev</title> <title>index_prev</title>
<para> <para>
index_prev est utilis<69> pour afficher l'index de parcours index_prev est utilis<69> pour afficher l'index de parcours
pr<70>c<EFBFBD>dent de la boucle. Au premier passage, il vaut -1. pr<70>c<EFBFBD>dent de la boucle. Au premier passage, il vaut -1.
</para> </para>
<example>
<title>propri<EFBFBD>t<EFBFBD> de section index_prev</title>
<programlisting>
<![CDATA[
{section name=client loop=$idClient}
{$smarty.section.client.index} id: {$idClient[client]}<br />
{* Pour votre information, $idClient[client.index] and $idClient[client] sont identiques *}
{if $idClient[client.index_prev] ne $idClient[client.index]}
L'id du client <20> <20>t<EFBFBD> modifi<66><br />
{/if}
{/section}
]]>
</programlisting>
<para>
L'exemple ci-dessus affichera :
</para>
<screen>
<![CDATA[
0 id: 1000<br />
L'id du client <20> <20>t<EFBFBD> modifi<66><br />
1 id: 1001<br />
L'id du client <20> <20>t<EFBFBD> modifi<66><br />
2 id: 1002<br />
L'id du client <20> <20>t<EFBFBD> modifi<66><br />
]]>
</screen>
</example>
</sect2> </sect2>
<sect2 id="section.property.index.next"> <sect2 id="section.property.index.next">
<title>index_next</title> <title>index_next</title>
<para> <para>
@@ -355,17 +496,37 @@ e-mail: jane@myexample.com<p>
index. Dans la derni<6E>re boucle, cel<65> reste la valeur incr<63>ment<6E>e, index. Dans la derni<6E>re boucle, cel<65> reste la valeur incr<63>ment<6E>e,
qui respecte l'attribut step si donn<6E>. qui respecte l'attribut step si donn<6E>.
</para> </para>
<example> <example>
<title>propri<EFBFBD>t<EFBFBD> de section index_next</title> <title>propri<EFBFBD>t<EFBFBD> de {section} index_next et index_prev</title>
<programlisting> <programlisting role="php">
<![CDATA[ <![CDATA[
{section name=client loop=$idClient} <?php
{$smarty.section.client.index} id: {$idClient[client]}<br />
{* Pour votre information, $idClient[client.index] and $idClient[client] sont identiques *} $data = array(1001,1002,1003,1004,1005);
{if $idClient[client.index_next] ne $idClient[client.index]} $smarty->assign('custid',$data);
L'id du client va changer<br />
{/if} ?>
{/section} ]]>
</programlisting>
<programlisting>
<![CDATA[
{* FYI, $custid[cus.index] et $custid[cus] sont identiques *}
<table>
<tr>
<th>index</th><th>id</th>
<th>index_prev</th><th>prev_id</th>
<th>index_next</th><th>next_id</th>
</tr>
{section name=cus loop=$custid}
<tr>
<td>{$smarty.section.cus.index}</td><td>{$custid[cus]}</td>
<td>{$smarty.section.cus.index_prev}</td><td>{$custid[cus.index_prev]}</td>
<td>{$smarty.section.cus.index_next}</td><td>{$custid[cus.index_next]}</td>
</tr>
{/section}
</table>
]]> ]]>
</programlisting> </programlisting>
<para> <para>
@@ -373,16 +534,17 @@ e-mail: jane@myexample.com<p>
</para> </para>
<screen> <screen>
<![CDATA[ <![CDATA[
0 id: 1000<br /> index id index_prev prev_id index_next next_id
L'id du client va changer<br /> 0 1001 -1 1 1002
1 id: 1001<br /> 1 1002 0 1001 2 1003
L'id du client va changer<br /> 2 1003 1 1002 3 1004
2 id: 1002<br /> 3 1004 2 1003 4 1005
L'id du client va changer<br /> 4 1005 3 1004 5
]]> ]]>
</screen> </screen>
</example> </example>
</sect2> </sect2>
<sect2 id="section.property.iteration"> <sect2 id="section.property.iteration">
<title>iteration</title> <title>iteration</title>
<para> <para>
@@ -397,17 +559,25 @@ e-mail: jane@myexample.com<p>
ils fonctionnent de la m<>me fa<66>on. ils fonctionnent de la m<>me fa<66>on.
</para> </para>
<example> <example>
<title>propri<EFBFBD>t<EFBFBD> iteration de section</title> <title>propri<EFBFBD>t<EFBFBD> iteration de {section}</title>
<programlisting role="php">
<![CDATA[
<?php
// Tableau de 3000 <20> 3015
$id = range(3000,3015);
$smarty->assign('custid',$id);
?>
]]>
</programlisting>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
{section name=client loop=$idClient start=5 step=2} {section name=cu loop=$custid start=5 step=2}
Iteration courante: {$smarty.section.client.iteration}<br /> iteration={$smarty.section.cu.iteration}
{$smarty.section.client.index} id: {$idClient[client]}<br /> index={$smarty.section.cu.index}
{* Pour votre information, $idClient[client.index] and $idClient[client] sont identiques *} id={$custid[cu]}<br />
{if $idCLient[client.index_next] ne $idClient[client.index]} {/section}
L'id du client va changer<br />
{/if}
{/section}
]]> ]]>
</programlisting> </programlisting>
<para> <para>
@@ -415,93 +585,84 @@ e-mail: jane@myexample.com<p>
</para> </para>
<screen> <screen>
<![CDATA[ <![CDATA[
Iteration courante: 1 iteration=1 index=5 id=3005<br />
5 id: 1000<br /> iteration=2 index=7 id=3007<br />
L'id du client va changer<br /> iteration=3 index=9 id=3009<br />
Iteration courante: 2 iteration=4 index=11 id=3011<br />
7 id: 1001<br /> iteration=5 index=13 id=3013<br />
L'id du client va changer<br /> iteration=6 index=15 id=3015<br />
Iteration courante: 3
9 id: 1002<br />
L'id du client va changer<br />
]]> ]]>
</screen> </screen>
<para>
Cet exemple utilise la propri<72>t<EFBFBD> iteration pour afficher
un block d'en-t<>te de tableau toutes les cinq lignes
(utilisez <link linkend="language.function.if">{if}</link>
avec l'op<6F>rateur mod).
</para>
<programlisting>
<![CDATA[
<table>
{section name=co loop=$contacts}
{if $smarty.section.co.iteration % 5 == 1}
<tr><th>&nbsp;</th><th>Name></th><th>Home</th><th>Cell</th><th>Email</th></tr>
{/if}
<tr>
<td><a href="view.php?id={$contacts[co].id}">view<a></td>
<td>{$contacts[co].name}</td>
<td>{$contacts[co].home}</td>
<td>{$contacts[co].cell}</td>
<td>{$contacts[co].email}</td>
<tr>
{/section}
</table>
]]>
</programlisting>
</example> </example>
</sect2> </sect2>
<sect2 id="section.property.first"> <sect2 id="section.property.first">
<title>first</title> <title>first</title>
<para> <para>
first est <20> true lorsque la section est parcouru pour la premi<6D>re fois. first est <20> true lorsque la section est parcouru pour la premi<6D>re fois.
</para> </para>
<example>
<title>propri<EFBFBD>t<EFBFBD> first de la section</title>
<programlisting>
<![CDATA[
{section name=client loop=$idClient}
{if $smarty.section.client.first}
<table>
{/if}
<tr><td>{$smarty.section.client.index} id:
{$idClient[client]}</td></tr>
{if $smarty.section.client.last}
</table>
{/if}
{/section}
]]>
</programlisting>
<para>
L'exemple ci-dessus affichera :
</para>
<screen>
<![CDATA[
<table>
<tr><td>0 id: 1000</td></tr>
<tr><td>1 id: 1001</td></tr>
<tr><td>2 id: 1002</td></tr>
</table>
]]>
</screen>
</example>
</sect2> </sect2>
<sect2 id="section.property.last"> <sect2 id="section.property.last">
<title>last</title> <title>last</title>
<para> <para>
last est <20> true lorsque la section est parcourue pour la derni<6E>re fois. last est <20> true lorsque la section est parcourue pour la derni<6E>re fois.
</para> </para>
<example> <example>
<title>Propri<EFBFBD>t<EFBFBD> last de section</title> <title>Propri<EFBFBD>t<EFBFBD> last et first de {section}</title>
<para>
Cet exemple boucle le tableau $customers ;
affiche un block d'en-t<>te lors de la premi<6D>re it<69>ration et,
<20> la derni<6E>re, affiche un block de pied de page
(utilisation de la propri<72>t<EFBFBD> <link linkend="section.property.total">total</link>)
</para>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
{section name=client loop=$idClient} {section name=customer loop=$customers}
{if $smarty.section.client.first} {if $smarty.section.customer.first}
<table> <table>
{/if} <tr><th>id</th><th>customer</th></tr>
{/if}
<tr><td>{$smarty.section.client.index} id: <tr>
{$idClient[client]}</td></tr> <td>{$customers[customer].id}}</td>
<td>{$customers[customer].name}</td>
</tr>
{if $smarty.section.client.last} {if $smarty.section.customer.last}
</table> <tr><td></td><td>{$smarty.section.customer.total} customers</td></tr>
{/if} </table>
{/section} {/if}
{/section}
]]> ]]>
</programlisting> </programlisting>
<para>
L'exemple ci-dessus affichera :
</para>
<screen>
<![CDATA[
<table>
<tr><td>0 id: 1000</td></tr>
<tr><td>1 id: 1001</td></tr>
<tr><td>2 id: 1002</td></tr>
</table>
]]>
</screen>
</example> </example>
</sect2> </sect2>
<sect2 id="section.property.rownum"> <sect2 id="section.property.rownum">
<title>rownum</title> <title>rownum</title>
<para> <para>
@@ -510,27 +671,8 @@ e-mail: jane@myexample.com<p>
linkend="section.property.iteration">iteration</link>, ils fonctionnent de fa<66>on linkend="section.property.iteration">iteration</link>, ils fonctionnent de fa<66>on
identique. identique.
</para> </para>
<example>
<title>propri<EFBFBD>t<EFBFBD> rownum de section</title>
<programlisting>
<![CDATA[
{section name=client loop=$idClient}
{$smarty.section.client.rownum} id: {$idClient[client]}<br />
{/section}
]]>
</programlisting>
<para>
L'exemple ci-dessus affichera :
</para>
<screen>
<![CDATA[
1 id: 1000<br />
2 id: 1001<br />
3 id: 1002<br />
]]>
</screen>
</example>
</sect2> </sect2>
<sect2 id="section.property.loop"> <sect2 id="section.property.loop">
<title>loop</title> <title>loop</title>
<para> <para>
@@ -538,14 +680,14 @@ e-mail: jane@myexample.com<p>
section a utilis<69>. Peut <20>tre utilis<69> dans ou en dehors de la section. section a utilis<69>. Peut <20>tre utilis<69> dans ou en dehors de la section.
</para> </para>
<example> <example>
<title>Propri<EFBFBD>t<EFBFBD> de section index</title> <title>Propri<EFBFBD>t<EFBFBD> de {section} index</title>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
{section name=client loop=$idClient} {section name=client loop=$idClient}
{$smarty.section.client.index} id: {$idClient[client]}<br /> {$smarty.section.client.index} id: {$idClient[client]}<br />
{/section} {/section}
Il y eu {$smarty.section.client.loop} clients d'affich<63>s. Il y eu {$smarty.section.client.loop} clients d'affich<63>s.
]]> ]]>
</programlisting> </programlisting>
<para> <para>
@@ -553,38 +695,41 @@ e-mail: jane@myexample.com<p>
</para> </para>
<screen> <screen>
<![CDATA[ <![CDATA[
0 id: 1000<br /> 0 id: 1000<br />
1 id: 1001<br /> 1 id: 1001<br />
2 id: 1002<br /> 2 id: 1002<br />
il y eu 3 clients d'affich<63>s. Il y eu 3 clients d'affich<63>s.
]]> ]]>
</screen> </screen>
</example> </example>
</sect2> </sect2>
<sect2 id="section.property.show"> <sect2 id="section.property.show">
<title>show</title> <title>show</title>
<para> <para>
<emphasis>show</emphasis> est utilis<69> comme param<61>tre de section. <emphasis>show</emphasis> est utilis<69> comme param<61>tre de section.
<emphasis>show</emphasis> est une valeur bool<6F>enne, true ou false. <emphasis>show</emphasis> est une valeur bool<6F>enne, true ou false.
Si show est <20> "false", la section ne sera pas affich<63>e. Si un Si show est <20> "false", la section ne sera pas affich<63>e. Si un
sectionelse est pr<70>sent, elle sera affich<63>. {sectionelse} est pr<70>sent, elle sera affich<63>e.
</para> </para>
<example> <example>
<title>section, attribut show</title> <title>{section}, attribut show</title>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
{* $show_client_info a pu <20>tre pass<73> par le script PHP, {*
pour d<>terminer si oui ou non on souhaite afficher la section *} $show_client_info a pu <20>tre pass<73> par le script PHP,
{section name=client loop=$idClient show=$show_client_info} pour d<>terminer si oui ou non on souhaite afficher la section
*}
{section name=client loop=$idClient show=$show_client_info}
{$smarty.section.client.rownum} id: {$idClient[client]}<br /> {$smarty.section.client.rownum} id: {$idClient[client]}<br />
{/section} {/section}
{if $smarty.section.client.show} {if $smarty.section.client.show}
la section <EFBFBD> <20>t<EFBFBD> affich<63>e. la section a <20>t<EFBFBD> affich<63>e.
{else} {else}
la section n'a pas <20>t<EFBFBD> affich<63>e. la section n'a pas <20>t<EFBFBD> affich<63>e.
{/if} {/if}
]]> ]]>
</programlisting> </programlisting>
<para> <para>
@@ -592,30 +737,31 @@ e-mail: jane@myexample.com<p>
</para> </para>
<screen> <screen>
<![CDATA[ <![CDATA[
1 id: 1000<br /> 1 id: 1000<br />
2 id: 1001<br /> 2 id: 1001<br />
3 id: 1002<br /> 3 id: 1002<br />
la section <EFBFBD> <20>t<EFBFBD> affich<63>e. la section a <20>t<EFBFBD> affich<63>e.
]]> ]]>
</screen> </screen>
</example> </example>
</sect2> </sect2>
<sect2 id="section.property.total"> <sect2 id="section.property.total">
<title>total</title> <title>total</title>
<para> <para>
total est utilis<69> pour afficher le nombre d'it<69>ration que la section <literal>total</literal> est utilis<69> pour afficher le nombre d'it<69>ration que la section
va ex<65>cuter. Peut <20>tre utilis<69> dans ou en dehors de la section. va ex<65>cuter. Peut <20>tre utilis<69> dans ou en dehors de la section.
</para> </para>
<example> <example>
<title>section, propri<72>t<EFBFBD> total</title> <title>{section}, propri<72>t<EFBFBD> <literal>total</literal></title>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
{section name=client loop=$idClient step=2} {section name=client loop=$idClient step=2}
{$smarty.section.client.index} id: {$idClient[client]}<br /> {$smarty.section.client.index} id: {$idClient[client]}<br />
{/section} {/section}
Il y eu {$smarty.section.client.total} clients affich<63>s. Il y eu {$smarty.section.client.total} clients affich<63>s.
]]> ]]>
</programlisting> </programlisting>
<para> <para>
@@ -623,21 +769,22 @@ e-mail: jane@myexample.com<p>
</para> </para>
<screen> <screen>
<![CDATA[ <![CDATA[
0 id: 1000<br /> 0 id: 1000<br />
2 id: 1001<br /> 2 id: 1001<br />
4 id: 1002<br /> 4 id: 1002<br />
Il y eu 3 clients affich<63>s. Il y eu 3 clients affich<63>s.
]]> ]]>
</screen> </screen>
</example> </example>
<para> <para>
Voir aussi Voir aussi
<link linkend="language.function.foreach">{foreach}</link> et <link linkend="language.function.foreach">{foreach}</link> et
<link linkend="language.variables.smarty.loops">$smarty.section</link>. <link linkend="language.variables.smarty.loops">$smarty.section</link>.
</para> </para>
</sect2> </sect2>
</sect1> </sect1>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file
Local variables: Local variables:
mode: sgml mode: sgml
@@ -657,4 +804,4 @@ End:
vim600: syn=xml fen fdm=syntax fdl=2 si vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml vim: et tw=78 syn=sgml
vi: ts=1 sw=1 vi: ts=1 sw=1
--> -->

View File

@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="iso-8859-1"?> <?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ --> <!-- $Revision$ -->
<!-- EN-Revision: 1.4 Maintainer: gerlad Status: ready --> <!-- EN-Revision: 1.8 Maintainer: yannick Status: ready -->
<sect1 id="language.function.strip"> <sect1 id="language.function.strip">
<title>strip</title> <title>{strip}</title>
<para> <para>
Il est fr<66>quent que les designers web rencontrent des probl<62>mes Il est fr<66>quent que les designers web rencontrent des probl<62>mes
dus aux espaces et retours chariots, qui affectent le rendu HTML dus aux espaces et retours chariots, qui affectent le rendu HTML
@@ -13,7 +14,7 @@
<para> <para>
Tout contenu situ<74> entre les balises {strip}{/strip} se verra Tout contenu situ<74> entre les balises {strip}{/strip} se verra
all<6C>g<EFBFBD> des espaces superflus et des retours chariots en d<>but ou en fin all<6C>g<EFBFBD> des espaces superflus et des retours chariots en d<>but ou en fin
de ligne, avant qu'il ne soit affich<63>s. De la sorte, vous pouvez de ligne, avant qu'il ne soit affich<63>. De la sorte, vous pouvez
conserver vos templates lisibles, sans vous soucier des effets conserver vos templates lisibles, sans vous soucier des effets
ind<6E>sirables que peuvent apporter les espaces superflus. ind<6E>sirables que peuvent apporter les espaces superflus.
</para> </para>
@@ -21,8 +22,8 @@
<title>Note technique</title> <title>Note technique</title>
<para> <para>
{strip}{/strip} n'affecte en aucun cas le contenu des variables de {strip}{/strip} n'affecte en aucun cas le contenu des variables de
template. Voir le <link linkend="language.modifier.strip">modificateur template. Voir aussi le <link linkend="language.modifier.strip">modificateur
strip</link> pour un rendu identique pour les variables. strip</link> pour un rendu identique pour les variables.
</para> </para>
</note> </note>
<example> <example>
@@ -31,12 +32,12 @@
<![CDATA[ <![CDATA[
{* la suite sera affich<63>e sur une seule ligne *} {* la suite sera affich<63>e sur une seule ligne *}
{strip} {strip}
<table border=0> <table border='0'>
<tr> <tr>
<td> <td>
<A HREF="{$url}"> <a href="{$url}">
<font color="red">Un test</font> <font color="red">Un test</font>
</A> </a>
</td> </td>
</tr> </tr>
</table> </table>
@@ -48,7 +49,7 @@
</para> </para>
<screen> <screen>
<![CDATA[ <![CDATA[
<table border=0><tr><td><A HREF="http://mon.example.com"><font color="red">Un test</font></A></td></tr></table> <table border='0'><tr><td><a href="http://mon.example.com"><font color="red">Un test</font></a></td></tr></table>
]]> ]]>
</screen> </screen>
</example> </example>
@@ -59,7 +60,12 @@
au suivant/pr<70>c<EFBFBD>dent et risque de ne pas <20>tre affich<63> selon au suivant/pr<70>c<EFBFBD>dent et risque de ne pas <20>tre affich<63> selon
l'effet d<>sir<69>. l'effet d<>sir<69>.
</para> </para>
<para>
Voir aussi
le <link linkend="language.modifier.strip">modificateur strip</link>.
</para>
</sect1> </sect1>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file
Local variables: Local variables:
mode: sgml mode: sgml
@@ -79,4 +85,4 @@ End:
vim600: syn=xml fen fdm=syntax fdl=2 si vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml vim: et tw=78 syn=sgml
vi: ts=1 sw=1 vi: ts=1 sw=1
--> -->

View File

@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="iso-8859-1"?> <?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ --> <!-- $Revision$ -->
<!-- EN-Revision: 1.3 Maintainer: gerald Status: ready --> <!-- EN-Revision: 1.7 Maintainer: yannick Status: ready -->
<sect1 id="language.assigned.variables"> <sect1 id="language.assigned.variables">
<title>Variables assign<67>es depuis PHP</title> <title>Variables assign<67>es depuis PHP</title>
<para> <para>
Pour utiliser une variables assign<EFBFBD>es depuis PHP, il Pour utiliser une variables <link linkend="api.assign">assign<EFBFBD>es</link> depuis PHP, il
faut la pr<70>fixer par le symbole dollar <literal>$</literal>. faut la pr<70>fixer par le symbole dollar <literal>$</literal>.
Les variables asign<67>es depuis un template gr<67>ce <20> la fonction Les variables asign<67>es depuis un template gr<67>ce <20> la fonction
<link linkend="language.function.assign">{assign}</link> sont <link linkend="language.function.assign">{assign}</link> sont
@@ -12,21 +13,44 @@
</para> </para>
<example> <example>
<title>Variables assign<67>es</title> <title>Variables assign<67>es</title>
<programlisting> <para>Script PHP</para>
<programlisting role="php">
<![CDATA[ <![CDATA[
Bienvenue {$prenom}, heureux de voir que tu es arriv<69> ici. <?php
<p>
La derni<6E>re connexion remonte au {$dateConnexionPrecedente}. $smarty = new Smarty;
$smarty->assign('firstname', 'Doug');
$smarty->assign('lastname', 'Evans');
$smarty->assign('meetingPlace', 'New York');
$smarty->display('index.tpl');
?>
]]> ]]>
</programlisting> </programlisting>
<para> <para>
Cel<EFBFBD> va afficher: o<> index.tpl est :
</para> </para>
<programlisting>
<![CDATA[
Bonjour {$firstname} {$lastname}, heureux de voir que tu es arriv<69> ici.
<br />
{* ceci ne fonctionnera pas car $vars est sensible <20> la casse *}
Cette semaine, le meeting est <20> {$meetingplace}.
{* ceci fonctionnera *}
Cette semaine, le meeting est <20> {$meetingPlace}.
]]>
</programlisting>
<para>
Cel<65> va afficher:
</para>
<screen> <screen>
<![CDATA[ <![CDATA[
Bienvenue Doug, heureux de voir que tu es arriv<69> ici. Bienvenue Doug, heureux de voir que tu es arriv<69> ici.
<p> <br />
La derni<6E>re connexion remonte au 11 janvier 2001. Cette semaine, le meeting est <20> .
Cette semaine, le meeting est <20> New York.
]]> ]]>
</screen> </screen>
</example> </example>
@@ -44,12 +68,13 @@ La derni
<![CDATA[ <![CDATA[
<?php <?php
$smarty = new Smarty;
$smarty->assign('Contacts', $smarty->assign('Contacts',
array('fax' => '555-222-9876', array('fax' => '555-222-9876',
'email' => 'zaphod@slartibartfast.com', 'email' => 'zaphod@slartibartfast.example.com',
'phone' => array('home' => '555-444-3333', 'phone' => array('home' => '555-444-3333',
'cell' => '555-111-1234'))); 'cell' => '555-111-1234')
)
);
$smarty->display('index.tpl'); $smarty->display('index.tpl');
?> ?>
]]> ]]>
@@ -72,7 +97,7 @@ $smarty->display('index.tpl');
<screen> <screen>
<![CDATA[ <![CDATA[
555-222-9876<br /> 555-222-9876<br />
zaphod@slartibartfast.com<br /> zaphod@slartibartfast.example.com<br />
555-444-3333<br /> 555-444-3333<br />
555-111-1234<br /> 555-111-1234<br />
]]> ]]>
@@ -91,12 +116,12 @@ zaphod@slartibartfast.com<br />
<programlisting role="php"> <programlisting role="php">
<![CDATA[ <![CDATA[
<?php <?php
$smarty = new Smarty; $smarty->assign('Contacts', array(
$smarty->assign('Contacts', '555-222-9876',
array('555-222-9876', 'zaphod@slartibartfast.example.com',
'zaphod@slartibartfast.com', array('555-444-3333',
array('555-444-3333', '555-111-1234')
'555-111-1234'))); ));
$smarty->display('index.tpl'); $smarty->display('index.tpl');
?> ?>
]]> ]]>
@@ -119,7 +144,7 @@ $smarty->display('index.tpl');
<screen> <screen>
<![CDATA[ <![CDATA[
555-222-9876<br /> 555-222-9876<br />
zaphod@slartibartfast.com<br /> zaphod@slartibartfast.example.com<br />
555-444-3333<br /> 555-444-3333<br />
555-111-1234<br /> 555-111-1234<br />
]]> ]]>
@@ -142,12 +167,12 @@ email: {$person->email}<br />
]]> ]]>
</programlisting> </programlisting>
<para> <para>
Ce qui donne en sortie : Ce qui donne en sortie :
</para> </para>
<screen> <screen>
<![CDATA[ <![CDATA[
nom: Zaphod Beeblebrox<br /> nom: Zaphod Beeblebrox<br />
email: zaphod@slartibartfast.com<br /> email: zaphod@slartibartfast.example.com<br />
]]> ]]>
</screen> </screen>
</example> </example>

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="iso-8859-1"?> <?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ --> <!-- $Revision$ -->
<!-- EN-Revision: 1.3 Maintainer: gerald Status: ready --> <!-- EN-Revision: 1.4 Maintainer: yannick Status: ready -->
<sect1 id="language.config.variables"> <sect1 id="language.config.variables">
<title>Variables charg<72>es depuis des fichiers de configuration</title> <title>Variables charg<72>es depuis des fichiers de configuration</title>
<para> <para>
@@ -93,6 +94,17 @@ rowBgColor = "#cccccc"
<link linkend="language.syntax.variables">variables</link> et les <link linkend="language.syntax.variables">variables</link> et les
<link linkend="language.variables.smarty">variables r<>serv<72>es $smarty</link>. <link linkend="language.variables.smarty">variables r<>serv<72>es $smarty</link>.
</para> </para>
<para>
Les variables des fichiers de configuration ne peuvent pas <20>tre utilis<69>es
tant qu'elles n'ont pas <20>t<EFBFBD> charg<72>es depuis un fichier de configuration. Cette proc<6F>dure
est expliqu<71> plus loin dans cette documentation sous la section
<link linkend="language.function.config.load"><command>{config_load}</command></link>.
</para>
<para>
Voir aussi
les <link linkend="language.syntax.variables">variables</link> et
les <link linkend="language.variables.smarty">variables r<>serv<72>es $smarty</link>.
</para>
</sect1> </sect1>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file

View File

@@ -1,39 +1,43 @@
<?xml version="1.0" encoding="iso-8859-1"?> <?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ --> <!-- $Revision$ -->
<!-- EN-Revision: 1.8 Maintainer: gerald Status: ready --> <!-- EN-Revision: 1.12 Maintainer: yannick Status: ready -->
<sect1 id="language.variables.smarty"> <sect1 id="language.variables.smarty">
<title>Variable r<>serv<72>e {$smarty}</title> <title>Variable r<>serv<72>e {$smarty}</title>
<para> <para>
La variable r<>serv<72>e {$smarty} peut <20>tre utilis<69>e pour acc<63>der <20> plusieurs La variable PHP r<EFBFBD>serv<EFBFBD>e {$smarty} peut <20>tre utilis<69>e pour acc<63>der <20> plusieurs
variables sp<73>ciales du template. En voici la liste compl<70>te. variables sp<73>ciales du template. En voici la liste compl<70>te.
</para> </para>
<sect2 id="language.variables.smarty.request"> <sect2 id="language.variables.smarty.request">
<title>Variables de requ<71>te</title> <title>Variables de requ<71>te</title>
<para> <para>
Les variables de requ<71>te comme GET, POST, COOKIES, SERVER, ENVIRONNEMENT Les <ulink url="&url.php-manual;reserved.variables">variables de requ<71>te</ulink>
et SESSION peuvent <20>tre utilis<69>es comme dans l'exemple suivant: comme $_GET, $_POST, $_COOKIE, $_SERVER, $_ENV and $_SESSION
(voir <link linkend="variable.request.vars.order">$request_vars_order</link>
et <link linkend="variable.request.use.auto.globals">$request_use_auto_globals</link>)
peuvent <20>tre utilis<69>es comme dans l'exemple suivant:
</para> </para>
<example> <example>
<title>Afficher des variables de requ<71>te</title> <title>Afficher des variables de requ<71>te</title>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
{* Affiche la valeur de page dans l'url (GET) http://www.example.com/index.php?page=foo *} {* Affiche la valeur de page dans l'url ($_GET) http://www.example.com/index.php?page=foo *}
{$smarty.get.page} {$smarty.get.page}
{* affiche la variable "page" r<>cup<75>r<EFBFBD>e depuis un formulaire (POST) *} {* affiche la variable "page" r<>cup<75>r<EFBFBD>e depuis un formulaire ($_POST['page']) *}
{$smarty.post.page} {$smarty.post.page}
{* affiche la valeur du cookie "utilisateur" *} {* affiche la valeur du cookie "utilisateur" ($_COOKIE['username']) *}
{$smarty.cookies.utilisateur} {$smarty.cookies.utilisateur}
{* affiche la variable serveur "SERVER_NAME" *} {* affiche la variable serveur "SERVER_NAME" ($_SERVER['SERVER_NAME']) *}
{$smarty.server.SERVER_NAME} {$smarty.server.SERVER_NAME}
{* affiche la variable d'environnement "PATH" *} {* affiche la variable d'environnement "PATH" *}
{$smarty.env.PATH} {$smarty.env.PATH}
{* affiche la variable de session PHP "id" *} {* affiche la variable de session PHP "id" ($_SESSION['id']) *}
{$smarty.session.id} {$smarty.session.id}
{* affiche la variable "utilisateur" du regroupement de get/post/cookies/server/env *} {* affiche la variable "utilisateur" du regroupement de get/post/cookies/server/env *}
@@ -41,19 +45,27 @@
]]> ]]>
</programlisting> </programlisting>
</example> </example>
<note>
<para>
Pour des raisons historiques, {$SCRIPT_NAME} peut <20>tre acc<63>d<EFBFBD>
directement, cependant, {$smarty.server.SCRIPT_NAME} est
la solution propos<6F>e pour acc<63>der <20> cette valeur.
</para>
</note>
</sect2> </sect2>
<sect2 id="language.variables.smarty.now"> <sect2 id="language.variables.smarty.now">
<title>{$smarty.now}</title> <title>{$smarty.now}</title>
<para> <para>
Le timestamp courant peut <20>tre r<>cup<75>r<EFBFBD> gr<67>ce <20> {$smarty.now}. Le <ulink url="&url.php-manual;function.time">timestamp</ulink>
courant peut <20>tre r<>cup<75>r<EFBFBD> gr<67>ce <20> {$smarty.now}.
Le nombre obtenu correspond au nombre de secondes <20>coul<75>es depuis Le nombre obtenu correspond au nombre de secondes <20>coul<75>es depuis
Epoch (1 Janvier 1970) et peut <20>tre pass<73> directement au modificateur Epoch (1 Janvier 1970) et peut <20>tre pass<73> directement au modificateur
de variable date <link linkend="language.modifier.date.format">date_format</link> de variable date <link linkend="language.modifier.date.format">date_format</link>
<20> des fins d'affichage. <20> des fins d'affichage.
</para> </para>
<example> <example>
<title>utilisation de {$smarty.now}</title> <title>Utilisation de {$smarty.now}</title>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
{* utilise le modificateur de variable date_format pour afficher la date et heure *} {* utilise le modificateur de variable date_format pour afficher la date et heure *}
@@ -62,12 +74,12 @@
</programlisting> </programlisting>
</example> </example>
</sect2> </sect2>
<sect2 id="language.variables.smarty.const"> <sect2 id="language.variables.smarty.const">
<title>{$smarty.const}</title> <title>{$smarty.const}</title>
<para> <para>
Vous pouvez directement acc<63>der aux constantes PHP. Vous pouvez directement acc<63>der aux constantes PHP.
Voir aussi les <link Voir aussi les <link linkend="smarty.constants">constantes smarty</link>.
linkend="smarty.constants">constantes smarty</link>.
</para> </para>
<example> <example>
<title>Utiliser {$smarty.const}</title> <title>Utiliser {$smarty.const}</title>
@@ -82,7 +94,7 @@
<sect2 id="language.variables.smarty.capture"> <sect2 id="language.variables.smarty.capture">
<title>{$smarty.capture}</title> <title>{$smarty.capture}</title>
<para> <para>
La capture r<>alis<69>e via La capture r<>alis<69>e via
<link linkend="language.function.capture">{capture}..{/capture}</link> <link linkend="language.function.capture">{capture}..{/capture}</link>
peut <20>tre r<>cup<75>r<EFBFBD>e par l'interm<72>diaire de la variable {$smarty}. Voir la section peut <20>tre r<>cup<75>r<EFBFBD>e par l'interm<72>diaire de la variable {$smarty}. Voir la section
sur <link linkend="language.function.capture">{capture}</link> pour un sur <link linkend="language.function.capture">{capture}</link> pour un
@@ -93,11 +105,10 @@
<sect2 id="language.variables.smarty.config"> <sect2 id="language.variables.smarty.config">
<title>{$smarty.config}</title> <title>{$smarty.config}</title>
<para> <para>
La variable {$smarty} peut <20>tre utilis<69>e pour d<>signer une <link La variable {$smarty} peut <20>tre utilis<69>e pour d<>signer une
linkend="language.config.variables">variable <link linkend="language.config.variables">variable d'un fichier de configuration</link>.
d'un fichier de configuration</link>. {$smarty.config.foo} est un synonyme de {$smarty.config.foo} est un synonyme de {#foo#}. Voir la section
{#foo#}. Voir la section <link <link linkend="language.function.config.load">{config_load}</link>
linkend="language.function.config.load">{config_load}</link>
pour un exemple <20> ce sujet. pour un exemple <20> ce sujet.
</para> </para>
</sect2> </sect2>
@@ -118,17 +129,24 @@
Cette variable contient le nom du template en cours de traitement. Cette variable contient le nom du template en cours de traitement.
</para> </para>
</sect2> </sect2>
<sect2 id="language.variables.smarty.version">
<title>{$smarty.version}</title>
<para>
Cette variable contient la version de Smarty utilis<69>e pour compiler un template.
</para>
</sect2>
<sect2 id="language.variables.smarty.ldelim"> <sect2 id="language.variables.smarty.ldelim">
<title>{$smarty.ldelim}, {$smarty.rdelim}</title> <title>{$smarty.ldelim}, {$smarty.rdelim}</title>
<para> <para>
Cette variable est utilis<69>e pour afficher le d<>l<EFBFBD>miteur gauche et le d<>limiteur droit. Lisez aussi Cette variable est utilis<69>e pour afficher le d<>l<EFBFBD>miteur gauche et le d<>limiteur droit. Lisez aussi
la partie <link la partie <link linkend="language.function.ldelim">{ldelim},{rdelim}</link>.
linkend="language.function.ldelim">{ldelim},{rdelim}</link>.
</para> </para>
<para> <para>
Voir aussi les Voir aussi
<link linkend="language.syntax.variables">variables</link> et les les <link linkend="language.syntax.variables">variables</link> et
<link linkend="language.config.variables">variables de configuration</link>. les <link linkend="language.config.variables">variables de configuration</link>.
</para> </para>
</sect2> </sect2>
</sect1> </sect1>

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="iso-8859-1"?> <?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ --> <!-- $Revision$ -->
<!-- EN-Revision: 1.10 Maintainer: didou Status: ready --> <!-- EN-Revision: 1.13 Maintainer: yannick Status: ready -->
<part id="getting.started"> <part id="getting.started">
<title>Pour commencer</title> <title>Pour commencer</title>
@@ -155,7 +156,7 @@
<sect1 id="installing.smarty.basic"> <sect1 id="installing.smarty.basic">
<title>Installation de base</title> <title>Installation de base</title>
<para> <para>
Copiez les fichiers biblioth<74>ques de Smarty du r<EFBFBD>pertoire Copiez les fichiers biblioth<74>ques de Smarty du sous-dossier
/libs/ de la distribution <20> un emplacement accessible <20> PHP. /libs/ de la distribution <20> un emplacement accessible <20> PHP.
Ce sont des fichiers PHP que vous NE DEVEZ PAS Ce sont des fichiers PHP que vous NE DEVEZ PAS
modifier. Ils sont partag<61>s par toutes les applications et ne seront modifier. Ils sont partag<61>s par toutes les applications et ne seront
@@ -177,18 +178,18 @@ debug.tpl
</example> </example>
<para> <para>
Smarty utilise une constante PHP appel<65>e <link Smarty utilise une <ulink url="&url.php-manual;define">constante</ulink> PHP appel<65>e <link
linkend="constant.smarty.dir">SMARTY_DIR</link> qui linkend="constant.smarty.dir">SMARTY_DIR</link> qui
repr<70>sente le chemin complet de la biblioth<74>que Smarty. En fait, repr<70>sente le <emphasis role="bold">chemin complet</emphasis> de la biblioth<74>que Smarty. En fait,
si votre application trouve le fichier si votre application trouve le fichier
<filename>Smarty.class.php</filename>, vous n'aurez pas <filename>Smarty.class.php</filename>, vous n'aurez pas
besoin de d<>finir la variable <link linkend="constant.smarty.dir">SMARTY_DIR</link>, besoin de d<>finir la variable <link linkend="constant.smarty.dir">SMARTY_DIR</link>,
Smarty s'en chargera pour vous. Smarty s'en chargera pour vous.
En revanche, si <filename>Smarty.class.php</filename> En revanche, si <filename>Smarty.class.php</filename>
n'est pas dans votre r<>pertoire d'inclusion ou que vous ne n'est pas dans votre r<>pertoire d'inclusion ou que vous ne
donnez pas un chemin absolu <20> votre application, vous donnez pas un chemin absolu <20> votre application, vous
devez d<>finir SMARTY_DIR explicitement. SMARTY_DIR devez d<>finir SMARTY_DIR explicitement. SMARTY_DIR
<emphasis>doit</emphasis> avoir <20>tre termin<69> par un slash. <emphasis role="bold">doit</emphasis> avoir <20>tre termin<69> par un slash.
</para> </para>
<para> <para>
@@ -200,8 +201,9 @@ debug.tpl
<programlisting role="php"> <programlisting role="php">
<![CDATA[ <![CDATA[
<?php <?php
require('Smarty.class.php'); // Note : Smarty a un 'S' majuscule
$smarty = new Smarty; require_once('Smarty.class.php');
$smarty = new Smarty();
?> ?>
]]> ]]>
</programlisting> </programlisting>
@@ -214,40 +216,50 @@ $smarty = new Smarty;
</para> </para>
<example> <example>
<title>fournir un chemin absolu vers la biblioth<74>que Smarty</title> <title>D<EFBFBD>finition manuelle de la constante SMARTY_DIR</title>
<programlisting role="php"> <programlisting role="php">
<![CDATA[ <![CDATA[
<?php <?php
require('/usr/local/lib/php/Smarty/Smarty.class.php'); // Style *nix (notez le 'S' majuscule)
$smarty = new Smarty; define('SMARTY_DIR', '/usr/local/lib/php/Smarty-v.e.r/libs/');
// Style Windows
define('SMARTY_DIR', 'c:/webroot/libs/Smarty-v.e.r/libs/');
require_once(SMARTY_DIR . 'Smarty.class.php');
$smarty = new Smarty();
?> ?>
]]> ]]>
</programlisting> </programlisting>
</example> </example>
<example> <example>
<title>Ajouter le r<>pertoire de la biblioth<74>que dans l'include_path de PHP</title> <title>D<EFBFBD>finir le chemin absolu au fichier de la biblioth<74>que</title>
<programlisting role="php"> <programlisting role="php">
<![CDATA[ <![CDATA[
<?php <?php
// Editez votre fichier php.ini file, ajoutez le chemin de la // Style *nix (notez le 'S' majuscule)
// biblioth<74>que Smarty et red<65>marrez les serveur web. require_once('/usr/local/lib/php/Smarty-v.e.r/libs/Smarty.class.php');
// la ligne suivante doit alors fonctionner :
require('Smarty.class.php'); // Style Windows
$smarty = new Smarty; require_once('c:/webroot/libs/Smarty-v.e.r/libs/Smarty.class.php');
$smarty = new Smarty();
?> ?>
]]> ]]>
</programlisting> </programlisting>
</example> </example>
<example> <example>
<title>D<EFBFBD>finir explicitement la constante SMARTY_DIR</title> <title>Ajout du dossier contenant la biblioth<74>que <20> l'include_path de PHP</title>
<programlisting role="php"> <programlisting role="php">
<![CDATA[ <![CDATA[
<?php <?php
define('SMARTY_DIR', '/usr/local/lib/php/Smarty/'); // Editez votre fichier php.ini, ajoutez le dossier contenant la
require(SMARTY_DIR . 'Smarty.class.php'); // biblioth<74>que Smarty <20> l'include_path et red<65>marrez le serveur web.
$smarty = new Smarty; // Puis, ce qui suit devrait fonctionner :
require_once('Smarty.class.php');
$smarty = new Smarty();
?> ?>
]]> ]]>
</programlisting> </programlisting>
@@ -258,7 +270,7 @@ $smarty = new Smarty;
il est temps de d<>finir les r<>pertoires de Smarty, pour votre application. il est temps de d<>finir les r<>pertoires de Smarty, pour votre application.
</para> </para>
<para> <para>
Smarty a besoin de quatre r<>pertoires qui sont (par d<>faut) Smarty a besoin de quatre r<>pertoires qui sont, par d<>faut,
<filename class="directory">'templates/'</filename>, <filename class="directory">'templates/'</filename>,
<filename class="directory">'templates_c/'</filename>, <filename class="directory">'templates_c/'</filename>,
<filename class="directory">'configs/'</filename> et <filename class="directory">'configs/'</filename> et
@@ -332,19 +344,19 @@ $smarty = new Smarty;
<title>Exemple de structure de fichiers</title> <title>Exemple de structure de fichiers</title>
<screen> <screen>
<![CDATA[ <![CDATA[
/usr/local/lib/php/Smarty/Smarty.class.php /usr/local/lib/php/Smarty-v.e.r/libs/Smarty.class.php
/usr/local/lib/php/Smarty/Smarty_Compiler.class.php /usr/local/lib/php/Smarty-v.e.r/libs/Smarty_Compiler.class.php
/usr/local/lib/php/Smarty/Config_File.class.php /usr/local/lib/php/Smarty-v.e.r/libs/Config_File.class.php
/usr/local/lib/php/Smarty/debug.tpl /usr/local/lib/php/Smarty-v.e.r/libs/debug.tpl
/usr/local/lib/php/Smarty/internals/*.php /usr/local/lib/php/Smarty-v.e.r/libs/internals/*.php
/usr/local/lib/php/Smarty/plugins/*.php /usr/local/lib/php/Smarty-v.e.r/libs/plugins/*.php
/web/www.example.com/smarty/livredor/templates/ /web/www.example.com/smarty/guestbook/templates/
/web/www.example.com/smarty/livredor/templates_c/ /web/www.example.com/smarty/guestbook/templates_c/
/web/www.example.com/smarty/livredor/configs/ /web/www.example.com/smarty/guestbook/configs/
/web/www.example.com/smarty/livredor/cache/ /web/www.example.com/smarty/guestbook/cache/
/web/www.example.com/docs/livredor/index.php /web/www.example.com/docs/guestbook/index.php
]]> ]]>
</screen> </screen>
</example> </example>
@@ -389,7 +401,7 @@ chmod 770 /web/www.example.com/smarty/livredor/cache/
<para> <para>
Nous devons cr<63>er le fichier 'index.tpl' que Smarty va charger. Nous devons cr<63>er le fichier 'index.tpl' que Smarty va charger.
Il va se trouver dans <link linkend="variable.template.dir">$template_dir</link>. Il va se trouver dans le dossier <link linkend="variable.template.dir">$template_dir</link>.
</para> </para>
<example> <example>
@@ -399,7 +411,7 @@ chmod 770 /web/www.example.com/smarty/livredor/cache/
{* Smarty *} {* Smarty *}
Hello, {$name}! Bonjour, {$name}, Bienvenue dans Smarty !
]]> ]]>
</screen> </screen>
</example> </example>
@@ -419,34 +431,32 @@ Hello, {$name}!
<para> <para>
Maintenant passons <20> l'<27>dition du fichier 'index.php'. Nous allons Maintenant passons <20> l'<27>dition du fichier 'index.php'. Nous allons
cr<63>er une instance de Smarty, assigner une valeur <20> une variable cr<63>er une instance de Smarty, <link linkend="api.assign">assigner</link>
de template et afficher le r<>sultat avec 'index.tpl'. Dans notre une valeur <20> une variable de template et
exemple d'environnement, "/usr/local/lib/php/Smarty" est dans notre <link linkend="api.display">afficher</link> le r<>sultat avec 'index.tpl'.
include_path. Assurez-vous de faire la m<>me chose ou d'utiliser
des chemins absolus.
</para> </para>
<example> <example>
<title><EFBFBD>dition de /web/www.example.com/docs/livredor/index.php</title> <title><EFBFBD>dition de /web/www.example.com/docs/livredor/index.php</title>
<screen> <programlisting role="php">
<![CDATA[ <![CDATA[
<?php <?php
// charge la biblioth<74>que Smarty // charge la biblioth<74>que Smarty
require('Smarty.class.php'); require_once(SMARTY_DIR . 'Smarty.class.php');
$smarty = new Smarty; $smarty = new Smarty();
$smarty->template_dir = '/web/www.example.com/smarty/livredor/templates/'; $smarty->template_dir = '/web/www.example.com/smarty/livredor/templates/';
$smarty->compile_dir = '/web/www.example.com/smarty/livredor/templates_c/'; $smarty->compile_dir = '/web/www.example.com/smarty/livredor/templates_c/';
$smarty->config_dir = '/web/www.example.com/smarty/livredor/configs/'; $smarty->config_dir = '/web/www.example.com/smarty/livredor/configs/';
$smarty->cache_dir = '/web/www.example.com/smarty/livredor/cache/'; $smarty->cache_dir = '/web/www.example.com/smarty/livredor/cache/';
$smarty->assign('name','Ned'); $smarty->assign('name','Ned');
$smarty->display('index.tpl'); $smarty->display('index.tpl');
?> ?>
]]> ]]>
</screen> </programlisting>
</example> </example>
<note> <note>
@@ -465,7 +475,7 @@ Hello, {$name}!
<para> <para>
Et maintenant appelez le fichier <filename>index.php</filename> avec navigateur Et maintenant appelez le fichier <filename>index.php</filename> avec navigateur
Web. Vous devriez voir "Hello, Ned!". Web. Vous devriez voir "Bonjour, Ned, Bienvenue dans Smarty !".
</para> </para>
<para> <para>
Vous venez de terminer l'installation de base de Smarty ! Vous venez de terminer l'installation de base de Smarty !