Subversion Repositories Applications.bazar

Rev

Rev 79 | Rev 87 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 79 Rev 83
1
<?php
1
<?php
2
/** baz_valeur_template() - Renvoi des valeurs inscrite dans le fichier de template
2
/** baz_valeur_template() - Renvoi des valeurs inscrite dans le fichier de template
3
*
3
*
4
* @param   string valeur du template de bazar_nature
4
* @param   string valeur du template de bazar_nature
5
*
5
*
6
* @return   mixed  tableau contenant les champs du fichier template
6
* @return   mixed  tableau contenant les champs du fichier template
7
*/
7
*/
8
function baz_valeurs_template($valeur_template) {
8
function baz_valeurs_template($valeur_template) {
9
	//Parcours du fichier de templates, pour mettre les champs spécifiques
9
	//Parcours du fichier de templates, pour mettre les champs spécifiques
10
	$nblignes=0;
10
	$nblignes=0;
11
	$chaine = explode ("\n", $valeur_template);
11
	$chaine = explode ("\n", $valeur_template);
12
	array_pop($chaine);
12
	array_pop($chaine);
13
	foreach ($chaine as $ligne)  {
13
	foreach ($chaine as $ligne)  {
14
		$souschaine = explode ("***", $ligne) ;
14
		$souschaine = explode ("***", $ligne) ;
15
		$tableau[$nblignes]['type'] = trim($souschaine[0]) ;
15
		$tableau[$nblignes]['type'] = trim($souschaine[0]) ;
16
		if (isset($souschaine[1])) {$tableau[$nblignes]['nom_bdd'] = trim($souschaine[1]);}
16
		if (isset($souschaine[1])) {$tableau[$nblignes]['nom_bdd'] = trim($souschaine[1]);}
17
		else {$tableau[$nblignes]['nom_bdd'] ='';}
17
		else {$tableau[$nblignes]['nom_bdd'] ='';}
18
		if (isset($souschaine[2])) $tableau[$nblignes]['label'] = trim($souschaine[2]);
18
		if (isset($souschaine[2])) $tableau[$nblignes]['label'] = trim($souschaine[2]);
19
		else {$tableau[$nblignes]['label'] ='';}
19
		else {$tableau[$nblignes]['label'] ='';}
20
		if (isset($souschaine[3])) $tableau[$nblignes]['limite1'] = trim($souschaine[3]);
20
		if (isset($souschaine[3])) $tableau[$nblignes]['limite1'] = trim($souschaine[3]);
21
		else {$tableau[$nblignes]['limite1'] ='';}
21
		else {$tableau[$nblignes]['limite1'] ='';}
22
		if (isset($souschaine[4])) $tableau[$nblignes]['limite2'] = trim($souschaine[4]);
22
		if (isset($souschaine[4])) $tableau[$nblignes]['limite2'] = trim($souschaine[4]);
23
		else {$tableau[$nblignes]['limite2'] ='';}
23
		else {$tableau[$nblignes]['limite2'] ='';}
24
		if (isset($souschaine[5])) $tableau[$nblignes]['defaut'] = trim($souschaine[5]);
24
		if (isset($souschaine[5])) $tableau[$nblignes]['defaut'] = trim($souschaine[5]);
25
		else {$tableau[$nblignes]['defaut'] ='';}
25
		else {$tableau[$nblignes]['defaut'] ='';}
26
		if (isset($souschaine[6])) $tableau[$nblignes]['table_source'] = trim($souschaine[6]);
26
		if (isset($souschaine[6])) $tableau[$nblignes]['table_source'] = trim($souschaine[6]);
27
		else {$tableau[$nblignes]['table_source'] ='';}
27
		else {$tableau[$nblignes]['table_source'] ='';}
28
		if (isset($souschaine[7])) $tableau[$nblignes]['id_source'] = trim($souschaine[7]);
28
		if (isset($souschaine[7])) $tableau[$nblignes]['id_source'] = trim($souschaine[7]);
29
		else {$tableau[$nblignes]['id_source'] ='';}
29
		else {$tableau[$nblignes]['id_source'] ='';}
30
		if (isset($souschaine[8])) $tableau[$nblignes]['obligatoire'] = trim($souschaine[8]);
30
		if (isset($souschaine[8])) $tableau[$nblignes]['obligatoire'] = trim($souschaine[8]);
31
		else {$tableau[$nblignes]['obligatoire'] ='';}
31
		else {$tableau[$nblignes]['obligatoire'] ='';}
32
		if (isset($souschaine[8])) $tableau[$nblignes]['recherche'] = trim($souschaine[9]);
32
		if (isset($souschaine[8])) $tableau[$nblignes]['recherche'] = trim($souschaine[9]);
33
		else {$tableau[$nblignes]['recherche'] ='';}
33
		else {$tableau[$nblignes]['recherche'] ='';}
34
		
34
		
35
		
35
		
36
		// traitement des cases à cocher, dans ce cas la, on a une table de jointure entre la table
36
		// traitement des cases à cocher, dans ce cas la, on a une table de jointure entre la table
37
		// de liste et la table bazar_fiche (elle porte un nom du genre bazar_ont_***)
37
		// de liste et la table bazar_fiche (elle porte un nom du genre bazar_ont_***)
38
		// dans le template, à la place d'un nom de champs dans 'nom_bdd', on a un nom de table
38
		// dans le template, à la place d'un nom de champs dans 'nom_bdd', on a un nom de table
39
		// et 2 noms de champs séparés par un virgule ex : bazar_ont_theme,bot_id_theme,bot_id_fiche
39
		// et 2 noms de champs séparés par un virgule ex : bazar_ont_theme,bot_id_theme,bot_id_fiche
40
		
40
		
41
		if (isset($tableau[$nblignes]['nom_bdd']) && preg_match('/,/', $tableau[$nblignes]['nom_bdd'])) {
41
		if (isset($tableau[$nblignes]['nom_bdd']) && preg_match('/,/', $tableau[$nblignes]['nom_bdd'])) {
42
			$tableau_info_jointe = explode (',', $tableau[$nblignes]['nom_bdd']) ;
42
			$tableau_info_jointe = explode (',', $tableau[$nblignes]['nom_bdd']) ;
43
			$tableau[$nblignes]['table_jointe'] = $tableau_info_jointe[0] ;
43
			$tableau[$nblignes]['table_jointe'] = $tableau_info_jointe[0] ;
44
			$tableau[$nblignes]['champs_id_fiche'] = $tableau_info_jointe[1] ;
44
			$tableau[$nblignes]['champs_id_fiche'] = $tableau_info_jointe[1] ;
45
			$tableau[$nblignes]['champs_id_table_jointe'] = $tableau_info_jointe[2] ;		
45
			$tableau[$nblignes]['champs_id_table_jointe'] = $tableau_info_jointe[2] ;		
46
		}
46
		}
47
		$nblignes++;
47
		$nblignes++;
48
	}
48
	}
49
	return $tableau;
49
	return $tableau;
50
}
50
}
51
 
51
 
52
/**  baz_voir_fiches() - Permet de visualiser en detail une liste de fiche  au format XHTML
52
/**  baz_voir_fiches() - Permet de visualiser en detail une liste de fiche  au format XHTML
53
*
53
*
54
* @global boolean Rajoute des informations internes à l'application (date de modification, lien vers la page de départ de l'appli)
54
* @global boolean Rajoute des informations internes à l'application (date de modification, lien vers la page de départ de l'appli)
55
* @global integer Tableau d(Identifiant des fiches à afficher
55
* @global integer Tableau d(Identifiant des fiches à afficher
56
*
56
*
57
* @return   string  HTML
57
* @return   string  HTML
58
*/
58
*/
59
function baz_voir_fiches($danslappli, $idfiches=array()) {
59
function baz_voir_fiches($danslappli, $idfiches=array()) {
60
	$res='';
60
	$res='';
61
	foreach($idfiches as $idfiche) {
61
	foreach($idfiches as $idfiche) {
62
			$res.=baz_voir_fiche($danslappli, $idfiche);
62
			$res.=baz_voir_fiche($danslappli, $idfiche);
63
	}
63
	}
64
	return $res;
64
	return $res;
65
}
65
}
66
 
66
 
67
 
67
 
