d5e31a9731ac4c65c9ae7a59f4e7f4f0f0470ad2
[ptitvelo/web/www.git] / www / ecrire / public / boucles.php
1 <?php
2
3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
5 * *
6 * Copyright (c) 2001-2012 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
8 * *
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 \***************************************************************************/
12
13
14 //
15 // Ce fichier definit les boucles standard de SPIP
16 //
17
18 if (!defined('_ECRIRE_INC_VERSION')) return;
19
20 //
21 // Boucle standard, sans condition rajoutee
22 //
23 // http://doc.spip.org/@boucle_DEFAUT_dist
24 function boucle_DEFAUT_dist($id_boucle, &$boucles) {
25 return calculer_boucle($id_boucle, $boucles);
26 }
27
28
29 //
30 // <BOUCLE(BOUCLE)> boucle dite recursive
31 //
32 // http://doc.spip.org/@boucle_BOUCLE_dist
33 function boucle_BOUCLE_dist($id_boucle, &$boucles) {
34
35 return calculer_boucle($id_boucle, $boucles);
36 }
37
38
39 //
40 // <BOUCLE(HIERARCHIE)>
41 //
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";
46
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}
50
51 $boucle->hierarchie = 'if (!($id_rubrique = intval('
52 . calculer_argument_precedent($boucle->id_boucle, 'id_rubrique', $boucles)
53 . ")))\n\t\treturn '';\n\t"
54 . '$hierarchie = '
55 . (isset($boucle->modificateur['tout']) ? '",$id_rubrique"' : "''")
56 . ";\n\t"
57 . 'while ($id_rubrique = sql_getfetsel("id_parent","spip_rubriques","id_rubrique=" . $id_rubrique,"","","", "", $connect)) {
58 $hierarchie = ",$id_rubrique$hierarchie";
59 }
60 if (!$hierarchie) return "";
61 $hierarchie = substr($hierarchie,1);';
62
63 $boucle->where[]= array("'IN'", "'$id_table'", '"($hierarchie)"');
64
65 $order = "FIELD($id_table, \$hierarchie)";
66 if (!isset($boucle->default_order[0]) OR $boucle->default_order[0] != " DESC")
67 $boucle->default_order[] = "\"$order\"";
68 else
69 $boucle->default_order[0] = "\"$order DESC\"";
70 return calculer_boucle($id_boucle, $boucles);
71 }
72
73
74 ?>