Subversion Repositories Sites.tela-botanica.org

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4 david 1
<?php
2
 
3
/***************************************************************************\
4
 *  SPIP, Systeme de publication pour l'internet                           *
5
 *                                                                         *
6
 *  Copyright (c) 2001-2005                                                *
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
// Ce fichier ne sera execute qu'une fois
19
if (defined("_INC_BOUCLES")) return;
20
define("_INC_BOUCLES", "1");
21
 
22
//
23
// Boucle sur une table hors SPIP
24
//
25
function boucle_DEFAUT($id_boucle, &$boucles) {
26
	global $table_des_tables;
27
	$boucle = &$boucles[$id_boucle];
28
	$t = $table_des_tables[$boucle->type_requete];
29
	$boucle->from[] =  $boucle->type_requete . " AS " .
30
	  ($t ? $t : $boucle->type_requete);
31
	return calculer_boucle($id_boucle, $boucles);
32
}
33
 
34
 
35
//
36
// <BOUCLE(BOUCLE)> boucle dite recursive
37
//
38
function boucle_BOUCLE_dist($id_boucle, &$boucles) {
39
 
40
	return calculer_boucle($id_boucle, $boucles);
41
}
42
 
43
//
44
// <BOUCLE(ARTICLES)>
45
//
46
function boucle_ARTICLES_dist($id_boucle, &$boucles) {
47
	$boucle = &$boucles[$id_boucle];
48
	$id_table = $boucle->id_table;
49
	$boucle->from[] =  "spip_articles AS $id_table";
50
 
51
	// Restreindre aux elements publies
52
	if (!isset($boucle->where['statut'])) {
53
		if (!$GLOBALS['var_preview']) {
54
			$boucle->where['statut'] = "$id_table.statut='publie'";
55
			if (lire_meta("post_dates") == 'non')
56
				$boucle->where['statut'] .= " AND $id_table.date < NOW()";
57
		} else
58
			$boucle->where['statut'] = "$id_table.statut IN ('publie','prop')";
59
	}
60
	return calculer_boucle($id_boucle, $boucles);
61
}
62
 
63
//
64
// <BOUCLE(AUTEURS)>
65
//
66
function boucle_AUTEURS_dist($id_boucle, &$boucles) {
67
	$boucle = &$boucles[$id_boucle];
68
	$id_table = $boucle->id_table;
69
	$boucle->from[] =  "spip_auteurs AS $id_table";
70
 
71
	// Restreindre aux elements publies
72
	if (!isset($boucle->where['statut'])) {
73
		// Si pas de lien avec un article, selectionner
74
		// uniquement les auteurs d'un article publie
75
		if (!$GLOBALS['var_preview'])
76
		if (!$boucle->lien AND !$boucle->tout) {
77
			$boucle->from[] =  "spip_auteurs_articles AS lien";
78
			$boucle->from[] =  "spip_articles AS articles";
79
			$boucle->where[] = "lien.id_auteur=$id_table.id_auteur";
80
			$boucle->where[] = 'lien.id_article=articles.id_article';
81
			$boucle->where['statut'] = "articles.statut='publie'";
82
			$boucle->group =  $boucle->id_table . '.' . $boucle->primary;
83
		}
84
		// pas d'auteurs poubellises
85
		$boucle->where[] = "NOT($id_table.statut='5poubelle')";
86
	}
87
 
88
	return calculer_boucle($id_boucle, $boucles);
89
}
90
 
91
//
92
// <BOUCLE(BREVES)>
93
//
94
function boucle_BREVES_dist($id_boucle, &$boucles) {
95
	$boucle = &$boucles[$id_boucle];
96
	$id_table = $boucle->id_table;
97
	$boucle->from[] =  "spip_breves AS $id_table";
98
 
99
	// Restreindre aux elements publies
100
	if (!isset($boucle->where['statut'])) {
101
		if (!$GLOBALS['var_preview'])
102
			$boucle->where['statut'] = "$id_table.statut='publie'";
103
		else
104
			$boucle->where['statut'] = "$id_table.statut IN ('publie','prop')";
105
	}
106
 
107
	return calculer_boucle($id_boucle, $boucles);
108
}
109
 
110
 
111
//
112
// <BOUCLE(FORUMS)>
113
//
114
function boucle_FORUMS_dist($id_boucle, &$boucles) {
115
	$boucle = &$boucles[$id_boucle];
116
	$id_table = $boucle->id_table;
117
	$boucle->from[] =  "spip_forum AS $id_table";
118
	// Par defaut, selectionner uniquement les forums sans pere
119
	if (!$boucle->tout AND !$boucle->plat)
120
		$boucle->where[] = "$id_table.id_parent=0";
121
 
122
	// Restreindre aux elements publies
123
	if (!isset($boucle->where['statut'])) {
124
		$boucle->where['statut'] = "$id_table.statut='publie'";
125
	}
126
 
127
	return calculer_boucle($id_boucle, $boucles);
128
}
129
 
130
 
131
//
132
// <BOUCLE(SIGNATURES)>
133
//
134
function boucle_SIGNATURES_dist($id_boucle, &$boucles) {
135
	$boucle = &$boucles[$id_boucle];
136
	$id_table = $boucle->id_table;
137
	$boucle->from[] =  "spip_signatures AS $id_table";
138
	$boucle->from[] =  "spip_petitions AS petitions";
139
	$boucle->from[] =  "spip_articles articles";
140
	$boucle->where[] = "petitions.id_article=articles.id_article";
141
	$boucle->where[] = "petitions.id_article=$id_table.id_article";
142
 
143
	// Restreindre aux elements publies
144
	if (!isset($boucle->where['statut'])) {
145
		$boucle->where['statut'] = "$id_table.statut='publie'";
146
	}
147
 
148
	$boucle->group =  $boucle->id_table . '.' . $boucle->primary;
149
	return calculer_boucle($id_boucle, $boucles);
150
}
151
 
152
 
153
//
154
// <BOUCLE(DOCUMENTS)>
155
//
156
function boucle_DOCUMENTS_dist($id_boucle, &$boucles) {
157
	$boucle = &$boucles[$id_boucle];
158
	$id_table = $boucle->id_table;
159
	$boucle->from[] =  "spip_documents AS $id_table";
160
	$boucle->from[] =  "spip_types_documents AS types_documents";
161
	$boucle->where[] = "$id_table.id_type=types_documents.id_type";
162
	// on ne veut pas des fichiers de taille nulle,
163
	// sauf s'ils sont distants (taille inconnue)
164
	$boucle->where[] = "($id_table.taille > 0 OR $id_table.distant='oui')";
165
	return calculer_boucle($id_boucle, $boucles);
166
}
167
 
168
 
169
//
170
// <BOUCLE(TYPES_DOCUMENTS)>
171
//
172
function boucle_TYPES_DOCUMENTS_dist($id_boucle, &$boucles) {
173
	$boucle = &$boucles[$id_boucle];
174
	$id_table = $boucle->id_table;
175
	$boucle->from[] =  "spip_types_documents AS $id_table";
176
	return calculer_boucle($id_boucle, $boucles);
177
}
178
 
179
 
180
//
181
// <BOUCLE(GROUPES_MOTS)>
182
//
183
function boucle_GROUPES_MOTS_dist($id_boucle, &$boucles) {
184
	$boucle = &$boucles[$id_boucle];
185
	$id_table = $boucle->id_table;
186
	$boucle->from[] =  "spip_groupes_mots AS $id_table";
187
	return calculer_boucle($id_boucle, $boucles);
188
}
189
 
190
 
191
//
192
// <BOUCLE(MOTS)>
193
//
194
function boucle_MOTS_dist($id_boucle, &$boucles) {
195
	$boucle = &$boucles[$id_boucle];
196
	$id_table = $boucle->id_table;
197
	$boucle->from[] =  "spip_mots AS $id_table";
198
	return calculer_boucle($id_boucle, $boucles);
199
}
200
 
201
 
202
//
203
// <BOUCLE(RUBRIQUES)>
204
//
205
function boucle_RUBRIQUES_dist($id_boucle, &$boucles) {
206
	$boucle = &$boucles[$id_boucle];
207
	$id_table = $boucle->id_table;
208
	$boucle->from[] =  "spip_rubriques AS $id_table";
209
 
210
	// Restreindre aux elements publies
211
	if (!isset($boucle->where['statut'])) {
212
		if (!$GLOBALS['var_preview'])
213
			if (!$boucle->tout)
214
				$boucle->where['statut'] = "$id_table.statut='publie'";
215
	}
216
 
217
	return calculer_boucle($id_boucle, $boucles);
218
}
219
 
220
 
221
//
222
// <BOUCLE(HIERARCHIE)>
223
//
224
function boucle_HIERARCHIE_dist($id_boucle, &$boucles) {
225
	$boucle = &$boucles[$id_boucle];
226
	$id_table = $boucle->id_table;
227
	$boucle->from[] =  "spip_rubriques AS $id_table";
228
 
229
	// Si la boucle mere est une boucle RUBRIQUES il faut ignorer la feuille
230
	// sauf si le critere {tout} est present (cf. inc-html-squel)
231
	$exclure_feuille = ($boucle->tout ? 'false' : 'true');
232
 
233
	// $hierarchie sera calculee par une fonction de inc-calcul-outils
234
	$boucle->where[] = 'id_rubrique IN ($hierarchie)';
235
	$boucle->select[] = 'FIND_IN_SET(id_rubrique, \'$hierarchie\')-1 AS rang';
236
	$boucle->default_order = array('rang');
237
	$boucle->hierarchie = '$hierarchie = calculer_hierarchie('
238
	. calculer_argument_precedent($boucle->id_boucle, 'id_rubrique', $boucles)
239
	. ', '
240
	. $exclure_feuille
241
	. ');';
242
	return calculer_boucle($id_boucle, $boucles);
243
}
244
 
245
 
246
//
247
// <BOUCLE(SYNDICATION)>
248
//
249
function boucle_SYNDICATION_dist($id_boucle, &$boucles) {
250
	$boucle = &$boucles[$id_boucle];
251
	$id_table = $boucle->id_table;
252
	$boucle->from[] =  "spip_syndic AS $id_table";
253
 
254
	// Restreindre aux elements publies
255
	if (!isset($boucle->where['statut'])) {
256
		if (!$GLOBALS['var_preview']) {
257
			$boucle->where['statut'] = "$id_table.statut='publie'";
258
		} else
259
			$boucle->where['statut'] = "$id_table.statut IN ('publie','prop')";
260
	}
261
 
262
	return calculer_boucle($id_boucle, $boucles);
263
}
264
 
265
 
266
//
267
// <BOUCLE(SYNDIC_ARTICLES)>
268
//
269
function boucle_SYNDIC_ARTICLES_dist($id_boucle, &$boucles) {
270
	$boucle = &$boucles[$id_boucle];
271
	$id_table = $boucle->id_table;
272
	$boucle->from[] =  "spip_syndic_articles  AS $id_table";
273
	$boucle->from[] =  "spip_syndic AS syndic";
274
	$boucle->where[] = "$id_table.id_syndic=syndic.id_syndic";
275
 
276
	// Restreindre aux elements publies
277
	if (!isset($boucle->where['statut'])) {
278
		if (!$GLOBALS['var_preview']) {
279
			$boucle->where['statut'] = "$id_table.statut='publie'";
280
			$boucle->where[] = "syndic.statut='publie'";
281
		} else
282
			$boucle->where['statut'] = "$id_table.statut IN ('publie','prop')";
283
	}
284
 
285
	return calculer_boucle($id_boucle, $boucles);
286
}
287
 
288
 
289
?>