68
/**  baz_voir_fiche() - Permet de visualiser en détail une fiche  au format XHTML
68
/**  baz_voir_fiche() - Permet de visualiser en détail une fiche  au format XHTML
69
*
69
*
70
* @global boolean Rajoute des informations internes à l'application (date de modification, lien vers la page de départ de l'appli) si à 1
70
* @global boolean Rajoute des informations internes à l'application (date de modification, lien vers la page de départ de l'appli) si à 1
71
* @global integer Identifiant de la fiche à afficher
71
* @global integer Identifiant de la fiche à afficher
72
*
72
*
73
* @return   string  HTML
73
* @return   string  HTML
74
*/
74
*/
75
function baz_voir_fiche($danslappli, $idfiche='') {
75
function baz_voir_fiche($danslappli, $idfiche='') {
76
	$res='';
76
	$res='';
77
	if (isset($_GET['id_fiche'])) $GLOBALS['_BAZAR_']['id_fiche']=$_GET['id_fiche'];
77
	if (isset($_GET['id_fiche'])) $GLOBALS['_BAZAR_']['id_fiche']=$_GET['id_fiche'];
78
	if ($idfiche!='') $GLOBALS['_BAZAR_']['id_fiche']=$idfiche;
78
	if ($idfiche!='') $GLOBALS['_BAZAR_']['id_fiche']=$idfiche;
79
	
79
	
80
	$url= $GLOBALS['_BAZAR_']['url'];
80
	$url= $GLOBALS['_BAZAR_']['url'];
81
	$url->addQueryString('action', BAZ_VOIR_FICHE);
81
	$url->addQueryString('action', BAZ_VOIR_FICHE);
82
	$url->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
82
	$url->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
83
	$url = preg_replace ('/&amp;/', '&', $url->getURL()) ;
83
	$url = preg_replace ('/&amp;/', '&', $url->getURL()) ;
84
	
84
	
85
	//cas ou un commentaire a été entré
85
	//cas ou un commentaire a été entré
86
	if (isset($_POST['Nom'])) {
86
	if (isset($_POST['Nom'])) {
87
		$requete = 'INSERT INTO bazar_commentaires VALUES ('.
87
		$requete = 'INSERT INTO bazar_commentaires VALUES ('.
88
					baz_nextid('bazar_commentaires', 'bc_id_commentaire', $GLOBALS['_BAZAR_']['db']).
88
					baz_nextid('bazar_commentaires', 'bc_id_commentaire', $GLOBALS['_BAZAR_']['db']).
89
					', '.$GLOBALS['_BAZAR_']['id_fiche'].', "'.$_POST['Nom'].'", "'.$_POST['Commentaire'].
89
					', '.$GLOBALS['_BAZAR_']['id_fiche'].', "'.$_POST['Nom'].'", "'.$_POST['Commentaire'].
90
					'", NOW() )';
90
					'", NOW() )';
91
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
91
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
92
	}
92
	}
93
	//cas ou un commentaire va etre supprime
93
	//cas ou un commentaire va etre supprime
94
	elseif (isset($_GET['id_commentaire'])) {
94
	elseif (isset($_GET['id_commentaire'])) {
95
		$requete = 'DELETE FROM bazar_commentaires WHERE bc_id_commentaire='.$_GET['id_commentaire'].' LIMIT 1';
95
		$requete = 'DELETE FROM bazar_commentaires WHERE bc_id_commentaire='.$_GET['id_commentaire'].' LIMIT 1';
96
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
96
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
97
	}
97
	}
98
	else {
98
	else {
99
		if (isset($_GET['action'])) {
99
		if (isset($_GET['action'])) {
100
			if ($_GET['action']==BAZ_VOIR_FICHE) {
100
			if ($_GET['action']==BAZ_VOIR_FICHE) {
101
				//sinon on met a jour le nb de visites pour la fiche, puisque c'est une simple consultation
101
				//sinon on met a jour le nb de visites pour la fiche, puisque c'est une simple consultation
102
				$requete = 'UPDATE bazar_fiche SET bf_nb_consultations=bf_nb_consultations+1 WHERE bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
102
				$requete = 'UPDATE bazar_fiche SET bf_nb_consultations=bf_nb_consultations+1 WHERE bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
103
				$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
103
				$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
104
			}
104
			}
105
		}
105
		}
106
	}
106
	}
107
	
107
	
108
	//on verifie si l'utilisateur est administrateur
108
	//on verifie si l'utilisateur est administrateur
109
	$est_admin=0;
109
	$est_admin=0;
110
	if ($GLOBALS['AUTH']->getAuth()) {
110
	if ($GLOBALS['AUTH']->getAuth()) {
111
		$requete='SELECT bn_id_nature FROM bazar_nature WHERE bn_label_nature="'.$GLOBALS['_BAZAR_']['typeannonce'].'"';
111
		$requete='SELECT bn_id_nature FROM bazar_nature WHERE bn_label_nature="'.$GLOBALS['_BAZAR_']['typeannonce'].'"';
112
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
112
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
113
		if (DB::isError($resultat)) {
113
		if (DB::isError($resultat)) {
114
			die ($resultat->getMessage().$resultat->getDebugInfo()) ;
114
			die ($resultat->getMessage().$resultat->getDebugInfo()) ;
115
		}
115
		}
116
		$result = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
116
		$result = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
117
		$id_nature = $result['bn_id_nature'];
117
		$id_nature = $result['bn_id_nature'];
118
		if ((niveau_droit($result['bn_id_nature'],$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))=='administrateur')
118
		if ((niveau_droit($result['bn_id_nature'],$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))=='administrateur')
119
		     or(niveau_droit('0',$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))=='superadministrateur'))
119
		     or(niveau_droit('0',$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))=='superadministrateur'))
120
		{
120
		{
121
		        $est_admin=1;
121
		        $est_admin=1;
122
		}
122
		}
123
	}
123
	}
124
	//affiche le titre sous forme d'image
124
	//affiche le titre sous forme d'image
125
	if ($GLOBALS['_BAZAR_']['image_titre']!='') {
125
	if ($GLOBALS['_BAZAR_']['image_titre']!='') {
126
		$res .= '<img id="BAZ_img_titre" src="client/bazar/images/'.$GLOBALS['_BAZAR_']['image_titre'].'" alt="'.$GLOBALS['_BAZAR_']['typeannonce'].'" />'.'<br />'."\n";
126
		$res .= '<img id="BAZ_img_titre" src="client/bazar/images/'.$GLOBALS['_BAZAR_']['image_titre'].'" alt="'.$GLOBALS['_BAZAR_']['typeannonce'].'" />'.'<br />'."\n";
127
	}
127
	}
128
	//affiche le texte sinon
128
	//affiche le texte sinon
129
	else {
129
	else {
130
		$res .= '<h1 class="BAZ_titre">'.$GLOBALS['_BAZAR_']['typeannonce'].'</h1>'."\n";
130
		$res .= '<h1 class="BAZ_titre">'.$GLOBALS['_BAZAR_']['typeannonce'].'</h1>'."\n";
131
	}
131
	}
132
	$res .= '<div class="BAZ_cadre_fiche">'."\n";
132
	$res .= '<div class="BAZ_cadre_fiche">'."\n";
133
	$res .= '<div class="BAZ_cadre_fiche_haut">'."\n";
133
	$res .= '<div class="BAZ_cadre_fiche_haut">'."\n";
134
	$res .= '&nbsp;</div>'."\n";
134
	$res .= '&nbsp;</div>'."\n";
135
	$res .= '<div class="BAZ_cadre_fiche_corps">'."\n";
135
	$res .= '<div class="BAZ_cadre_fiche_corps">'."\n";
136
	$requete = 'SELECT * FROM bazar_fiche WHERE bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
136
	$requete = 'SELECT * FROM bazar_fiche WHERE bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
137
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
137
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
138
	if (DB::isError ($resultat)) {
138
	if (DB::isError ($resultat)) {
139
		die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
139
		die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
140
	}
140
	}
141
	$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC) ;
141
	$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC) ;
142
		
142
		
143
	//si le template existe, on genere le template
143
	//si le template existe, on genere le template
144
	if ((file_exists(BAZ_CHEMIN_APPLI.'templates/'.$GLOBALS['_BAZAR_']['typeannonce'].'-fiche.php'))) {
144
	if ((file_exists(BAZ_CHEMIN_APPLI.'templates/'.$GLOBALS['_BAZAR_']['typeannonce'].'-fiche.php'))) {
145
		include_once(BAZ_CHEMIN_APPLI.'templates/'.$GLOBALS['_BAZAR_']['typeannonce'].'-fiche.php');
145
		include_once(BAZ_CHEMIN_APPLI.'templates/'.$GLOBALS['_BAZAR_']['typeannonce'].'-fiche.php');
146
		$res .=genere_fiche($ligne);
146
		$res .=genere_fiche($ligne);
147
	}
147
	}
148
	//on affiche ligne par ligne sinon
148
	//on affiche ligne par ligne sinon
149
	else {		
149
	else {
150
		//cas d'une image personalisée
150
		//cas d'une image personalisée
151
		if (isset($ligne['bf_url_image'])) {
151
		if (isset($ligne['bf_url_image'])) {
152
			$res .= '<div id="fiche_image">'."\n";
152
			$res .= '<div id="fiche_image">'."\n";
153
			$res .= '<img src="client/bazar/images/'.$ligne['bf_url_image'].'" border=0 alt="'.BAZ_TEXTE_IMG_ALTERNATIF.'" width="130" height="130"  />'."\n";
153
			$res .= '<img src="client/bazar/images/'.$ligne['bf_url_image'].'" border=0 alt="'.BAZ_TEXTE_IMG_ALTERNATIF.'" width="130" height="130"  />'."\n";
154
			$res .= '</div>'."\n";
154
			$res .= '</div>'."\n";
155
		}
155
		}
156
		//cas d'une image par défaut
156
		//cas d'une image par défaut
157
		elseif ($GLOBALS['_BAZAR_']['image_logo']!='') {
157
		elseif ($GLOBALS['_BAZAR_']['image_logo']!='') {
158
			$res .= '<div id="fiche_image">'."\n";
158
			$res .= '<div id="fiche_image">'."\n";
159
			$res .= '<img src="client/bazar/images/'.$GLOBALS['_BAZAR_']['image_logo'].'" border=0 alt="'.BAZ_TEXTE_IMG_ALTERNATIF.'" width="130" height="130" />'."\n";
159
			$res .= '<img src="client/bazar/images/'.$GLOBALS['_BAZAR_']['image_logo'].'" border=0 alt="'.BAZ_TEXTE_IMG_ALTERNATIF.'" width="130" height="130" />'."\n";
160
			$res .= '</div>'."\n";
160
			$res .= '</div>'."\n";
161
		}
161
		}
162
		$res .= '<h1 id="fiche_titre">'.$ligne['bf_titre'].'</h1>'."\n";
162
		$res .= '<h1 id="fiche_titre">'.$ligne['bf_titre'].'</h1>'."\n";
163
		$res .= '<div id="BAZ_description">'.$ligne['bf_description'].'</div>'."\n";
163
		$res .= '<div id="BAZ_description">'.$ligne['bf_description'].'</div>'."\n";
164
		$tableau=baz_valeurs_template($GLOBALS['_BAZAR_']['template']);
164
		$tableau=baz_valeurs_template($GLOBALS['_BAZAR_']['template']);
165
		for ($i=0; $i<count($tableau); $i++) {
165
		for ($i=0; $i<count($tableau); $i++) {
166
			if (isset($ligne[$tableau[$i]['nom_bdd']])) {
166
			if (isset($ligne[$tableau[$i]['nom_bdd']])) {
167
				$val=$ligne[$tableau[$i]['nom_bdd']];
167
				$val=$ligne[$tableau[$i]['nom_bdd']];
168
				if (($tableau[$i]['nom_bdd']!='bf_titre')and($tableau[$i]['nom_bdd']!='bf_description')and($tableau[$i]['nom_bdd']!='bf_date_debut_validite_fiche')and($tableau[$i]['nom_bdd']!='bf_date_fin_validite_fiche')) {
168
				if (!in_array($val, array ('bf_titre', 'bf_description', 'bf_date_debut_validite_fiche',
-
 
169
								'bf_date_fin_validite_fiche'))) {
169
					if (($val!='')and($val!=BAZ_CHOISIR)and($val!=BAZ_NON_PRECISE)) {
170
					if ($val != '' and $val != BAZ_CHOISIR and $val != BAZ_NON_PRECISE) {
170
						$res .= '<span class="rubrique">'.constant($tableau[$i]['label']).':</span>'."\n";
171
						$res .= '<span class="rubrique">'.constant($tableau[$i]['label']).':</span>'."\n";
171
						$res .= '<span class="description"> '.$val.'</span>'."\n".'<br />'."\n";
172
						$res .= '<span class="description"> '.$val.'</span>'."\n".'<br />'."\n";
172
					}
173
					}
173
				}
174
				}
174
			}
175
			}
175
			elseif (($tableau[$i]['type']=='liste')or($tableau[$i]['type']=='checkbox')) {
176
			elseif (($tableau[$i]['type']=='liste')or($tableau[$i]['type']=='checkbox')) {
176
				//pour les champs renseignes par une liste, on va chercher le label de la liste, plutot que l'id				
177
				//pour les champs renseignes par une liste, on va chercher le label de la liste, plutot que l'id				
177
				$requete = 'SELECT blv_label FROM bazar_fiche_valeur_liste, bazar_liste_valeurs WHERE bfvl_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].
178
				$requete = 'SELECT blv_label FROM bazar_fiche_valeur_liste, bazar_liste_valeurs WHERE bfvl_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].
178
				' 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'].'"';
179
				' 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'].'"';
179
				$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
180
				$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
180
				if (DB::isError ($resultat)) {
181
				if (DB::isError ($resultat)) {
181
					die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
182
					die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
182
				}
183
				}
183
				$val='';$nb=0;
184
				$val='';$nb=0;
184
				while ($tab = $resultat->fetchRow()) {
185
				while ($tab = $resultat->fetchRow()) {
185
					if ($nb>0) $val .= ', ';
186
					if ($nb>0) $val .= ', ';
186
					$val .= $tab[0];
187
					$val .= $tab[0];
187
					$nb++;
188
					$nb++;
188
				}				
189
				}				
189
				$res .= '<span class="rubrique">'.constant($tableau[$i]['label']).':</span>'."\n";
190
				$res .= '<span class="rubrique">'.constant($tableau[$i]['label']).':</span>'."\n";
190
				$res .= '<span class="description"> '.$val.'</span>'."\n".'<br />'."\n";
191
				$res .= '<span class="description"> '.$val.'</span>'."\n".'<br />'."\n";
191
			}
192
			}
192
		}
193
		}
