Subversion Repositories Applications.bazar

Rev

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

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