Subversion Repositories Applications.bazar

Rev

Rev 5 | Rev 9 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5 florian 1
<?php
2
/** baz_valeur_template() - Renvoi des valeurs inscrite dans le fichier de template
3
*
4
* @param   string nom du fichier de template
5
*
6
* @return   mixed  tableau contenant les champs du fichier template
7
*/
8
function baz_valeurs_template($fichier_template) {
9
	//Parcours du fichier de templates, pour mettre les champs spécifiques
10
	$nblignes=0;
11
	$fichier=file_get_contents(BAZ_CHEMIN_APPLI.'templates/'.$fichier_template);
12
	$chaine = explode ("\n", $fichier);
13
	array_pop($chaine);
14
	foreach ($chaine as $ligne)  {
15
		$souschaine = explode ("***", $ligne) ;
16
		$tableau[$nblignes]['type'] = trim($souschaine[0]) ;
17
		if (isset($souschaine[1])) {$tableau[$nblignes]['nom_bdd'] = trim($souschaine[1]);}
18
		else {$tableau[$nblignes]['nom_bdd'] ='';}
19
		if (isset($souschaine[2])) $tableau[$nblignes]['label'] = trim($souschaine[2]);
20
		else {$tableau[$nblignes]['label'] ='';}
21
		if (isset($souschaine[3])) $tableau[$nblignes]['limite1'] = trim($souschaine[3]);
22
		else {$tableau[$nblignes]['limite1'] ='';}
23
		if (isset($souschaine[4])) $tableau[$nblignes]['limite2'] = trim($souschaine[4]);
24
		else {$tableau[$nblignes]['limite2'] ='';}
25
		if (isset($souschaine[5])) $tableau[$nblignes]['defaut'] = trim($souschaine[5]);
26
		else {$tableau[$nblignes]['defaut'] ='';}
27
		if (isset($souschaine[6])) $tableau[$nblignes]['table_source'] = trim($souschaine[6]);
28
		else {$tableau[$nblignes]['table_source'] ='';}
29
		if (isset($souschaine[7])) $tableau[$nblignes]['id_source'] = trim($souschaine[7]);
30
		else {$tableau[$nblignes]['id_source'] ='';}
31
		if (isset($souschaine[8])) $tableau[$nblignes]['obligatoire'] = trim($souschaine[8]);
32
		else {$tableau[$nblignes]['obligatoire'] ='';}
33
		$nblignes++;
34
	}
35
	return $tableau;
36
}
37
 
38
 
39
/**  baz_voir_fiche() - Permet de visualiser en détail une fiche  au format XHTML
40
*
41
* @global boolean Rajoute des informations internes à l'application (date de modification, lien vers la page de départ de l'appli) si à 1
42
* @global integer Identifiant de la fiche à afficher
43
*
44
* @return   string  HTML
45
*/
46
function baz_voir_fiche($danslappli, $idfiche='') {
47
	if (isset($_GET['id_fiche'])) $GLOBALS['_BAZAR_']['id_fiche']=$_GET['id_fiche'];
48
	if ($idfiche!='') $GLOBALS['_BAZAR_']['id_fiche']=$idfiche;
49
 
7 florian 50
	//on met à jour le nb de visites pour la fiche
51
	$requete = 'UPDATE bazar_fiche SET bf_nb_consultations=bf_nb_consultations+1 WHERE bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
5 florian 52
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
7 florian 53
 
54
	//on cherche le type d'annonce, l'annonceur et les stats
55
	$requete = 'SELECT bn_label_nature, bn_commentaire, bn_appropriation, bf_ce_utilisateur,bf_nb_consultations  FROM bazar_fiche, bazar_nature WHERE bn_id_nature=bf_ce_nature AND bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
56
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
5 florian 57
	if (DB::isError($resultat)) {
58
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
59
	}
60
	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
61
		$GLOBALS['_BAZAR_']['typeannonce']=$ligne['bn_label_nature'];
7 florian 62
		$GLOBALS['_BAZAR_']['commentaire']=$ligne['bn_commentaire'];
63
		$GLOBALS['_BAZAR_']['appropriation']=$ligne['bn_appropriation'];
64
		$GLOBALS['_BAZAR_']['annonceur']=$ligne['bf_ce_utilisateur'];
65
		$GLOBALS['_BAZAR_']['nb_consultations']=$ligne['bf_nb_consultations'];
5 florian 66
	}