193
	//afficher les liens pour l'annonce
194
	//afficher les liens pour l'annonce
194
	$requete = 'SELECT  bu_url, bu_descriptif_url FROM bazar_url WHERE bu_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
195
	$requete = 'SELECT  bu_url, bu_descriptif_url FROM bazar_url WHERE bu_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
195
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
196
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
196
	if (DB::isError($resultat)) {
197
	if (DB::isError($resultat)) {
197
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
198
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
198
	}
199
	}
199
	if ($resultat->numRows()>0) {
200
	if ($resultat->numRows()>0) {
200
		$res .= '<span class="rubrique">'.BAZ_LIEN_INTERNET.':</span>'."\n";
201
		$res .= '<span class="rubrique">'.BAZ_LIEN_INTERNET.':</span>'."\n";
201
		$res .= '<span class="description">'."\n";
202
		$res .= '<span class="description">'."\n";
202
		$res .= '<ul>'."\n";
203
		$res .= '<ul>'."\n";
203
		while ($ligne1 = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
204
		while ($ligne1 = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
204
			$res .= '<li><a href="'.$ligne1['bu_url'].'" target="_blank">'.$ligne1['bu_descriptif_url'].'</a></li>'."\n";
205
			$res .= '<li><a href="'.$ligne1['bu_url'].'" target="_blank">'.$ligne1['bu_descriptif_url'].'</a></li>'."\n";
205
		}
206
		}
206
		$res .= '</ul></span>'."\n";
207
		$res .= '</ul></span>'."\n";
207
	}
208
	}
208
	
209
	
209
	//afficher les fichiers pour l'annonce
210
	//afficher les fichiers pour l'annonce
210
	$requete = 'SELECT  bfj_description, bfj_fichier FROM bazar_fichier_joint WHERE bfj_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
211
	$requete = 'SELECT  bfj_description, bfj_fichier FROM bazar_fichier_joint WHERE bfj_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
211
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
212
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
212
	if (DB::isError($resultat)) {
213
	if (DB::isError($resultat)) {
213
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
214
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
214
	}
215
	}
215
	if ($resultat->numRows()>0) {
216
	if ($resultat->numRows()>0) {
216
		$res .= '<span class="rubrique">'.BAZ_LISTE_FICHIERS_JOINTS.':</span>'."\n";
217
		$res .= '<span class="rubrique">'.BAZ_LISTE_FICHIERS_JOINTS.':</span>'."\n";
217
		$res .= '<span class="description">'."\n";
218
		$res .= '<span class="description">'."\n";
218
		$res .= '<ul>'."\n";
219
		$res .= '<ul>'."\n";
219
		while ($ligne2 = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
220
		while ($ligne2 = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
220
			$res .= '<li><a href="http://'.$_SERVER['HTTP_HOST'].'/client/bazar/upload/'.$ligne2['bfj_fichier'].'">'.$ligne2['bfj_description'].'</a></li>'."\n";
221
			$res .= '<li><a href="http://'.$_SERVER['HTTP_HOST'].'/client/bazar/upload/'.$ligne2['bfj_fichier'].'">'.$ligne2['bfj_description'].'</a></li>'."\n";
221
		}
222
		}
222
		$res .= '</ul></span>'."\n";
223
		$res .= '</ul></span>'."\n";
223
	}
224
	}
224
	$res .= '<div class="bulle_haut">&nbsp;</div>'."\n";
225
	$res .= '<div class="bulle_haut">&nbsp;</div>'."\n";
225
	$res .= '<div class="bulle_corps">'."\n";
226
	$res .= '<div class="bulle_corps">'."\n";
226
	
227
	
227
	//affichage du redacteur de la fiche
228
	//affichage du redacteur de la fiche
228
	$requete = 'SELECT '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.', '.BAZ_CHAMPS_EMAIL.
229
	$requete = 'SELECT '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.', '.BAZ_CHAMPS_EMAIL.
229
					' FROM '.BAZ_ANNUAIRE.' WHERE '.BAZ_CHAMPS_ID.'='.$ligne['bf_ce_utilisateur'];
230
					' FROM '.BAZ_ANNUAIRE.' WHERE '.BAZ_CHAMPS_ID.'='.$ligne['bf_ce_utilisateur'];
230
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
231
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
231
	if (DB::isError($resultat)) {
232
	if (DB::isError($resultat)) {
232
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
233
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
233
	}
234
	}
234
	while ($redacteur = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
235
	while ($redacteur = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
235
		$res .= BAZ_FICHE_ECRITE.'<a href="mailto:'.$redacteur[BAZ_CHAMPS_EMAIL].'">'.$redacteur[BAZ_CHAMPS_PRENOM].' '.$redacteur[BAZ_CHAMPS_NOM].'</a><br />'."\n";
236
		$res .= BAZ_FICHE_ECRITE.'<a href="mailto:'.$redacteur[BAZ_CHAMPS_EMAIL].'">'.$redacteur[BAZ_CHAMPS_PRENOM].' '.$redacteur[BAZ_CHAMPS_NOM].'</a><br />'."\n";
236
	}
237
	}
237
	$res .= BAZ_NB_VUS.'<strong>'.$ligne['bf_nb_consultations'].'</strong>'.BAZ_FOIS.'<br />'."\n";
238
	$res .= BAZ_NB_VUS.'<strong>'.$ligne['bf_nb_consultations'].'</strong>'.BAZ_FOIS.'<br />'."\n";
238
	$res .= '</div>'."\n";
239
	$res .= '</div>'."\n";
239
	$res .= '<div class="bulle_bas">&nbsp;</div>'."\n";
240
	$res .= '<div class="bulle_bas">&nbsp;</div>'."\n";
240
	$res .= '<div id="BAZ_bas_page">';
241
	$res .= '<div id="BAZ_bas_page">';
241
	}
242
	}
242
	
243
	
243
	//informations complementaires (id fiche, etat publication,... )
244
	//informations complementaires (id fiche, etat publication,... )
244
	if ($danslappli==1) {
245
	if ($danslappli==1) {
245
		$res .= '<span class="rubrique">'.BAZ_NUM_FICHE.':</span> '.$GLOBALS['_BAZAR_']['id_fiche'].'<br />'."\n";
246
		$res .= '<span class="rubrique">'.BAZ_NUM_FICHE.':</span> '.$GLOBALS['_BAZAR_']['id_fiche'].'<br />'."\n";
246
		if ($ligne['bf_statut_fiche']==1) {
247
		if ($ligne['bf_statut_fiche']==1) {
247
			$res .= '<span class="rubrique">'.BAZ_PUBLIEE.':</span> '.BAZ_DU.' '.strftime('%d.%m.%Y',strtotime($ligne['bf_date_debut_validite_fiche'])).' '.BAZ_AU.' '.strftime('%d.%m.%Y',strtotime($ligne['bf_date_fin_validite_fiche'])).'<br />'."\n";
248
			$res .= '<span class="rubrique">'.BAZ_PUBLIEE.':</span> '.BAZ_DU.' '.strftime('%d.%m.%Y',strtotime($ligne['bf_date_debut_validite_fiche'])).' '.BAZ_AU.' '.strftime('%d.%m.%Y',strtotime($ligne['bf_date_fin_validite_fiche'])).'<br />'."\n";
248
		}
249
		}
249
		else {
250
		else {
250
			$res .= '<span class="rubrique">'.BAZ_PUBLIEE.':</span> '.BAZ_NON.'<br />'."\n";
251
			$res .= '<span class="rubrique">'.BAZ_PUBLIEE.':</span> '.BAZ_NON.'<br />'."\n";
251
		}
252
		}
252
		$res .= '<span class="rubrique">'.BAZ_DATE_CREATION.' :</span> '.strftime('%d.%m.%Y &agrave; %H:%M',strtotime($ligne['bf_date_creation_fiche'])).'<br />'."\n";
253
		$res .= '<span class="rubrique">'.BAZ_DATE_CREATION.' :</span> '.strftime('%d.%m.%Y &agrave; %H:%M',strtotime($ligne['bf_date_creation_fiche'])).'<br />'."\n";
253
		$res .= '<span class="rubrique">'.BAZ_DATE_MAJ.' :</span> '.strftime('%d.%m.%Y &agrave; %H:%M',strtotime($ligne['bf_date_maj_fiche'])).'<br />'."\n";
254
		$res .= '<span class="rubrique">'.BAZ_DATE_MAJ.' :</span> '.strftime('%d.%m.%Y &agrave; %H:%M',strtotime($ligne['bf_date_maj_fiche'])).'<br />'."\n";
254
		
255
		
255
		if (($est_admin)or($GLOBALS['_BAZAR_']['annonceur']==$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))) {
256
		if (($est_admin)or($GLOBALS['_BAZAR_']['annonceur']==$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))) {
256
			$lien_modifier=$GLOBALS['_BAZAR_']['url'];
257
			$lien_modifier=$GLOBALS['_BAZAR_']['url'];
257
			$lien_modifier->addQueryString('action', BAZ_ACTION_MODIFIER);
258
			$lien_modifier->addQueryString('action', BAZ_ACTION_MODIFIER);
258
			$lien_modifier->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
259
			$lien_modifier->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
259
			$lien_modifier->addQueryString('typeannonce', $ligne['bf_ce_nature']);
260
			$lien_modifier->addQueryString('typeannonce', $ligne['bf_ce_nature']);
260
			$res .= '&nbsp;<a href="'.$lien_modifier->getURL().'">'.BAZ_MODIFIER_LA_FICHE.'</a>'."\n";
261
			$res .= '&nbsp;<a href="'.$lien_modifier->getURL().'">'.BAZ_MODIFIER_LA_FICHE.'</a>'."\n";
261
		}
262
		}
