Subversion Repositories Applications.bazar

Rev

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

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