7 florian 67
	$res = '<div class="BAZ_cadre_fiche">'."\n";
68
	$res .= '<div class="BAZ_cadre_fiche_haut">'."\n";
5 florian 69
	$res .= '&nbsp;</div>'."\n";
7 florian 70
	$res .= '<div class="BAZ_cadre_fiche_corps">'."\n";
5 florian 71
 
72
	//si le template existe, on génère le template
73
	if ((file_exists(BAZ_CHEMIN_APPLI.'templates/'.$GLOBALS['_BAZAR_']['typeannonce'].'-fiche.php'))) {
74
		include_once(BAZ_CHEMIN_APPLI.'templates/'.$GLOBALS['_BAZAR_']['typeannonce'].'-fiche.php');
7 florian 75
		$res .=genere_fiche($GLOBALS['_BAZAR_']['id_fiche']);
5 florian 76
	}
77
	//on affiche ligne par ligne sinon
78
	else {
79
		$requete = 'SELECT * FROM bazar_fiche WHERE bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
80
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
81
		if (DB::isError ($resultat)) {
82
			die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
83
		}
84
		$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC) ;
85
 
7 florian 86
		if (isset($ligne['bf_url_image'])) {
87
			$res .= '<div id="fiche_image">'."\n";
88
			$res .= '<img src="'.'http://'.$_SERVER['HTTP_HOST'].'/client/bazar/images/'.$ligne['bf_url_image'].'" border=0 alt="'.BAZ_TEXTE_IMG_ALTERNATIF.'" />'."\n";
89
			$res .= '</div>'."\n";
90
			$res .= '<div id="fiche_titre_image">'.$ligne['bf_titre'];
91
		}
92
		else {
93
			$res .= '<div id="fiche_titre">'.$ligne['bf_titre'];
94
		}
95
		$res .= '</div>'."\n";
96
		$res .= '<div id="BAZ_description">'.$ligne['bf_description'].'</div>'."\n";
5 florian 97
		$tableau=baz_valeurs_template($GLOBALS['_BAZAR_']['typeannonce'].'.tpl');
98
		for ($i=0; $i<count($tableau); $i++) {
99
			if (isset($ligne[$tableau[$i]['nom_bdd']])) {
100
				//pour les champs renseignés par une liste, on va chercher le label de la liste, plutot que l'id
101
				if ($tableau[$i]['type']=='liste') {
102
					$requete = 'SELECT '.$tableau[$i]['table_source'].'.* FROM bazar_fiche, '.$tableau[$i]['table_source'].
103
					' WHERE '.$tableau[$i]['nom_bdd'].'='.$tableau[$i]['id_source'].' AND bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
104
					$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
105
					if (DB::isError ($resultat)) {
106
						die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
107
					}
108
					while ($tab = $resultat->fetchRow()) {
7 florian 109
						$val=$tab[1];
5 florian 110
					}
111
				}
112
				else {
7 florian 113
					$val=$ligne[$tableau[$i]['nom_bdd']];
5 florian 114
				}
115
				if (($tableau[$i]['nom_bdd']!='bf_titre')and($tableau[$i]['nom_bdd']!='bf_description')) {
7 florian 116
					if ($val!='') {
117
						$res .= '<span class="rubrique">'.constant($tableau[$i]['label']).':</span>'."\n";
118
						$res .= '<span class="description"> '.$val.'</span>'."\n".'<br />'."\n";
119
					}
5 florian 120
				}
121
			}
122
		}
7 florian 123
	}
124
	//afficher les liens pour l'annonce
125
	$requete = 'SELECT  bu_url, bu_descriptif_url FROM bazar_url WHERE bu_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
126
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
127
	if (DB::isError($resultat)) {
128
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
129
	}
130
	if ($resultat->numRows()>0) {
131
		$res .= '<span class="rubrique">'.BAZ_LIEN_INTERNET.':</span>'."\n";
132
		$res .= '<span class="description">'."\n";
133
		$res .= '<ul>'."\n";
134
		while ($ligne1 = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
135
			$res .= '<li><a href="'.$ligne1['bu_url'].'" target="_blank">'.$ligne1['bu_descriptif_url'].'</a></li>'."\n";
5 florian 136
		}
7 florian 137
		$res .= '</ul></span>'."\n";
138
	}