262
	}
263
	}
263
	$res .= '</div>'."\n";
264
	$res .= '</div>'."\n";
264
	$res .= '</div>'."\n";
265
	$res .= '</div>'."\n";
265
	$res .= '<div class="BAZ_cadre_fiche_bas">&nbsp;</div>'."\n";
266
	$res .= '<div class="BAZ_cadre_fiche_bas">&nbsp;</div>'."\n";
266
	$res .= '</div>'."\n";
267
	$res .= '</div>'."\n";
267
	
268
	
268
	//on ajoute les appropriations, s'il le faut
269
	//on ajoute les appropriations, s'il le faut
269
	if (($danslappli==1)and($GLOBALS['_BAZAR_']['appropriation']==1)) {
270
	if (($danslappli==1)and($GLOBALS['_BAZAR_']['appropriation']==1)) {
270
		$res .= '<br />'."\n".'<div class="BAZ_cadre_fiche">'."\n";
271
		$res .= '<br />'."\n".'<div class="BAZ_cadre_fiche">'."\n";
271
		$res .= '<div class="BAZ_cadre_fiche_haut">&nbsp;</div>'."\n";
272
		$res .= '<div class="BAZ_cadre_fiche_haut">&nbsp;</div>'."\n";
272
		$res .= '<div class="BAZ_cadre_fiche_corps">'."\n";
273
		$res .= '<div class="BAZ_cadre_fiche_corps">'."\n";
273
		$res .= '<h3>'.BAZ_LES_STRUCTURES_POSSEDANT_UNE_RESSOURCE.'</h3>'."\n";
274
		$res .= '<h3>'.BAZ_LES_STRUCTURES_POSSEDANT_UNE_RESSOURCE.'</h3>'."\n";
274
		
275
		
275
		$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';
276
		$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';
276
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
277
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
277
		if (DB::isError ($resultat)) {
278
		if (DB::isError ($resultat)) {
278
			die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
279
			die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
279
		}
280
		}
280
		if ($resultat->numRows()>0) {
281
		if ($resultat->numRows()>0) {
281
			$res .= BAZ_IL_Y_A.$resultat->numRows().' ';
282
			$res .= BAZ_IL_Y_A.$resultat->numRows().' ';
282
			if ($resultat->numRows()==1) $res .= BAZ_COMMENTAIRE.'<br />'."\n";
283
			if ($resultat->numRows()==1) $res .= BAZ_COMMENTAIRE.'<br />'."\n";
283
			else $res .= BAZ_COMMENTAIRES.'<br />'."\n";
284
			else $res .= BAZ_COMMENTAIRES.'<br />'."\n";
284
			while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
285
			while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
285
				$res .= '<div class="bulle_haut">&nbsp;</div>'."\n";
286
				$res .= '<div class="bulle_haut">&nbsp;</div>'."\n";
286
				$res .= '<div class="bulle_corps">'."\n";
287
				$res .= '<div class="bulle_corps">'."\n";
287
				//affichage du commentaire
288
				//affichage du commentaire
288
				$res .= $ligne['bc_commentaire'].'<br />'."\n";
289
				$res .= $ligne['bc_commentaire'].'<br />'."\n";
289
				$res .= '</div>'."\n";
290
				$res .= '</div>'."\n";
290
				$res .= '<div class="bulle_bas">'."\n";
291
				$res .= '<div class="bulle_bas">'."\n";
291
				$res .= '<div style="font-size:9px;margin-left:10px;">'.BAZ_PAR.' : <strong>'.$ligne['bc_nom'].'</strong>'.BAZ_ECRIT_LE.$ligne['bc_date'].'</div>'."\n";
292
				$res .= '<div style="font-size:9px;margin-left:10px;">'.BAZ_PAR.' : <strong>'.$ligne['bc_nom'].'</strong>'.BAZ_ECRIT_LE.$ligne['bc_date'].'</div>'."\n";
292
				//pour les identifiés seulement, administrateurs de la rubrique ou superadmins
293
				//pour les identifiés seulement, administrateurs de la rubrique ou superadmins
293
				if ($est_admin==1) {
294
				if ($est_admin==1) {
294
					$url_comment= $GLOBALS['_BAZAR_']['url'];
295
					$url_comment= $GLOBALS['_BAZAR_']['url'];
295
					$url_comment->addQueryString('action', BAZ_VOIR_FICHE);
296
					$url_comment->addQueryString('action', BAZ_VOIR_FICHE);
296
					$url_comment->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
297
					$url_comment->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
297
					$url_comment->addQueryString('id_commentaire', $ligne['bc_id_commentaire']);
298
					$url_comment->addQueryString('id_commentaire', $ligne['bc_id_commentaire']);
298
					$res .= '<a href="'.$url_comment->getURL().'" style="font-size:9px;float:right;">'.BAZ_SUPPRIMER.'</a>'."\n";
299
					$res .= '<a href="'.$url_comment->getURL().'" style="font-size:9px;float:right;">'.BAZ_SUPPRIMER.'</a>'."\n";
299
				}
300
				}
300
				$res .= '</div>'."\n";
301
				$res .= '</div>'."\n";
301
			}
302
			}
302
		}
303
		}
303
		else $res .= BAZ_PAS_D_APPROPRIATION.'<br /><br />'."\n";
304
		else $res .= BAZ_PAS_D_APPROPRIATION.'<br /><br />'."\n";
304
		
305
		
305
		$res .= '</div>'."\n";
306
		$res .= '</div>'."\n";
306
		$res .= '<div class="BAZ_cadre_fiche_bas">&nbsp;</div>'."\n";
307
		$res .= '<div class="BAZ_cadre_fiche_bas">&nbsp;</div>'."\n";
307
		$res .= '</div>'."\n";
308
		$res .= '</div>'."\n";
308
	}
309
	}
309
	
310
	
310
	//on ajoute les commentaires, s'il le faut
311
	//on ajoute les commentaires, s'il le faut
311
	if (($danslappli==1)and($GLOBALS['_BAZAR_']['commentaire']==1)) {
312
	if (($danslappli==1)and($GLOBALS['_BAZAR_']['commentaire']==1)) {
312
		$res .= '<br />'."\n".'<div class="BAZ_cadre_fiche">'."\n";
313
		$res .= '<br />'."\n".'<div class="BAZ_cadre_fiche">'."\n";
313
		$res .= '<div class="BAZ_cadre_fiche_haut">&nbsp;</div>'."\n";
314
		$res .= '<div class="BAZ_cadre_fiche_haut">&nbsp;</div>'."\n";
314
		$res .= '<div class="BAZ_cadre_fiche_corps">'."\n";
315
		$res .= '<div class="BAZ_cadre_fiche_corps">'."\n";
315
		$res .= '<h3>'.BAZ_LES_COMMENTAIRES.'</h3>'."\n";
316
		$res .= '<h3>'.BAZ_LES_COMMENTAIRES.'</h3>'."\n";
316
		$requete = 'SELECT * FROM bazar_commentaires WHERE bc_ce_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].' ORDER BY bc_date ASC';
317
		$requete = 'SELECT * FROM bazar_commentaires WHERE bc_ce_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].' ORDER BY bc_date ASC';
317
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
318
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
318
		if (DB::isError ($resultat)) {
319
		if (DB::isError ($resultat)) {
319
			die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
320
			die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
320
		}
321
		}
321
		if ($resultat->numRows()>0) {
322
		if ($resultat->numRows()>0) {
322
			$res .= BAZ_IL_Y_A.$resultat->numRows().' ';
323
			$res .= BAZ_IL_Y_A.$resultat->numRows().' ';
323
			if ($resultat->numRows()==1) $res .= BAZ_COMMENTAIRE.'<br />'."\n";
324
			if ($resultat->numRows()==1) $res .= BAZ_COMMENTAIRE.'<br />'."\n";
324
			else $res .= BAZ_COMMENTAIRES.'<br />'."\n";
325
			else $res .= BAZ_COMMENTAIRES.'<br />'."\n";
325
			while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
326
			while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
326
				$res .= '<div class="bulle_haut">&nbsp;</div>'."\n";
327
				$res .= '<div class="bulle_haut">&nbsp;</div>'."\n";
327
				$res .= '<div class="bulle_corps">'."\n";
328
				$res .= '<div class="bulle_corps">'."\n";
328
				//affichage du commentaire
329
				//affichage du commentaire
329
				$res .= $ligne['bc_commentaire'].'<br />'."\n";
330
				$res .= $ligne['bc_commentaire'].'<br />'."\n";
330
				$res .= '</div>'."\n";
331
				$res .= '</div>'."\n";
331
				$res .= '<div class="bulle_bas">'."\n";
332
				$res .= '<div class="bulle_bas">'."\n";
332
				$res .= '<div style="font-size:9px;margin-left:10px;">'.BAZ_PAR.' : <strong>'.$ligne['bc_nom'].'</strong>'.BAZ_ECRIT_LE.$ligne['bc_date'].'</div>'."\n";
333
				$res .= '<div style="font-size:9px;margin-left:10px;">'.BAZ_PAR.' : <strong>'.$ligne['bc_nom'].'</strong>'.BAZ_ECRIT_LE.$ligne['bc_date'].'</div>'."\n";
333
				//pour les identifiés seulement, administrateurs de la rubrique ou superadmins
334
				//pour les identifiés seulement, administrateurs de la rubrique ou superadmins
334
				if ($est_admin==1) {
335
				if ($est_admin==1) {
335
					$url_comment= $GLOBALS['_BAZAR_']['url'];
336
					$url_comment= $GLOBALS['_BAZAR_']['url'];
336
					$url_comment->addQueryString('action', BAZ_VOIR_FICHE);
337
					$url_comment->addQueryString('action', BAZ_VOIR_FICHE);
337
					$url_comment->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
338
					$url_comment->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
338
					$url_comment->addQueryString('id_commentaire', $ligne['bc_id_commentaire']);
339
					$url_comment->addQueryString('id_commentaire', $ligne['bc_id_commentaire']);
339
					$res .= '<a href="'.$url_comment->getURL().'" style="font-size:9px;float:right;">'.BAZ_SUPPRIMER.'</a>'."\n";
340
					$res .= '<a href="'.$url_comment->getURL().'" style="font-size:9px;float:right;">'.BAZ_SUPPRIMER.'</a>'."\n";
340
				}
341
				}
341
				$res .= '</div>'."\n";
342
				$res .= '</div>'."\n";
342
			}
343
			}
343
		}
344
		}
