Subversion Repositories Applications.bazar

Rev

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

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