Subversion Repositories Applications.bazar

Rev

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

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