344
		else $res .= BAZ_PAS_DE_COMMENTAIRES.'<br /><br />'."\n";
345
		else $res .= BAZ_PAS_DE_COMMENTAIRES.'<br /><br />'."\n";
345
		
346
		
346
		//formulaire des commentaires
347
		//formulaire des commentaires
347
		$form_commentaire = new HTML_QuickForm('commentaire', 'post', $url);
348
		$form_commentaire = new HTML_QuickForm('commentaire', 'post', $url);
348
		$squelette =& $form_commentaire->defaultRenderer();
349
		$squelette =& $form_commentaire->defaultRenderer();
349
		$squelette->setFormTemplate("\n".'<form {attributes}>'."\n".'{content}'."\n".'</form>'."\n");
350
		$squelette->setFormTemplate("\n".'<form {attributes}>'."\n".'{content}'."\n".'</form>'."\n");
350
		$squelette->setElementTemplate( '<label style="width:200px;">{label}&nbsp;</label><br />'."\n".'{element}<br />'."\n");
351
		$squelette->setElementTemplate( '<label style="width:200px;">{label}&nbsp;</label><br />'."\n".'{element}<br />'."\n");
351
		$squelette->setRequiredNoteTemplate("\n".'{requiredNote} '."\n");
352
		$squelette->setRequiredNoteTemplate("\n".'{requiredNote} '."\n");
352
		$option=array('style'=>'width:300px;', 'maxlength'=>100);
353
		$option=array('style'=>'width:300px;', 'maxlength'=>100);
353
		$form_commentaire->addElement('text', 'Nom', BAZ_ENTREZ_VOTRE_NOM, $option);
354
		$form_commentaire->addElement('text', 'Nom', BAZ_ENTREZ_VOTRE_NOM, $option);
354
		$option=array('style'=>'width:100%;height:100px;white-space: pre;padding:3px;');
355
		$option=array('style'=>'width:100%;height:100px;white-space: pre;padding:3px;');
355
		require_once 'HTML/QuickForm/textarea.php';
356
		require_once 'HTML/QuickForm/textarea.php';
356
		$formtexte= new HTML_QuickForm_textarea('Commentaire', BAZ_ENTREZ_VOTRE_COMMENTAIRE, $option);
357
		$formtexte= new HTML_QuickForm_textarea('Commentaire', BAZ_ENTREZ_VOTRE_COMMENTAIRE, $option);
357
		$form_commentaire->addElement($formtexte) ;
358
		$form_commentaire->addElement($formtexte) ;
358
		$form_commentaire->addElement('submit', 'Envoyer', BAZ_ENVOYER);
359
		$form_commentaire->addElement('submit', 'Envoyer', BAZ_ENVOYER);
359
		$form_commentaire->addRule('Nom', BAZ_NOM_REQUIS, 'required', '', 'client') ;
360
		$form_commentaire->addRule('Nom', BAZ_NOM_REQUIS, 'required', '', 'client') ;
360
		$form_commentaire->addRule('Commentaire', BAZ_COMMENTAIRE_REQUIS, 'required', '', 'client') ;
361
		$form_commentaire->addRule('Commentaire', BAZ_COMMENTAIRE_REQUIS, 'required', '', 'client') ;
361
		$form_commentaire->setRequiredNote(BAZ_CHAMPS_REQUIS) ;
362
		$form_commentaire->setRequiredNote(BAZ_CHAMPS_REQUIS) ;
362
		$res .= $form_commentaire->toHTML();
363
		$res .= $form_commentaire->toHTML();
363
		
364
		
364
		$res .= '</div>'."\n";
365
		$res .= '</div>'."\n";
365
		$res .= '<div class="BAZ_cadre_fiche_bas">&nbsp;</div>'."\n";
366
		$res .= '<div class="BAZ_cadre_fiche_bas">&nbsp;</div>'."\n";
366
		$res .= '</div>'."\n";
367
		$res .= '</div>'."\n";
367
	}
368
	}
368
	
369
	
369
	return $res ;
370
	return $res ;
370
}
371
}
371
 
372
 
372
 
373
 
373
/** RSSversHTML () transforme un flux RSS (en XML) en page HTML
374
/** RSSversHTML () transforme un flux RSS (en XML) en page HTML
374
*
375
*
375
*   On passe en paramètre le contenu du flux RSS, on affiche ou non la description,
376
*   On passe en paramètre le contenu du flux RSS, on affiche ou non la description,
376
*   et on choisit de format de la date à l'affichage. On a en sortie du code HTML à afficher 
377
*   et on choisit de format de la date à l'affichage. On a en sortie du code HTML à afficher 
377
*
378
*
378
*   @param  string   le contenu du flux RSS
379
*   @param  string   le contenu du flux RSS
379
*   @param  boolean  afficher ou non la description
380
*   @param  boolean  afficher ou non la description
380
*   @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
381
*   @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
381
*
382
*
382
*   @return  string    le code HTML
383
*   @return  string    le code HTML
383
*/
384
*/
384
function RSSversHTML($rss, $voirdesc, $formatdate, $affichenb) {
385
function RSSversHTML($rss, $voirdesc, $formatdate, $affichenb) {
385
	if ($rss!='') {
386
	if ($rss!='') {
386
		$rawitems='';$title='';$url='';$cat='';$date='';
387
		$rawitems='';$title='';$url='';$cat='';$date='';
387
		$res='';
388
		$res='';
388
		if( eregi('<item>(.*)</item>', $rss, $rawitems ) ) {
389
		if( eregi('<item>(.*)</item>', $rss, $rawitems ) ) {
389
			$items = explode('<item>', $rawitems[0]);
390
			$items = explode('<item>', $rawitems[0]);
390
			$res.='<ul>'."\n";
391
			$res.='<ul id="BAZ_liste_fiche">'."\n";
391
			for( $i = 0; $i < count($items)-1; $i++ ) {
392
			for( $i = 0; $i < count($items)-1; $i++ ) {
392
				eregi('<title>(.*)</title>',$items[$i+1], $title );
393
				eregi('<title>(.*)</title>',$items[$i+1], $title );
393
				eregi('<link>(.*)</link>',$items[$i+1], $url );
394
				eregi('<link>(.*)</link>',$items[$i+1], $url );
394
				eregi('<description>(.*)</description>',$items[$i+1], $cat);
395
				eregi('<description>(.*)</description>',$items[$i+1], $cat);
395
				eregi('<pubDate>(.*)</pubDate>',$items[$i+1], $date);
396
				eregi('<pubDate>(.*)</pubDate>',$items[$i+1], $date);
396
				$res.='<li>';
397
				$res.='<li>';
397
				if ($formatdate=='jm') {$res.=strftime('%d.%m',strtotime($date[1])).': ';}
398
				if ($formatdate=='jm') {$res.=strftime('%d.%m',strtotime($date[1])).': ';}
398
				if ($formatdate=='jma') {$res.=strftime('%d.%m.%Y',strtotime($date[1])).': ';}
399
				if ($formatdate=='jma') {$res.=strftime('%d.%m.%Y',strtotime($date[1])).': ';}
399
				if ($formatdate=='jmh') {$res.=strftime('%d.%m %H:%M',strtotime($date[1])).': ';}
400
				if ($formatdate=='jmh') {$res.=strftime('%d.%m %H:%M',strtotime($date[1])).': ';}
400
				if ($formatdate=='jmah') {$res.=strftime('%d.%m.%Y %H:%M',strtotime($date[1])).': ';}
401
				if ($formatdate=='jmah') {$res.=strftime('%d.%m.%Y %H:%M',strtotime($date[1])).': ';}
401
				$res.='<a href="'.preg_replace ('/&amp;/', '&', $url[1]).'">'.$title[1].'</a>';
402
				$res.='<a href="'.preg_replace ('/&amp;/', '&', $url[1]).'">'.$title[1].'</a>';
402
				if ($voirdesc) {$res.=$cat[1];}
403
				if ($voirdesc) {$res.=$cat[1];}
403
				// Ajout du bouton supprimer pour les superadministrateur
404
				// Ajout du bouton supprimer pour les superadministrateur
404
				if ($GLOBALS['AUTH']->getAuth() && niveau_droit(0,$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))=='superadministrateur')
405
				if ($GLOBALS['AUTH']->getAuth() && niveau_droit(0,$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))=='superadministrateur')
405
					{
406
					{
406
					$mon_url = preg_replace ('/&amp;/', '&', $url[1]) ; 
407
					$mon_url = preg_replace ('/&amp;/', '&', $url[1]) ; 
407
					$url_suppr = new Net_URL(preg_replace ('/&amp;/', '&', $mon_url)) ;
408
					$url_suppr = new Net_URL(preg_replace ('/&amp;/', '&', $mon_url)) ;
408
					$url_suppr->addQueryString('action', BAZ_ACTION_SUPPRESSION) ;
409
					$url_suppr->addQueryString('action', BAZ_ACTION_SUPPRESSION) ;
409
		        	$res .= ' ( <a href="'.$url_suppr->getURL().
410
		        	$res .= ' ( <a href="'.$url_suppr->getURL().
410
							'" onclick="javascript:return confirm(\''.BAZ_SUPPRIMER.' ?\');">'.
411
							'" onclick="javascript:return confirm(\''.BAZ_SUPPRIMER.' ?\');">'.
411
							BAZ_SUPPRIMER.'</a> )'."\n" ;
412
							BAZ_SUPPRIMER.'</a> )'."\n" ;
412
					}
413
					}
413
				$res.='</li>'."\n";
414
				$res.='</li>'."\n";
414
			}
415
			}
415
			$res.='</ul>'."\n";
416
			$res.='</ul>'."\n";
416
			if ($affichenb==1) {
417
			if ($affichenb==1) {
417
				//une annonce trouvee, on accorde au singulier
418
				//une annonce trouvee, on accorde au singulier
418
				if (((count($items)-1)==1)and($title!=BAZ_PAS_D_ANNONCES)) {
419
				if (((count($items)-1)==1)and($title!=BAZ_PAS_D_ANNONCES)) {
419
					$res = '<br /><h4>'.BAZ_IL_Y_A.' 1 '.BAZ_FICHE_CORRESPONDANTE.'</h4><br />'."\n".$res;
420
					$res = '<br /><h4>'.BAZ_IL_Y_A.' 1 '.BAZ_FICHE_CORRESPONDANTE.'</h4><br />'."\n".$res;
420
				}
421
				}
421
				//plusieures annonces trouvees, on accorde au pluriel
422
				//plusieures annonces trouvees, on accorde au pluriel
422
				else {
423
				else {
423
					$res = '<br /><h4>'.BAZ_IL_Y_A.(count($items)-1).' '.BAZ_FICHES_CORRESPONDANTES.'</h4><br />'."\n".$res;
424
					$res = '<br /><h4>'.BAZ_IL_Y_A.(count($items)-1).' '.BAZ_FICHES_CORRESPONDANTES.'</h4><br />'."\n".$res;
424
				}
425
				}
425
			}
426
			}
426
			//cas des fiches pas trouvées
427
			//cas des fiches pas trouvées
427
			if (((count($items)-1)==1)and($title[1]==BAZ_PAS_D_ANNONCES)) {
428
			if (((count($items)-1)==1)and($title[1]==BAZ_PAS_D_ANNONCES)) {
428
				$res = '<br /><h4>'.BAZ_PAS_D_ANNONCES.'</h4><br />'."\n";
429
				$res = '<br /><h4>'.BAZ_PAS_D_ANNONCES.'</h4><br />'."\n";
429
			}  
430
			}  
430
		}
431
		}
431
	}
432
	}
