Subversion Repositories Applications.papyrus

Rev

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

Rev Author Line No. Line
427 florian 1
<?php
845 alexandre_ 2
/*vim: set expandtab tabstop=4 shiftwidth=4: */
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 4.1                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
8
// | This library is free software; you can redistribute it and/or                                        |
9
// | modify it under the terms of the GNU Lesser General Public                                           |
10
// | License as published by the Free Software Foundation; either                                         |
11
// | version 2.1 of the License, or (at your option) any later version.                                   |
12
// |                                                                                                      |
13
// | This library is distributed in the hope that it will be useful,                                      |
14
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
15
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
16
// | Lesser General Public License for more details.                                                      |
17
// |                                                                                                      |
18
// | You should have received a copy of the GNU Lesser General Public                                     |
19
// | License along with this library; if not, write to the Free Software                                  |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// +------------------------------------------------------------------------------------------------------+
1243 alexandre_ 22
// CVS : $Id: bazar.fonct.rss.php,v 1.60.2.10 2007-03-06 09:41:15 alexandre_tb Exp $
845 alexandre_ 23
/**
24
*
25
*@package bazar
26
//Auteur original :
27
*@author        Alexandre GRANIER <alexandre@tela-botanica.org>
28
*@author        Florian Schmitt <florian@ecole-et-nature.org>
29
//Autres auteurs :
30
*@copyright     Tela-Botanica 2000-2006
1243 alexandre_ 31
*@version       $Revision: 1.60.2.10 $
845 alexandre_ 32
// +------------------------------------------------------------------------------------------------------+
33
*/
828 florian 34
 
845 alexandre_ 35
// +------------------------------------------------------------------------------------------------------+
36
// |                                            ENTETE du PROGRAMME                                       |
37
// +------------------------------------------------------------------------------------------------------+
38
 
828 florian 39
require_once BAZ_CHEMIN_APPLI.'bibliotheque/bazar.class.php';
40
require_once BAZ_CHEMIN_APPLI.'bibliotheque/bazar.fonct.php';
41
 
845 alexandre_ 42
 
427 florian 43
/** baz_valeur_template() - Renvoi des valeurs inscrite dans le fichier de template
44
*
694 florian 45
* @param   string valeur du template de bazar_nature
427 florian 46
*
47
* @return   mixed  tableau contenant les champs du fichier template
48
*/
694 florian 49
function baz_valeurs_template($valeur_template) {
955 florian 50
	//Parcours du fichier de templates, pour mettre les champs specifiques
847 florian 51
	$tableau= array();
427 florian 52
	$nblignes=0;
694 florian 53
	$chaine = explode ("\n", $valeur_template);
427 florian 54
	array_pop($chaine);
55
	foreach ($chaine as $ligne)  {
56
		$souschaine = explode ("***", $ligne) ;
57
		$tableau[$nblignes]['type'] = trim($souschaine[0]) ;
58
		if (isset($souschaine[1])) {$tableau[$nblignes]['nom_bdd'] = trim($souschaine[1]);}
59
		else {$tableau[$nblignes]['nom_bdd'] ='';}
60
		if (isset($souschaine[2])) $tableau[$nblignes]['label'] = trim($souschaine[2]);
61
		else {$tableau[$nblignes]['label'] ='';}
62
		if (isset($souschaine[3])) $tableau[$nblignes]['limite1'] = trim($souschaine[3]);
63
		else {$tableau[$nblignes]['limite1'] ='';}
64
		if (isset($souschaine[4])) $tableau[$nblignes]['limite2'] = trim($souschaine[4]);
65
		else {$tableau[$nblignes]['limite2'] ='';}
66
		if (isset($souschaine[5])) $tableau[$nblignes]['defaut'] = trim($souschaine[5]);
67
		else {$tableau[$nblignes]['defaut'] ='';}
68
		if (isset($souschaine[6])) $tableau[$nblignes]['table_source'] = trim($souschaine[6]);
69
		else {$tableau[$nblignes]['table_source'] ='';}
70
		if (isset($souschaine[7])) $tableau[$nblignes]['id_source'] = trim($souschaine[7]);
71
		else {$tableau[$nblignes]['id_source'] ='';}
72
		if (isset($souschaine[8])) $tableau[$nblignes]['obligatoire'] = trim($souschaine[8]);
73
		else {$tableau[$nblignes]['obligatoire'] ='';}
721 alexandre_ 74
		if (isset($souschaine[9])) $tableau[$nblignes]['recherche'] = trim($souschaine[9]);
684 florian 75
		else {$tableau[$nblignes]['recherche'] ='';}
689 alexandre_ 76
 
77
 
78
		// traitement des cases à cocher, dans ce cas la, on a une table de jointure entre la table
79
		// de liste et la table bazar_fiche (elle porte un nom du genre bazar_ont_***)
80
		// dans le template, à la place d'un nom de champs dans 'nom_bdd', on a un nom de table
81
		// et 2 noms de champs séparés par un virgule ex : bazar_ont_theme,bot_id_theme,bot_id_fiche
82
 
83
		if (isset($tableau[$nblignes]['nom_bdd']) && preg_match('/,/', $tableau[$nblignes]['nom_bdd'])) {
84
			$tableau_info_jointe = explode (',', $tableau[$nblignes]['nom_bdd']) ;
85
			$tableau[$nblignes]['table_jointe'] = $tableau_info_jointe[0] ;
86
			$tableau[$nblignes]['champs_id_fiche'] = $tableau_info_jointe[1] ;
87
			$tableau[$nblignes]['champs_id_table_jointe'] = $tableau_info_jointe[2] ;
88
		}
427 florian 89
		$nblignes++;
90
	}
91
	return $tableau;
92
}
93
 
542 ddelon 94
/**  baz_voir_fiches() - Permet de visualiser en detail une liste de fiche  au format XHTML
95
*
96
* @global boolean Rajoute des informations internes à l'application (date de modification, lien vers la page de départ de l'appli)
97
* @global integer Tableau d(Identifiant des fiches à afficher
98
*
99
* @return   string  HTML
100
*/
101
function baz_voir_fiches($danslappli, $idfiches=array()) {
102
	$res='';
103
	foreach($idfiches as $idfiche) {
104
			$res.=baz_voir_fiche($danslappli, $idfiche);
105
	}
106
	return $res;
107
}
611 florian 108
 
109
 
834 florian 110
/**  baz_voir_fiche() - Permet de visualiser en detail une fiche  au format XHTML
427 florian 111
*
834 florian 112
* @global boolean Rajoute des informations internes a l'application (date de modification, lien vers la page de départ de l'appli) si a 1
113
* @global integer Identifiant de la fiche a afficher
427 florian 114
*
115
* @return   string  HTML
116
*/
117
function baz_voir_fiche($danslappli, $idfiche='') {
626 florian 118
	$res='';
427 florian 119
	if (isset($_GET['id_fiche'])) $GLOBALS['_BAZAR_']['id_fiche']=$_GET['id_fiche'];
834 florian 120
	if ($idfiche!='') $GLOBALS['_BAZAR_']['id_fiche']=$idfiche;
488 florian 121
	$url= $GLOBALS['_BAZAR_']['url'];
122
	$url->addQueryString('action', BAZ_VOIR_FICHE);
123
	$url->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
124
	$url = preg_replace ('/&amp;/', '&', $url->getURL()) ;
479 florian 125
 
834 florian 126
	//cas ou la fiche a été validee
127
	if (isset($_GET['publiee'])) {
128
		publier_fiche($_GET['publiee']);
129
	}
130
 
131
	//cas on une structure s'approprie une ressource
132
	if (isset($_GET['appropriation'])) {
133
		if ($_GET['appropriation']==1) {
134
			$requete = 'INSERT INTO bazar_appropriation VALUES ('.$GLOBALS['_BAZAR_']['id_fiche'].', '.$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID).')';
135
			$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
136
		}
137
		elseif ($_GET['appropriation']==0) {
138
			$requete = 'DELETE FROM bazar_appropriation WHERE  ba_ce_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].' AND ba_ce_id_structure='.$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID);
139
			$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
140
		}
141
	}
142
 
143
	//cas ou un commentaire a été entre
488 florian 144
	if (isset($_POST['Nom'])) {
555 alexandre_ 145
		$requete = 'INSERT INTO bazar_commentaires VALUES ('.
146
					baz_nextid('bazar_commentaires', 'bc_id_commentaire', $GLOBALS['_BAZAR_']['db']).
147
					', '.$GLOBALS['_BAZAR_']['id_fiche'].', "'.$_POST['Nom'].'", "'.$_POST['Commentaire'].
148
					'", NOW() )';
488 florian 149
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
150
	}
611 florian 151
	//cas ou un commentaire va etre supprime
494 florian 152
	elseif (isset($_GET['id_commentaire'])) {
153
		$requete = 'DELETE FROM bazar_commentaires WHERE bc_id_commentaire='.$_GET['id_commentaire'].' LIMIT 1';
488 florian 154
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
155
	}
494 florian 156
	else {
157
		if (isset($_GET['action'])) {
158
			if ($_GET['action']==BAZ_VOIR_FICHE) {
611 florian 159
				//sinon on met a jour le nb de visites pour la fiche, puisque c'est une simple consultation
494 florian 160
				$requete = 'UPDATE bazar_fiche SET bf_nb_consultations=bf_nb_consultations+1 WHERE bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
161
				$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
162
			}
163
		}
164
	}
918 alexandre_ 165
	$requete = 'SELECT * FROM bazar_fiche WHERE bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
488 florian 166
 
918 alexandre_ 167
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
168
	(DB::isError($resultat)) ? die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete))
169
	    : '';
170
 
1222 jp_milcent 171
		$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC) ;
172
	if (!isset($GLOBALS['_BAZAR_']['typeannonce'])) $GLOBALS['_BAZAR_']['typeannonce'] = $ligne['bf_ce_nature'];
918 alexandre_ 173
 
589 florian 174
	//on verifie si l'utilisateur est administrateur
