253 |
alexandre_ |
1 |
<?php
|
416 |
jpm |
2 |
/*vim: set expandtab tabstop=4 shiftwidth=4: */
|
253 |
alexandre_ |
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 |
// +------------------------------------------------------------------------------------------------------+
|
416 |
jpm |
22 |
// CVS : $Id: bazar.carte_google.php,v 1.9 2008-10-29 15:51:36 alexandre_tb Exp $
|
253 |
alexandre_ |
23 |
/**
|
416 |
jpm |
24 |
*
|
253 |
alexandre_ |
25 |
*@package bazar
|
|
|
26 |
//Auteur original :
|
|
|
27 |
*@author Alexandre GRANIER <alexandre@tela-botanica.org>
|
|
|
28 |
//Autres auteurs :
|
|
|
29 |
*@copyright Tela-Botanica 2000-2007
|
416 |
jpm |
30 |
*@version $Revision: 1.9 $
|
253 |
alexandre_ |
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 |
|
416 |
jpm |
43 |
// Le fichier de script de google map
|
283 |
alexandre_ |
44 |
GEN_stockerFichierScript('googleMapScript', 'http://maps.google.com/maps?file=api&v=2&key='.BAZ_GOOGLE_KEY);
|
253 |
alexandre_ |
45 |
|
416 |
jpm |
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 |
|
283 |
alexandre_ |
55 |
if (defined('PAP_VERSION')) { //si on est dans Papyrus
|
416 |
jpm |
56 |
GEN_stockerStyleExterne( 'bazar_interne', 'client/bazar/bazar.interne.css');
|
283 |
alexandre_ |
57 |
}
|
253 |
alexandre_ |
58 |
$GLOBALS['_BAZAR_']['id_typeannonce']=$GLOBALS['_GEN_commun']['info_application']->id_nature;
|
363 |
alexandre_ |
59 |
$GLOBALS['_BAZAR_']['categorie_nature']=$GLOBALS['_GEN_commun']['info_application']->categorie_nature;
|
253 |
alexandre_ |
60 |
// requete sur le bazar pour recuperer les evenements
|
|
|
61 |
|
416 |
jpm |
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;
|
253 |
alexandre_ |
91 |
$resultat = $GLOBALS['_BAZAR_']['db']->query ($requete);
|
|
|
92 |
|
283 |
alexandre_ |
93 |
if (DB::isError($resultat)) {
|
313 |
alexandre_ |
94 |
return BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage().'<br />'.$resultat->getDebugInfo(), $requete);echo $requete;
|
283 |
alexandre_ |
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 |
|
253 |
alexandre_ |
103 |
if ($resultat->numRows() != 0) {
|
416 |
jpm |
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 |
}
|
253 |
alexandre_ |
145 |
} else {
|
416 |
jpm |
146 |
$script_marker = '';
|
253 |
alexandre_ |
147 |
}
|
|
|
148 |
|
376 |
alexandre_ |
149 |
$script = ' // Variables globales
|
416 |
jpm |
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) ;';
|
355 |
alexandre_ |
164 |
if (BAZ_GOOGLE_MAXIMISE_TAILLE) $script .= '
|
255 |
alexandre_ |
165 |
// Pour gerer la taille
|
283 |
alexandre_ |
166 |
var winW = 630, winH = 560;
|
|
|
167 |
var deltaH = 220;
|
|
|
168 |
var deltaW = 270;
|
355 |
alexandre_ |
169 |
|
255 |
alexandre_ |
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 |
}
|
355 |
alexandre_ |
178 |
|
255 |
alexandre_ |
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();
|
355 |
alexandre_ |
189 |
}';
|
|
|
190 |
$script .= '
|
255 |
alexandre_ |
191 |
|
416 |
jpm |
192 |
function createMarker(point, chaine, icon) {
|
|
|
193 |
|
283 |
alexandre_ |
194 |
var marker = new GMarker(point, icon);
|
253 |
alexandre_ |
195 |
GEvent.addListener(marker, "click", function() {
|
|
|
196 |
marker.openInfoWindowHtml(chaine);
|
|
|
197 |
});
|
|
|
198 |
return marker;
|
|
|
199 |
}
|
416 |
jpm |
200 |
function loadMap() {';
|
355 |
alexandre_ |
201 |
if (BAZ_GOOGLE_MAXIMISE_TAILLE) $script .= '
|
|
|
202 |
setWinHW();';
|
|
|
203 |
$script .= '
|
253 |
alexandre_ |
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
|
313 |
alexandre_ |
212 |
center = new GLatLng('.BAZ_GOOGLE_CENTRE_LAT.', '.BAZ_GOOGLE_CENTRE_LON.');
|
|
|
213 |
map.setCenter(center, '.BAZ_GOOGLE_ALTITUDE.');
|
363 |
alexandre_ |
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 |
}
|
376 |
alexandre_ |
225 |
};
|
253 |
alexandre_ |
226 |
';
|
416 |
jpm |
227 |
|
253 |
alexandre_ |
228 |
GEN_stockerCodeScript($script);
|
348 |
jp_milcent |
229 |
// On ajoute l attribut load a la balise body
|
416 |
jpm |
230 |
//GEN_AttributsBody('onload', 'load()');
|
|
|
231 |
|
253 |
alexandre_ |
232 |
|
416 |
jpm |
233 |
|
253 |
alexandre_ |
234 |
function afficherContenuCorps() {
|
|
|
235 |
|
274 |
alexandre_ |
236 |
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazarTemplate.class.php';
|
|
|
237 |
$modele = new bazarTemplate($GLOBALS['_BAZAR_']['db']);
|
363 |
alexandre_ |
238 |
$html = $modele->getTemplate(BAZ_TEMPLATE_ACCUEIL_CARTE_GOOGLE, $GLOBALS['_BAZAR_']['langue'], $GLOBALS['_BAZAR_']['categorie_nature']);
|
|
|
239 |
if (PEAR::isError($html)) return $html->getMessage();
|
355 |
alexandre_ |
240 |
$res = str_replace ('{CARTE}', '<div id="map" style="width: '.BAZ_GOOGLE_IMAGE_LARGEUR.
|
|
|
241 |
'px; height: '.BAZ_GOOGLE_IMAGE_HAUTEUR.'px"></div>', $html);
|
274 |
alexandre_ |
242 |
|
253 |
alexandre_ |
243 |
return $res;
|
|
|
244 |
}
|
|
|
245 |
|
|
|
246 |
|
|
|
247 |
/* +--Fin du code ----------------------------------------------------------------------------------------+
|
|
|
248 |
*
|
|
|
249 |
* $Log: not supported by cvs2svn $
|
376 |
alexandre_ |
250 |
* Revision 1.5.2.3 2008-01-29 09:41:11 alexandre_tb
|
|
|
251 |
* utilisation des constantes BAZ_GOOGLE_FOND_KML
|
|
|
252 |
*
|
363 |
alexandre_ |
253 |
* Revision 1.5.2.2 2007-12-14 09:57:15 alexandre_tb
|
|
|
254 |
* utilisation des constantes de la carte google
|
|
|
255 |
*
|
355 |
alexandre_ |
256 |
* Revision 1.5.2.1 2007-12-04 16:19:32 jp_milcent
|
|
|
257 |
* Ajout de la prise en charge de l'applette body_attributs
|
|
|
258 |
*
|
348 |
jp_milcent |
259 |
* Revision 1.5 2007-10-01 12:07:03 alexandre_tb
|
|
|
260 |
* utilisation de constantes du fichier de conf pour centrer la carte
|
|
|
261 |
*
|
313 |
alexandre_ |
262 |
* Revision 1.4 2007-08-27 12:27:34 alexandre_tb
|
|
|
263 |
* mise en place d un icone personnalise
|
|
|
264 |
* et de l affichage de plusieurs donnees sur un meme point
|
|
|
265 |
*
|
283 |
alexandre_ |
266 |
* Revision 1.3 2007-07-04 10:08:41 alexandre_tb
|
|
|
267 |
* Appel du template carte_google
|
|
|
268 |
*
|
274 |
alexandre_ |
269 |
* Revision 1.2 2007-06-13 10:02:47 alexandre_tb
|
|
|
270 |
* le carte s adapte a la taille du conteneur
|
|
|
271 |
*
|
255 |
alexandre_ |
272 |
* Revision 1.1 2007-06-04 15:26:57 alexandre_tb
|
|
|
273 |
* version initiale
|
|
|
274 |
*
|
253 |
alexandre_ |
275 |
* +-- Fin du code ----------------------------------------------------------------------------------------+
|
|
|
276 |
*/
|