432
	else $res = BAZ_PAS_D_ANNONCES;
433
	else $res = BAZ_PAS_D_ANNONCES;
433
	return $res;
434
	return $res;
434
}
435
}
435
 
436
 
436
/** gen_RSS() - générer un fichier de flux RSS par type d'annonce 
437
/** gen_RSS() - generer un fichier de flux RSS par type d'annonce 
437
*
438
*
438
* @param   string Le type de l'annonce (laisser vide pour tout type d'annonce)
439
* @param   string Le type de l'annonce (laisser vide pour tout type d'annonce)
439
* @param   integer Le nombre d'annonces a regrouper dans le fichier XML (laisser vide pour toutes)
440
* @param   integer Le nombre d'annonces a regrouper dans le fichier XML (laisser vide pour toutes)
440
* @param   integer L'identifiant de l'emetteur (laisser vide pour tous)
441
* @param   integer L'identifiant de l'emetteur (laisser vide pour tous)
441
* @param   integer L'etat de validation de l'annonce (laisser 1 pour les annonces validees, 0 pour les non-validees)
442
* @param   integer L'etat de validation de l'annonce (laisser 1 pour les annonces validees, 0 pour les non-validees)
442
* @param   string La requete SQL personnalisee
443
* @param   string La requete SQL personnalisee
443
*
444
*
444
* @return  string Le code du flux RSS
445
* @return  string Le code du flux RSS
445
*/
446
*/
446
function gen_RSS($typeannonce='', $nbitem='', $emetteur='', $valide=1, $requeteSQL='') {
447
function gen_RSS($typeannonce='', $nbitem='', $emetteur='', $valide=1, $requeteSQL='') {
447
	// generation de la requete MySQL personnalisee
448
	// generation de la requete MySQL personnalisee
448
	$req_where=0;
449
	$req_where=0;
449
	$requete = 'SELECT DISTINCT bf_id_fiche, bf_titre, bf_date_debut_validite_fiche FROM bazar_fiche, bazar_nature WHERE ';
450
	$requete = 'SELECT DISTINCT bf_id_fiche, bf_titre, bf_date_debut_validite_fiche '.
-
 
451
				'FROM bazar_fiche, bazar_nature WHERE ';
450
	if ($valide!=2) {
452
	if ($valide!=2) {
451
		$requete .= 'bf_statut_fiche='.$valide;
453
		$requete .= 'bf_statut_fiche='.$valide;
452
		$req_where=1;
454
		$req_where=1;
453
	}
455
	}
454
	$nomflux=BAZ_DERNIERE_ACTU;
456
	$nomflux=BAZ_DERNIERE_ACTU;
455
	if (($typeannonce!='')and($typeannonce!='toutes')) {
457
	if (($typeannonce!='')and($typeannonce!='toutes')) {
456
		if ($req_where==1) {$requete .= ' AND ';}
458
		if ($req_where==1) {$requete .= ' AND ';}
457
		$requete .= 'bf_ce_nature='.$typeannonce;
459
		$requete .= 'bf_ce_nature='.$typeannonce;
458
		$req_where=1;
460
		$req_where=1;
459
		//le nom du flux devient le type d'annonce
461
		//le nom du flux devient le type d'annonce
460
		$nomflux = $typeannonce;
462
		$nomflux = $typeannonce;
461
	}
463
	}
462
	if ($valide!=0) {
464
	if ($valide!=0) {
463
		if ($req_where==1) {$requete .= ' AND ';}
465
		if ($req_where==1) {$requete .= ' AND ';}
-
 
466
		if ($GLOBALS['AUTH']->getAuth() && niveau_droit(0,$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))!='superadministrateur') {
-
 
467
			$req_where=1;$requete .= '1' ;	
-
 
468
		} else {
-
 
469
			
464
		$requete .= '(bf_date_debut_validite_fiche<=NOW() or bf_date_debut_validite_fiche="0000-00-00")'.
470
			$requete .= '(bf_date_debut_validite_fiche<=NOW() or bf_date_debut_validite_fiche="0000-00-00")'.
465
					' AND (bf_date_fin_validite_fiche>=NOW() or bf_date_fin_validite_fiche="0000-00-00") AND bn_id_nature=bf_ce_nature';
471
						' AND (bf_date_fin_validite_fiche>=NOW() or bf_date_fin_validite_fiche="0000-00-00") AND bn_id_nature=bf_ce_nature';
-
 
472
			
466
		$req_where=1;
473
		}
467
	}
474
	}
468
	else $nomflux .= BAZ_A_MODERER;
475
	else $nomflux .= BAZ_A_MODERER;
469
	if ($emetteur!='' && $emetteur!='tous') {
476
	if ($emetteur!='' && $emetteur!='tous') {
470
		if ($req_where==1) {$requete .= ' AND ';}
477
		if ($req_where==1) {$requete .= ' AND ';}
471
		$requete .= 'bf_ce_utilisateur='.$emetteur;
478
		$requete .= 'bf_ce_utilisateur='.$emetteur;
472
		$req_where=1;
479
		$req_where=1;
473
		//requete pour afficher le nom de la structure
480
		//requete pour afficher le nom de la structure
474
		$requetenom = 'SELECT '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.' FROM '.
481
		$requetenom = 'SELECT '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.' FROM '.
475
						BAZ_ANNUAIRE.' WHERE '.BAZ_CHAMPS_ID.'='.$emetteur;
482
						BAZ_ANNUAIRE.' WHERE '.BAZ_CHAMPS_ID.'='.$emetteur;
476
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requetenom) ;
483
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requetenom) ;
477
		if (DB::isError($resultat)) {
484
		if (DB::isError($resultat)) {
478
			echo ($resultat->getMessage().$resultat->getDebugInfo()) ;
485
			echo ($resultat->getMessage().$resultat->getDebugInfo()) ;
479
		}
486
		}
480
		$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
487
		$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
481
		$nomflux .= ' ('.$ligne[BAZ_CHAMPS_NOM].' '.$ligne[BAZ_CHAMPS_PRENOM].')';
488
		$nomflux .= ' ('.$ligne[BAZ_CHAMPS_NOM].' '.$ligne[BAZ_CHAMPS_PRENOM].')';
482
	}
489
	}
483
	if ($requeteSQL!='') {
490
	if ($requeteSQL!='') {
484
		if ($req_where==1) {$requete .= ' AND ';}
491
		if ($req_where==1) {$requete .= ' AND ';}
485
		$requete .= '('.$requeteSQL.')';
492
		$requete .= '('.$requeteSQL.')';
486
		$req_where=1;
493
		$req_where=1;
487
	}
494
	}
488
	$requete .= ' ORDER BY  bf_date_debut_validite_fiche DESC, bf_date_fin_validite_fiche DESC, bf_date_maj_fiche DESC';
495
	$requete .= ' ORDER BY  bf_date_debut_validite_fiche DESC, bf_date_fin_validite_fiche DESC, bf_date_maj_fiche DESC';
489
	if ($nbitem!='') {$requete .= ' LIMIT 0,'.$nbitem;}
496
	if ($nbitem!='') {$requete .= ' LIMIT 0,'.$nbitem;}
490
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
497
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
491
	if (DB::isError($resultat)) {
498
	if (DB::isError($resultat)) {
492
		die ($GLOBALS['_BAZAR_']['db']->getMessage().$GLOBALS["db"]->getDebugInfo()) ;
499
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
493
	}
500
	}
494
	// En-tete du flux RSS version 2.0
501
	// En-tete du flux RSS version 2.0
495
	$xml = '<?xml version="1.0" encoding="ISO-8859-1"?>'."\n".'<rss version="2.0">'."\n";
502
	$xml = '<?xml version="1.0" encoding="ISO-8859-1"?>'."\n".'<rss version="2.0">'."\n";
496
	$xml .= '<channel>'."\n".'<title>'.$nomflux.'</title>'."\n".'<link>'.BAZ_RSS_ADRESSESITE.'</link>'."\n";
503
	$xml .= '<channel>'."\n".'<title>'.$nomflux.'</title>'."\n".'<link>'.BAZ_RSS_ADRESSESITE.'</link>'."\n";
497
	$xml .= '<description>'.BAZ_RSS_DESCRIPTIONSITE.'</description>'."\n".'<language>fr-FR</language>'."\n".
504
	$xml .= '<description>'.BAZ_RSS_DESCRIPTIONSITE.'</description>'."\n".'<language>fr-FR</language>'."\n".
498
	'<copyright>Copyright 2005 '.BAZ_RSS_NOMSITE.'</copyright>'."\n";
505
	'<copyright>Copyright 2005 '.BAZ_RSS_NOMSITE.'</copyright>'."\n";
499
	// Ajout de la date actuelle de publication (suivant la DTD RSS)
506
	// Ajout de la date actuelle de publication (suivant la DTD RSS)
500
	$xml .= '<lastBuildDate>'.strftime('%d %b %Y %H:%M:%S GMT').'</lastBuildDate>'."\n";