488 florian 175
	$est_admin=0;
1222 jp_milcent 176
	$requete='SELECT bn_id_nature, bn_template, bn_commentaire FROM bazar_nature WHERE bn_id_nature="'.$GLOBALS['_BAZAR_']['typeannonce'].'"';
177
 
918 alexandre_ 178
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
179
	if (DB::isError($resultat)) {
180
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
181
	}
182
	$result = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
183
	$id_nature = $result['bn_id_nature'];
184
	if (!isset($GLOBALS['_BAZAR_']['template'])) $GLOBALS['_BAZAR_']['template'] = $result['bn_template'];
185
	if (!isset($GLOBALS['_BAZAR_']['commentaire'])) $GLOBALS['_BAZAR_']['commentaire'] = $result['bn_commentaire'];
488 florian 186
	if ($GLOBALS['AUTH']->getAuth()) {
187
		if ((niveau_droit($result['bn_id_nature'],$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))=='administrateur')
188
		     or(niveau_droit('0',$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))=='superadministrateur'))
189
		{
190
		        $est_admin=1;
191
		}
192
	}
704 florian 193
	//affiche le titre sous forme d'image
718 alexandre_ 194
	if (isset ($GLOBALS['_BAZAR_']['image_titre']) && $GLOBALS['_BAZAR_']['image_titre']!='') {
1219 jp_milcent 195
		$res .= '<img id="BAZ_img_titre" src="client/bazar/images/'.$GLOBALS['_BAZAR_']['image_titre'].'" alt="'.$result['bn_label_nature'].'" />'.'<br />'."\n";
626 florian 196
	}
627 florian 197
	//affiche le texte sinon
198
	else {
918 alexandre_ 199
		//$res .= '<h2 class="BAZ_titre">'.$GLOBALS['_BAZAR_']['typeannonce'].'</h2>'."\n";
627 florian 200
	}
626 florian 201
	$res .= '<div class="BAZ_cadre_fiche">'."\n";
839 alexandre_ 202
 
718 alexandre_ 203
	$GLOBALS['_BAZAR_']['annonceur'] = $ligne['bf_ce_utilisateur'] ;
589 florian 204
	//si le template existe, on genere le template
427 florian 205
	if ((file_exists(BAZ_CHEMIN_APPLI.'templates/'.$GLOBALS['_BAZAR_']['typeannonce'].'-fiche.php'))) {
206
		include_once(BAZ_CHEMIN_APPLI.'templates/'.$GLOBALS['_BAZAR_']['typeannonce'].'-fiche.php');
626 florian 207
		$res .=genere_fiche($ligne);
427 florian 208
	}
209
	//on affiche ligne par ligne sinon
713 alexandre_ 210
	else {
626 florian 211
		//cas d'une image personalisée
479 florian 212
		if (isset($ligne['bf_url_image'])) {
213
			$res .= '<div id="fiche_image">'."\n";
1196 alexandre_ 214
			$res .= '<img src="client/bazar/upload/'.$ligne['bf_url_image'].'" border=0 alt="'.BAZ_TEXTE_IMG_ALTERNATIF.'" />'."\n";
479 florian 215
			$res .= '</div>'."\n";
216
		}
626 florian 217
		//cas d'une image par défaut
718 alexandre_ 218
		elseif (isset ($GLOBALS['_BAZAR_']['image_logo']) && $GLOBALS['_BAZAR_']['image_logo']!='') {
626 florian 219
			$res .= '<div id="fiche_image">'."\n";
701 florian 220
			$res .= '<img src="client/bazar/images/'.$GLOBALS['_BAZAR_']['image_logo'].'" border=0 alt="'.BAZ_TEXTE_IMG_ALTERNATIF.'" width="130" height="130" />'."\n";
626 florian 221
			$res .= '</div>'."\n";
479 florian 222
		}
626 florian 223
		$res .= '<h1 id="fiche_titre">'.$ligne['bf_titre'].'</h1>'."\n";
838 florian 224
		$res .= '<div id="BAZ_description">'.nl2br($ligne['bf_description']).'</div>'."\n";
695 alexandre_ 225
		$tableau=baz_valeurs_template($GLOBALS['_BAZAR_']['template']);
427 florian 226
		for ($i=0; $i<count($tableau); $i++) {
834 florian 227
			if (isset($ligne[$tableau[$i]['nom_bdd']]) && ( $tableau[$i]['type']=='texte' || $tableau[$i]['type']=='textelong' ) ) {
718 alexandre_ 228
				$val=$tableau[$i]['nom_bdd'];
838 florian 229
				if (!in_array($val, array ('bf_titre', 'bf_description'))) {
230
					if ($ligne[$val] != '' and $ligne[$val] != BAZ_CHOISIR and $ligne[$val] != BAZ_NON_PRECISE) {
1243 alexandre_ 231
						$res .= '<span class="rubrique" id="'.$tableau[$i]['nom_bdd'].'_rubrique">'.$tableau[$i]['label'].':</span>'."\n";
232
						$res .= '<span class="description" id="'.$tableau[$i]['nom_bdd'].'_description"> '.nl2br($ligne[$val]).'</span>'."\n".'<br />'."\n";
479 florian 233
					}
427 florian 234
				}
235
			}
834 florian 236
			elseif ( $tableau[$i]['type']=='liste' || $tableau[$i]['type']=='checkbox' ) {
701 florian 237
				//pour les champs renseignes par une liste, on va chercher le label de la liste, plutot que l'id
238
				$requete = 'SELECT blv_label FROM bazar_fiche_valeur_liste, bazar_liste_valeurs WHERE bfvl_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].
239
				' AND  bfvl_ce_liste='.$tableau[$i]['nom_bdd'].' AND bfvl_valeur=blv_valeur AND blv_ce_liste='.$tableau[$i]['nom_bdd'].' AND blv_ce_i18n="'.$GLOBALS['_BAZAR_']['langue'].'"';
240
				$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
241
				if (DB::isError ($resultat)) {
242
					die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
243
				}
704 florian 244
				$val='';$nb=0;
701 florian 245
				while ($tab = $resultat->fetchRow()) {
704 florian 246
					if ($nb>0) $val .= ', ';
247
					$val .= $tab[0];
248
					$nb++;
701 florian 249
				}
838 florian 250
				if ($val != '' and $val != BAZ_CHOISIR and $val != BAZ_NON_PRECISE) {
1243 alexandre_ 251
					$res .= '<span class="rubrique" id="rubrique_'.$tableau[$i]['nom_bdd'].'">'.$tableau[$i]['label'].':</span>'."\n";
252
					$res .= '<span class="description" id="description_'.$tableau[$i]['nom_bdd'].'"> '.$val.'</span>'."\n".'<br />'."\n";
838 florian 253
				}
701 florian 254
			}
838 florian 255
			elseif ( $tableau[$i]['type']=='listedatedeb' || $tableau[$i]['type']=='listedatefin' ) {
256
				$val=$tableau[$i]['nom_bdd'];
257
				if (!in_array($val, array ('bf_date_debut_validite_fiche', 'bf_date_fin_validite_fiche'))) {
1199 alexandre_ 258
					if ($ligne[$val] != '' && $ligne[$val] != '0000-00-00') {
1243 alexandre_ 259
						$res .= '<span class="rubrique" id="'.$tableau[$i]['nom_bdd'].'_rubrique">'.$tableau[$i]['label'].':</span>'."\n";
260
						$res .= '<span class="description" id="'.$tableau[$i]['nom_bdd'].'_description"> '.strftime('%d.%m.%Y',strtotime($ligne[$val])).'</span>'."\n".'<br />'."\n";
838 florian 261
					}
262
				}
263
			}
955 florian 264
			elseif ( $tableau[$i]['type']=='wikini' ) {
265
				$res .= '<div class="lien_wikini"><a href="wikini/'.baz_titre_wiki($ligne["bf_titre"]).'">'.BAZ_ENTRER_PROJET.'</a></div>'."\n";
266
			}
427 florian 267
		}
479 florian 268
	//afficher les liens pour l'annonce
269
	$requete = 'SELECT  bu_url, bu_descriptif_url FROM bazar_url WHERE bu_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
270
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
271
	if (DB::isError($resultat)) {
272
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
273
	}
274
	if ($resultat->numRows()>0) {
275
		$res .= '<span class="rubrique">'.BAZ_LIEN_INTERNET.':</span>'."\n";
276
		$res .= '<span class="description">'."\n";
277
		$res .= '<ul>'."\n";
278
		while ($ligne1 = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
279
			$res .= '<li><a href="'.$ligne1['bu_url'].'" target="_blank">'.$ligne1['bu_descriptif_url'].'</a></li>'."\n";
427 florian 280
		}
479 florian 281
		$res .= '</ul></span>'."\n";
282
	}
283
 
284
	//afficher les fichiers pour l'annonce
285
	$requete = 'SELECT  bfj_description, bfj_fichier FROM bazar_fichier_joint WHERE bfj_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
286
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
287
	if (DB::isError($resultat)) {
288
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
289
	}
290
	if ($resultat->numRows()>0) {
291
		$res .= '<span class="rubrique">'.BAZ_LISTE_FICHIERS_JOINTS.':</span>'."\n";
292
		$res .= '<span class="description">'."\n";
293
		$res .= '<ul>'."\n";
294
		while ($ligne2 = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
834 florian 295
			$res .= '<li><a href="client/bazar/upload/'.$ligne2['bfj_fichier'].'">'.$ligne2['bfj_description'].'</a></li>'."\n";
479 florian 296
		}
297
		$res .= '</ul></span>'."\n";
298
	}
488 florian 299
	$res .= '<div class="bulle_haut">&nbsp;</div>'."\n";
300
	$res .= '<div class="bulle_corps">'."\n";
479 florian 301
 
589 florian 302
	//affichage du redacteur de la fiche
695 alexandre_ 303
	$requete = 'SELECT '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.', '.BAZ_CHAMPS_EMAIL.
304
					' FROM '.BAZ_ANNUAIRE.' WHERE '.BAZ_CHAMPS_ID.'='.$ligne['bf_ce_utilisateur'];
479 florian 305
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
306
	if (DB::isError($resultat)) {
307
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
308
	}
309
	while ($redacteur = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
310
		$res .= BAZ_FICHE_ECRITE.'<a href="mailto:'.$redacteur[BAZ_CHAMPS_EMAIL].'">'.$redacteur[BAZ_CHAMPS_PRENOM].' '.$redacteur[BAZ_CHAMPS_NOM].'</a><br />'."\n";
311
	}
704 florian 312
	$res .= BAZ_NB_VUS.'<strong>'.$ligne['bf_nb_consultations'].'</strong>'.BAZ_FOIS.'<br />'."\n";
479 florian 313
	$res .= '</div>'."\n";
488 florian 314
	$res .= '<div class="bulle_bas">&nbsp;</div>'."\n";
479 florian 315
	$res .= '<div id="BAZ_bas_page">';
626 florian 316
	}
