Subversion Repositories Applications.bazar

Rev

Rev 392 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
253 alexandre_ 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
// +------------------------------------------------------------------------------------------------------+
406 alexandre_ 22
// CVS : $Id: bazar.carte_google.php,v 1.9 2008-10-29 15:51:36 alexandre_tb Exp $
253 alexandre_ 23
/**
24
*
25
*@package bazar
26
//Auteur original :
27
*@author        Alexandre GRANIER <alexandre@tela-botanica.org>
28
//Autres auteurs :
29
*@copyright     Tela-Botanica 2000-2007
406 alexandre_ 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
 
406 alexandre_ 43
// Le fichier de script de google map
283 alexandre_ 44
GEN_stockerFichierScript('googleMapScript', 'http://maps.google.com/maps?file=api&amp;v=2&amp;key='.BAZ_GOOGLE_KEY);
253 alexandre_ 45
 
406 alexandre_ 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
56
	GEN_stockerStyleExterne( 'bazar_interne', 'client/bazar/bazar.interne.css');
57
}
253 alexandre_ 58
$GLOBALS['_BAZAR_']['id_typeannonce']=$GLOBALS['_GEN_commun']['info_application']->id_nature;
392 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
 
406 alexandre_ 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
$requete = 'SELECT blv_label,blv_valeur, bazar_fiche.*'.
86
 ' FROM bazar_fiche, bazar_fiche_valeur_liste , bazar_liste_valeurs'.
87
 ' WHERE   bf_statut_fiche =1 and bf_id_fiche=bfvl_ce_fiche'.
88
 ' and  bfvl_ce_liste=blv_ce_liste and bfvl_ce_liste=31 and bfvl_valeur=blv_valeur '.$requete_where.' and '.
89
 $requete_date;
253 alexandre_ 90
$resultat = $GLOBALS['_BAZAR_']['db']->query ($requete);
406 alexandre_ 91
//trigger_error($requete);
283 alexandre_ 92
if (DB::isError($resultat)) {
406 alexandre_ 93
	return BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage().'<br />'.$resultat->getDebugInfo(), $requete);
283 alexandre_ 94
}
95
 
96
// Le code complique avec ces 2 tableaux sert
97
// a ne pas mettre 2 points aux memes coordonnees
98
// car dans ce cas la seul le second serait visible
99
 
100
$donnees = array();
101
 
253 alexandre_ 102
if ($resultat->numRows() != 0) {
103
	$script_marker = '';
406 alexandre_ 104
	$couleur_drapeau = array ( 1 => 'bleu', 2 => 'vert', 3 => 'orange', 4 => 'rose');
253 alexandre_ 105
	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
283 alexandre_ 106
		if ($ligne['bf_latitude'] == 0 && $ligne['bf_longitude'] == 0) continue;
107
		$cle = $ligne['bf_latitude'].'-'.$ligne['bf_longitude'];
108
		$donnees[$cle][] = $ligne;
253 alexandre_ 109
	}
283 alexandre_ 110
	foreach ($donnees as $valeur) {
111
		// cas un : une seule entree pour le point de coordonnees
112
		if (count ($valeur) == 1) {
113
			$chaine = $valeur[0];
406 alexandre_ 114
 
115
			$script_marker .= 'var icon = new GIcon(G_DEFAULT_ICON);
116
		icon.image = "client/bazar/images/drapeau_'.$couleur_drapeau[$chaine['blv_valeur']].'.png";'."\n".'
117
		icon.shadow = "http://www.google.com/mapfiles/shadow50.png";
118
		icon.iconSize = new GSize(16, 16);
119
		icon.shadowSize = new GSize(16, 16);
120
		icon.iconAnchor = new GPoint(6, 16);
121
		icon.infoWindowAnchor = new GPoint(5, 1);'."\n";
283 alexandre_ 122
			$script_marker .= "\t".'point = new GLatLng('.$chaine['bf_latitude'].','.$chaine['bf_longitude'].');'."\n"
123
				."\t".'map.addOverlay(createMarker(point, \''.'<div class="BAZ_cadre_map">'.
124
				preg_replace ('/\n/', '', str_replace ("\r\n", '',
406 alexandre_ 125
					str_replace ("'", "\'", baz_voir_fiche(0, $chaine['bf_id_fiche'])))).'</div>\',icon));'."\n";
283 alexandre_ 126
		} else { // Cas 2 plusieurs entrees
127
			$tableau_id = array();
128
			foreach ($valeur as $val) {
129
				array_push ($tableau_id, $val['bf_id_fiche']);
130
			}
406 alexandre_ 131
			$script_marker .= 'var icon = new GIcon();
132
		icon.image = "http://www.tela-botanica.org/client/bazar/images/drapeau_'.$couleur_drapeau[$chaine['blv_valeur']].'.png";
133
		icon.shadow = "http://www.google.com/mapfiles/shadow50.png";
134
		icon.iconSize = new GSize(16, 16);
135
		icon.shadowSize = new GSize(37, 34);
136
		icon.iconAnchor = new GPoint(6, 34);
137
		icon.infoWindowAnchor = new GPoint(5, 1);';
283 alexandre_ 138
			$script_marker .= "\t".'point = new GLatLng('.$val['bf_latitude'].','.$val['bf_longitude'].');'."\n"
139
				."\t".'map.addOverlay(createMarker(point, \''.'<div class="BAZ_cadre_map">'.
140
				preg_replace ('/\n/', '', str_replace ("\r\n", '',
406 alexandre_ 141
					str_replace ("'", "\'", baz_voir_fiches(0, $tableau_id)))).'</div>\', icon));'."\n";
283 alexandre_ 142
		}
143
	}
253 alexandre_ 144
} else {
145
	$script_marker = '';
146
}
147
 
148
$script = '
149
    // Variables globales
150
    var map = null;
151
	var lat = document.getElementById("latitude");
356 alexandre_ 152
    var lon = document.getElementById("longitude");';
153
if (BAZ_GOOGLE_MAXIMISE_TAILLE) $script .= '
255 alexandre_ 154
    // Pour gerer la taille
283 alexandre_ 155
    var winW = 630, winH = 560;
156
    var deltaH = 220;
157
    var deltaW = 270;
253 alexandre_ 158
 
255 alexandre_ 159
    function setWinHW() {
160
	if (window.innerHeight) {
161
	    winW = window.innerWidth  - deltaW;
162
	    winH = window.innerHeight - deltaH;
163
        } else {
164
	    winW = document.documentElement.offsetWidth  - 20 - deltaW;
165
	    winH = document.documentElement.offsetHeight - 20 - deltaH ;
166
        }
167
 
168
	var me = document.getElementById("map");
169
	if (me != null) {
170
	    me.style.width= \'\' + winW + \'px\';
171
	    me.style.height= \'\' + winH + \'px\';
172
        }
173
    }
174
 
175
    window.onresize = function () {
176
	setWinHW();
177
	if (map)  map.checkResize();
356 alexandre_ 178
    }';
179
$script .= '
255 alexandre_ 180
 
406 alexandre_ 181
    function createMarker(point, chaine,icon) {
182
 
283 alexandre_ 183
	  	var marker = new GMarker(point, icon);
253 alexandre_ 184
	  	GEvent.addListener(marker, "click", function() {
185
	    	marker.openInfoWindowHtml(chaine);
186
	  	});
187
	  	return marker;
188
	}
356 alexandre_ 189
    function load() {';
190
if (BAZ_GOOGLE_MAXIMISE_TAILLE) $script .= '
191
    setWinHW();';
192
$script .= '
253 alexandre_ 193
    if (GBrowserIsCompatible()) {
194
      map = new GMap2(document.getElementById("map"));
195
      map.addControl(new GSmallMapControl());
196
	  map.addControl(new GMapTypeControl());
197
	  map.addControl(new GScaleControl());
198
	  map.enableContinuousZoom();
199
 
200
	  // On centre la carte sur le languedoc roussillon
313 alexandre_ 201
	  center = new GLatLng('.BAZ_GOOGLE_CENTRE_LAT.', '.BAZ_GOOGLE_CENTRE_LON.');
202
      map.setCenter(center, '.BAZ_GOOGLE_ALTITUDE.');
392 alexandre_ 203
	  map.setMapType(G_HYBRID_MAP);' ;
204
	  if (BAZ_GOOGLE_FOND_KML != '') {
205
	  	$script .= 'var geoXml = new GGeoXml("'.BAZ_GOOGLE_FOND_KML.'");';
206
	  }
207
 
208
      $script .= $script_marker;
209
	  if (BAZ_GOOGLE_FOND_KML != '') {
210
	  	$script .= 'map.addOverlay(geoXml);';
211
	  }
212
	  $script .= '
213
   }
214
	};
253 alexandre_ 215
';
216
GEN_stockerCodeScript($script);
349 jp_milcent 217
// On ajoute l attribut load a la balise body
218
GEN_AttributsBody('onload', 'load()');
253 alexandre_ 219
 
220
function afficherContenuCorps() {
221
 
274 alexandre_ 222
	include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazarTemplate.class.php';
223
    $modele = new bazarTemplate($GLOBALS['_BAZAR_']['db']);
406 alexandre_ 224
    $html = $modele->getTemplate(BAZ_TEMPLATE_ACCUEIL_CARTE_GOOGLE, $GLOBALS['_BAZAR_']['langue'], $GLOBALS['_BAZAR_']['categorie_nature']);
392 alexandre_ 225
    if (PEAR::isError($html)) return $html->getMessage();
406 alexandre_ 226
 
227
    // Nettoyage url
228
    $GLOBALS['_BAZAR_'] ['url']->removeQueryString(BAZ_VARIABLE_ID_FICHE);
229
    $GLOBALS['_BAZAR_'] ['url']->removeQueryString(BAZ_VARIABLE_ACTION);
230
    $html = bazar::getFormulaireFiltre($html);
231
 
356 alexandre_ 232
	$res = str_replace ('{CARTE}', '<div id="map" style="width: '.BAZ_GOOGLE_IMAGE_LARGEUR.
233
							'px; height: '.BAZ_GOOGLE_IMAGE_HAUTEUR.'px"></div>', $html);
274 alexandre_ 234
 
253 alexandre_ 235
	return $res;
236
}
237
 
238
 
239
/* +--Fin du code ----------------------------------------------------------------------------------------+
240
*
241
* $Log: not supported by cvs2svn $
406 alexandre_ 242
* Revision 1.8  2008-09-17 14:08:45  alexandre_tb
243
* merge depuis aha
244
*
392 alexandre_ 245
* Revision 1.7  2007-12-14 09:59:15  alexandre_tb
246
* Fusion avec la livraison AHA : 14 decembre 2007
247
*
356 alexandre_ 248
* Revision 1.6  2007-12-04 16:20:23  jp_milcent
249
* Fusion avec la livraison AHA : 4 décembre 2007
250
*
349 jp_milcent 251
* Revision 1.5.2.1  2007-12-04 16:19:32  jp_milcent
252
* Ajout de la prise en charge de l'applette body_attributs
253
*
254
* Revision 1.5  2007-10-01 12:07:03  alexandre_tb
255
* utilisation de constantes du fichier de conf pour centrer la carte
256
*
313 alexandre_ 257
* Revision 1.4  2007-08-27 12:27:34  alexandre_tb
258
* mise en place d un icone personnalise
259
* et de l affichage de plusieurs donnees sur un meme point
260
*
283 alexandre_ 261
* Revision 1.3  2007-07-04 10:08:41  alexandre_tb
262
* Appel du template carte_google
263
*
274 alexandre_ 264
* Revision 1.2  2007-06-13 10:02:47  alexandre_tb
265
* le carte s adapte a la taille du conteneur
266
*
255 alexandre_ 267
* Revision 1.1  2007-06-04 15:26:57  alexandre_tb
268
* version initiale
269
*
253 alexandre_ 270
* +-- Fin du code ----------------------------------------------------------------------------------------+
271
*/