507
	$xml .= '<lastBuildDate>'.strftime('%d %b %Y %H:%M:%S GMT').'</lastBuildDate>'."\n";
501
	// En-tete suite et fin
508
	// En-tete suite et fin
502
	$xml .= '<docs>http://www.stervinou.com/projets/rss/</docs>'."\n".'<category>'.BAZ_RSS_CATEGORIE.'</category>'."\n".
509
	$xml .= '<docs>http://www.stervinou.com/projets/rss/</docs>'."\n".'<category>'.BAZ_RSS_CATEGORIE.'</category>'."\n".
503
	'<managingEditor>'.BAZ_RSS_MANAGINGEDITOR.'</managingEditor>'."\n".'<webMaster>'.BAZ_RSS_WEBMASTER.'</webMaster>'."\n";
510
	'<managingEditor>'.BAZ_RSS_MANAGINGEDITOR.'</managingEditor>'."\n".'<webMaster>'.BAZ_RSS_WEBMASTER.'</webMaster>'."\n";
504
	$xml .= '<ttl>60</ttl>'."\n".'<image>'."\n".'<title>'.BAZ_RSS_NOMSITE.'</title>'."\n".'<url>'.BAZ_RSS_LOGOSITE.'</url>'."\n".
511
	$xml .= '<ttl>60</ttl>'."\n".'<image>'."\n".'<title>'.BAZ_RSS_NOMSITE.'</title>'."\n".'<url>'.BAZ_RSS_LOGOSITE.'</url>'."\n".
505
	'<link>'.BAZ_RSS_ADRESSESITE.'</link>'."\n".'</image>'."\n";
512
	'<link>'.BAZ_RSS_ADRESSESITE.'</link>'."\n".'</image>'."\n";
506
	if ($resultat->numRows()>0) {
513
	if ($resultat->numRows()>0) {
507
		// Creation des items : titre + lien + description + date de publication
514
		// Creation des items : titre + lien + description + date de publication
508
		while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
515
		while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
509
			$xml .= '<item>'."\n";
516
			$xml .= '<item>'."\n";
510
			$xml .= '<title>'.$ligne['bf_titre'].'</title>'."\n";
517
			$xml .= '<title>'.$ligne['bf_titre'].'</title>'."\n";
511
			$lien=$GLOBALS['_BAZAR_']['url'];
518
			$lien=$GLOBALS['_BAZAR_']['url'];
512
			$lien->addQueryString('action', BAZ_VOIR_FICHE);
519
			$lien->addQueryString('action', BAZ_VOIR_FICHE);
513
			$lien->addQueryString('id_fiche', $ligne['bf_id_fiche']);
520
			$lien->addQueryString('id_fiche', $ligne['bf_id_fiche']);
514
			$xml .= '<link>'.str_replace ('&', '&amp;', $lien->getURL()).'</link>'."\n";
521
			$xml .= '<link>'.str_replace ('&', '&amp;', $lien->getURL()).'</link>'."\n";
515
			$xml .= '<description>'."\n".'<![CDATA['.baz_voir_fiche(0,$ligne['bf_id_fiche']).']]>'."\n".'</description>'."\n";
522
			$xml .= '<description>'."\n".'<![CDATA['.baz_voir_fiche(0,$ligne['bf_id_fiche']).']]>'."\n".'</description>'."\n";
516
			$xml .= '<pubDate>'.strftime('%d %b %Y %H:%M:%S GMT',strtotime($ligne['bf_date_debut_validite_fiche'])).'</pubDate>'."\n";
523
			$xml .= '<pubDate>'.strftime('%d %b %Y %H:%M:%S GMT',strtotime($ligne['bf_date_debut_validite_fiche'])).'</pubDate>'."\n";
517
			$xml .= '</item>'."\n";
524
			$xml .= '</item>'."\n";
518
		}
525
		}
519
	}
526
	}
520
	else {//pas d'annonces
527
	else {//pas d'annonces
521
		$xml .= '<item>'."\n";
528
		$xml .= '<item>'."\n";
522
		$xml .= '<title>'.BAZ_PAS_D_ANNONCES.'</title>'."\n";
529
		$xml .= '<title>'.BAZ_PAS_D_ANNONCES.'</title>'."\n";
523
		$xml .= '<link>#</link>'."\n";
530
		$xml .= '<link>#</link>'."\n";
524
		$xml .= '<description>'.BAZ_PAS_D_ANNONCES.'</description>'."\n";
531
		$xml .= '<description>'.BAZ_PAS_D_ANNONCES.'</description>'."\n";
525
		$xml .= '<pubDate>'.strftime('%d %b %Y %H:%M:%S GMT',strtotime('12/12/2004')).'</pubDate>'."\n";
532
		$xml .= '<pubDate>'.strftime('%d %b %Y %H:%M:%S GMT',strtotime('12/12/2004')).'</pubDate>'."\n";
526
		$xml .= '</item>'."\n";
533
		$xml .= '</item>'."\n";
527
	}
534
	}
528
	$xml .= '</channel>'."\n".'</rss>'."\n";
535
	$xml .= '</channel>'."\n".'</rss>'."\n";
529
	return $xml;
536
	return $xml;
530
}
537
}
531
 
538
 
532
 
539
 
533
/** baz_liste() Formate la liste de toutes les annonces actuelles
540
/** baz_liste() Formate la liste de toutes les annonces actuelles
534
*
541
*
535
*   @return  string    le code HTML a afficher
542
*   @return  string    le code HTML a afficher
536
*/
543
*/
537
function baz_liste($typeannonce='toutes') {
544
function baz_liste($typeannonce='toutes') {
538
	//creation du lien pour le formulaire de recherche
545
	//creation du lien pour le formulaire de recherche
539
	$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_VOIR_TOUTES_ANNONCES);
546
	$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_VOIR_TOUTES_ANNONCES);
540
	$lien_formulaire=preg_replace ('/&amp;/', '&', $GLOBALS['_BAZAR_']['url']->getURL()) ;
547
	$lien_formulaire=preg_replace ('/&amp;/', '&', $GLOBALS['_BAZAR_']['url']->getURL()) ;
541
	$formtemplate = new HTML_QuickForm('formulaire', 'post', $lien_formulaire) ;
548
	$formtemplate = new HTML_QuickForm('formulaire', 'post', $lien_formulaire) ;
542
	$squelette =&$formtemplate->defaultRenderer();
549
	$squelette =&$formtemplate->defaultRenderer();
543
	$squelette->setFormTemplate("\n".'<form{attributes}>'."\n".'<ul style="padding:0;margin:0;">'."\n".'{content}'."\n".'</ul>'."\n".'</form>'."\n");
550
	$squelette->setFormTemplate("\n".'<form{attributes}>'."\n".'<ul style="padding:0;margin:0;">'."\n".'{content}'."\n".'</ul>'."\n".'</form>'."\n");
544
	$squelette->setElementTemplate( '<li class="enligne">'."\n".'{element}'."\n".'</li>'."\n");
551
	$squelette->setElementTemplate( '<li class="enligne">'."\n".'{element}'."\n".'</li>'."\n");
545
		
552
		
546
	//cas du formulaire de recherche proposant de chercher parmis tous les types d'annonces 
553
	//cas du formulaire de recherche proposant de chercher parmis tous les types d'annonces 
547
	if ($GLOBALS['_BAZAR_']['typeannonce']=='toutes') {
554
	if ($GLOBALS['_BAZAR_']['typeannonce']=='toutes') {
548
		$res= '<h2>'.BAZ_TOUTES_LES_ANNONCES.'</h2><br />'."\n";
555
		$res= '<h2>'.BAZ_TOUTES_LES_ANNONCES.'</h2><br />'."\n";
549
		//requete pour obtenir l'id et le label des types d'annonces
556
		//requete pour obtenir l'id et le label des types d'annonces
550
		$requete = 'SELECT bn_id_nature, bn_label_nature '.
557
		$requete = 'SELECT bn_id_nature, bn_label_nature '.
551
		           'FROM bazar_nature WHERE bn_ce_id_menu='.$GLOBALS['_BAZAR_']['categorie_nature'].' '.
558
		           'FROM bazar_nature WHERE bn_ce_id_menu='.$GLOBALS['_BAZAR_']['categorie_nature'].' '.
552
				   'ORDER BY bn_label_nature ASC';
559
				   'ORDER BY bn_label_nature ASC';
553
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
560
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
554
		if (DB::isError($resultat)) {
561
		if (DB::isError($resultat)) {
555
			die ($resultat->getMessage().$resultat->getDebugInfo()) ;
562
			die ($resultat->getMessage().$resultat->getDebugInfo()) ;
556
		}
563
		}
557
		$type_annonce_select['toutes']=BAZ_TOUS_TYPES_FICHES;
564
		$type_annonce_select['toutes']=BAZ_TOUS_TYPES_FICHES;
558
		while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
565
		while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
559
			$type_annonce_select[$ligne['bn_id_nature']] = constant($ligne['bn_label_nature']);
566
			$type_annonce_select[$ligne['bn_id_nature']] = constant($ligne['bn_label_nature']);
560
		}
567
		}
561
		$option=array('style'=>'border:1px solid #000;width: 140px;font:12px Myriad, Arial, sans-serif;');
568
		$option=array('style'=>'border:1px solid #000;width: 140px;font:12px Myriad, Arial, sans-serif;');
562
		$formtemplate->addElement ('select', 'nature', BAZ_TYPEANNONCE, $type_annonce_select, $option) ;
569
		$formtemplate->addElement ('select', 'nature', BAZ_TYPEANNONCE, $type_annonce_select, $option) ;
563
	}
570
	}
564
	//cas du type d'annonces prédéfini 
571
	//cas du type d'annonces prédéfini 
565
	else {
572
	else {
566
		$res = '<h2>'.BAZ_TOUTES_LES_ANNONCES_DE_TYPE.' '.constant($GLOBALS['_BAZAR_']['typeannonce']).'</h2>'."\n";
573
		$res = '<h2>'.BAZ_TOUTES_LES_ANNONCES_DE_TYPE.' '.constant($GLOBALS['_BAZAR_']['typeannonce']).'</h2>'."\n";
567
	}
574
	}
-
 
575
 
568
		
576
	
569
	//requete pour obtenir l'id, le nom et prenom de toutes les personnes ayant depose une fiche
577
	//requete pour obtenir l'id, le nom et prenom de toutes les personnes ayant depose une fiche
570
	$requete = 'SELECT '.BAZ_CHAMPS_ID.', '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.' '.
578
	$requete = 'SELECT '.BAZ_CHAMPS_ID.', '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.' '.