488 florian 317
 
589 florian 318
	//informations complementaires (id fiche, etat publication,... )
918 alexandre_ 319
	if ($danslappli==1) {
1199 alexandre_ 320
		if ($ligne['bf_statut_fiche']==1 && $GLOBALS['_BAZAR_']['appropriation']!=1) {
321
			if ($ligne['bf_date_debut_validite_fiche'] != '0000-00-00' && $ligne['bf_date_fin_validite_fiche'] != '0000-00-00') {
322
			$res .= '<span class="rubrique">'.BAZ_PUBLIEE.':</span> '.BAZ_DU.
323
					' '.strftime('%d.%m.%Y',strtotime($ligne['bf_date_debut_validite_fiche'])).' '.
324
					BAZ_AU.' '.strftime('%d.%m.%Y',strtotime($ligne['bf_date_fin_validite_fiche'])).'<br />'."\n";
325
			}
479 florian 326
		}
834 florian 327
		elseif ($GLOBALS['_BAZAR_']['appropriation']!=1 || $ligne['bf_statut_fiche']!=1) {
328
			$res .= '<span class="rubrique">'.BAZ_PUBLIEE.':</span> '.BAZ_NON;
329
			if ( $est_admin ) {
330
				$res .= '&nbsp;&nbsp;&nbsp;<strong>'.BAZ_VALIDER_PUBLICATION.'&nbsp;:&nbsp;</strong>'."\n";
331
				$lien_publie = &$GLOBALS['_BAZAR_']['url'];
332
				$lien_publie->addQueryString('action', BAZ_VOIR_FICHE);
333
				$lien_publie->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
334
				$lien_publie->addQueryString('typeannonce', $ligne['bf_ce_nature']);
335
				$lien_publie->addQueryString('publiee', 1);
336
				$res .= '<a href="'.$lien_publie->getURL().'">'.BAZ_OUI.'</a>&nbsp;/&nbsp;';
337
				$lien_publie->removeQueryString('publiee');
338
				$lien_publie->addQueryString('publiee', 0);
339
				$res .='<a href="'.$lien_publie->getURL().'">'.BAZ_NON.'</a>'."\n";
340
				$lien_publie->removeQueryString('publiee');
341
			}
342
			$res .= '<br />'."\n";
479 florian 343
		}
834 florian 344
		//affichage des infos pouvant interesser les admins
345
		if ( $est_admin ) {
909 alexandre_ 346
			$res .= '<span class="rubrique" id="numero_fiche">'.BAZ_NUM_FICHE.':</span> '.$GLOBALS['_BAZAR_']['id_fiche'].'<br />'."\n";
347
			$res .= '<span class="rubrique" id="date_creation">'.BAZ_DATE_CREATION.' :</span> '.strftime('%d.%m.%Y &agrave; %H:%M',strtotime($ligne['bf_date_creation_fiche'])).'<br />'."\n";
834 florian 348
		}
349
		//affichage des infos et du lien pour la mise a jour de la fiche
350
		if ( $est_admin || $GLOBALS['_BAZAR_']['annonceur']==$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID) ) {
909 alexandre_ 351
			$res .= '<span class="rubrique" id="date_mise_a_jour">'.BAZ_DATE_MAJ.' :</span> '.strftime('%d.%m.%Y &agrave; %H:%M',strtotime($ligne['bf_date_maj_fiche']))."\n";
488 florian 352
			$lien_modifier=$GLOBALS['_BAZAR_']['url'];
353
			$lien_modifier->addQueryString('action', BAZ_ACTION_MODIFIER);
354
			$lien_modifier->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
695 alexandre_ 355
			$lien_modifier->addQueryString('typeannonce', $ligne['bf_ce_nature']);
909 alexandre_ 356
			$res .= '&nbsp;&nbsp;&nbsp;<a href="'.$lien_modifier->getURL().'" id="modifier_fiche">'.BAZ_MODIFIER_LA_FICHE.'</a>'."\n";
427 florian 357
		}
479 florian 358
	}
359
	$res .= '</div>'."\n";
360
	$res .= '</div>'."\n";
361
 
561 florian 362
	//on ajoute les appropriations, s'il le faut
363
	if (($danslappli==1)and($GLOBALS['_BAZAR_']['appropriation']==1)) {
364
		$res .= '<br />'."\n".'<div class="BAZ_cadre_fiche">'."\n";
834 florian 365
		$res .= '<h3>'.BAZ_LES_STRUCTURES_POSSEDANT_UNE_RESSOURCE.'</h3>'."\n";
568 florian 366
		$requete = 'SELECT '.BAZ_CHAMPS_ID.', '.BAZ_CHAMPS_NOM.' FROM bazar_appropriation,'.BAZ_ANNUAIRE.' WHERE ba_ce_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].' AND ba_ce_id_structure='.BAZ_CHAMPS_ID.' ORDER BY '.BAZ_CHAMPS_NOM.' ASC';
367
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
368
		if (DB::isError ($resultat)) {
369
			die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
370
		}
834 florian 371
		$possede_ressource=0;
568 florian 372
		if ($resultat->numRows()>0) {
373
			$res .= BAZ_IL_Y_A.$resultat->numRows().' ';
834 florian 374
			if ($resultat->numRows()==1) $res .= BAZ_STRUCTURE_POSSEDANT.'<br />'."\n";
375
			else $res .= BAZ_STRUCTURES_POSSEDANT.'<br />'."\n";
376
			$res .= '<ul>'."\n";
568 florian 377
			while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
834 florian 378
				$res .= '<li><a href="'.BAZ_URL_ANNUAIRE.'&amp;voir_fiche='.$ligne[BAZ_CHAMPS_ID].'" onclick="javascript:window.open(this.href);return false;">'.$ligne[BAZ_CHAMPS_NOM].'</a></li>'."\n";
379
				if ($GLOBALS['AUTH']->getAuth() && $GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID)==$ligne[BAZ_CHAMPS_ID]) $possede_ressource=1;
568 florian 380
			}
834 florian 381
			$res .= '</ul><br />'."\n";
568 florian 382
		}
383
		else $res .= BAZ_PAS_D_APPROPRIATION.'<br /><br />'."\n";
834 florian 384
		$res .='<p class="bulle_corps">'."\n";
385
		$lien_appropriation = $GLOBALS['_BAZAR_']['url'];
386
		$lien_appropriation->addQueryString('action', BAZ_VOIR_FICHE);
387
		$lien_appropriation->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
388
		if ($possede_ressource) {
389
			$lien_appropriation->addQueryString('appropriation', 0);
390
			$res .= BAZ_POSSEDE_DEJA_RESSOURCE.'<br />'."\n".'<a href="'.$lien_appropriation->getURL().'">'.BAZ_CLIQUER_POUR_VOUS_ENLEVER.'</a>'."\n";
391
			$lien_appropriation->removeQueryString('appropriation');
392
		}
393
		elseif ($GLOBALS['AUTH']->getAuth() && $GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_EST_STRUCTURE)) {
394
			$lien_appropriation->addQueryString('appropriation', 1);
395
			$res .= BAZ_SI_POSSEDE_RESSOURCE.'<br />'."\n".'<a href="'.$lien_appropriation->getURL().'">'.BAZ_CLIQUER_POUR_APPARAITRE.'</a>'."\n";
396
			$lien_appropriation->removeQueryString('appropriation');
397
		}
398
		elseif ($GLOBALS['AUTH']->getAuth() && !$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_EST_STRUCTURE)) {
399
			$res .= BAZ_IL_FAUT_ETRE_STRUCTURE."\n";
400
		}
401
		elseif (!$GLOBALS['AUTH']->getAuth()) {
402
			$res .= BAZ_IL_FAUT_ETRE_IDENTIFIE_STRUCTURE."\n";
403
		}
404
		$res .='</p>'."\n";
561 florian 405
		$res .= '</div>'."\n";
406
	}
407
 
479 florian 408
	//on ajoute les commentaires, s'il le faut
