469 |
mathias |
1 |
<?php
|
|
|
2 |
/*vim: set expandtab tabstop=4 shiftwidth=4: */
|
|
|
3 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
4 |
// | PHP version 4.1 |
|
|
|
5 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
6 |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
|
|
|
7 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
8 |
// | This library is free software; you can redistribute it and/or |
|
|
|
9 |
// | modify it under the terms of the GNU Lesser General Public |
|
|
|
10 |
// | License as published by the Free Software Foundation; either |
|
|
|
11 |
// | version 2.1 of the License, or (at your option) any later version. |
|
|
|
12 |
// | |
|
|
|
13 |
// | This library is distributed in the hope that it will be useful, |
|
|
|
14 |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
15 |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
|
|
16 |
// | Lesser General Public License for more details. |
|
|
|
17 |
// | |
|
|
|
18 |
// | You should have received a copy of the GNU Lesser General Public |
|
|
|
19 |
// | License along with this library; if not, write to the Free Software |
|
|
|
20 |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
|
|
21 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
22 |
// CVS : $Id: bazar.carte_google.php,v 1.9 2008-10-29 15:51:36 alexandre_tb Exp $
|
|
|
23 |
/**
|
|
|
24 |
*
|
|
|
25 |
*@package bazar
|
|
|
26 |
//Auteur original :
|
|
|
27 |
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
|
|
|
28 |
//Autres auteurs :
|
|
|
29 |
*@copyright Tela-Satanica 2000-2007
|
|
|
30 |
*@version $Revision: 1.9 $
|
|
|
31 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
32 |
*/
|
|
|
33 |
|
|
|
34 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
35 |
// | ENTETE du PROGRAMME |
|
|
|
36 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
include_once 'configuration/baz_config.inc.php';
|
|
|
40 |
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazar.fonct.php';
|
|
|
41 |
// Inclusion d'une classe personnalise si elle existe
|
|
|
42 |
|
|
|
43 |
// Le fichier de script de google map
|
|
|
44 |
GEN_stockerFichierScript('googleMapScript', 'http://maps.google.com/maps?file=api&v=2&key='.BAZ_GOOGLE_KEY);
|
|
|
45 |
|
|
|
46 |
// Le fichier jquery pour le date picker
|
|
|
47 |
//GEN_stockerFichierScript('jquery', 'api/js/jquery/jquery.js');
|
|
|
48 |
//GEN_stockerFichierScript('jquery', 'http://code.jquery.com/jquery-latest.js');
|
|
|
49 |
GEN_stockerFichierScript('jquery_date_picker', 'api/js/jquery/ui.datepicker.js');
|
|
|
50 |
GEN_stockerFichierScript('jquery_date_picker_fr', 'api/js/jquery/ui.datepicker-fr.js');
|
|
|
51 |
|
|
|
52 |
GEN_stockerStyleExterne( 'jquery_date_picker_style', 'api/js/jquery/ui.datepicker.css');
|
|
|
53 |
|
|
|
54 |
|
|
|
55 |
if (defined('PAP_VERSION')) { //si on est dans Papyrus
|
|
|
56 |
GEN_stockerStyleExterne( 'bazar_interne', 'client/bazar/bazar.interne.css');
|
|
|
57 |
}
|
|
|
58 |
$GLOBALS['_BAZAR_']['id_typeannonce']=$GLOBALS['_GEN_commun']['info_application']->id_nature;
|
|
|
59 |
$GLOBALS['_BAZAR_']['categorie_nature']=$GLOBALS['_GEN_commun']['info_application']->categorie_nature;
|
|
|
60 |
// requete sur le bazar pour recuperer les evenements
|
|
|
61 |
|
|
|
62 |
$requete_where = '';
|
|
|
63 |
foreach ($_POST as $cle => $valeur) {
|
|
|
64 |
if (preg_match ('/bazar_filtre_([0-9]+)/', $cle, $sousmotif)) {
|
|
|
65 |
$variable = $sousmotif[0] ;
|
|
|
66 |
if ($_POST[$variable] != '*') {
|
|
|
67 |
$requete_where = ' and bfvl_ce_liste="'.$sousmotif[1].'" and bfvl_valeur="'.$_POST[$variable].'" ';
|
|
|
68 |
} else {
|
|
|
69 |
$requete_where = ' and bfvl_ce_liste="'.$sousmotif[1].'" ';
|
|
|
70 |
}
|
|
|
71 |
} else {
|
|
|
72 |
|
|
|
73 |
}
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
if (isset($_POST['date_debut']) && $_POST['date_debut'] != '') {
|
|
|
77 |
|
|
|
78 |
$requete_date = '((bf_date_debut_evenement <= "'.date('Y-m-d', strtotime($_POST['date_fin'])).'" and bf_date_debut_evenement >="'.date('Y-m-d', strtotime($_POST['date_debut'])).'" )' .
|
|
|
79 |
' or (bf_date_fin_evenement >="'.date('Y-m-d', strtotime($_POST['date_debut'])).'" and bf_date_fin_evenement <="'.date('Y-m-d', strtotime($_POST['date_fin'])).'")' .
|
|
|
80 |
' or bf_date_debut_evenement <= "'.date('Y-m-d', strtotime($_POST['date_debut'])).'" and bf_date_fin_evenement >= "'.date('Y-m-d', strtotime($_POST['date_fin'])).'") ';
|
|
|
81 |
} else {
|
|
|
82 |
$requete_date = '((bf_date_debut_validite_fiche <= now( ) AND bf_date_fin_validite_fiche >= now( ))
|
|
|
83 |
OR (bf_date_fin_validite_fiche = "0000-00-00" AND date_add( bf_date_fin_evenement, INTERVAL 15 DAY ) > now( )) )';
|
|
|
84 |
}
|
|
|
85 |
|
|
|
86 |
$requete = 'SELECT blv_label,blv_valeur, bazar_fiche.*'.
|
|
|
87 |
' FROM bazar_fiche, bazar_fiche_valeur_liste , bazar_liste_valeurs'.
|
|
|
88 |
' WHERE bf_statut_fiche =1 and bf_id_fiche=bfvl_ce_fiche'.
|
|
|
89 |
' and bfvl_ce_liste=blv_ce_liste and bfvl_ce_liste=31 and bfvl_valeur=blv_valeur '.$requete_where.' and '.
|
|
|
90 |
$requete_date;
|
|
|
91 |
$resultat = $GLOBALS['_BAZAR_']['db']->query ($requete);
|
|
|
92 |
|
|
|
93 |
if (DB::isError($resultat)) {
|
|
|
94 |
return BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage().'<br />'.$resultat->getDebugInfo(), $requete);echo $requete;
|
|
|
95 |
}
|
|
|
96 |
|
|
|
97 |
// Le code complique avec ces 2 tableaux sert
|
|
|
98 |
// a ne pas mettre 2 points aux memes coordonnees
|
|
|
99 |
// car dans ce cas la seul le second serait visible
|
|
|
100 |
|
|
|
101 |
$donnees = array();
|
|
|
102 |
|
|
|
103 |
if ($resultat->numRows() != 0) {
|
|
|
104 |
$script_marker = '';
|
|
|
105 |
$couleur_drapeau = array ( 1 => 'bleu', 2 => 'vert', 3 => 'orange', 4 => 'rose');
|
|
|
106 |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
|
|
|
107 |
if ($ligne['bf_latitude'] == 0 && $ligne['bf_longitude'] == 0) continue;
|
|
|
108 |
$cle = $ligne['bf_latitude'].'-'.$ligne['bf_longitude'];
|
|
|
109 |
$donnees[$cle][] = $ligne;
|
|
|
110 |
}
|
|
|
111 |
foreach ($donnees as $valeur) {
|
|
|
112 |
// cas un : une seule entree pour le point de coordonnees
|
|
|
113 |
if (count ($valeur) == 1) {
|
|
|
114 |
$chaine = $valeur[0];
|
|
|
115 |
|
|
|
116 |
$script_marker .= 'var icon = new GIcon(G_DEFAULT_ICON);
|
|
|
117 |
icon.image = "client/bazar/images/drapeau_'.$couleur_drapeau[$chaine['blv_valeur']].'.png";'."\n".'
|
|
|
118 |
icon.shadow = "http://www.google.com/mapfiles/shadow50.png";
|
|
|
119 |
icon.iconSize = new GSize(16, 16);
|
|
|
120 |
icon.shadowSize = new GSize(16, 16);
|
|
|
121 |
icon.iconAnchor = new GPoint(6, 16);
|
|
|
122 |
icon.infoWindowAnchor = new GPoint(5, 1);'."\n";
|
|
|
123 |
$script_marker .= "\t".'point = new GLatLng('.$chaine['bf_latitude'].','.$chaine['bf_longitude'].');'."\n"
|
|
|
124 |
."\t".'map.addOverlay(createMarker(point, \''.'<div class="BAZ_cadre_map">'.
|
|
|
125 |
preg_replace ('/\n/', '', str_replace ("\r\n", '',
|
|
|
126 |
str_replace ("'", "\'", baz_voir_fiche(0, $chaine['bf_id_fiche'])))).'</div>\',icon));'."\n";
|
|
|
127 |
} else { // Cas 2 plusieurs entrees
|
|
|
128 |
$tableau_id = array();
|
|
|
129 |
foreach ($valeur as $val) {
|
|
|
130 |
array_push ($tableau_id, $val['bf_id_fiche']);
|
|
|
131 |
}
|
|
|
132 |
$script_marker .= 'var icon = new GIcon();
|
|
|
133 |
icon.image = "http://www.tela-botanica.org/client/bazar/images/drapeau_'.$couleur_drapeau[$chaine['blv_valeur']].'.png";
|
|
|
134 |
icon.shadow = "http://www.google.com/mapfiles/shadow50.png";
|
|
|
135 |
icon.iconSize = new GSize(16, 16);
|
|
|
136 |
icon.shadowSize = new GSize(37, 34);
|
|
|
137 |
icon.iconAnchor = new GPoint(6, 34);
|
|
|
138 |
icon.infoWindowAnchor = new GPoint(5, 1);';
|
|
|
139 |
$script_marker .= "\t".'point = new GLatLng('.$val['bf_latitude'].','.$val['bf_longitude'].');'."\n"
|
|
|
140 |
."\t".'map.addOverlay(createMarker(point, \''.'<div class="BAZ_cadre_map">'.
|
|
|
141 |
preg_replace ('/\n/', '', str_replace ("\r\n", '',
|
|
|
142 |
str_replace ("'", "\'", baz_voir_fiches(0, $tableau_id)))).'</div>\', icon));'."\n";
|
|
|
143 |
}
|
|
|
144 |
}
|
|
|
145 |
} else {
|
|
|
146 |
$script_marker = '';
|
|
|
147 |
}
|
|
|
148 |
|
|
|
149 |
$script = ' // Variables globales
|
|
|
150 |
var map = null;
|
|
|
151 |
// cette fonction peut déjà être présente
|
|
|
152 |
if (typeof(addListener) != \'function\') {
|
|
|
153 |
// fonction portable pour ajout de listeners
|
|
|
154 |
function addListener(element, baseName, handler)
|
|
|
155 |
{
|
|
|
156 |
if (element.addEventListener) {
|
|
|
157 |
element.addEventListener(baseName, handler, false) ;
|
|
|
158 |
} else if (element.attachEvent) {
|
|
|
159 |
element.attachEvent(\'on\'+baseName, handler) ;
|
|
|
160 |
}
|
|
|
161 |
}
|
|
|
162 |
}
|
|
|
163 |
addListener(window,\'load\',loadMap) ;';
|
|
|
164 |
if (BAZ_GOOGLE_MAXIMISE_TAILLE) $script .= '
|
|
|
165 |
// Pour gerer la taille
|
|
|
166 |
var winW = 630, winH = 560;
|
|
|
167 |
var deltaH = 220;
|
|
|
168 |
var deltaW = 270;
|
|
|
169 |
|
|
|
170 |
function setWinHW() {
|
|
|
171 |
if (window.innerHeight) {
|
|
|
172 |
winW = window.innerWidth - deltaW;
|
|
|
173 |
winH = window.innerHeight - deltaH;
|
|
|
174 |
} else {
|
|
|
175 |
winW = document.documentElement.offsetWidth - 20 - deltaW;
|
|
|
176 |
winH = document.documentElement.offsetHeight - 20 - deltaH ;
|
|
|
177 |
}
|
|
|
178 |
|
|
|
179 |
var me = document.getElementById("map");
|
|
|
180 |
if (me != null) {
|
|
|
181 |
me.style.width= \'\' + winW + \'px\';
|
|
|
182 |
me.style.height= \'\' + winH + \'px\';
|
|
|
183 |
}
|
|
|
184 |
}
|
|
|
185 |
|
|
|
186 |
window.onresize = function () {
|
|
|
187 |
setWinHW();
|
|
|
188 |
if (map) map.checkResize();
|
|
|
189 |
}';
|
|
|
190 |
$script .= '
|
|
|
191 |
|
|
|
192 |
function createMarker(point, chaine, icon) {
|
|
|
193 |
|
|
|
194 |
var marker = new GMarker(point, icon);
|
|
|
195 |
GEvent.addListener(marker, "click", function() {
|
|
|
196 |
marker.openInfoWindowHtml(chaine);
|
|
|
197 |
});
|
|
|
198 |
return marker;
|
|
|
199 |
}
|
|
|
200 |
function loadMap() {';
|
|
|
201 |
if (BAZ_GOOGLE_MAXIMISE_TAILLE) $script .= '
|
|
|
202 |
setWinHW();';
|
|
|
203 |
$script .= '
|
|
|
204 |
if (GBrowserIsCompatible()) {
|
|
|
205 |
map = new GMap2(document.getElementById("map"));
|
|
|
206 |
map.addControl(new GSmallMapControl());
|
|
|
207 |
map.addControl(new GMapTypeControl());
|
|
|
208 |
map.addControl(new GScaleControl());
|
|
|
209 |
map.enableContinuousZoom();
|
|
|
210 |
|
|
|
211 |
// On centre la carte sur le languedoc roussillon
|
|
|
212 |
center = new GLatLng('.BAZ_GOOGLE_CENTRE_LAT.', '.BAZ_GOOGLE_CENTRE_LON.');
|
|
|
213 |
map.setCenter(center, '.BAZ_GOOGLE_ALTITUDE.');
|
|
|
214 |
map.setMapType(G_HYBRID_MAP);' ;
|
|
|
215 |
if (BAZ_GOOGLE_FOND_KML != '') {
|
|
|
216 |
$script .= 'var geoXml = new GGeoXml("'.BAZ_GOOGLE_FOND_KML.'");';
|
|
|
217 |
}
|
|
|
218 |
|
|
|
219 |
$script .= $script_marker;
|
|
|
220 |
if (BAZ_GOOGLE_FOND_KML != '') {
|
|
|
221 |
$script .= 'map.addOverlay(geoXml);';
|
|
|
222 |
}
|
|
|
223 |
$script .= '
|
|
|
224 |
}
|
|
|
225 |
};
|
|
|
226 |
';
|
|
|
227 |
|
|
|
228 |
GEN_stockerCodeScript($script);
|
|
|
229 |
// On ajoute l attribut load a la balise body
|
|
|
230 |
//GEN_AttributsBody('onload', 'load()');
|
|
|
231 |
|
|
|
232 |
|
|
|
233 |
|
|
|
234 |
function afficherContenuCorps() {
|
|
|
235 |
|
|
|
236 |
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazarTemplate.class.php';
|
|
|
237 |
$modele = new bazarTemplate($GLOBALS['_BAZAR_']['db']);
|
|
|
238 |
$html = $modele->getTemplate(BAZ_TEMPLATE_ACCUEIL_CARTE_GOOGLE, $GLOBALS['_BAZAR_']['langue'], $GLOBALS['_BAZAR_']['categorie_nature']);
|
|
|
239 |
if (PEAR::isError($html)) return $html->getMessage();
|
|
|
240 |
|
|
|
241 |
// nettoyage url
|
|
|
242 |
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ID_FICHE) ;
|
|
|
243 |
$GLOBALS['_BAZAR_']['url']->removeQueryString(BAZ_VARIABLE_ACTION) ;
|
|
|
244 |
$html = bazar::getFormulaireFiltre($html) ;
|
|
|
245 |
|
|
|
246 |
$res = str_replace ('{CARTE}', '<div id="map" style="width: '.BAZ_GOOGLE_IMAGE_LARGEUR.
|
|
|
247 |
'px; height: '.BAZ_GOOGLE_IMAGE_HAUTEUR.'px"></div>', $html);
|
|
|
248 |
|
|
|
249 |
return $res;
|
|
|
250 |
}
|
|
|
251 |
|
|
|
252 |
|
|
|
253 |
/* +--Fin du code ----------------------------------------------------------------------------------------+
|
|
|
254 |
*
|
|
|
255 |
* $Log: not supported by cvs2svn $
|
|
|
256 |
* Revision 1.5.2.3 2008-01-29 09:41:11 alexandre_tb
|
|
|
257 |
* utilisation des constantes BAZ_GOOGLE_FOND_KML
|
|
|
258 |
*
|
|
|
259 |
* Revision 1.5.2.2 2007-12-14 09:57:15 alexandre_tb
|
|
|
260 |
* utilisation des constantes de la carte google
|
|
|
261 |
*
|
|
|
262 |
* Revision 1.5.2.1 2007-12-04 16:19:32 jp_milcent
|
|
|
263 |
* Ajout de la prise en charge de l'applette body_attributs
|
|
|
264 |
*
|
|
|
265 |
* Revision 1.5 2007-10-01 12:07:03 alexandre_tb
|
|
|
266 |
* utilisation de constantes du fichier de conf pour centrer la carte
|
|
|
267 |
*
|
|
|
268 |
* Revision 1.4 2007-08-27 12:27:34 alexandre_tb
|
|
|
269 |
* mise en place d un icone personnalise
|
|
|
270 |
* et de l affichage de plusieurs donnees sur un meme point
|
|
|
271 |
*
|
|
|
272 |
* Revision 1.3 2007-07-04 10:08:41 alexandre_tb
|
|
|
273 |
* Appel du template carte_google
|
|
|
274 |
*
|
|
|
275 |
* Revision 1.2 2007-06-13 10:02:47 alexandre_tb
|
|
|
276 |
* le carte s adapte a la taille du conteneur
|
|
|
277 |
*
|
|
|
278 |
* Revision 1.1 2007-06-04 15:26:57 alexandre_tb
|
|
|
279 |
* version initiale
|
|
|
280 |
*
|
|
|
281 |
* +-- Fin du code ----------------------------------------------------------------------------------------+
|
|
|
282 |
*/
|