139
 
140
	//afficher les fichiers pour l'annonce
141
	$requete = 'SELECT  bfj_description, bfj_fichier FROM bazar_fichier_joint WHERE bfj_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
142
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
143
	if (DB::isError($resultat)) {
144
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
145
	}
146
	if ($resultat->numRows()>0) {
147
		$res .= '<span class="rubrique">'.BAZ_LISTE_FICHIERS_JOINTS.':</span>'."\n";
148
		$res .= '<span class="description">'."\n";
149
		$res .= '<ul>'."\n";
150
		while ($ligne2 = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
151
			$res .= '<li><a href="http://'.$_SERVER['HTTP_HOST'].'/client/bazar/upload/'.$ligne2['bfj_fichier'].'">'.$ligne2['bfj_description'].'</a></li>'."\n";
152
		}
153
		$res .= '</ul></span>'."\n";
154
	}
155
	$res .= '<div id="bulle_haut">&nbsp;</div>'."\n";
156
	$res .= '<div id="bulle_corps">'."\n";
157
 
158
	//affichage du rédacteur de la fiche
159
	$requete = 'SELECT '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.', '.BAZ_CHAMPS_EMAIL.' FROM '.BAZ_ANNUAIRE.' WHERE '.BAZ_CHAMPS_ID.'='.$GLOBALS['_BAZAR_']['annonceur'];
160
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
161
	if (DB::isError($resultat)) {
162
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
163
	}
164
	while ($redacteur = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
165
		$res .= BAZ_FICHE_ECRITE.'<a href="mailto:'.$redacteur[BAZ_CHAMPS_EMAIL].'">'.$redacteur[BAZ_CHAMPS_PRENOM].' '.$redacteur[BAZ_CHAMPS_NOM].'</a><br />'."\n";
166
	}
167
	$res .= BAZ_NB_VUS.'<strong>'.$GLOBALS['_BAZAR_']['nb_consultations'].'</strong>'.BAZ_FOIS.'<br />'."\n";
168
	$res .= '</div>'."\n";
169
	$res .= '<div id="bulle_bas">&nbsp;</div>'."\n";
170
	$res .= '<div id="BAZ_bas_page">';
171
	//informations complémentaires (id fiche, état publication,... )
172
	if ($danslappli==1) {
173
		$res .= '<span class="rubrique">'.BAZ_NUM_FICHE.':</span> '.$GLOBALS['_BAZAR_']['id_fiche'].'<br />'."\n";
174
		$res .= '<span class="rubrique">'.BAZ_NATURE.':</span> '.$GLOBALS['_BAZAR_']['typeannonce'].'<br />'."\n";
175
		if ($ligne['bf_statut_fiche']==1) {
176
			$res .= '<span class="rubrique">'.BAZ_PUBLIEE.':</span> '.BAZ_OUI.'<br />'."\n";
177
		}
178
		else {
179
			$res .= '<span class="rubrique">'.BAZ_PUBLIEE.':</span> '.BAZ_NON.'<br />'."\n";
180
		}
181
		$res .= '<span class="rubrique">'.BAZ_DATE_CREATION.':</span> '.strftime('%d.%m.%Y &agrave; %H:%M',strtotime($ligne['bf_date_creation_fiche'])).'<br />'."\n";
182
		$res .= '<span class="rubrique">'.BAZ_DATE_MAJ.':</span> '.strftime('%d.%m.%Y &agrave; %H:%M',strtotime($ligne['bf_date_maj_fiche']));
183
		//pour les identifiés seulement, administrateurs de la rubrique ou superadmins
184
		if ($GLOBALS['AUTH']->getAuth()) {
185
			$est_admin=0;
186
			$requete='SELECT bn_id_nature FROM bazar_nature WHERE bn_label_nature="'.$GLOBALS['_BAZAR_']['typeannonce'].'"';
187
			$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
188
			if (DB::isError($resultat)) {
189
				die ($resultat->getMessage().$resultat->getDebugInfo()) ;
5 florian 190
			}
7 florian 191
			$result = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
192
			if ((niveau_droit($result['bn_id_nature'],$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID)))=='administrateur') {
193
				$est_admin=1;
194
			}
195
			if (($est_admin)or(niveau_droit($id_nature_offre='0',$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))=='superadministrateur')or($GLOBALS['_BAZAR_']['annonceur']==$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))) {
196
				$lien_modifier=$GLOBALS['_BAZAR_']['url'];
197
				$lien_modifier->addQueryString('action', BAZ_ACTION_MODIFIER);
198
				$lien_modifier->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
199
				$lien_modifier->addQueryString('typeannonce', $GLOBALS['_BAZAR_']['typeannonce']);
200
				$res .= '&nbsp;<a href="'.$lien_modifier->getURL().'">'.BAZ_MODIFIER_LA_FICHE.'</a>'."\n";
201
			}