522 florian 409
	if (($danslappli==1)and($GLOBALS['_BAZAR_']['commentaire']==1)) {
561 florian 410
		$res .= '<br />'."\n".'<div class="BAZ_cadre_fiche">'."\n";
479 florian 411
		$res .= '<h3>'.BAZ_LES_COMMENTAIRES.'</h3>'."\n";
412
		$requete = 'SELECT * FROM bazar_commentaires WHERE bc_ce_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].' ORDER BY bc_date ASC';
427 florian 413
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
479 florian 414
		if (DB::isError ($resultat)) {
415
			die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
427 florian 416
		}
417
		if ($resultat->numRows()>0) {
488 florian 418
			$res .= BAZ_IL_Y_A.$resultat->numRows().' ';
419
			if ($resultat->numRows()==1) $res .= BAZ_COMMENTAIRE.'<br />'."\n";
420
			else $res .= BAZ_COMMENTAIRES.'<br />'."\n";
427 florian 421
			while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
488 florian 422
				$res .= '<div class="bulle_haut">&nbsp;</div>'."\n";
423
				$res .= '<div class="bulle_corps">'."\n";
424
				//affichage du commentaire
425
				$res .= $ligne['bc_commentaire'].'<br />'."\n";
426
				$res .= '</div>'."\n";
427
				$res .= '<div class="bulle_bas">'."\n";
494 florian 428
				$res .= '<div style="font-size:9px;margin-left:10px;">'.BAZ_PAR.' : <strong>'.$ligne['bc_nom'].'</strong>'.BAZ_ECRIT_LE.$ligne['bc_date'].'</div>'."\n";
834 florian 429
				//pour les identifies seulement, administrateurs de la rubrique ou superadmins
488 florian 430
				if ($est_admin==1) {
431
					$url_comment= $GLOBALS['_BAZAR_']['url'];
432
					$url_comment->addQueryString('action', BAZ_VOIR_FICHE);
433
					$url_comment->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
494 florian 434
					$url_comment->addQueryString('id_commentaire', $ligne['bc_id_commentaire']);
435
					$res .= '<a href="'.$url_comment->getURL().'" style="font-size:9px;float:right;">'.BAZ_SUPPRIMER.'</a>'."\n";
488 florian 436
				}
437
				$res .= '</div>'."\n";
427 florian 438
			}
439
		}
488 florian 440
		else $res .= BAZ_PAS_DE_COMMENTAIRES.'<br /><br />'."\n";
441
 
442
		//formulaire des commentaires
834 florian 443
		$form_commentaire = new HTML_QuickForm('bazar_commentaire', 'post', $url);
488 florian 444
		$squelette =& $form_commentaire->defaultRenderer();
445
		$squelette->setFormTemplate("\n".'<form {attributes}>'."\n".'{content}'."\n".'</form>'."\n");
834 florian 446
		$squelette->setElementTemplate( '<label style="width:200px;">{label}'.
447
										'<!-- BEGIN required --><span class="symbole_obligatoire">&nbsp;*</span><!-- END required -->'."\n".
448
									    '</label><br />'."\n".'{element}<br />'."\n");
449
		$squelette->setRequiredNoteTemplate("\n".'<span class="symbole_obligatoire"> *{requiredNote}</span>'."\n");
450
		$option=array('style'=>'width:300px;border:1px solid #000;', 'maxlength'=>100);
488 florian 451
		$form_commentaire->addElement('text', 'Nom', BAZ_ENTREZ_VOTRE_NOM, $option);
834 florian 452
		$option=array('style'=>'width:95%;height:100px;white-space: pre;padding:3px;border:1px solid #000;');
828 florian 453
		require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/textarea.php';
488 florian 454
		$formtexte= new HTML_QuickForm_textarea('Commentaire', BAZ_ENTREZ_VOTRE_COMMENTAIRE, $option);
455
		$form_commentaire->addElement($formtexte) ;
834 florian 456
		$option=array('style'=>'border:1px solid #000;');
457
		$form_commentaire->addElement('submit', 'Envoyer', BAZ_ENVOYER, $option);
488 florian 458
		$form_commentaire->addRule('Nom', BAZ_NOM_REQUIS, 'required', '', 'client') ;
459
		$form_commentaire->addRule('Commentaire', BAZ_COMMENTAIRE_REQUIS, 'required', '', 'client') ;
460
		$form_commentaire->setRequiredNote(BAZ_CHAMPS_REQUIS) ;
461
		$res .= $form_commentaire->toHTML();
479 florian 462
		$res .= '</div>'."\n";
463
	}
464
 
427 florian 465
	return $res ;
466
}
467
 
468
 
469
/** RSSversHTML () transforme un flux RSS (en XML) en page HTML
470
*
471
*   On passe en paramètre le contenu du flux RSS, on affiche ou non la description,
472
*   et on choisit de format de la date à l'affichage. On a en sortie du code HTML à afficher
473
*
474
*   @param  string   le contenu du flux RSS
475
*   @param  boolean  afficher ou non la description
476
*   @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
477
*
478
*   @return  string    le code HTML
479
*/
684 florian 480
function RSSversHTML($rss, $voirdesc, $formatdate, $affichenb) {
427 florian 481
	if ($rss!='') {
611 florian 482
		$rawitems='';$title='';$url='';$cat='';$date='';
427 florian 483
		$res='';
484
		if( eregi('<item>(.*)</item>', $rss, $rawitems ) ) {
485
			$items = explode('<item>', $rawitems[0]);
713 alexandre_ 486
			$res.='<ul id="BAZ_liste_fiche">'."\n";
427 florian 487
			for( $i = 0; $i < count($items)-1; $i++ ) {
488
				eregi('<title>(.*)</title>',$items[$i+1], $title );
489
				eregi('<link>(.*)</link>',$items[$i+1], $url );
490
				eregi('<description>(.*)</description>',$items[$i+1], $cat);
491
				eregi('<pubDate>(.*)</pubDate>',$items[$i+1], $date);
492
				$res.='<li>';
493
				if ($formatdate=='jm') {$res.=strftime('%d.%m',strtotime($date[1])).': ';}
494
				if ($formatdate=='jma') {$res.=strftime('%d.%m.%Y',strtotime($date[1])).': ';}
495
				if ($formatdate=='jmh') {$res.=strftime('%d.%m %H:%M',strtotime($date[1])).': ';}
496
				if ($formatdate=='jmah') {$res.=strftime('%d.%m.%Y %H:%M',strtotime($date[1])).': ';}
698 alexandre_ 497
				$res.='<a href="'.preg_replace ('/&amp;/', '&', $url[1]).'">'.$title[1].'</a>';
427 florian 498
				if ($voirdesc) {$res.=$cat[1];}
698 alexandre_ 499
				// Ajout du bouton supprimer pour les superadministrateur
731 florian 500
				if (($GLOBALS['AUTH']->getAuth() && niveau_droit(0,$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))=='superadministrateur')and($url[1]!='#')) {
698 alexandre_ 501
					$mon_url = preg_replace ('/&amp;/', '&', $url[1]) ;
502
					$url_suppr = new Net_URL(preg_replace ('/&amp;/', '&', $mon_url)) ;
503
					$url_suppr->addQueryString('action', BAZ_ACTION_SUPPRESSION) ;
504
		        	$res .= ' ( <a href="'.$url_suppr->getURL().
505
							'" onclick="javascript:return confirm(\''.BAZ_SUPPRIMER.' ?\');">'.
506
							BAZ_SUPPRIMER.'</a> )'."\n" ;
507
					}
427 florian 508
				$res.='</li>'."\n";
509
			}
510
			$res.='</ul>'."\n";
684 florian 511
			if ($affichenb==1) {
512
				//une annonce trouvee, on accorde au singulier
513
				if (((count($items)-1)==1)and($title!=BAZ_PAS_D_ANNONCES)) {
514
					$res = '<br /><h4>'.BAZ_IL_Y_A.' 1 '.BAZ_FICHE_CORRESPONDANTE.'</h4><br />'."\n".$res;
515
				}
516
				//plusieures annonces trouvees, on accorde au pluriel
517
				else {
518
					$res = '<br /><h4>'.BAZ_IL_Y_A.(count($items)-1).' '.BAZ_FICHES_CORRESPONDANTES.'</h4><br />'."\n".$res;
519
				}
520
			}
521
			//cas des fiches pas trouvées
522
			if (((count($items)-1)==1)and($title[1]==BAZ_PAS_D_ANNONCES)) {
523
				$res = '<br /><h4>'.BAZ_PAS_D_ANNONCES.'</h4><br />'."\n";
524
			}
427 florian 525
		}
526
	}
527
	else $res = BAZ_PAS_D_ANNONCES;
845 alexandre_ 528
 
427 florian 529
	return $res;
530
}
531
 
