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