5 florian 202
		}
7 florian 203
	}
204
	$res .= '</div>'."\n";
205
	$res .= '</div>'."\n";
206
	$res .= '<div class="BAZ_cadre_fiche_bas">&nbsp;</div>'."\n";
207
	$res .= '</div>'."\n";
208
 
209
	//on ajoute les commentaires, s'il le faut
210
	if ($GLOBALS['_BAZAR_']['commentaire']==1) {
211
		$res .= '<div class="BAZ_cadre_fiche">'."\n";
212
		$res .= '<div class="BAZ_cadre_fiche_haut">&nbsp;</div>'."\n";
213
		$res .= '<div class="BAZ_cadre_fiche_corps">'."\n";
214
		$res .= '<h3>'.BAZ_LES_COMMENTAIRES.'</h3>'."\n";
215
		$requete = 'SELECT * FROM bazar_commentaires WHERE bc_ce_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].' ORDER BY bc_date ASC';
5 florian 216
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
7 florian 217
		if (DB::isError ($resultat)) {
218
			die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
5 florian 219
		}
220
		if ($resultat->numRows()>0) {
7 florian 221
			$res .= 'Il y a '.$resultat->numRows();
222
			if ($resultat->numRows()==1) $res .= 'commentaire : '.'<br />'."\n";
223
			else $res .= 'commentaires : '.'<br />'."\n";
5 florian 224
			while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
7 florian 225
				$res .= 'essai'."\n";
5 florian 226
			}
227
		}
7 florian 228
		else $res .= BAZ_PAS_DE_COMMENTAIRES.'<br />'."\n";
229
		$res .= '</div>'."\n";
230
		$res .= '<div class="BAZ_cadre_fiche_bas">&nbsp;</div>'."\n";
231
		$res .= '</div>'."\n";
232
	}
233
 
234
	//on ajoute les appropriations, s'il le faut
235
	if ($GLOBALS['_BAZAR_']['appropriation']==1) {
236
		$res .= '<div class="BAZ_cadre_fiche">'."\n";
237
		$res .= '<div class="BAZ_cadre_fiche_haut">&nbsp;</div>'."\n";
238
		$res .= '<div class="BAZ_cadre_fiche_corps">'."\n";
5 florian 239
 
7 florian 240
		$res .= '</div>'."\n";
241
		$res .= '<div class="BAZ_cadre_fiche_bas">&nbsp;</div>'."\n";
242
		$res .= '</div>'."\n";
5 florian 243
	}
7 florian 244
 
5 florian 245
	return $res ;
246
}
247
 
248
 
249
/** RSSversHTML () transforme un flux RSS (en XML) en page HTML
250
*
251
*   On passe en paramètre le contenu du flux RSS, on affiche ou non la description,
252
*   et on choisit de format de la date à l'affichage. On a en sortie du code HTML à afficher
253
*
254
*   @param  string   le contenu du flux RSS
255
*   @param  boolean  afficher ou non la description
256
*   @param  string  choisir le format de date: jmah (12/02/2004 12h34) jmh (12/02 12h34) jma (12/02/2004) jm (12/02) ou rien
257
*
258
*   @return  string    le code HTML
259
*/
260
 