713 alexandre_ 532
/** gen_RSS() - generer un fichier de flux RSS par type d'annonce
427 florian 533
*
534
* @param   string Le type de l'annonce (laisser vide pour tout type d'annonce)
535
* @param   integer Le nombre d'annonces a regrouper dans le fichier XML (laisser vide pour toutes)
536
* @param   integer L'identifiant de l'emetteur (laisser vide pour tous)
694 florian 537
* @param   integer L'etat de validation de l'annonce (laisser 1 pour les annonces validees, 0 pour les non-validees)
538
* @param   string La requete SQL personnalisee
847 florian 539
* @param   integer La categorie des fiches bazar
427 florian 540
*
541
* @return  string Le code du flux RSS
542
*/
847 florian 543
function gen_RSS($typeannonce='', $nbitem='', $emetteur='', $valide=1, $requeteSQL='', $requeteSQLFrom = '', $requeteWhereListe = '', $categorie_nature='') {
684 florian 544
	// generation de la requete MySQL personnalisee
545
	$req_where=0;
1208 alexandre_ 546
	$requete = 'SELECT DISTINCT bf_id_fiche, bf_titre, bf_date_debut_validite_fiche, bf_description,  bn_label_nature, bf_date_creation_fiche '.
845 alexandre_ 547
				'FROM bazar_fiche, bazar_nature '.$requeteSQLFrom.' WHERE '.$requeteWhereListe;
684 florian 548
	if ($valide!=2) {
549
		$requete .= 'bf_statut_fiche='.$valide;
550
		$req_where=1;
551
	}
427 florian 552
	$nomflux=BAZ_DERNIERE_ACTU;
726 alexandre_ 553
	if (!is_array ($typeannonce) && $typeannonce!='' and $typeannonce!='toutes') {
684 florian 554
		if ($req_where==1) {$requete .= ' AND ';}
1233 alexandre_ 555
		$requete .= 'bf_ce_nature='.$typeannonce.' and bf_ce_nature=bn_id_nature ';;
684 florian 556
		$req_where=1;
427 florian 557
		//le nom du flux devient le type d'annonce
1219 jp_milcent 558
		$requete_nom_flux = 'select bn_label_nature from bazar_nature where bn_id_nature = '.$typeannonce;
937 alexandre_ 559
		$nomflux = $GLOBALS['_BAZAR_']['db']->getOne($requete_nom_flux) ;
427 florian 560
	}
726 alexandre_ 561
	// Cas où il y plusieurs type d annonce demande
562
	if (is_array ($typeannonce)) {
563
		if ($req_where==1) {$requete .= ' AND ';}
564
		$requete .= 'bf_ce_nature IN (' ;
565
		$chaine = '';
566
		foreach ($typeannonce as $valeur) $chaine .= '"'.$valeur.'",' ;
567
		$requete .= substr ($chaine, 0, strlen ($chaine)-1) ;
1243 alexandre_ 568
		$requete .= ') and bf_ce_nature=bn_id_nature ';
726 alexandre_ 569
	}
802 alexandre_ 570
	$utilisateur = new Administrateur_bazar ($GLOBALS['AUTH']) ;
684 florian 571
	if ($valide!=0) {
729 alexandre_ 572
 
728 alexandre_ 573
		if ($utilisateur->isSuperAdmin()) {
729 alexandre_ 574
			$req_where=1;
713 alexandre_ 575
		} else {
729 alexandre_ 576
			if ($req_where==1) {
577
				$requete .= ' AND ';
578
			}
713 alexandre_ 579
			$requete .= '(bf_date_debut_validite_fiche<=NOW() or bf_date_debut_validite_fiche="0000-00-00")'.
580
						' AND (bf_date_fin_validite_fiche>=NOW() or bf_date_fin_validite_fiche="0000-00-00") AND bn_id_nature=bf_ce_nature';
581
		}
684 florian 582
	}
427 florian 583
	else $nomflux .= BAZ_A_MODERER;
695 alexandre_ 584
	if ($emetteur!='' && $emetteur!='tous') {
684 florian 585
		if ($req_where==1) {$requete .= ' AND ';}
586
		$requete .= 'bf_ce_utilisateur='.$emetteur;
587
		$req_where=1;
427 florian 588
		//requete pour afficher le nom de la structure
695 alexandre_ 589
		$requetenom = 'SELECT '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.' FROM '.
590
						BAZ_ANNUAIRE.' WHERE '.BAZ_CHAMPS_ID.'='.$emetteur;
427 florian 591
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requetenom) ;
592
		if (DB::isError($resultat)) {
834 florian 593
			die ($resultat->getMessage().$resultat->getDebugInfo()) ;
427 florian 594
		}
595
		$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
596
		$nomflux .= ' ('.$ligne[BAZ_CHAMPS_NOM].' '.$ligne[BAZ_CHAMPS_PRENOM].')';
597
	}
684 florian 598
	if ($requeteSQL!='') {
599
		if ($req_where==1) {$requete .= ' AND ';}
600
		$requete .= '('.$requeteSQL.')';
601
		$req_where=1;
602
	}
847 florian 603
	if ($categorie_nature!='') {
604
		if ($req_where==1) {$requete .= ' AND ';}
1243 alexandre_ 605
		$requete .= 'bn_ce_id_menu IN ('.$categorie_nature.') and bf_ce_nature=bn_id_nature ';
847 florian 606
		$req_where=1;
607
	}
608
 
1196 alexandre_ 609
	$requete .= ' ORDER BY   bf_date_creation_fiche DESC, bf_date_fin_validite_fiche DESC, bf_date_maj_fiche DESC';
427 florian 610
	if ($nbitem!='') {$requete .= ' LIMIT 0,'.$nbitem;}
611
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
612
	if (DB::isError($resultat)) {
713 alexandre_ 613
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
427 florian 614
	}
1234 alexandre_ 615
 
616
	function xmlEntities($s){
617
		//build first an assoc. array with the entities we want to match
618
		$table1 = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES);
619
 
620
		//now build another assoc. array with the entities we want to replace (numeric entities)
621
		foreach ($table1 as $k=>$v){
622
		  $table1[$k] = "/$v/";
623
		  $c = htmlentities($k,ENT_QUOTES,"UTF-8");
624
		  $table2[$c] = "&#".ord($k).";";
625
		}
626
 
627
		//now perform a replacement using preg_replace
628
		//each matched value in array 1 will be replaced with the corresponding value in array 2
629
		$s = preg_replace($table1,$table2,$s);
630
		return $s;
631
	}
632
 
1233 alexandre_ 633
	include_once 'XML/Util.php' ;
634
 
635
	$xml = XML_Util::getXMLDeclaration('1.0', 'ISO-8859-1', 'no') ;
636
	$xml .= XML_Util::createStartElement ('rss', array('version' => '2.0')) ;
637
	$xml .= XML_Util::createStartElement ('channel');
638
	$xml .= XML_Util::createTag ('title', null, $nomflux, null, false);
639
	$xml .= XML_Util::createTag ('link', null, BAZ_RSS_ADRESSESITE);
640
	$xml .= XML_Util::createTag ('description', null, BAZ_RSS_DESCRIPTIONSITE);
641
	$xml .= XML_Util::createTag ('language', null, 'fr-FR');
642
	$xml .= XML_Util::createTag ('copyright', null, 'Copyright 2005 '.BAZ_RSS_NOMSITE);
643
	$xml .= XML_Util::createTag ('lastBuildDate', null, strftime('%d %b %Y %H:%M:%S GMT'));
644
	$xml .= XML_Util::createTag ('docs', null, 'http://www.stervinou.com/projets/rss/');
645
	$xml .= XML_Util::createTag ('category', null, BAZ_RSS_CATEGORIE);
646
	$xml .= XML_Util::createTag ('managingEditor', null, BAZ_RSS_MANAGINGEDITOR);
647
	$xml .= XML_Util::createTag ('webMaster', null, BAZ_RSS_WEBMASTER);
648
	$xml .= XML_Util::createTag ('ttl', null, '60');
649
	$xml .= XML_Util::createStartElement ('image');
650
		$xml .= XML_Util::createTag ('title', null, BAZ_RSS_NOMSITE);
651
		$xml .= XML_Util::createTag ('url', null, BAZ_RSS_LOGOSITE);
652
		$xml .= XML_Util::createTag ('link', null, BAZ_RSS_ADRESSESITE);
653
	$xml .= XML_Util::createEndElement ('image');
427 florian 654
	if ($resultat->numRows()>0) {
655
		// Creation des items : titre + lien + description + date de publication
656
		while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
1233 alexandre_ 657
			$xml .= XML_Util::createStartElement ('item');
1243 alexandre_ 658
			$caractere = array('/\x92/', '/\x85/', '/\x80/', '/\x97/', '/\x96/');
659
			$caractere_remplacement = array ('&#8217;', '&#8230;', '&#8364;', '&#8212;', '&#8211;');
660
			$xml .= XML_Util::createTag ('title', null, preg_replace ($caractere, $caractere_remplacement,
661
													XML_Util::replaceEntities($ligne['bf_titre'])));
427 florian 662
			$lien=$GLOBALS['_BAZAR_']['url'];
663
			$lien->addQueryString('action', BAZ_VOIR_FICHE);
664
			$lien->addQueryString('id_fiche', $ligne['bf_id_fiche']);
1233 alexandre_ 665
			$xml .= XML_Util::createTag ('link', null, $lien->getURL());
666
			$xml .= XML_Util::createTag ('guid', null, $lien->getURL());
667
			$xml .= XML_Util::createStartElement ('description');
718 alexandre_ 668
			if ($_GET['action'] != BAZ_VOIR_TOUTES_ANNONCES) {
1243 alexandre_ 669
				$xml .= XML_Util::createCDataSection (preg_replace ($caractere, $caractere_remplacement, $ligne['bf_description']));
718 alexandre_ 670
			}
1233 alexandre_ 671
			$xml .= XML_Util::createEndElement ('description');
1208 alexandre_ 672
			if ($ligne['bf_date_debut_validite_fiche'] == '0000-00-00') $date_pub = $ligne[' bf_date_creation_fiche'] ; else
673
					$date_pub =  $ligne['bf_date_debut_validite_fiche'];
1233 alexandre_ 674
			$xml .= XML_Util::createTag ('pubDate', null, strftime('%d %b %Y %H:%M:%S GMT',strtotime($date_pub)));
675
			$xml .= XML_Util::createEndElement ('item');
427 florian 676
		}
677
	}
678
	else {//pas d'annonces
1233 alexandre_ 679
		$xml .= XML_Util::createStartElement ('item');
680
		$xml .= XML_Util::createTag ('title', null, BAZ_PAS_D_ANNONCES);
681
		$xml .= XML_Util::createTag ('link', null, '#');
682
		$xml .= XML_Util::createTag ('description', null, BAZ_PAS_D_ANNONCES);
683
		$xml .= XML_Util::createTag ('pubDate', null, strftime('%d %b %Y %H:%M:%S GMT',strtotime('12/12/2004')));
684
		$xml .= XML_Util::createEndElement ('item');
1243 alexandre_ 685
 
427 florian 686
	}
1233 alexandre_ 687
	$xml .= XML_Util::createEndElement ('channel');
688
	$xml .= XML_Util::createEndElement('rss') ;
427 florian 689
	return $xml;
690
}
691
 
692
 
693
/** baz_liste() Formate la liste de toutes les annonces actuelles
694
*
684 florian 695
*   @return  string    le code HTML a afficher
427 florian 696
*/
697
function baz_liste($typeannonce='toutes') {
589 florian 698
	//creation du lien pour le formulaire de recherche
522 florian 699
	$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_VOIR_TOUTES_ANNONCES);
849 alexandre_ 700
	if (isset($_REQUEST['recherche_avancee'])) $GLOBALS['_BAZAR_']['url']->addQueryString ('recherche_avancee', $_REQUEST['recherche_avancee']);
726 alexandre_ 701
	$lien_formulaire = preg_replace ('/&amp;/', '&', $GLOBALS['_BAZAR_']['url']->getURL()) ;
522 florian 702
	$formtemplate = new HTML_QuickForm('formulaire', 'post', $lien_formulaire) ;
847 florian 703
	$squelette =& $formtemplate->defaultRenderer();