571
	           'FROM bazar_fiche,'.BAZ_ANNUAIRE.' '.
579
	           'FROM bazar_fiche,'.BAZ_ANNUAIRE.' where' ;
-
 
580
 
572
		       'WHERE bf_date_debut_validite_fiche<=NOW() AND bf_date_fin_validite_fiche>=NOW() AND bf_ce_utilisateur='.BAZ_CHAMPS_ID.' ';
581
	$requete .= ' bf_date_debut_validite_fiche<=NOW() AND bf_date_fin_validite_fiche>=NOW() and';	
-
 
582
 
-
 
583
	$requete .= ' bf_ce_utilisateur='.BAZ_CHAMPS_ID.' ';
573
    if (!isset($_REQUEST['nature'])) {
584
    if (!isset($_REQUEST['nature'])) {
574
    	if (isset($GLOBALS['_BAZAR_']['id_typeannonce'])) {
585
    	if (isset($GLOBALS['_BAZAR_']['id_typeannonce'])) {
575
    		$requete .= 'AND bf_ce_nature='.$GLOBALS['_BAZAR_']['id_typeannonce'].' ';
586
    		$requete .= 'AND bf_ce_nature='.$GLOBALS['_BAZAR_']['id_typeannonce'].' ';
576
    	} 
587
    	} 
577
    }
588
    }
578
    else {
589
    else {
579
    	if ($_REQUEST['nature']!='toutes') {
590
    	if ($_REQUEST['nature']!='toutes') {
580
    		$requete .= 'AND bf_ce_nature='.$_REQUEST['nature'].' ';
591
    		$requete .= 'AND bf_ce_nature='.$_REQUEST['nature'].' ';
581
    	}
592
    	}
582
    }
593
    }
583
    
594
    
584
    $requete .= 'ORDER BY '.BAZ_CHAMPS_NOM.' ASC';
595
    $requete .= 'ORDER BY '.BAZ_CHAMPS_NOM.' ASC';
585
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
596
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
586
	if (DB::isError($resultat)) {
597
	if (DB::isError($resultat)) {
587
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
598
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
588
	}
599
	}
589
	$personnes_select['tous']=BAZ_TOUS_LES_EMETTEURS;
600
	$personnes_select['tous']=BAZ_TOUS_LES_EMETTEURS;
590
	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
601
	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
591
		$personnes_select[$ligne[BAZ_CHAMPS_ID]] = $ligne[BAZ_CHAMPS_NOM]." ".$ligne[BAZ_CHAMPS_PRENOM] ;
602
		$personnes_select[$ligne[BAZ_CHAMPS_ID]] = $ligne[BAZ_CHAMPS_NOM]." ".$ligne[BAZ_CHAMPS_PRENOM] ;
592
	}
603
	}
593
	$option=array('style'=>'border:1px solid #000;width: 140px;font:12px Myriad, Arial, sans-serif;');
604
	$option=array('style'=>'border:1px solid #000;width: 140px;font:12px Myriad, Arial, sans-serif;');
594
	$formtemplate->addElement ('select', 'personnes', BAZ_EMETTEUR, $personnes_select, $option) ;
605
	$formtemplate->addElement ('select', 'personnes', BAZ_EMETTEUR, $personnes_select, $option) ;
595
	
-
 
596
	//pour les super-administrateurs, on peut voir les annonces non validées
606
		//pour les super-administrateurs, on peut voir les annonces non validées
597
	//on verifie si l'utilisateur est administrateur
607
	//on verifie si l'utilisateur est administrateur
598
	$est_admin=0;
608
	$est_admin=0;
599
	if ($GLOBALS['AUTH']->getAuth()) {
609
	if ($GLOBALS['AUTH']->getAuth()) {
600
		if (niveau_droit(0,$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))=='superadministrateur')
610
		if (niveau_droit(0,$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))=='superadministrateur')
601
		{
611
		{
602
		        $est_admin=1;
612
		        $est_admin=1;
603
		}
613
		}
604
	}
614
	}
-
 
615
 
605
	if ($est_admin==1) {
616
	if ($est_admin==1) {
606
		$option=array('style'=>'border:1px solid #000;width: 60px;font:12px Myriad, Arial, sans-serif;');
617
		$option=array('style'=>'border:1px solid #000;width: 60px;font:12px Myriad, Arial, sans-serif;');
607
		$valide_select[0] = BAZ_FICHES_PAS_VALIDEES;
618
		$valide_select[0] = BAZ_FICHES_PAS_VALIDEES;
608
		$valide_select[1] = BAZ_FICHES_VALIDEES;
619
		$valide_select[1] = BAZ_FICHES_VALIDEES;
609
		$valide_select[2] = BAZ_LES_DEUX;
620
		$valide_select[2] = BAZ_LES_DEUX;
610
		$formtemplate->addElement ('select', 'valides', BAZ_VALIDE, $valide_select, $option) ; 
621
		$formtemplate->addElement ('select', 'valides', BAZ_VALIDE, $valide_select, $option) ; 
611
		$defauts=array('valides'=>2);
622
		$defauts=array('valides'=>2);
612
		$formtemplate->setDefaults($defauts);
623
		$formtemplate->setDefaults($defauts);
613
	}
624
	}
614
	
625
	
615
	//champs texte pour entrer les mots cles
626
	//champs texte pour entrer les mots cles
616
	$option=array('maxlength'=>60,'style'=>'border:1px solid #000;width:100px;font:12px Myriad, Arial, sans-serif;');
627
	$option=array('maxlength'=>60,'style'=>'border:1px solid #000;width:100px;font:12px Myriad, Arial, sans-serif;');
617
	$formtemplate->addElement('text', 'recherche_mots_cles', BAZ_MOT_CLE, $option) ;
628
	$formtemplate->addElement('text', 'recherche_mots_cles', BAZ_MOT_CLE, $option) ;
618
	$defauts=array('recherche_mots_cles'=>BAZ_MOT_CLE);
629
	$defauts=array('recherche_mots_cles'=>BAZ_MOT_CLE);
619
	$formtemplate->setDefaults($defauts);
630
	$formtemplate->setDefaults($defauts);
620
	
631
	
621
	//option cachee pour savoir si le formulaire a ete appele deja 
632
	//option cachee pour savoir si le formulaire a ete appele deja 
622
	$formtemplate->addElement('hidden', 'recherche_effectuee', 1) ;
633
	$formtemplate->addElement('hidden', 'recherche_effectuee', 1) ;
623
	
634
	
624
	//Bouton de validation du formulaire
635
	//Bouton de validation du formulaire
625
	$option=array('style'=>'border:1px solid #000;width:50px;font:12px Myriad, Arial, sans-serif;');
636
	$option=array('style'=>'border:1px solid #000;width:50px;font:12px Myriad, Arial, sans-serif;');
626
	$bouton[] = &HTML_QuickForm::createElement('submit', 'valider', BAZ_VALIDER, $option);
637
	$bouton[] = &HTML_QuickForm::createElement('submit', 'valider', BAZ_VALIDER, $option);
627
	$formtemplate->addGroup($bouton, null, null, '');
638
	$formtemplate->addGroup($bouton, null, null, '');
628
	
639
	
629
	//affichage du formulaire
640
	//affichage du formulaire
630
	$res.=$formtemplate->toHTML()."\n";
641
	$res.=$formtemplate->toHTML()."\n";
631
	
642
	
632
	//affichage des resultats de la recherche si le formulaire a ete envoye
643
	//affichage des resultats de la recherche si le formulaire a ete envoye
633
	if (isset($_REQUEST['recherche_effectuee'])) {
644
	if (isset($_REQUEST['recherche_effectuee'])) {
634
		//preparation de la requete pour trouver les mots cles
645
		//preparation de la requete pour trouver les mots cles
635
		if (($_POST['recherche_mots_cles']!='')and($_POST['recherche_mots_cles']!=BAZ_MOT_CLE)) {
646
		if (($_POST['recherche_mots_cles']!='')and($_POST['recherche_mots_cles']!=BAZ_MOT_CLE)) {
636
			//decoupage des mots cles
647
			//decoupage des mots cles
637
			$recherche = split(' ', $_POST['recherche_mots_cles']) ;
648
			$recherche = split(' ', $_POST['recherche_mots_cles']) ;
638
			$nbmots=count($recherche);
649
			$nbmots=count($recherche);
639
			$requeteSQL=''; 
650
			$requeteSQL=''; 
640
			for ($i=0; $i<$nbmots; $i++) {
651
			for ($i=0; $i<$nbmots; $i++) {
641
				if ($i>0) $requeteSQL.=' OR ';
652
				if ($i>0) $requeteSQL.=' OR ';
642
				$requeteSQL.='bf_titre LIKE "%'.$recherche[$i].'%" OR bf_description LIKE "%'.$recherche[$i].'%" ';
653
				$requeteSQL.='bf_titre LIKE "%'.$recherche[$i].'%" OR bf_description LIKE "%'.$recherche[$i].'%" ';
643
			}
654
			}
644
		}
655
		}
645
		if (!isset($_REQUEST['nature'])) {$typedefiches=$GLOBALS['_BAZAR_']['id_nature'] ; }
656
		if (!isset($_REQUEST['nature'])) {$typedefiches=$GLOBALS['_BAZAR_']['id_nature'] ; }
646
		else {$typedefiches=$_REQUEST['nature'] ; }
657
		else {$typedefiches=$_REQUEST['nature'] ; }
647
		
658
		
648
		if (isset($_POST['valides'])) {$valides=$_POST['valides'];}
659
		if (isset($_POST['valides'])) {$valides=$_POST['valides'];}
649
		else {$valides=1;}
660
		else {$valides=1;}
650
		//generation de la liste de flux a afficher
661
		//generation de la liste de flux a afficher
651
		
662
		
652
		$res.=RSSversHTML(gen_RSS($typedefiches, '', $_POST['personnes'], $valides, $requeteSQL), 0, BAZ_TYPE_AFFICHAGE_LISTE, 1) ;
663
		$res.=RSSversHTML(gen_RSS($typedefiches, '', $_POST['personnes'], $valides, $requeteSQL), 0, BAZ_TYPE_AFFICHAGE_LISTE, 1) ;
653
	}
664
	}
654
	else {
665
	else {
655
		//on affiche toutes les annonces
666
		//on affiche toutes les annonces
656
		$res .= '<br />'."\n".BAZ_ENTRER_VOS_CRITERES_DE_RECHERCHE;		
667
		$res .= '<br />'."\n".BAZ_ENTRER_VOS_CRITERES_DE_RECHERCHE;		
657
	}
668
	}
658
	return $res;
669
	return $res;
659
}
670
}
660
?>
671
?>