261
function RSSversHTML($rss, $voirdesc, $formatdate) {
262
	if ($rss!='') {
263
		$res='';
264
		if( eregi('<item>(.*)</item>', $rss, $rawitems ) ) {
265
			$items = explode('<item>', $rawitems[0]);
266
			$res.='<ul>'."\n";
267
			for( $i = 0; $i < count($items)-1; $i++ ) {
268
				eregi('<title>(.*)</title>',$items[$i+1], $title );
269
				eregi('<link>(.*)</link>',$items[$i+1], $url );
270
				eregi('<description>(.*)</description>',$items[$i+1], $cat);
271
				eregi('<pubDate>(.*)</pubDate>',$items[$i+1], $date);
272
				$res.='<li>';
273
				if ($formatdate=='jm') {$res.=strftime('%d.%m',strtotime($date[1])).': ';}
274
				if ($formatdate=='jma') {$res.=strftime('%d.%m.%Y',strtotime($date[1])).': ';}
275
				if ($formatdate=='jmh') {$res.=strftime('%d.%m %H:%M',strtotime($date[1])).': ';}
276
				if ($formatdate=='jmah') {$res.=strftime('%d.%m.%Y %H:%M',strtotime($date[1])).': ';}
277
				$res.='<a href="'.preg_replace ('/&amp;/', '&', $url[1]).'">'.$title[1].'</a><br />';
278
				if ($voirdesc) {$res.=$cat[1];}
279
				$res.='</li>'."\n";
280
			}
281
			$res.='</ul>'."\n";
282
		}
283
	}
284
	else $res = BAZ_PAS_D_ANNONCES;
285
	return $res;
286
}
287
 
288
/** gen_RSS() - générer un fichier de flux RSS par type d'annonce
289
*
290
* @param   string Le type de l'annonce (laisser vide pour tout type d'annonce)
291
* @param   integer Le nombre d'annonces a regrouper dans le fichier XML (laisser vide pour toutes)
292
* @param   integer L'identifiant de l'emetteur (laisser vide pour tous)
293
* @param   integer L'état de validation de l'annonce (laisser 1 pour les annonces validées, 0 pour les non-validées)
294
* @param   string La requète SQL personnalisée
295
*
296
* @return  string Le code du flux RSS
297
*/
298
function gen_RSS($typeannonce='', $nbitem='', $emetteur='', $valide=1, $requeteSQL='') {
299
	// génération de la requete MySQL personnalisée
300
	$requete = 'SELECT DISTINCT bf_id_fiche, bf_titre, bf_date_debut_validite_fiche, bn_label_nature FROM bazar_fiche, bazar_nature';
301
	$requete .= ' WHERE bf_statut_fiche='.$valide;
302
	$nomflux=BAZ_DERNIERE_ACTU;
303
	if (($typeannonce!='')and($typeannonce!='toutes')) {
304
		$requete .= ' AND bn_label_nature="'.$typeannonce.'"';
305
		//le nom du flux devient le type d'annonce
306
		$nomflux = $typeannonce;
307
	}
308
	if ($valide!=0) $requete .= ' AND bf_date_debut_validite_fiche<=NOW() AND bf_date_fin_validite_fiche>=NOW() AND bn_id_nature=bf_ce_nature';
309
	else $nomflux .= BAZ_A_MODERER;
310
	if (($emetteur!='')and($emetteur!='tous')) {
311
		$requete .= ' AND bf_ce_utilisateur='.$emetteur;
312
		//requete pour afficher le nom de la structure
313
		$requetenom = 'SELECT '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.' FROM '.BAZ_ANNUAIRE.' WHERE '.BAZ_CHAMPS_ID.'='.$emetteur;
314
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requetenom) ;
315
		if (DB::isError($resultat)) {
316
			die ($resultat->getMessage().$resultat->getDebugInfo()) ;
317
		}
318
		$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
319
		$nomflux .= ' ('.$ligne[BAZ_CHAMPS_NOM].' '.$ligne[BAZ_CHAMPS_PRENOM].')';
320
	}
321
	if ($requeteSQL!='') $requete .= ' AND ('.$requeteSQL.')';
322
	$requete .= ' ORDER BY  bf_date_debut_validite_fiche, bf_date_fin_validite_fiche, bf_date_maj_fiche DESC';
323
	if ($nbitem!='') {$requete .= ' LIMIT 0,'.$nbitem;}