704
   	$squelette->setFormTemplate("\n".'<form {attributes}>'."\n".'<table style="border:0;width:100%;">'."\n".'{content}'."\n".'</table>'."\n".'</form>'."\n");
705
    $squelette->setElementTemplate( '<tr>'."\n".'<td style="font-size:12px;width:120px;text-align:right;">'."\n".'{label}'.
706
    		                        '<!-- BEGIN required --><span class="symbole_obligatoire">&nbsp;*</span><!-- END required -->'."\n".
707
    								' :</td>'."\n".'<td style="text-align:left;padding:5px;"> '."\n".'{element}'."\n".
708
                                    '<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n".
709
                                    '</td>'."\n".'</tr>'."\n");
710
 	$squelette->setElementTemplate( '<tr>'."\n".'<td colspan="2" class="liste_a_cocher"><strong>{label}&nbsp;{element}</strong>'."\n".
711
                                    '<!-- BEGIN required --><span class="symbole_obligatoire">&nbsp;*</span><!-- END required -->'."\n".'</td>'."\n".'</tr>'."\n", 'accept_condition');
873 florian 712
  	$squelette->setElementTemplate( '<tr><td colspan="2">{label}{element}</td></tr>'."\n", 'rechercher');
847 florian 713
 
714
 	$squelette->setRequiredNoteTemplate("\n".'<tr>'."\n".'<td colspan="2" class="symbole_obligatoire">* {requiredNote}</td></tr>'."\n");
715
	//Traduction de champs requis
716
	$formtemplate->setRequiredNote(BAZ_CHAMPS_REQUIS) ;
717
	$formtemplate->setJsWarnings(BAZ_ERREUR_SAISIE,BAZ_VEUILLEZ_CORRIGER);
718
 
684 florian 719
 
720
	//cas du formulaire de recherche proposant de chercher parmis tous les types d'annonces
726 alexandre_ 721
	//requete pour obtenir l'id et le label des types d'annonces
722
	$requete = 'SELECT bn_id_nature, bn_label_nature '.
1219 jp_milcent 723
	           'FROM bazar_nature WHERE bn_ce_id_menu IN ('.$GLOBALS['_BAZAR_']['categorie_nature'].') '.
726 alexandre_ 724
			   'ORDER BY bn_label_nature ASC';
725
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
726
	if (DB::isError($resultat)) {
727
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
728
	}
847 florian 729
	//on récupère le nb de types de fiches, pour plus tard
730
	$nb_type_de_fiches=$resultat->numRows();
726 alexandre_ 731
	$type_annonce_select['toutes']=BAZ_TOUS_TYPES_FICHES;
732
	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
761 florian 733
		$type_annonce_select[$ligne['bn_id_nature']] = $ligne['bn_label_nature'];
726 alexandre_ 734
		$tableau_typeannonces[] = $ligne['bn_id_nature'] ;
735
	}
847 florian 736
	if ($nb_type_de_fiches>1 && $GLOBALS['_BAZAR_']['typeannonce']=='toutes') {
684 florian 737
		$res= '<h2>'.BAZ_TOUTES_LES_ANNONCES.'</h2><br />'."\n";
847 florian 738
		$option=array('style'=>'border:1px solid #000;width: 200px;font:12px Myriad, Arial, sans-serif;',
819 alexandre_ 739
						'onchange' => 'javascript:this.form.submit();');
684 florian 740
		$formtemplate->addElement ('select', 'nature', BAZ_TYPEANNONCE, $type_annonce_select, $option) ;
847 florian 741
		if (isset($_REQUEST['nature'])) {
742
			$defauts=array('nature'=>$_REQUEST['nature']);
743
			$formtemplate->setDefaults($defauts);
744
		}
522 florian 745
	}
684 florian 746
	//cas du type d'annonces prédéfini
747
	else {
967 florian 748
		if ($nb_type_de_fiches==1) {
749
			$GLOBALS['_BAZAR_']['typeannonce']=end($type_annonce_select);
750
			$GLOBALS['_BAZAR_']['id_typeannonce']=key($type_annonce_select);
751
		}
761 florian 752
		$res = '<h2>'.BAZ_TOUTES_LES_ANNONCES_DE_TYPE.' '.$GLOBALS['_BAZAR_']['typeannonce'].'</h2>'."\n";
522 florian 753
	}
713 alexandre_ 754
 
684 florian 755
	//requete pour obtenir l'id, le nom et prenom de toutes les personnes ayant depose une fiche
847 florian 756
	// dans le but de construire l'élément de formulaire select avec les noms des émetteurs de fiche
726 alexandre_ 757
	if (BAZ_RECHERCHE_PAR_EMETTEUR) {
758
		$requete = 'SELECT '.BAZ_CHAMPS_ID.', '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.' '.
858 florian 759
		           'FROM bazar_fiche,'.BAZ_ANNUAIRE.' WHERE ' ;
726 alexandre_ 760
 
761
		$requete .= ' bf_date_debut_validite_fiche<=NOW() AND bf_date_fin_validite_fiche>=NOW() and';
762
 
763
		$requete .= ' bf_ce_utilisateur='.BAZ_CHAMPS_ID.' ';
764
	    if (!isset($_REQUEST['nature'])) {
847 florian 765
	    		if (isset($GLOBALS['_BAZAR_']['id_typeannonce'])) {
766
	    			$requete .= 'AND bf_ce_nature="'.$GLOBALS['_BAZAR_']['id_typeannonce'].'" ';
767
	    		}
768
		}
769
		else {
770
	    		if ($_REQUEST['nature']!='toutes') {
771
	    			$requete .= 'AND bf_ce_nature='.$_REQUEST['nature'].' ';
772
	    		}
726 alexandre_ 773
	    }
774
 
775
	    $requete .= 'ORDER BY '.BAZ_CHAMPS_NOM.' ASC';
776
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
777
		if (DB::isError($resultat)) {
778
			die ($resultat->getMessage().$resultat->getDebugInfo()) ;
779
		}
780
		$personnes_select['tous']=BAZ_TOUS_LES_EMETTEURS;
781
		while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
782
			$personnes_select[$ligne[BAZ_CHAMPS_ID]] = $ligne[BAZ_CHAMPS_NOM]." ".$ligne[BAZ_CHAMPS_PRENOM] ;
783
		}
847 florian 784
		$option=array('style'=>'border:1px solid #000;width: 200px;font:12px Myriad, Arial, sans-serif;');
726 alexandre_ 785
		$formtemplate->addElement ('select', 'personnes', BAZ_EMETTEUR, $personnes_select, $option) ;
786
	} else {
787
		$formtemplate->addElement ('hidden', 'personnes', 'tous') ;
522 florian 788
	}
726 alexandre_ 789
 
713 alexandre_ 790
		//pour les super-administrateurs, on peut voir les annonces non validées
684 florian 791
	//on verifie si l'utilisateur est administrateur
802 alexandre_ 792
	$utilisateur = new Administrateur_bazar($GLOBALS['AUTH']) ;
713 alexandre_ 793
 
726 alexandre_ 794
	if ($utilisateur->isSuperAdmin()) {
847 florian 795
		$option=array('style'=>'border:1px solid #000;width: 200px;font:12px Myriad, Arial, sans-serif;');
684 florian 796
		$valide_select[0] = BAZ_FICHES_PAS_VALIDEES;
797
		$valide_select[1] = BAZ_FICHES_VALIDEES;
798
		$valide_select[2] = BAZ_LES_DEUX;
799
		$formtemplate->addElement ('select', 'valides', BAZ_VALIDE, $valide_select, $option) ;
731 florian 800
		$defauts=array('valides'=>1);
684 florian 801
		$formtemplate->setDefaults($defauts);
802
	}
803
 
804
	//champs texte pour entrer les mots cles
847 florian 805
	$option=array('maxlength'=>60,'style'=>'border:1px solid #000;width:200px;font:12px Myriad, Arial, sans-serif;');
522 florian 806
	$formtemplate->addElement('text', 'recherche_mots_cles', BAZ_MOT_CLE, $option) ;
684 florian 807
 
808
	//option cachee pour savoir si le formulaire a ete appele deja
809
	$formtemplate->addElement('hidden', 'recherche_effectuee', 1) ;
845 alexandre_ 810
 
811
	// Ajout des options si un type de fiche a ete choisie
967 florian 812
	if ( (isset($_REQUEST['nature']) && $_REQUEST['nature'] != 'toutes') || (isset($GLOBALS['_BAZAR_']['categorie_nature']) && $nb_type_de_fiches==1)) {
847 florian 813
		if ( BAZ_MOTEUR_RECHERCHE_AVANCEE || ( isset($_REQUEST['recherche_avancee'])&&$_REQUEST['recherche_avancee']==1) ) {
814
			if ($GLOBALS['_BAZAR_']['categorie_nature'] != '') {
815
				$champs_requete = '' ;
816
				if (!isset($_REQUEST['nature']) || $_REQUEST['nature'] == '') {
817
					$_REQUEST['nature'] = $tableau_typeannonces[0];
818
				}
845 alexandre_ 819
			}
847 florian 820
			// Récupération du template
1219 jp_milcent 821
			$requete = 'SELECT bn_template FROM bazar_nature WHERE bn_id_nature = '.$_REQUEST['nature'];
847 florian 822
			$resultat = $GLOBALS['_BAZAR_']['db']->getOne($requete) ;
823
			if (DB::isError($resultat)) {
824
				die ($resultat->getMessage().$resultat->getDebugInfo()) ;
825
			}
826
 
967 florian 827
			if (isset($_REQUEST['recherche_avancee']) && $_REQUEST['recherche_avancee']==1) {
847 florian 828
				foreach(array_merge($_POST, $_GET) as $cle => $valeur) $GLOBALS['_BAZAR_']['url']->addQueryString($cle, $valeur);
829
				$GLOBALS['_BAZAR_']['url']->addQueryString('recherche_avancee', '0');
830
				$lien_recherche_de_base = '<a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">'.BAZ_RECHERCHE_DE_BASE.'</a><br />';
831
				//lien recherche de base
832
				labelhtml($formtemplate,'',$lien_recherche_de_base,'','','','','');
833
			}
834
 
835
			$tableau = baz_valeurs_template($resultat) ;
836
			for ($i=0; $i<count($tableau); $i++) {
837
				if (($tableau[$i]['type'] == 'liste' || $tableau[$i]['type'] == 'checkbox') && $tableau[$i]['recherche'] == 1) {
838
					$tableau[$i]['type']($formtemplate, $tableau[$i]['nom_bdd'], $tableau[$i]['label'], $tableau[$i]['limite1'],
839
			                         $tableau[$i]['limite2'], $tableau[$i]['defaut'], $tableau[$i]['table_source'], $tableau[$i]['obligatoire'], 1) ;
845 alexandre_ 840
				}
841
			}
847 florian 842
 
843
		}
844
		else {
845
			foreach(array_merge($_POST, $_GET) as $cle => $valeur) $GLOBALS['_BAZAR_']['url']->addQueryString($cle, $valeur);
846
			$GLOBALS['_BAZAR_']['url']->addQueryString('recherche_avancee', '1');
847
			$lien_recherche_avancee = '<a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">'.BAZ_RECHERCHE_AVANCEE.'</a><br />';
848
		}
845 alexandre_ 849
	}
