From 02ec1f2dd43a2ef03ad6bc194ef8b6caa0f0f61f Mon Sep 17 00:00:00 2001 From: Matthieu Marcillaud <marcimat@rezo.net> Date: Wed, 9 Apr 2008 12:03:55 +0000 Subject: [PATCH] =?UTF-8?q?-=20introduction=20de=203=20filtres=20pour=20si?= =?UTF-8?q?mplifier=20certaines=20ecritures=20conditionnelles=20:=20et,=20?= =?UTF-8?q?ou=20et=20xou=20(ou=20exclusif).=20Ces=20fonctions=20retournent?= =?UTF-8?q?=20l'=C3=A9quivalent=20de=20|=3F{'=20',''}=20soit=20un=20espace?= =?UTF-8?q?=20si=20la=20condition=20est=20v=C3=A9rifi=C3=A9e,=20sinon=20un?= =?UTF-8?q?e=20chaine=20vide.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cette écriture php : if ($a=='oui' OR ($b=='oui' AND $c=='oui')) {echo "OK";} peut s'écrire dans un squelette : [(#A|=={oui} |ou{[(#B|=={oui} |et{[(#C|=={oui})]})]}) OK ] ou plus simplement : [(#B|=={oui} |et{[(#C|=={oui})] |ou{[(#A|=={oui})]}) OK ] --- ecrire/inc/filtres.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/ecrire/inc/filtres.php b/ecrire/inc/filtres.php index fc52e218e5..c6d3b15607 100644 --- a/ecrire/inc/filtres.php +++ b/ecrire/inc/filtres.php @@ -1800,6 +1800,31 @@ function filtre_find($array, $val) { return ($array != '' AND in_array($val, $array)); } + +// fonctions et, ou et xou +// pour faciliter l'ecriture de tests conditionnels +// ces fonctions retournent un espace si la condition +// est verifiee, sinon une chaine vide. + +// Filtre et : ($a && $b) +// [(#BALISE|=={val}|et{[(#AUTRE|=={val})]) Condition OK ] +function filtre_et($a, $b){ + return ($a && $b)?' ':''; +} + +// Filtre ou : ($a || $b) +// [(#BALISE|=={val}|ou{[(#AUTRE|=={val})]) Condition OK ] +function filtre_ou($a, $b){ + return ($a || $b)?' ':''; +} + +// Filtre xou : ($a xor $b) +// [(#BALISE|=={val}|xou{[(#AUTRE|=={val})]) Condition OK ] +function filtre_xou($a, $b){ + return ($a XOR $b)?' ':''; +} + + // // fonction standard de calcul de la balise #PAGINATION // on peut la surcharger en definissant dans mes_fonctions : -- GitLab