1 |
<?php
|
1 |
<?php
|
2 |
/** baz_valeur_template() - Renvoi des valeurs inscrite dans le fichier de template
|
2 |
/** baz_valeur_template() - Renvoi des valeurs inscrite dans le fichier de template
|
3 |
*
|
3 |
*
|
4 |
* @param string nom du fichier de template
|
4 |
* @param string nom du fichier de template
|
5 |
*
|
5 |
*
|
6 |
* @return mixed tableau contenant les champs du fichier template
|
6 |
* @return mixed tableau contenant les champs du fichier template
|
7 |
*/
|
7 |
*/
|
8 |
function baz_valeurs_template($fichier_template) {
|
8 |
function baz_valeurs_template($fichier_template) {
|
9 |
//Parcours du fichier de templates, pour mettre les champs spécifiques
|
9 |
//Parcours du fichier de templates, pour mettre les champs spécifiques
|
10 |
$nblignes=0;
|
10 |
$nblignes=0;
|
11 |
$fichier=file_get_contents(BAZ_CHEMIN_APPLI.'templates/'.$fichier_template);
|
11 |
$fichier=file_get_contents(BAZ_CHEMIN_APPLI.'templates/'.$fichier_template);
|
12 |
$chaine = explode ("\n", $fichier);
|
12 |
$chaine = explode ("\n", $fichier);
|
13 |
array_pop($chaine);
|
13 |
array_pop($chaine);
|
14 |
foreach ($chaine as $ligne) {
|
14 |
foreach ($chaine as $ligne) {
|
15 |
$souschaine = explode ("***", $ligne) ;
|
15 |
$souschaine = explode ("***", $ligne) ;
|
16 |
$tableau[$nblignes]['type'] = trim($souschaine[0]) ;
|
16 |
$tableau[$nblignes]['type'] = trim($souschaine[0]) ;
|
17 |
if (isset($souschaine[1])) {$tableau[$nblignes]['nom_bdd'] = trim($souschaine[1]);}
|
17 |
if (isset($souschaine[1])) {$tableau[$nblignes]['nom_bdd'] = trim($souschaine[1]);}
|
18 |
else {$tableau[$nblignes]['nom_bdd'] ='';}
|
18 |
else {$tableau[$nblignes]['nom_bdd'] ='';}
|
19 |
if (isset($souschaine[2])) $tableau[$nblignes]['label'] = trim($souschaine[2]);
|
19 |
if (isset($souschaine[2])) $tableau[$nblignes]['label'] = trim($souschaine[2]);
|
20 |
else {$tableau[$nblignes]['label'] ='';}
|
20 |
else {$tableau[$nblignes]['label'] ='';}
|
21 |
if (isset($souschaine[3])) $tableau[$nblignes]['limite1'] = trim($souschaine[3]);
|
21 |
if (isset($souschaine[3])) $tableau[$nblignes]['limite1'] = trim($souschaine[3]);
|
22 |
else {$tableau[$nblignes]['limite1'] ='';}
|
22 |
else {$tableau[$nblignes]['limite1'] ='';}
|
23 |
if (isset($souschaine[4])) $tableau[$nblignes]['limite2'] = trim($souschaine[4]);
|
23 |
if (isset($souschaine[4])) $tableau[$nblignes]['limite2'] = trim($souschaine[4]);
|
24 |
else {$tableau[$nblignes]['limite2'] ='';}
|
24 |
else {$tableau[$nblignes]['limite2'] ='';}
|
25 |
if (isset($souschaine[5])) $tableau[$nblignes]['defaut'] = trim($souschaine[5]);
|
25 |
if (isset($souschaine[5])) $tableau[$nblignes]['defaut'] = trim($souschaine[5]);
|
26 |
else {$tableau[$nblignes]['defaut'] ='';}
|
26 |
else {$tableau[$nblignes]['defaut'] ='';}
|
27 |
if (isset($souschaine[6])) $tableau[$nblignes]['table_source'] = trim($souschaine[6]);
|
27 |
if (isset($souschaine[6])) $tableau[$nblignes]['table_source'] = trim($souschaine[6]);
|
28 |
else {$tableau[$nblignes]['table_source'] ='';}
|
28 |
else {$tableau[$nblignes]['table_source'] ='';}
|
29 |
if (isset($souschaine[7])) $tableau[$nblignes]['id_source'] = trim($souschaine[7]);
|
29 |
if (isset($souschaine[7])) $tableau[$nblignes]['id_source'] = trim($souschaine[7]);
|
30 |
else {$tableau[$nblignes]['id_source'] ='';}
|
30 |
else {$tableau[$nblignes]['id_source'] ='';}
|
31 |
if (isset($souschaine[8])) $tableau[$nblignes]['obligatoire'] = trim($souschaine[8]);
|
31 |
if (isset($souschaine[8])) $tableau[$nblignes]['obligatoire'] = trim($souschaine[8]);
|
32 |
else {$tableau[$nblignes]['obligatoire'] ='';}
|
32 |
else {$tableau[$nblignes]['obligatoire'] ='';}
|
33 |
$nblignes++;
|
33 |
$nblignes++;
|
34 |
}
|
34 |
}
|
35 |
return $tableau;
|
35 |
return $tableau;
|
36 |
}
|
36 |
}
|
37 |
|
37 |
|
38 |
|
38 |
|
39 |
/** baz_voir_fiche() - Permet de visualiser en détail une fiche au format XHTML
|
39 |
/** baz_voir_fiche() - Permet de visualiser en détail une fiche au format XHTML
|
40 |
*
|
40 |
*
|
41 |
* @global boolean Rajoute des informations internes à l'application (date de modification, lien vers la page de départ de l'appli) si à 1
|
41 |
* @global boolean Rajoute des informations internes à l'application (date de modification, lien vers la page de départ de l'appli) si à 1
|
42 |
* @global integer Identifiant de la fiche à afficher
|
42 |
* @global integer Identifiant de la fiche à afficher
|
43 |
*
|
43 |
*
|
44 |
* @return string HTML
|
44 |
* @return string HTML
|
45 |
*/
|
45 |
*/
|
46 |
function baz_voir_fiche($danslappli, $idfiche='') {
|
46 |
function baz_voir_fiche($danslappli, $idfiche='') {
|
47 |
if (isset($_GET['id_fiche'])) $GLOBALS['_BAZAR_']['id_fiche']=$_GET['id_fiche'];
|
47 |
if (isset($_GET['id_fiche'])) $GLOBALS['_BAZAR_']['id_fiche']=$_GET['id_fiche'];
|
48 |
if ($idfiche!='') $GLOBALS['_BAZAR_']['id_fiche']=$idfiche;
|
48 |
if ($idfiche!='') $GLOBALS['_BAZAR_']['id_fiche']=$idfiche;
|
- |
|
49 |
|
- |
|
50 |
$url= $GLOBALS['_BAZAR_']['url'];
|
- |
|
51 |
$url->addQueryString('action', BAZ_VOIR_FICHE);
|
- |
|
52 |
$url->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
|
- |
|
53 |
$url = preg_replace ('/&/', '&', $url->getURL()) ;
|
- |
|
54 |
|
- |
|
55 |
//cas ou un commetaire a été entré
|
- |
|
56 |
if (isset($_POST['Nom'])) {
|
- |
|
57 |
$requete = 'INSERT INTO bazar_commentaires VALUES ('.$GLOBALS['_BAZAR_']['id_fiche'].', "'.$_POST['Nom'].'", "'.$_POST['Commentaire'].'", NOW() )';
|
- |
|
58 |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
|
- |
|
59 |
}
|
49 |
|
60 |
else {
|
50 |
//on met à jour le nb de visites pour la fiche
|
61 |
//sinon on met à jour le nb de visites pour la fiche, puisque c'est une simple consultation
|
51 |
$requete = 'UPDATE bazar_fiche SET bf_nb_consultations=bf_nb_consultations+1 WHERE bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
|
62 |
$requete = 'UPDATE bazar_fiche SET bf_nb_consultations=bf_nb_consultations+1 WHERE bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
|
- |
|
63 |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
|
52 |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
|
64 |
}
|
53 |
|
65 |
|
54 |
//on cherche le type d'annonce, l'annonceur et les stats
|
66 |
//on cherche le type d'annonce, l'annonceur et les stats
|
55 |
$requete = 'SELECT bn_label_nature, bn_commentaire, bn_appropriation, bf_ce_utilisateur,bf_nb_consultations FROM bazar_fiche, bazar_nature WHERE bn_id_nature=bf_ce_nature AND bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
|
67 |
$requete = 'SELECT bn_label_nature, bn_commentaire, bn_appropriation, bf_ce_utilisateur,bf_nb_consultations FROM bazar_fiche, bazar_nature WHERE bn_id_nature=bf_ce_nature AND bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
|
56 |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
|
68 |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
|
57 |
if (DB::isError($resultat)) {
|
69 |
if (DB::isError($resultat)) {
|
58 |
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
|
70 |
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
|
59 |
}
|
71 |
}
|
60 |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
|
72 |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
|
61 |
$GLOBALS['_BAZAR_']['typeannonce']=$ligne['bn_label_nature'];
|
73 |
$GLOBALS['_BAZAR_']['typeannonce']=$ligne['bn_label_nature'];
|
62 |
$GLOBALS['_BAZAR_']['commentaire']=$ligne['bn_commentaire'];
|
74 |
$GLOBALS['_BAZAR_']['commentaire']=$ligne['bn_commentaire'];
|
63 |
$GLOBALS['_BAZAR_']['appropriation']=$ligne['bn_appropriation'];
|
75 |
$GLOBALS['_BAZAR_']['appropriation']=$ligne['bn_appropriation'];
|
64 |
$GLOBALS['_BAZAR_']['annonceur']=$ligne['bf_ce_utilisateur'];
|
76 |
$GLOBALS['_BAZAR_']['annonceur']=$ligne['bf_ce_utilisateur'];
|
65 |
$GLOBALS['_BAZAR_']['nb_consultations']=$ligne['bf_nb_consultations'];
|
77 |
$GLOBALS['_BAZAR_']['nb_consultations']=$ligne['bf_nb_consultations'];
|
66 |
}
|
78 |
}
|
- |
|
79 |
|
- |
|
80 |
//on vérifie si l'utilisateur est administrateur
|
- |
|
81 |
$est_admin=0;
|
- |
|
82 |
if ($GLOBALS['AUTH']->getAuth()) {
|
- |
|
83 |
$requete='SELECT bn_id_nature FROM bazar_nature WHERE bn_label_nature="'.$GLOBALS['_BAZAR_']['typeannonce'].'"';
|
- |
|
84 |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
|
- |
|
85 |
if (DB::isError($resultat)) {
|
- |
|
86 |
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
|
- |
|
87 |
}
|
- |
|
88 |
$result = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
|
- |
|
89 |
if ((niveau_droit($result['bn_id_nature'],$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))=='administrateur')
|
- |
|
90 |
or(niveau_droit('0',$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))=='superadministrateur'))
|
- |
|
91 |
{
|
- |
|
92 |
$est_admin=1;
|
- |
|
93 |
}
|
- |
|
94 |
}
|
- |
|
95 |
|
67 |
$res = '<div class="BAZ_cadre_fiche">'."\n";
|
96 |
$res = '<div class="BAZ_cadre_fiche">'."\n";
|
68 |
$res .= '<div class="BAZ_cadre_fiche_haut">'."\n";
|
97 |
$res .= '<div class="BAZ_cadre_fiche_haut">'."\n";
|
69 |
$res .= ' </div>'."\n";
|
98 |
$res .= ' </div>'."\n";
|
70 |
$res .= '<div class="BAZ_cadre_fiche_corps">'."\n";
|
99 |
$res .= '<div class="BAZ_cadre_fiche_corps">'."\n";
|
71 |
|
100 |
|
72 |
//si le template existe, on génère le template
|
101 |
//si le template existe, on génère le template
|
73 |
if ((file_exists(BAZ_CHEMIN_APPLI.'templates/'.$GLOBALS['_BAZAR_']['typeannonce'].'-fiche.php'))) {
|
102 |
if ((file_exists(BAZ_CHEMIN_APPLI.'templates/'.$GLOBALS['_BAZAR_']['typeannonce'].'-fiche.php'))) {
|
74 |
include_once(BAZ_CHEMIN_APPLI.'templates/'.$GLOBALS['_BAZAR_']['typeannonce'].'-fiche.php');
|
103 |
include_once(BAZ_CHEMIN_APPLI.'templates/'.$GLOBALS['_BAZAR_']['typeannonce'].'-fiche.php');
|
75 |
$res .=genere_fiche($GLOBALS['_BAZAR_']['id_fiche']);
|
104 |
$res .=genere_fiche($GLOBALS['_BAZAR_']['id_fiche']);
|
76 |
}
|
105 |
}
|
77 |
//on affiche ligne par ligne sinon
|
106 |
//on affiche ligne par ligne sinon
|
78 |
else {
|
107 |
else {
|
79 |
$requete = 'SELECT * FROM bazar_fiche WHERE bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
|
108 |
$requete = 'SELECT * FROM bazar_fiche WHERE bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
|
80 |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
|
109 |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
|
81 |
if (DB::isError ($resultat)) {
|
110 |
if (DB::isError ($resultat)) {
|
82 |
die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
|
111 |
die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
|
83 |
}
|
112 |
}
|
84 |
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC) ;
|
113 |
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC) ;
|
85 |
|
114 |
|
86 |
if (isset($ligne['bf_url_image'])) {
|
115 |
if (isset($ligne['bf_url_image'])) {
|
87 |
$res .= '<div id="fiche_image">'."\n";
|
116 |
$res .= '<div id="fiche_image">'."\n";
|
88 |
$res .= '<img src="'.'http://'.$_SERVER['HTTP_HOST'].'/client/bazar/images/'.$ligne['bf_url_image'].'" border=0 alt="'.BAZ_TEXTE_IMG_ALTERNATIF.'" />'."\n";
|
117 |
$res .= '<img src="'.'http://'.$_SERVER['HTTP_HOST'].'/client/bazar/images/'.$ligne['bf_url_image'].'" border=0 alt="'.BAZ_TEXTE_IMG_ALTERNATIF.'" />'."\n";
|
89 |
$res .= '</div>'."\n";
|
118 |
$res .= '</div>'."\n";
|
90 |
$res .= '<div id="fiche_titre_image">'.$ligne['bf_titre'];
|
119 |
$res .= '<div id="fiche_titre_image">'.$ligne['bf_titre'];
|
91 |
}
|
120 |
}
|
92 |
else {
|
121 |
else {
|
93 |
$res .= '<div id="fiche_titre">'.$ligne['bf_titre'];
|
122 |
$res .= '<div id="fiche_titre">'.$ligne['bf_titre'];
|
94 |
}
|
123 |
}
|
95 |
$res .= '</div>'."\n";
|
124 |
$res .= '</div>'."\n";
|
96 |
$res .= '<div id="BAZ_description">'.$ligne['bf_description'].'</div>'."\n";
|
125 |
$res .= '<div id="BAZ_description">'.$ligne['bf_description'].'</div>'."\n";
|
97 |
$tableau=baz_valeurs_template($GLOBALS['_BAZAR_']['typeannonce'].'.tpl');
|
126 |
$tableau=baz_valeurs_template($GLOBALS['_BAZAR_']['typeannonce'].'.tpl');
|
98 |
for ($i=0; $i<count($tableau); $i++) {
|
127 |
for ($i=0; $i<count($tableau); $i++) {
|
99 |
if (isset($ligne[$tableau[$i]['nom_bdd']])) {
|
128 |
if (isset($ligne[$tableau[$i]['nom_bdd']])) {
|
100 |
//pour les champs renseignés par une liste, on va chercher le label de la liste, plutot que l'id
|
129 |
//pour les champs renseignés par une liste, on va chercher le label de la liste, plutot que l'id
|
101 |
if ($tableau[$i]['type']=='liste') {
|
130 |
if ($tableau[$i]['type']=='liste') {
|
102 |
$requete = 'SELECT '.$tableau[$i]['table_source'].'.* FROM bazar_fiche, '.$tableau[$i]['table_source'].
|
131 |
$requete = 'SELECT '.$tableau[$i]['table_source'].'.* FROM bazar_fiche, '.$tableau[$i]['table_source'].
|
103 |
' WHERE '.$tableau[$i]['nom_bdd'].'='.$tableau[$i]['id_source'].' AND bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
|
132 |
' WHERE '.$tableau[$i]['nom_bdd'].'='.$tableau[$i]['id_source'].' AND bf_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
|
104 |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
|
133 |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
|
105 |
if (DB::isError ($resultat)) {
|
134 |
if (DB::isError ($resultat)) {
|
106 |
die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
|
135 |
die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
|
107 |
}
|
136 |
}
|
108 |
while ($tab = $resultat->fetchRow()) {
|
137 |
while ($tab = $resultat->fetchRow()) {
|
109 |
$val=$tab[1];
|
138 |
$val=$tab[1];
|
110 |
}
|
139 |
}
|
111 |
}
|
140 |
}
|
112 |
else {
|
141 |
else {
|
113 |
$val=$ligne[$tableau[$i]['nom_bdd']];
|
142 |
$val=$ligne[$tableau[$i]['nom_bdd']];
|
114 |
}
|
143 |
}
|
115 |
if (($tableau[$i]['nom_bdd']!='bf_titre')and($tableau[$i]['nom_bdd']!='bf_description')) {
|
144 |
if (($tableau[$i]['nom_bdd']!='bf_titre')and($tableau[$i]['nom_bdd']!='bf_description')) {
|
116 |
if ($val!='') {
|
145 |
if ($val!='') {
|
117 |
$res .= '<span class="rubrique">'.constant($tableau[$i]['label']).':</span>'."\n";
|
146 |
$res .= '<span class="rubrique">'.constant($tableau[$i]['label']).':</span>'."\n";
|
118 |
$res .= '<span class="description"> '.$val.'</span>'."\n".'<br />'."\n";
|
147 |
$res .= '<span class="description"> '.$val.'</span>'."\n".'<br />'."\n";
|
119 |
}
|
148 |
}
|
120 |
}
|
149 |
}
|
121 |
}
|
150 |
}
|
122 |
}
|
151 |
}
|
123 |
}
|
152 |
}
|
124 |
//afficher les liens pour l'annonce
|
153 |
//afficher les liens pour l'annonce
|
125 |
$requete = 'SELECT bu_url, bu_descriptif_url FROM bazar_url WHERE bu_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
|
154 |
$requete = 'SELECT bu_url, bu_descriptif_url FROM bazar_url WHERE bu_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
|
126 |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
|
155 |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
|
127 |
if (DB::isError($resultat)) {
|
156 |
if (DB::isError($resultat)) {
|
128 |
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
|
157 |
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
|
129 |
}
|
158 |
}
|
130 |
if ($resultat->numRows()>0) {
|
159 |
if ($resultat->numRows()>0) {
|
131 |
$res .= '<span class="rubrique">'.BAZ_LIEN_INTERNET.':</span>'."\n";
|
160 |
$res .= '<span class="rubrique">'.BAZ_LIEN_INTERNET.':</span>'."\n";
|
132 |
$res .= '<span class="description">'."\n";
|
161 |
$res .= '<span class="description">'."\n";
|
133 |
$res .= '<ul>'."\n";
|
162 |
$res .= '<ul>'."\n";
|
134 |
while ($ligne1 = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
|
163 |
while ($ligne1 = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
|
135 |
$res .= '<li><a href="'.$ligne1['bu_url'].'" target="_blank">'.$ligne1['bu_descriptif_url'].'</a></li>'."\n";
|
164 |
$res .= '<li><a href="'.$ligne1['bu_url'].'" target="_blank">'.$ligne1['bu_descriptif_url'].'</a></li>'."\n";
|
136 |
}
|
165 |
}
|
137 |
$res .= '</ul></span>'."\n";
|
166 |
$res .= '</ul></span>'."\n";
|
138 |
}
|
167 |
}
|
139 |
|
168 |
|
140 |
//afficher les fichiers pour l'annonce
|
169 |
//afficher les fichiers pour l'annonce
|
141 |
$requete = 'SELECT bfj_description, bfj_fichier FROM bazar_fichier_joint WHERE bfj_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
|
170 |
$requete = 'SELECT bfj_description, bfj_fichier FROM bazar_fichier_joint WHERE bfj_ce_fiche='.$GLOBALS['_BAZAR_']['id_fiche'];
|
142 |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
|
171 |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
|
143 |
if (DB::isError($resultat)) {
|
172 |
if (DB::isError($resultat)) {
|
144 |
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
|
173 |
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
|
145 |
}
|
174 |
}
|
146 |
if ($resultat->numRows()>0) {
|
175 |
if ($resultat->numRows()>0) {
|
147 |
$res .= '<span class="rubrique">'.BAZ_LISTE_FICHIERS_JOINTS.':</span>'."\n";
|
176 |
$res .= '<span class="rubrique">'.BAZ_LISTE_FICHIERS_JOINTS.':</span>'."\n";
|
148 |
$res .= '<span class="description">'."\n";
|
177 |
$res .= '<span class="description">'."\n";
|
149 |
$res .= '<ul>'."\n";
|
178 |
$res .= '<ul>'."\n";
|
150 |
while ($ligne2 = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
|
179 |
while ($ligne2 = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
|
151 |
$res .= '<li><a href="http://'.$_SERVER['HTTP_HOST'].'/client/bazar/upload/'.$ligne2['bfj_fichier'].'">'.$ligne2['bfj_description'].'</a></li>'."\n";
|
180 |
$res .= '<li><a href="http://'.$_SERVER['HTTP_HOST'].'/client/bazar/upload/'.$ligne2['bfj_fichier'].'">'.$ligne2['bfj_description'].'</a></li>'."\n";
|
152 |
}
|
181 |
}
|
153 |
$res .= '</ul></span>'."\n";
|
182 |
$res .= '</ul></span>'."\n";
|
154 |
}
|
183 |
}
|
155 |
$res .= '<div id="bulle_haut"> </div>'."\n";
|
184 |
$res .= '<div class="bulle_haut"> </div>'."\n";
|
156 |
$res .= '<div id="bulle_corps">'."\n";
|
185 |
$res .= '<div class="bulle_corps">'."\n";
|
157 |
|
186 |
|
158 |
//affichage du rédacteur de la fiche
|
187 |
//affichage du rédacteur de la fiche
|
159 |
$requete = 'SELECT '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.', '.BAZ_CHAMPS_EMAIL.' FROM '.BAZ_ANNUAIRE.' WHERE '.BAZ_CHAMPS_ID.'='.$GLOBALS['_BAZAR_']['annonceur'];
|
188 |
$requete = 'SELECT '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.', '.BAZ_CHAMPS_EMAIL.' FROM '.BAZ_ANNUAIRE.' WHERE '.BAZ_CHAMPS_ID.'='.$GLOBALS['_BAZAR_']['annonceur'];
|
160 |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
|
189 |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
|
161 |
if (DB::isError($resultat)) {
|
190 |
if (DB::isError($resultat)) {
|
162 |
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
|
191 |
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
|
163 |
}
|
192 |
}
|
164 |
while ($redacteur = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
|
193 |
while ($redacteur = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
|
165 |
$res .= BAZ_FICHE_ECRITE.'<a href="mailto:'.$redacteur[BAZ_CHAMPS_EMAIL].'">'.$redacteur[BAZ_CHAMPS_PRENOM].' '.$redacteur[BAZ_CHAMPS_NOM].'</a><br />'."\n";
|
194 |
$res .= BAZ_FICHE_ECRITE.'<a href="mailto:'.$redacteur[BAZ_CHAMPS_EMAIL].'">'.$redacteur[BAZ_CHAMPS_PRENOM].' '.$redacteur[BAZ_CHAMPS_NOM].'</a><br />'."\n";
|
166 |
}
|
195 |
}
|
167 |
$res .= BAZ_NB_VUS.'<strong>'.$GLOBALS['_BAZAR_']['nb_consultations'].'</strong>'.BAZ_FOIS.'<br />'."\n";
|
196 |
$res .= BAZ_NB_VUS.'<strong>'.$GLOBALS['_BAZAR_']['nb_consultations'].'</strong>'.BAZ_FOIS.'<br />'."\n";
|
168 |
$res .= '</div>'."\n";
|
197 |
$res .= '</div>'."\n";
|
169 |
$res .= '<div id="bulle_bas"> </div>'."\n";
|
198 |
$res .= '<div class="bulle_bas"> </div>'."\n";
|
170 |
$res .= '<div id="BAZ_bas_page">';
|
199 |
$res .= '<div id="BAZ_bas_page">';
|
- |
|
200 |
|
171 |
//informations complémentaires (id fiche, état publication,... )
|
201 |
//informations complémentaires (id fiche, état publication,... )
|
172 |
if ($danslappli==1) {
|
202 |
if ($danslappli==1) {
|
173 |
$res .= '<span class="rubrique">'.BAZ_NUM_FICHE.':</span> '.$GLOBALS['_BAZAR_']['id_fiche'].'<br />'."\n";
|
203 |
$res .= '<span class="rubrique">'.BAZ_NUM_FICHE.':</span> '.$GLOBALS['_BAZAR_']['id_fiche'].'<br />'."\n";
|
174 |
$res .= '<span class="rubrique">'.BAZ_NATURE.':</span> '.$GLOBALS['_BAZAR_']['typeannonce'].'<br />'."\n";
|
204 |
$res .= '<span class="rubrique">'.BAZ_NATURE.':</span> '.$GLOBALS['_BAZAR_']['typeannonce'].'<br />'."\n";
|
175 |
if ($ligne['bf_statut_fiche']==1) {
|
205 |
if ($ligne['bf_statut_fiche']==1) {
|
176 |
$res .= '<span class="rubrique">'.BAZ_PUBLIEE.':</span> '.BAZ_OUI.'<br />'."\n";
|
206 |
$res .= '<span class="rubrique">'.BAZ_PUBLIEE.':</span> '.BAZ_OUI.'<br />'."\n";
|
177 |
}
|
207 |
}
|
178 |
else {
|
208 |
else {
|
179 |
$res .= '<span class="rubrique">'.BAZ_PUBLIEE.':</span> '.BAZ_NON.'<br />'."\n";
|
209 |
$res .= '<span class="rubrique">'.BAZ_PUBLIEE.':</span> '.BAZ_NON.'<br />'."\n";
|
180 |
}
|
210 |
}
|
181 |
$res .= '<span class="rubrique">'.BAZ_DATE_CREATION.':</span> '.strftime('%d.%m.%Y à %H:%M',strtotime($ligne['bf_date_creation_fiche'])).'<br />'."\n";
|
211 |
$res .= '<span class="rubrique">'.BAZ_DATE_CREATION.':</span> '.strftime('%d.%m.%Y à %H:%M',strtotime($ligne['bf_date_creation_fiche'])).'<br />'."\n";
|
182 |
$res .= '<span class="rubrique">'.BAZ_DATE_MAJ.':</span> '.strftime('%d.%m.%Y à %H:%M',strtotime($ligne['bf_date_maj_fiche']));
|
212 |
$res .= '<span class="rubrique">'.BAZ_DATE_MAJ.':</span> '.strftime('%d.%m.%Y à %H:%M',strtotime($ligne['bf_date_maj_fiche']));
|
183 |
//pour les identifiés seulement, administrateurs de la rubrique ou superadmins
|
- |
|
184 |
if ($GLOBALS['AUTH']->getAuth()) {
|
- |
|
185 |
$est_admin=0;
|
- |
|
186 |
$requete='SELECT bn_id_nature FROM bazar_nature WHERE bn_label_nature="'.$GLOBALS['_BAZAR_']['typeannonce'].'"';
|
- |
|
187 |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
|
- |
|
188 |
if (DB::isError($resultat)) {
|
- |
|
189 |
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
|
- |
|
190 |
}
|
- |
|
191 |
$result = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
|
- |
|
192 |
if ((niveau_droit($result['bn_id_nature'],$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID)))=='administrateur') {
|
213 |
if (($est_admin)or($GLOBALS['_BAZAR_']['annonceur']==$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))) {
|
193 |
$est_admin=1;
|
- |
|
194 |
}
|
- |
|
195 |
if (($est_admin)or(niveau_droit($id_nature_offre='0',$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))=='superadministrateur')or($GLOBALS['_BAZAR_']['annonceur']==$GLOBALS['AUTH']->getAuthData(BAZ_CHAMPS_ID))) {
|
- |
|
196 |
$lien_modifier=$GLOBALS['_BAZAR_']['url'];
|
214 |
$lien_modifier=$GLOBALS['_BAZAR_']['url'];
|
197 |
$lien_modifier->addQueryString('action', BAZ_ACTION_MODIFIER);
|
215 |
$lien_modifier->addQueryString('action', BAZ_ACTION_MODIFIER);
|
198 |
$lien_modifier->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
|
216 |
$lien_modifier->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
|
199 |
$lien_modifier->addQueryString('typeannonce', $GLOBALS['_BAZAR_']['typeannonce']);
|
217 |
$lien_modifier->addQueryString('typeannonce', $GLOBALS['_BAZAR_']['typeannonce']);
|
200 |
$res .= ' <a href="'.$lien_modifier->getURL().'">'.BAZ_MODIFIER_LA_FICHE.'</a>'."\n";
|
218 |
$res .= ' <a href="'.$lien_modifier->getURL().'">'.BAZ_MODIFIER_LA_FICHE.'</a>'."\n";
|
201 |
}
|
- |
|
202 |
}
|
219 |
}
|
203 |
}
|
220 |
}
|
204 |
$res .= '</div>'."\n";
|
221 |
$res .= '</div>'."\n";
|
205 |
$res .= '</div>'."\n";
|
222 |
$res .= '</div>'."\n";
|
206 |
$res .= '<div class="BAZ_cadre_fiche_bas"> </div>'."\n";
|
223 |
$res .= '<div class="BAZ_cadre_fiche_bas"> </div>'."\n";
|
207 |
$res .= '</div>'."\n";
|
224 |
$res .= '</div>'."\n";
|
208 |
|
225 |
|
209 |
//on ajoute les commentaires, s'il le faut
|
226 |
//on ajoute les commentaires, s'il le faut
|
210 |
if ($GLOBALS['_BAZAR_']['commentaire']==1) {
|
227 |
if ($GLOBALS['_BAZAR_']['commentaire']==1) {
|
211 |
$res .= '<div class="BAZ_cadre_fiche">'."\n";
|
228 |
$res .= '<div class="BAZ_cadre_fiche">'."\n";
|
212 |
$res .= '<div class="BAZ_cadre_fiche_haut"> </div>'."\n";
|
229 |
$res .= '<div class="BAZ_cadre_fiche_haut"> </div>'."\n";
|
213 |
$res .= '<div class="BAZ_cadre_fiche_corps">'."\n";
|
230 |
$res .= '<div class="BAZ_cadre_fiche_corps">'."\n";
|
214 |
$res .= '<h3>'.BAZ_LES_COMMENTAIRES.'</h3>'."\n";
|
231 |
$res .= '<h3>'.BAZ_LES_COMMENTAIRES.'</h3>'."\n";
|
215 |
$requete = 'SELECT * FROM bazar_commentaires WHERE bc_ce_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].' ORDER BY bc_date ASC';
|
232 |
$requete = 'SELECT * FROM bazar_commentaires WHERE bc_ce_id_fiche='.$GLOBALS['_BAZAR_']['id_fiche'].' ORDER BY bc_date ASC';
|
216 |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
|
233 |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
|
217 |
if (DB::isError ($resultat)) {
|
234 |
if (DB::isError ($resultat)) {
|
218 |
die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
|
235 |
die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
|
219 |
}
|
236 |
}
|
220 |
if ($resultat->numRows()>0) {
|
237 |
if ($resultat->numRows()>0) {
|
221 |
$res .= 'Il y a '.$resultat->numRows();
|
238 |
$res .= BAZ_IL_Y_A.$resultat->numRows().' ';
|
222 |
if ($resultat->numRows()==1) $res .= 'commentaire : '.'<br />'."\n";
|
239 |
if ($resultat->numRows()==1) $res .= BAZ_COMMENTAIRE.'<br />'."\n";
|
223 |
else $res .= 'commentaires : '.'<br />'."\n";
|
240 |
else $res .= BAZ_COMMENTAIRES.'<br />'."\n";
|
224 |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
|
241 |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
|
- |
|
242 |
$res .= '<div class="bulle_haut"> </div>'."\n";
|
- |
|
243 |
$res .= '<div class="bulle_corps">'."\n";
|
- |
|
244 |
//affichage du commentaire
|
- |
|
245 |
$res .= $ligne['bc_commentaire'].'<br />'."\n";
|
225 |
$res .= 'essai'."\n";
|
246 |
$res .= '</div>'."\n";
|
- |
|
247 |
$res .= '<div class="bulle_bas">'."\n";
|
- |
|
248 |
$res .= '<span style="font-size:9px;margin-left:10px;">'.BAZ_PAR.' : <strong>'.$ligne['bc_nom'].'</strong>'.BAZ_ECRIT_LE.$ligne['bc_date'].'</span>'."\n";
|
- |
|
249 |
//pour les identifiés seulement, administrateurs de la rubrique ou superadmins
|
- |
|
250 |
if ($est_admin==1) {
|
- |
|
251 |
$url_comment= $GLOBALS['_BAZAR_']['url'];
|
- |
|
252 |
$url_comment->addQueryString('action', BAZ_VOIR_FICHE);
|
- |
|
253 |
$url_comment->addQueryString('id_fiche', $GLOBALS['_BAZAR_']['id_fiche']);
|
- |
|
254 |
$url_comment->addQueryString('date', $ligne['bc_date']);
|
- |
|
255 |
$res .= '<span style="float:right;"><a href="'.$url_comment->getURL().'">'.BAZ_SUPPRIMER.'</a></span>'."\n";
|
- |
|
256 |
}
|
- |
|
257 |
$res .= '</div>'."\n";
|
226 |
}
|
258 |
}
|
227 |
}
|
259 |
}
|
228 |
else $res .= BAZ_PAS_DE_COMMENTAIRES.'<br />'."\n";
|
260 |
else $res .= BAZ_PAS_DE_COMMENTAIRES.'<br /><br />'."\n";
|
- |
|
261 |
|
- |
|
262 |
//formulaire des commentaires
|
- |
|
263 |
$form_commentaire = new HTML_QuickForm('commentaire', 'post', $url);
|
- |
|
264 |
$squelette =& $form_commentaire->defaultRenderer();
|
- |
|
265 |
$squelette->setFormTemplate("\n".'<form {attributes}>'."\n".'{content}'."\n".'</form>'."\n");
|
- |
|
266 |
$squelette->setElementTemplate( '<label style="width:200px;">{label} </label><br />'."\n".'{element}<br />'."\n");
|
- |
|
267 |
$squelette->setRequiredNoteTemplate("\n".'{requiredNote} '."\n");
|
- |
|
268 |
$option=array('style'=>'width:300px;', 'maxlength'=>100);
|
- |
|
269 |
$form_commentaire->addElement('text', 'Nom', BAZ_ENTREZ_VOTRE_NOM, $option);
|
- |
|
270 |
$option=array('style'=>'width:100%;height:100px;white-space: pre;padding:3px;');
|
- |
|
271 |
require_once 'HTML/QuickForm/textarea.php';
|
- |
|
272 |
$formtexte= new HTML_QuickForm_textarea('Commentaire', BAZ_ENTREZ_VOTRE_COMMENTAIRE, $option);
|
- |
|
273 |
$form_commentaire->addElement($formtexte) ;
|
- |
|
274 |
$form_commentaire->addElement('submit', 'Envoyer', BAZ_ENVOYER);
|
- |
|
275 |
$form_commentaire->addRule('Nom', BAZ_NOM_REQUIS, 'required', '', 'client') ;
|
- |
|
276 |
$form_commentaire->addRule('Commentaire', BAZ_COMMENTAIRE_REQUIS, 'required', '', 'client') ;
|
- |
|
277 |
$form_commentaire->setRequiredNote(BAZ_CHAMPS_REQUIS) ;
|
- |
|
278 |
$res .= $form_commentaire->toHTML();
|
- |
|
279 |
|
229 |
$res .= '</div>'."\n";
|
280 |
$res .= '</div>'."\n";
|
230 |
$res .= '<div class="BAZ_cadre_fiche_bas"> </div>'."\n";
|
281 |
$res .= '<div class="BAZ_cadre_fiche_bas"> </div>'."\n";
|
231 |
$res .= '</div>'."\n";
|
282 |
$res .= '</div>'."\n";
|
232 |
}
|
283 |
}
|
233 |
|
284 |
|
234 |
//on ajoute les appropriations, s'il le faut
|
285 |
//on ajoute les appropriations, s'il le faut
|
235 |
if ($GLOBALS['_BAZAR_']['appropriation']==1) {
|
286 |
if ($GLOBALS['_BAZAR_']['appropriation']==1) {
|
236 |
$res .= '<div class="BAZ_cadre_fiche">'."\n";
|
287 |
$res .= '<div class="BAZ_cadre_fiche">'."\n";
|
237 |
$res .= '<div class="BAZ_cadre_fiche_haut"> </div>'."\n";
|
288 |
$res .= '<div class="BAZ_cadre_fiche_haut"> </div>'."\n";
|
238 |
$res .= '<div class="BAZ_cadre_fiche_corps">'."\n";
|
289 |
$res .= '<div class="BAZ_cadre_fiche_corps">'."\n";
|
239 |
|
290 |
|
240 |
$res .= '</div>'."\n";
|
291 |
$res .= '</div>'."\n";
|
241 |
$res .= '<div class="BAZ_cadre_fiche_bas"> </div>'."\n";
|
292 |
$res .= '<div class="BAZ_cadre_fiche_bas"> </div>'."\n";
|
242 |
$res .= '</div>'."\n";
|
293 |
$res .= '</div>'."\n";
|
243 |
}
|
294 |
}
|
244 |
|
295 |
|
245 |
return $res ;
|
296 |
return $res ;
|
246 |
}
|
297 |
}
|
247 |
|
298 |
|
248 |
|
299 |
|
249 |
/** RSSversHTML () transforme un flux RSS (en XML) en page HTML
|
300 |
/** RSSversHTML () transforme un flux RSS (en XML) en page HTML
|
250 |
*
|
301 |
*
|
251 |
* On passe en paramètre le contenu du flux RSS, on affiche ou non la description,
|
302 |
* On passe en paramètre le contenu du flux RSS, on affiche ou non la description,
|
252 |
* et on choisit de format de la date à l'affichage. On a en sortie du code HTML à afficher
|
303 |
* et on choisit de format de la date à l'affichage. On a en sortie du code HTML à afficher
|
253 |
*
|
304 |
*
|
254 |
* @param string le contenu du flux RSS
|
305 |
* @param string le contenu du flux RSS
|
255 |
* @param boolean afficher ou non la description
|
306 |
* @param boolean afficher ou non la description
|
256 |
* @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
|
307 |
* @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
|
257 |
*
|
308 |
*
|
258 |
* @return string le code HTML
|
309 |
* @return string le code HTML
|
259 |
*/
|
310 |
*/
|
260 |
|
311 |
|
261 |
function RSSversHTML($rss, $voirdesc, $formatdate) {
|
312 |
function RSSversHTML($rss, $voirdesc, $formatdate) {
|
262 |
if ($rss!='') {
|
313 |
if ($rss!='') {
|
263 |
$res='';
|
314 |
$res='';
|
264 |
if( eregi('<item>(.*)</item>', $rss, $rawitems ) ) {
|
315 |
if( eregi('<item>(.*)</item>', $rss, $rawitems ) ) {
|
265 |
$items = explode('<item>', $rawitems[0]);
|
316 |
$items = explode('<item>', $rawitems[0]);
|
266 |
$res.='<ul>'."\n";
|
317 |
$res.='<ul>'."\n";
|
267 |
for( $i = 0; $i < count($items)-1; $i++ ) {
|
318 |
for( $i = 0; $i < count($items)-1; $i++ ) {
|
268 |
eregi('<title>(.*)</title>',$items[$i+1], $title );
|
319 |
eregi('<title>(.*)</title>',$items[$i+1], $title );
|
269 |
eregi('<link>(.*)</link>',$items[$i+1], $url );
|
320 |
eregi('<link>(.*)</link>',$items[$i+1], $url );
|
270 |
eregi('<description>(.*)</description>',$items[$i+1], $cat);
|
321 |
eregi('<description>(.*)</description>',$items[$i+1], $cat);
|
271 |
eregi('<pubDate>(.*)</pubDate>',$items[$i+1], $date);
|
322 |
eregi('<pubDate>(.*)</pubDate>',$items[$i+1], $date);
|
272 |
$res.='<li>';
|
323 |
$res.='<li>';
|
273 |
if ($formatdate=='jm') {$res.=strftime('%d.%m',strtotime($date[1])).': ';}
|
324 |
if ($formatdate=='jm') {$res.=strftime('%d.%m',strtotime($date[1])).': ';}
|
274 |
if ($formatdate=='jma') {$res.=strftime('%d.%m.%Y',strtotime($date[1])).': ';}
|
325 |
if ($formatdate=='jma') {$res.=strftime('%d.%m.%Y',strtotime($date[1])).': ';}
|
275 |
if ($formatdate=='jmh') {$res.=strftime('%d.%m %H:%M',strtotime($date[1])).': ';}
|
326 |
if ($formatdate=='jmh') {$res.=strftime('%d.%m %H:%M',strtotime($date[1])).': ';}
|
276 |
if ($formatdate=='jmah') {$res.=strftime('%d.%m.%Y %H:%M',strtotime($date[1])).': ';}
|
327 |
if ($formatdate=='jmah') {$res.=strftime('%d.%m.%Y %H:%M',strtotime($date[1])).': ';}
|
277 |
$res.='<a href="'.preg_replace ('/&/', '&', $url[1]).'">'.$title[1].'</a><br />';
|
328 |
$res.='<a href="'.preg_replace ('/&/', '&', $url[1]).'">'.$title[1].'</a><br />';
|
278 |
if ($voirdesc) {$res.=$cat[1];}
|
329 |
if ($voirdesc) {$res.=$cat[1];}
|
279 |
$res.='</li>'."\n";
|
330 |
$res.='</li>'."\n";
|
280 |
}
|
331 |
}
|
281 |
$res.='</ul>'."\n";
|
332 |
$res.='</ul>'."\n";
|
282 |
}
|
333 |
}
|
283 |
}
|
334 |
}
|
284 |
else $res = BAZ_PAS_D_ANNONCES;
|
335 |
else $res = BAZ_PAS_D_ANNONCES;
|
285 |
return $res;
|
336 |
return $res;
|
286 |
}
|
337 |
}
|
287 |
|
338 |
|
288 |
/** gen_RSS() - générer un fichier de flux RSS par type d'annonce
|
339 |
/** gen_RSS() - générer un fichier de flux RSS par type d'annonce
|
289 |
*
|
340 |
*
|
290 |
* @param string Le type de l'annonce (laisser vide pour tout type d'annonce)
|
341 |
* @param string Le type de l'annonce (laisser vide pour tout type d'annonce)
|
291 |
* @param integer Le nombre d'annonces a regrouper dans le fichier XML (laisser vide pour toutes)
|
342 |
* @param integer Le nombre d'annonces a regrouper dans le fichier XML (laisser vide pour toutes)
|
292 |
* @param integer L'identifiant de l'emetteur (laisser vide pour tous)
|
343 |
* @param integer L'identifiant de l'emetteur (laisser vide pour tous)
|
293 |
* @param integer L'état de validation de l'annonce (laisser 1 pour les annonces validées, 0 pour les non-validées)
|
344 |
* @param integer L'état de validation de l'annonce (laisser 1 pour les annonces validées, 0 pour les non-validées)
|
294 |
* @param string La requète SQL personnalisée
|
345 |
* @param string La requète SQL personnalisée
|
295 |
*
|
346 |
*
|
296 |
* @return string Le code du flux RSS
|
347 |
* @return string Le code du flux RSS
|
297 |
*/
|
348 |
*/
|
298 |
function gen_RSS($typeannonce='', $nbitem='', $emetteur='', $valide=1, $requeteSQL='') {
|
349 |
function gen_RSS($typeannonce='', $nbitem='', $emetteur='', $valide=1, $requeteSQL='') {
|
299 |
// génération de la requete MySQL personnalisée
|
350 |
// génération de la requete MySQL personnalisée
|
300 |
$requete = 'SELECT DISTINCT bf_id_fiche, bf_titre, bf_date_debut_validite_fiche, bn_label_nature FROM bazar_fiche, bazar_nature';
|
351 |
$requete = 'SELECT DISTINCT bf_id_fiche, bf_titre, bf_date_debut_validite_fiche, bn_label_nature FROM bazar_fiche, bazar_nature';
|
301 |
$requete .= ' WHERE bf_statut_fiche='.$valide;
|
352 |
$requete .= ' WHERE bf_statut_fiche='.$valide;
|
302 |
$nomflux=BAZ_DERNIERE_ACTU;
|
353 |
$nomflux=BAZ_DERNIERE_ACTU;
|
303 |
if (($typeannonce!='')and($typeannonce!='toutes')) {
|
354 |
if (($typeannonce!='')and($typeannonce!='toutes')) {
|
304 |
$requete .= ' AND bn_label_nature="'.$typeannonce.'"';
|
355 |
$requete .= ' AND bn_label_nature="'.$typeannonce.'"';
|
305 |
//le nom du flux devient le type d'annonce
|
356 |
//le nom du flux devient le type d'annonce
|
306 |
$nomflux = $typeannonce;
|
357 |
$nomflux = $typeannonce;
|
307 |
}
|
358 |
}
|
308 |
if ($valide!=0) $requete .= ' AND bf_date_debut_validite_fiche<=NOW() AND bf_date_fin_validite_fiche>=NOW() AND bn_id_nature=bf_ce_nature';
|
359 |
if ($valide!=0) $requete .= ' AND bf_date_debut_validite_fiche<=NOW() AND bf_date_fin_validite_fiche>=NOW() AND bn_id_nature=bf_ce_nature';
|
309 |
else $nomflux .= BAZ_A_MODERER;
|
360 |
else $nomflux .= BAZ_A_MODERER;
|
310 |
if (($emetteur!='')and($emetteur!='tous')) {
|
361 |
if (($emetteur!='')and($emetteur!='tous')) {
|
311 |
$requete .= ' AND bf_ce_utilisateur='.$emetteur;
|
362 |
$requete .= ' AND bf_ce_utilisateur='.$emetteur;
|
312 |
//requete pour afficher le nom de la structure
|
363 |
//requete pour afficher le nom de la structure
|
313 |
$requetenom = 'SELECT '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.' FROM '.BAZ_ANNUAIRE.' WHERE '.BAZ_CHAMPS_ID.'='.$emetteur;
|
364 |
$requetenom = 'SELECT '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.' FROM '.BAZ_ANNUAIRE.' WHERE '.BAZ_CHAMPS_ID.'='.$emetteur;
|
314 |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requetenom) ;
|
365 |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requetenom) ;
|
315 |
if (DB::isError($resultat)) {
|
366 |
if (DB::isError($resultat)) {
|
316 |
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
|
367 |
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
|
317 |
}
|
368 |
}
|
318 |
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
|
369 |
$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
|
319 |
$nomflux .= ' ('.$ligne[BAZ_CHAMPS_NOM].' '.$ligne[BAZ_CHAMPS_PRENOM].')';
|
370 |
$nomflux .= ' ('.$ligne[BAZ_CHAMPS_NOM].' '.$ligne[BAZ_CHAMPS_PRENOM].')';
|
320 |
}
|
371 |
}
|
321 |
if ($requeteSQL!='') $requete .= ' AND ('.$requeteSQL.')';
|
372 |
if ($requeteSQL!='') $requete .= ' AND ('.$requeteSQL.')';
|
322 |
$requete .= ' ORDER BY bf_date_debut_validite_fiche, bf_date_fin_validite_fiche, bf_date_maj_fiche DESC';
|
373 |
$requete .= ' ORDER BY bf_date_debut_validite_fiche, bf_date_fin_validite_fiche, bf_date_maj_fiche DESC';
|
323 |
if ($nbitem!='') {$requete .= ' LIMIT 0,'.$nbitem;}
|
374 |
if ($nbitem!='') {$requete .= ' LIMIT 0,'.$nbitem;}
|
324 |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
|
375 |
$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
|
325 |
if (DB::isError($resultat)) {
|
376 |
if (DB::isError($resultat)) {
|
326 |
die ($GLOBALS['_BAZAR_']['db']->getMessage().$GLOBALS["db"]->getDebugInfo()) ;
|
377 |
die ($GLOBALS['_BAZAR_']['db']->getMessage().$GLOBALS["db"]->getDebugInfo()) ;
|
327 |
}
|
378 |
}
|
328 |
// En-tête du flux RSS version 2.0
|
379 |
// En-tête du flux RSS version 2.0
|
329 |
$xml = '<?xml version="1.0" encoding="ISO-8859-1"?>'."\n".'<rss version="2.0">'."\n";
|
380 |
$xml = '<?xml version="1.0" encoding="ISO-8859-1"?>'."\n".'<rss version="2.0">'."\n";
|
330 |
$xml .= '<channel>'."\n".'<title>'.$nomflux.'</title>'."\n".'<link>'.BAZ_RSS_ADRESSESITE.'</link>'."\n";
|
381 |
$xml .= '<channel>'."\n".'<title>'.$nomflux.'</title>'."\n".'<link>'.BAZ_RSS_ADRESSESITE.'</link>'."\n";
|
331 |
$xml .= '<description>'.BAZ_RSS_DESCRIPTIONSITE.'</description>'."\n".'<language>fr-FR</language>'."\n".
|
382 |
$xml .= '<description>'.BAZ_RSS_DESCRIPTIONSITE.'</description>'."\n".'<language>fr-FR</language>'."\n".
|
332 |
'<copyright>Copyright 2005 '.BAZ_RSS_NOMSITE.'</copyright>'."\n";
|
383 |
'<copyright>Copyright 2005 '.BAZ_RSS_NOMSITE.'</copyright>'."\n";
|
333 |
// Ajout de la date actuelle de publication (suivant la DTD RSS)
|
384 |
// Ajout de la date actuelle de publication (suivant la DTD RSS)
|
334 |
$xml .= '<lastBuildDate>'.strftime('%d %b %Y %H:%M:%S GMT').'</lastBuildDate>'."\n";
|
385 |
$xml .= '<lastBuildDate>'.strftime('%d %b %Y %H:%M:%S GMT').'</lastBuildDate>'."\n";
|
335 |
// En-tête suite et fin
|
386 |
// En-tête suite et fin
|
336 |
$xml .= '<docs>http://www.stervinou.com/projets/rss/</docs>'."\n".'<category>'.BAZ_RSS_CATEGORIE.'</category>'."\n".
|
387 |
$xml .= '<docs>http://www.stervinou.com/projets/rss/</docs>'."\n".'<category>'.BAZ_RSS_CATEGORIE.'</category>'."\n".
|
337 |
'<managingEditor>'.BAZ_RSS_MANAGINGEDITOR.'</managingEditor>'."\n".'<webMaster>'.BAZ_RSS_WEBMASTER.'</webMaster>'."\n";
|
388 |
'<managingEditor>'.BAZ_RSS_MANAGINGEDITOR.'</managingEditor>'."\n".'<webMaster>'.BAZ_RSS_WEBMASTER.'</webMaster>'."\n";
|
338 |
$xml .= '<ttl>60</ttl>'."\n".'<image>'."\n".'<title>'.BAZ_RSS_NOMSITE.'</title>'."\n".'<url>'.BAZ_RSS_LOGOSITE.'</url>'."\n".
|
389 |
$xml .= '<ttl>60</ttl>'."\n".'<image>'."\n".'<title>'.BAZ_RSS_NOMSITE.'</title>'."\n".'<url>'.BAZ_RSS_LOGOSITE.'</url>'."\n".
|
339 |
'<link>'.BAZ_RSS_ADRESSESITE.'</link>'."\n".'</image>'."\n";
|
390 |
'<link>'.BAZ_RSS_ADRESSESITE.'</link>'."\n".'</image>'."\n";
|
340 |
if ($resultat->numRows()>0) {
|
391 |
if ($resultat->numRows()>0) {
|
341 |
// Creation des items : titre + lien + description + date de publication
|
392 |
// Creation des items : titre + lien + description + date de publication
|
342 |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
|
393 |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
|
343 |
$xml .= '<item>'."\n";
|
394 |
$xml .= '<item>'."\n";
|
344 |
$xml .= '<title>'.$ligne['bf_titre'].'</title>'."\n";
|
395 |
$xml .= '<title>'.$ligne['bf_titre'].'</title>'."\n";
|
345 |
$lien=$GLOBALS['_BAZAR_']['url'];
|
396 |
$lien=$GLOBALS['_BAZAR_']['url'];
|
346 |
$lien->addQueryString('action', BAZ_VOIR_FICHE);
|
397 |
$lien->addQueryString('action', BAZ_VOIR_FICHE);
|
347 |
$lien->addQueryString('id_fiche', $ligne['bf_id_fiche']);
|
398 |
$lien->addQueryString('id_fiche', $ligne['bf_id_fiche']);
|
348 |
$xml .= '<link>'.str_replace ('&', '&', $lien->getURL()).'</link>'."\n";
|
399 |
$xml .= '<link>'.str_replace ('&', '&', $lien->getURL()).'</link>'."\n";
|
349 |
$xml .= '<description>'."\n".'<![CDATA['.baz_voir_fiche(0,$ligne['bf_id_fiche']).']]>'."\n".'</description>'."\n";
|
400 |
$xml .= '<description>'."\n".'<![CDATA['.baz_voir_fiche(0,$ligne['bf_id_fiche']).']]>'."\n".'</description>'."\n";
|
350 |
$xml .= '<pubDate>'.strftime('%d %b %Y %H:%M:%S GMT',strtotime($ligne['bf_date_debut_validite_fiche'])).'</pubDate>'."\n";
|
401 |
$xml .= '<pubDate>'.strftime('%d %b %Y %H:%M:%S GMT',strtotime($ligne['bf_date_debut_validite_fiche'])).'</pubDate>'."\n";
|
351 |
$xml .= '</item>'."\n";
|
402 |
$xml .= '</item>'."\n";
|
352 |
}
|
403 |
}
|
353 |
}
|
404 |
}
|
354 |
else {//pas d'annonces
|
405 |
else {//pas d'annonces
|
355 |
$xml .= '<item>'."\n";
|
406 |
$xml .= '<item>'."\n";
|
356 |
$xml .= '<title> </title>'."\n";
|
407 |
$xml .= '<title> </title>'."\n";
|
357 |
$xml .= '<link>http://test.educ-envir.org</link>'."\n";
|
408 |
$xml .= '<link>http://test.educ-envir.org</link>'."\n";
|
358 |
$xml .= '<description> </description>'."\n";
|
409 |
$xml .= '<description> </description>'."\n";
|
359 |
$xml .= '<pubDate>'.strftime('%d %b %Y %H:%M:%S GMT',strtotime('12/12/2004')).'</pubDate>'."\n";
|
410 |
$xml .= '<pubDate>'.strftime('%d %b %Y %H:%M:%S GMT',strtotime('12/12/2004')).'</pubDate>'."\n";
|
360 |
$xml .= '</item>'."\n";
|
411 |
$xml .= '</item>'."\n";
|
361 |
}
|
412 |
}
|
362 |
$xml .= '</channel>'."\n".'</rss>'."\n";
|
413 |
$xml .= '</channel>'."\n".'</rss>'."\n";
|
363 |
return $xml;
|
414 |
return $xml;
|
364 |
}
|
415 |
}
|
365 |
|
416 |
|
366 |
|
417 |
|
367 |
/** baz_liste() Formate la liste de toutes les annonces actuelles
|
418 |
/** baz_liste() Formate la liste de toutes les annonces actuelles
|
368 |
*
|
419 |
*
|
369 |
* @return string le code HTML à afficher
|
420 |
* @return string le code HTML à afficher
|
370 |
*/
|
421 |
*/
|
371 |
function baz_liste($typeannonce='toutes') {
|
422 |
function baz_liste($typeannonce='toutes') {
|
372 |
if ($typeannonce=='toutes') $res= '<h2>'.BAZ_TOUTES_LES_ANNONCES.'</h2>'."\n";
|
423 |
if ($typeannonce=='toutes') $res= '<h2>'.BAZ_TOUTES_LES_ANNONCES.'</h2>'."\n";
|
373 |
else $res= '<h2>'.BAZ_TOUTES_LES_ANNONCES_DE_TYPE.$typeannonce.'</h2>'."\n";
|
424 |
else $res= '<h2>'.BAZ_TOUTES_LES_ANNONCES_DE_TYPE.$typeannonce.'</h2>'."\n";
|
374 |
$res.=RSSversHTML(gen_RSS($typeannonce, '', '', 1, ''), 0, 'jm') ;
|
425 |
$res.=RSSversHTML(gen_RSS($typeannonce, '', '', 1, ''), 0, 'jm') ;
|
375 |
return $res;
|
426 |
return $res;
|
376 |
}
|
427 |
}
|
377 |
|
428 |
|
378 |
?>
|
429 |
?>
|