847 florian 850
 
851
	//lien recherche avancee
852
	if (isset($lien_recherche_avancee)) {
853
		labelhtml($formtemplate,'',$lien_recherche_avancee,'','','','','');
854
	}
855
 
522 florian 856
	//Bouton de validation du formulaire
967 florian 857
	$option=array('style'=>'border:1px solid #000;width:100px;font:12px Myriad, Arial, sans-serif;');
873 florian 858
	$formtemplate->addElement('submit', 'rechercher', BAZ_RECHERCHER, $option);
684 florian 859
 
860
	//affichage du formulaire
523 florian 861
	$res.=$formtemplate->toHTML()."\n";
684 florian 862
 
845 alexandre_ 863
 
819 alexandre_ 864
	// Ajout de la table bazar_fiche_liste_valeur dans le from de la requete
865
	$case_coche = false ;
847 florian 866
	$nb_jointures=0;
819 alexandre_ 867
	$requeteFrom = '' ;
1219 jp_milcent 868
	$requeteWhere = ' bn_ce_id_menu IN ('.$GLOBALS['_BAZAR_']['categorie_nature'].') AND bn_id_nature=bf_ce_nature AND ' ;
819 alexandre_ 869
	$requeteWhereListe = '' ;
870
 
847 florian 871
 	if ( isset($tableau) ) {
872
	 	for ($i = 0; $i < count ($tableau); $i++) {
873
			if ($tableau[$i]['type'] == 'checkbox' || $tableau[$i]['type'] == 'liste') {
874
				$nb_jointures++;
875
				$nom_liste = $tableau[$i]['type'].$tableau[$i]['nom_bdd'] ;
876
				if (isset($_REQUEST[$nom_liste]) && is_array($_REQUEST[$nom_liste])) {
877
					$case_coche = true;
878
					$requeteWhereListe .= ' bfvl'.$nb_jointures.'.bfvl_ce_liste='.$tableau[$i]['nom_bdd'].' AND ' ; // Numéro de la liste
879
					$requeteWhereListe .= ' bfvl'.$nb_jointures.'.bfvl_valeur IN (' ;
880
					$chaine = '';
881
					//var_dump($_REQUEST[$nom_liste]);
882
					foreach ($_REQUEST[$nom_liste] as $cle =>$valeur) {
883
						if ($valeur == 1) {
884
							$chaine .= '"'.$cle.'",' ;
885
						}
886
					}
887
					$requeteWhereListe .= substr ($chaine, 0, strlen ($chaine)-1) ;
888
					$requeteWhereListe .= ') AND ';
889
				} else {
890
					if (isset ($_REQUEST[$nom_liste]) && $_REQUEST[$nom_liste]!=0) {
891
						$requeteWhereListe .= ' bfvl'.$nb_jointures.'.bfvl_ce_liste='.$tableau[$i]['nom_bdd'].' AND ' ; // Numéro de la liste
892
						$requeteWhereListe .= ' bfvl'.$nb_jointures.'.bfvl_valeur='.$_REQUEST[$nom_liste].' AND ';
893
						$case_coche = true;
845 alexandre_ 894
					}
895
				}
896
			}
897
		}
847 florian 898
 	}
845 alexandre_ 899
	if ($case_coche) {
847 florian 900
		for ($i = 0; $i < $nb_jointures ; $i++) {
901
			$requeteFrom .= ', bazar_fiche_valeur_liste  as bfvl'.($i+1) ;
902
			$requeteWhere .= ' bfvl'.($i+1).'.bfvl_ce_fiche=bf_id_fiche AND ';
903
		}
904
		 $requeteWhere .= $requeteWhereListe;
845 alexandre_ 905
	}
847 florian 906
	if (isset($_REQUEST['nature']) && $_REQUEST['nature']!='' && $_REQUEST['nature']!='toutes') {
845 alexandre_ 907
		$requeteWhere = 'bf_ce_nature="'.$_REQUEST['nature'].'" AND '.$requeteWhere;
908
	}
909
 
684 florian 910
	//affichage des resultats de la recherche si le formulaire a ete envoye
718 alexandre_ 911
	$requeteSQL='';
684 florian 912
	if (isset($_REQUEST['recherche_effectuee'])) {
913
		//preparation de la requete pour trouver les mots cles
845 alexandre_ 914
		if (($_REQUEST['recherche_mots_cles']!='')and($_REQUEST['recherche_mots_cles']!=BAZ_MOT_CLE)) {
684 florian 915
			//decoupage des mots cles
845 alexandre_ 916
			$recherche = split(' ', $_REQUEST['recherche_mots_cles']) ;
684 florian 917
			$nbmots=count($recherche);
918
			$requeteSQL='';
522 florian 919
			for ($i=0; $i<$nbmots; $i++) {
920
				if ($i>0) $requeteSQL.=' OR ';
921
				$requeteSQL.='bf_titre LIKE "%'.$recherche[$i].'%" OR bf_description LIKE "%'.$recherche[$i].'%" ';
922
			}
923
		}
726 alexandre_ 924
		if (!isset($_REQUEST['nature'])) {
925
			if (!isset ($GLOBALS['_BAZAR_']['id_nature'])) $typedefiches = $tableau_typeannonces;
926
			else $typedefiches = $GLOBALS['_BAZAR_']['id_nature'] ;
927
		} else {
928
			$typedefiches = $_REQUEST['nature'] ;
929
			if ($typedefiches == 'toutes') $typedefiches = $tableau_typeannonces ;
930
		}
730 florian 931
		if ($typeannonce!='toutes') $typedefiches=$typeannonce;
845 alexandre_ 932
		if (isset($_REQUEST['valides'])) {$valides=$_REQUEST['valides'];}
684 florian 933
		else {$valides=1;}
934
		//generation de la liste de flux a afficher
847 florian 935
		if (!isset($_REQUEST['personne'])) $_REQUEST['personne']='tous';
936
		$res .= baz_liste_pagine_HTML($typedefiches, '', $_REQUEST['personne'], $valides, $requeteSQL, $requeteFrom, $requeteWhere);
522 florian 937
	}
938
	else {
523 florian 939
		//on affiche toutes les annonces
774 florian 940
		$res .= '<br /><p class="zone_info">'."\n".BAZ_ENTRER_VOS_CRITERES_DE_RECHERCHE.'</p>'."\n";
941
		$GLOBALS['_BAZAR_']['url']->removeQueryString('action');
942
		$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_VOIR_FLUX_RSS);
847 florian 943
		$GLOBALS['_BAZAR_']['url']->addQueryString('annonce', $typeannonce);
944
		$GLOBALS['_BAZAR_']['url']->addQueryString('categorie_nature', $GLOBALS['_BAZAR_']['categorie_nature']);
1207 alexandre_ 945
		$res .= '{{Syndication titre="'.BAZ_DERNIERES_FICHES.'" url="'.preg_replace ('/&amp;/', '&', $GLOBALS['_BAZAR_']['url']->getURL()).
847 florian 946
                '" nb=10 nouvellefenetre=0 formatdate="'.BAZ_TYPE_AFFICHAGE_LISTE.'"}}';
522 florian 947
	}
427 florian 948
	return $res;
949
}
845 alexandre_ 950
 
951
/**
952
 * Cette fonction renvoie du HTML
953
 */
858 florian 954
function baz_liste_pagine_HTML($typeannonce, $nbitem, $emetteur, $valide, $requeteSQL = '', $requeteFrom = '', $requeteWhere = '') {
845 alexandre_ 955
	// generation de la requete MySQL personnalisee
956
	$req_where=0;
967 florian 957
	$requete = 'SELECT DISTINCT bf_id_fiche, bf_titre, bf_ce_utilisateur, bf_date_debut_validite_fiche '.
845 alexandre_ 958
				'FROM bazar_fiche, bazar_nature '.$requeteFrom.' WHERE '.$requeteWhere;
959
	if ($valide!=2) {
858 florian 960
		if ($req_where==1) {$requete .= ' AND ';}
845 alexandre_ 961
		$req_where=1;
858 florian 962
		$requete .= 'bf_statut_fiche='.$valide;
880 alexandre_ 963
	} else {
964
		$requete .= '1 ' ;
965
	}
845 alexandre_ 966
 
918 alexandre_ 967
	$utilisateur = new Administrateur_bazar ($GLOBALS['AUTH']) ;
845 alexandre_ 968
	if ($valide!=0) {
969
		if ($utilisateur->isSuperAdmin()) {
970
			$req_where=1;
971
		} else {
873 florian 972
			if ($req_where==1) {$requete .= ' AND ';}
845 alexandre_ 973
			$requete .= '(bf_date_debut_validite_fiche<=NOW() or bf_date_debut_validite_fiche="0000-00-00")'.
974
						' AND (bf_date_fin_validite_fiche>=NOW() or bf_date_fin_validite_fiche="0000-00-00") AND bn_id_nature=bf_ce_nature';
873 florian 975
			$req_where=1;
845 alexandre_ 976
		}
977
	}
978
	if ($emetteur!='' && $emetteur!='tous') {
979
		if ($req_where==1) {$requete .= ' AND ';}
980
		$requete .= 'bf_ce_utilisateur='.$emetteur;
981
		$req_where=1;
982
		//requete pour afficher le nom de la structure
983
		$requetenom = 'SELECT '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.' FROM '.
984
						BAZ_ANNUAIRE.' WHERE '.BAZ_CHAMPS_ID.'='.$emetteur;
985
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requetenom) ;
986
		if (DB::isError($resultat)) {
987
			die ($resultat->getMessage().$resultat->getDebugInfo()) ;
988
		}
989
		$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
990
		$nomflux .= ' ('.$ligne[BAZ_CHAMPS_NOM].' '.$ligne[BAZ_CHAMPS_PRENOM].')';
991
	}