324
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
325
	if (DB::isError($resultat)) {
326
		die ($GLOBALS['_BAZAR_']['db']->getMessage().$GLOBALS["db"]->getDebugInfo()) ;
327
	}
328
	// En-tête du flux RSS version 2.0
329
	$xml = '<?xml version="1.0" encoding="ISO-8859-1"?>'."\n".'<rss version="2.0">'."\n";
330
	$xml .= '<channel>'."\n".'<title>'.$nomflux.'</title>'."\n".'<link>'.BAZ_RSS_ADRESSESITE.'</link>'."\n";
331
	$xml .= '<description>'.BAZ_RSS_DESCRIPTIONSITE.'</description>'."\n".'<language>fr-FR</language>'."\n".
332
	'<copyright>Copyright 2005 '.BAZ_RSS_NOMSITE.'</copyright>'."\n";
333
	// Ajout de la date actuelle de publication (suivant la DTD RSS)
334
	$xml .= '<lastBuildDate>'.strftime('%d %b %Y %H:%M:%S GMT').'</lastBuildDate>'."\n";
335
	// En-tête suite et fin
336
	$xml .= '<docs>http://www.stervinou.com/projets/rss/</docs>'."\n".'<category>'.BAZ_RSS_CATEGORIE.'</category>'."\n".
337
	'<managingEditor>'.BAZ_RSS_MANAGINGEDITOR.'</managingEditor>'."\n".'<webMaster>'.BAZ_RSS_WEBMASTER.'</webMaster>'."\n";
338
	$xml .= '<ttl>60</ttl>'."\n".'<image>'."\n".'<title>'.BAZ_RSS_NOMSITE.'</title>'."\n".'<url>'.BAZ_RSS_LOGOSITE.'</url>'."\n".
339
	'<link>'.BAZ_RSS_ADRESSESITE.'</link>'."\n".'</image>'."\n";
340
	if ($resultat->numRows()>0) {
341
		// Creation des items : titre + lien + description + date de publication
342
		while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
343
			$xml .= '<item>'."\n";
344
			$xml .= '<title>'.$ligne['bf_titre'].'</title>'."\n";
345
			$lien=$GLOBALS['_BAZAR_']['url'];
346
			$lien->addQueryString('action', BAZ_VOIR_FICHE);
347
			$lien->addQueryString('id_fiche', $ligne['bf_id_fiche']);
348
			$xml .= '<link>'.str_replace ('&', '&amp;', $lien->getURL()).'</link>'."\n";
349
			$xml .= '<description>'."\n".'<![CDATA['.baz_voir_fiche(0,$ligne['bf_id_fiche']).']]>'."\n".'</description>'."\n";
350
			$xml .= '<pubDate>'.strftime('%d %b %Y %H:%M:%S GMT',strtotime($ligne['bf_date_debut_validite_fiche'])).'</pubDate>'."\n";
351
			$xml .= '</item>'."\n";
352
		}
353
	}
354
	else {//pas d'annonces
355
		$xml .= '<item>'."\n";
356
		$xml .= '<title>&nbsp;</title>'."\n";
357
		$xml .= '<link>http://test.educ-envir.org</link>'."\n";
358
		$xml .= '<description>&nbsp;</description>'."\n";
359
		$xml .= '<pubDate>'.strftime('%d %b %Y %H:%M:%S GMT',strtotime('12/12/2004')).'</pubDate>'."\n";
360
		$xml .= '</item>'."\n";
361
	}
362
	$xml .= '</channel>'."\n".'</rss>'."\n";
363
	return $xml;
364
}
365
 
366
 
367
/** baz_liste() Formate la liste de toutes les annonces actuelles
368
*
369
*   @return  string    le code HTML à afficher
370
*/
371
function baz_liste($typeannonce='toutes') {
372
	if ($typeannonce=='toutes') $res= '<h2>'.BAZ_TOUTES_LES_ANNONCES.'</h2>'."\n";
373
	else $res= '<h2>'.BAZ_TOUTES_LES_ANNONCES_DE_TYPE.$typeannonce.'</h2>'."\n";
374
	$res.=RSSversHTML(gen_RSS($typeannonce, '', '', 1, ''), 0, 'jm') ;
375
	return $res;
376
}
377
 
378
?>