Subversion Repositories Applications.bazar

Rev

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

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