992
	if ($requeteSQL!='') {
993
		if ($req_where==1) {$requete .= ' AND ';}
994
		$requete .= '('.$requeteSQL.')';
995
		$req_where=1;
996
	}
997
	$requete .= ' ORDER BY  bf_date_debut_validite_fiche DESC, bf_date_fin_validite_fiche DESC, bf_date_maj_fiche DESC';
998
	if ($nbitem!='') {$requete .= ' LIMIT 0,'.$nbitem;}
847 florian 999
 
845 alexandre_ 1000
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
1001
	if (DB::isError($resultat)) {
1002
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
1003
	}
1004
	$res = '<br /><h4>'.BAZ_IL_Y_A.($resultat->numRows()).' '.BAZ_FICHES_CORRESPONDANTES.'</h4><br />'."\n";
1005
	$res .= '<ul>' ;
1006
	$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_VOIR_FICHE);
1007
 
1008
	$donnees = array();
1009
	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
1010
		$GLOBALS['_BAZAR_']['url']->addQueryString('id_fiche', $ligne->bf_id_fiche) ;
967 florian 1011
		array_push ($donnees, array ($ligne->bf_id_fiche,$ligne->bf_titre,$ligne->bf_ce_utilisateur));
845 alexandre_ 1012
	}
1013
	// Mise en place du Pager
847 florian 1014
	include_once PAP_CHEMIN_API_PEAR.'Pager/Pager.php';
845 alexandre_ 1015
	$params = array(
1016
    'mode'       => BAZ_MODE_DIVISION,
1017
    'perPage'    => BAZ_NOMBRE_RES_PAR_PAGE,
1018
    'delta'      => BAZ_DELTA,
1019
    'httpMethod' => 'GET',
847 florian 1020
    'extraVars' => array_merge($_POST, $_GET),
845 alexandre_ 1021
    'altNext' => BAZ_SUIVANT,
1022
    'altPrev' => BAZ_PRECEDENT,
1023
    'nextImg' => BAZ_SUIVANT,
1024
    'prevImg' => BAZ_PRECEDENT,
1025
    'itemData'   => $donnees
1026
	);
1027
	$pager = & Pager::factory($params);
1028
	$data  = $pager->getPageData();
1029
	$links = $pager->getLinks();
852 alexandre_ 1030
    $res .= '<div class="bazar_numero">'.$pager->links.'</div>'."\n";
845 alexandre_ 1031
	foreach ($data as $valeur) {
1032
		$GLOBALS['_BAZAR_']['url']->addQueryString('id_fiche', $valeur[0]) ;
909 alexandre_ 1033
		$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_VOIR_FICHE) ;
901 alexandre_ 1034
		$res .= '<li><a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">'.$valeur[1].'</a>'."\n" ;
967 florian 1035
		if ($utilisateur->isSuperAdmin() || $GLOBALS['id_user']==$valeur[2]) {
1036
			$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_ACTION_MODIFIER);
1211 alexandre_ 1037
			$GLOBALS['_BAZAR_']['url']->addQueryString('typeannonce', $GLOBALS['_BAZAR_']['id_typeannonce']);
1038
			$GLOBALS['_BAZAR_']['url']->removeQueryString('personnes');
1039
			$GLOBALS['_BAZAR_']['url']->removeQueryString('recherche_effectuee');
967 florian 1040
			$res .= '<a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'">('.BAZ_MODIFIER.')</a>&nbsp;' ;
1041
			$GLOBALS['_BAZAR_']['url']->removeQueryString('action');
901 alexandre_ 1042
			$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_ACTION_SUPPRESSION);
1043
			$res .= '<a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'" onclick="javascript:return confirm(\''.BAZ_SUPPRIMER.'\');">('.BAZ_SUPPRIMER.')</a>' ;
909 alexandre_ 1044
			$GLOBALS['_BAZAR_']['url']->removeQueryString('action');
901 alexandre_ 1045
		}
1046
		$res .= '</li>';
845 alexandre_ 1047
	}
1048
	$res .= '</ul>';
852 alexandre_ 1049
	$res .= '<div class="bazar_numero">'.$pager->links.'</div>'."\n";
845 alexandre_ 1050
 
1051
	return $res ;
1052
}
1053
 
1054
/* +--Fin du code ----------------------------------------------------------------------------------------+
1055
*
847 florian 1056
* $Log: not supported by cvs2svn $
1243 alexandre_ 1057
* Revision 1.60.2.9  2007/02/27 15:32:40  alexandre_tb
1058
* utilisation de la fonction xmlEntities pour transformer les &amp; en &#...;
1059
* fixe les plantages des flux rss lorsque des guillemets ou des esperluettes étaient présents
1060
*
1234 alexandre_ 1061
* Revision 1.60.2.8  2007/02/27 15:11:00  alexandre_tb
1062
* correction d une jointure dans la requete pour les flux rss
1063
* utilisation de la librairie XML_Util de pear pour generer le flux RSS -> plus clair
1064
*
1233 alexandre_ 1065
* Revision 1.60.2.7  2007/02/15 17:39:00  jp_milcent
1066
* Remise dans le code d'un bogue...
1067
* A corriger!
1068
*
1222 jp_milcent 1069
* Revision 1.60.2.6  2007/02/15 13:42:16  jp_milcent
1070
* Utilisation de IN à la place du = dans les requêtes traitant les catégories de fiches.
1071
* Permet d'utiliser la syntaxe 1,2,3 dans la configuration de categorie_nature.
1072
*
1219 jp_milcent 1073
* Revision 1.60.2.5  2007/02/02 13:46:54  alexandre_tb
1074
* correction bug sur une date
1075
*
1211 alexandre_ 1076
* Revision 1.60.2.4  2007/01/30 15:45:01  alexandre_tb
1077
* affichage de la date de création e la fiche lorsque la date de début de validité n'est plus bonne
1078
*
1208 alexandre_ 1079
* Revision 1.60.2.3  2007/01/29 10:53:46  alexandre_tb
1080
* Mise en place de la constante BAZ_DERNIERES_FICHES pour remplacer le label en francais dans baz_liste
1081
*
1207 alexandre_ 1082
* Revision 1.60.2.2  2007/01/17 16:01:27  alexandre_tb
1083
* les dates ne s'affichent pas si elles sont vides.
1084
* les champs dates propose 4 années avant l'année actuelle
1085
*
1199 alexandre_ 1086
* Revision 1.60.2.1  2007/01/05 14:41:49  alexandre_tb
1087
* backport ordre d affichage des dernieres news et suppression de la taille des images uploadees
1088
*
1196 alexandre_ 1089
* Revision 1.60  2006/10/05 08:53:50  florian
1090
* amelioration moteur de recherche, correction de bugs
1091
*
967 florian 1092
* Revision 1.59  2006/09/21 14:19:39  florian
1093
* amélioration des fonctions liés au wikini
1094
*
955 florian 1095
* Revision 1.58  2006/09/15 12:31:40  alexandre_tb
1096
* correction du nom du flux RSS.
1097
*
937 alexandre_ 1098
* Revision 1.57  2006/07/25 13:22:27  alexandre_tb
1099
* réorganisation du code, sans grand changement
1100
*
918 alexandre_ 1101
* Revision 1.56  2006/07/18 14:13:35  alexandre_tb
1102
* Ajout d identifiant HTML
1103
*
909 alexandre_ 1104
* Revision 1.55  2006/07/04 14:29:18  alexandre_tb
1105
* Ajout du bouton supprimer pour les administrateurs
1106
*
901 alexandre_ 1107
* Revision 1.54  2006/07/03 09:51:21  alexandre_tb
1108
* correction du bug recherche sur fiches validés et invalidés.
1109
*
880 alexandre_ 1110
* Revision 1.53  2006/06/29 10:29:51  florian
1111
* correction bug moteur de recherche
1112
*
873 florian 1113
* Revision 1.52  2006/06/02 09:29:07  florian
1114
* debut d'integration de wikini
1115
*
858 florian 1116
* Revision 1.51  2006/05/23 15:41:27  alexandre_tb
1117
* ajout de la numérotation des pages en haut et en bas ds résultats et ajout d'une div class=bazar_numero pour les entourer
1118
*
852 alexandre_ 1119
* Revision 1.50  2006/05/22 09:55:12  alexandre_tb
1120
* ajout de la variable recherche_avancee dans l'action du formulaire
1121
*
849 alexandre_ 1122
* Revision 1.49  2006/05/19 13:54:11  florian
1123
* stabilisation du moteur de recherche, corrections bugs, lien recherche avancee
1124
*
847 florian 1125
* Revision 1.48  2006/05/17 09:50:13  alexandre_tb
1126
* Ajout du moteur de recherche évolué et du découpage par page
1127
*
845 alexandre_ 1128
* +-- Fin du code ----------------------------------------------------------------------------------------+
1129
*/
523 florian 1130
?>