3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
6 * Copyright (c) 2001-2012 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
9 * Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
10 * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
11 \***************************************************************************/
15 // Ce fichier definit les boucles standard de SPIP
18 if (!defined('_ECRIRE_INC_VERSION')) return;
21 // Boucle standard, sans condition rajoutee
23 // http://doc.spip.org/@boucle_DEFAUT_dist
24 function boucle_DEFAUT_dist($id_boucle, &$boucles) {
25 return calculer_boucle($id_boucle, $boucles);
30 // <BOUCLE(BOUCLE)> boucle dite recursive
32 // http://doc.spip.org/@boucle_BOUCLE_dist
33 function boucle_BOUCLE_dist($id_boucle, &$boucles) {
35 return calculer_boucle($id_boucle, $boucles);
40 // <BOUCLE(HIERARCHIE)>
42 // http://doc.spip.org/@boucle_HIERARCHIE_dist
43 function boucle_HIERARCHIE_dist($id_boucle, &$boucles) {
44 $boucle = &$boucles[$id_boucle];
45 $id_table = $boucle->id_table
. ".id_rubrique";
47 // Si la boucle mere est une boucle RUBRIQUES il faut ignorer la feuille
48 // sauf en presence du critere {tout} (vu par phraser_html)
49 // ou {id_article} qui positionne aussi le {tout}
51 $boucle->hierarchie
= 'if (!($id_rubrique = intval('
52 . calculer_argument_precedent($boucle->id_boucle
, 'id_rubrique', $boucles)
53 . ")))\n\t\treturn '';\n\t"
55 . (isset($boucle->modificateur
['tout']) ?
'",$id_rubrique"' : "''")
57 . 'while ($id_rubrique = sql_getfetsel("id_parent","spip_rubriques","id_rubrique=" . $id_rubrique,"","","", "", $connect)) {
58 $hierarchie = ",$id_rubrique$hierarchie";
60 if (!$hierarchie) return "";
61 $hierarchie = substr($hierarchie,1);';
63 $boucle->where
[]= array("'IN'", "'$id_table'", '"($hierarchie)"');
65 $order = "FIELD($id_table, \$hierarchie)";
66 if (!isset($boucle->default_order
[0]) OR $boucle->default_order
[0] != " DESC")
67 $boucle->default_order
[] = "\"$order\"";
69 $boucle->default_order
[0] = "\"$order DESC\"";
70 return calculer_boucle($id_boucle, $boucles);