Subversion Repositories Applications.bazar

Rev

Go to most recent revision | Details | 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
// +------------------------------------------------------------------------------------------------------+
376 alexandre_ 22
// CVS : $Id: bazar.carte_google.php,v 1.5.2.4 2008-02-08 08:20:24 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
376 alexandre_ 30
*@version       $Revision: 1.5.2.4 $
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
 
283 alexandre_ 43
GEN_stockerFichierScript('googleMapScript', 'http://maps.google.com/maps?file=api&amp;v=2&amp;key='.BAZ_GOOGLE_KEY);
253 alexandre_ 44
 
283 alexandre_ 45
if (defined('PAP_VERSION')) { //si on est dans Papyrus
46
	GEN_stockerStyleExterne( 'bazar_interne', 'client/bazar/bazar.interne.css');
47
}
253 alexandre_ 48
$GLOBALS['_BAZAR_']['id_typeannonce']=$GLOBALS['_GEN_commun']['info_application']->id_nature;
363 alexandre_ 49
$GLOBALS['_BAZAR_']['categorie_nature']=$GLOBALS['_GEN_commun']['info_application']->categorie_nature;
253 alexandre_ 50
// requete sur le bazar pour recuperer les evenements
51
 
52
$requete = 'select * from bazar_fiche where ';
283 alexandre_ 53
if ($GLOBALS['_BAZAR_']['id_typeannonce'] != '') $requete .= 'bf_ce_nature in ('.$GLOBALS['_BAZAR_']['id_typeannonce'].') and ' ;
313 alexandre_ 54
$requete .= ' ((bf_date_debut_validite_fiche<=now() and bf_date_fin_validite_fiche>=now()) or (bf_date_fin_validite_fiche="0000-00-00"' .
376 alexandre_ 55
		' ))'.
283 alexandre_ 56
			' and bf_statut_fiche=1';
253 alexandre_ 57
$resultat = $GLOBALS['_BAZAR_']['db']->query ($requete);
58
 
283 alexandre_ 59
if (DB::isError($resultat)) {
313 alexandre_ 60
	return BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage().'<br />'.$resultat->getDebugInfo(), $requete);echo $requete;
283 alexandre_ 61
}
62
 
63
// Le code complique avec ces 2 tableaux sert
64
// a ne pas mettre 2 points aux memes coordonnees
65
// car dans ce cas la seul le second serait visible
66
 
67
$donnees = array();
68
 
253 alexandre_ 69
if ($resultat->numRows() != 0) {
70
	$script_marker = '';
71
	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
283 alexandre_ 72
		if ($ligne['bf_latitude'] == 0 && $ligne['bf_longitude'] == 0) continue;
73
		$cle = $ligne['bf_latitude'].'-'.$ligne['bf_longitude'];
74
		$donnees[$cle][] = $ligne;
253 alexandre_ 75
	}
283 alexandre_ 76
	foreach ($donnees as $valeur) {
77
		// cas un : une seule entree pour le point de coordonnees
78
		if (count ($valeur) == 1) {
79
			$chaine = $valeur[0];
80
			$script_marker .= "\t".'point = new GLatLng('.$chaine['bf_latitude'].','.$chaine['bf_longitude'].');'."\n"
81
				."\t".'map.addOverlay(createMarker(point, \''.'<div class="BAZ_cadre_map">'.
82
				preg_replace ('/\n/', '', str_replace ("\r\n", '',
83
					str_replace ("'", "\'", baz_voir_fiche(0, $chaine['bf_id_fiche'])))).'</div>\'));'."\n";
84
		} else { // Cas 2 plusieurs entrees
85
			$tableau_id = array();
86
			foreach ($valeur as $val) {
87
				array_push ($tableau_id, $val['bf_id_fiche']);
88
			}
89
			$script_marker .= "\t".'point = new GLatLng('.$val['bf_latitude'].','.$val['bf_longitude'].');'."\n"
90
				."\t".'map.addOverlay(createMarker(point, \''.'<div class="BAZ_cadre_map">'.
91
				preg_replace ('/\n/', '', str_replace ("\r\n", '',
92
					str_replace ("'", "\'", baz_voir_fiches(0, $tableau_id)))).'</div>\'));'."\n";
93
		}
94
	}
253 alexandre_ 95
} else {
96
	$script_marker = '';
97
}
98
 
376 alexandre_ 99
$script = '    // Variables globales
100
    var map = null;';
355 alexandre_ 101
if (BAZ_GOOGLE_MAXIMISE_TAILLE) $script .= '
255 alexandre_ 102
    // Pour gerer la taille
283 alexandre_ 103
    var winW = 630, winH = 560;
104
    var deltaH = 220;
105
    var deltaW = 270;
355 alexandre_ 106
 
255 alexandre_ 107
    function setWinHW() {
108
	if (window.innerHeight) {
109
	    winW = window.innerWidth  - deltaW;
110
	    winH = window.innerHeight - deltaH;
111
        } else {
112
	    winW = document.documentElement.offsetWidth  - 20 - deltaW;
113
	    winH = document.documentElement.offsetHeight - 20 - deltaH ;
114
        }
355 alexandre_ 115
 
255 alexandre_ 116
	var me = document.getElementById("map");
117
	if (me != null) {
118
	    me.style.width= \'\' + winW + \'px\';
119
	    me.style.height= \'\' + winH + \'px\';
120
        }
121
    }
122
 
123
    window.onresize = function () {
124
	setWinHW();
125
	if (map)  map.checkResize();
355 alexandre_ 126
    }';
127
$script .= '
255 alexandre_ 128
 
253 alexandre_ 129
    function createMarker(point, chaine) {
376 alexandre_ 130
	    var icon = new GIcon();
283 alexandre_ 131
		icon.image = "http://connaisciences.fr/sites/connaisc/fr/images/marker.png";
132
		icon.shadow = "http://www.google.com/mapfiles/shadow50.png";
133
		icon.iconSize = new GSize(20, 34);
134
		icon.shadowSize = new GSize(37, 34);
135
		icon.iconAnchor = new GPoint(6, 34);
136
		icon.infoWindowAnchor = new GPoint(5, 1);
137
	  	var marker = new GMarker(point, icon);
253 alexandre_ 138
	  	GEvent.addListener(marker, "click", function() {
139
	    	marker.openInfoWindowHtml(chaine);
140
	  	});
141
	  	return marker;
142
	}
355 alexandre_ 143
    function load() {';
144
if (BAZ_GOOGLE_MAXIMISE_TAILLE) $script .= '
145
    setWinHW();';
146
$script .= '
253 alexandre_ 147
    if (GBrowserIsCompatible()) {
148
      map = new GMap2(document.getElementById("map"));
149
      map.addControl(new GSmallMapControl());
150
	  map.addControl(new GMapTypeControl());
151
	  map.addControl(new GScaleControl());
152
	  map.enableContinuousZoom();
153
 
154
	  // On centre la carte sur le languedoc roussillon
313 alexandre_ 155
	  center = new GLatLng('.BAZ_GOOGLE_CENTRE_LAT.', '.BAZ_GOOGLE_CENTRE_LON.');
156
      map.setCenter(center, '.BAZ_GOOGLE_ALTITUDE.');
363 alexandre_ 157
	  map.setMapType(G_HYBRID_MAP);' ;
158
	  if (BAZ_GOOGLE_FOND_KML != '') {
159
	  	$script .= 'var geoXml = new GGeoXml("'.BAZ_GOOGLE_FOND_KML.'");';
160
	  }
161
 
162
      $script .= $script_marker;
163
	  if (BAZ_GOOGLE_FOND_KML != '') {
164
	  	$script .= 'map.addOverlay(geoXml);';
165
	  }
166
	  $script .= '
167
   }
376 alexandre_ 168
	};
253 alexandre_ 169
';
170
GEN_stockerCodeScript($script);
348 jp_milcent 171
// On ajoute l attribut load a la balise body
172
GEN_AttributsBody('onload', 'load()');
253 alexandre_ 173
 
174
function afficherContenuCorps() {
175
 
274 alexandre_ 176
	include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazarTemplate.class.php';
177
    $modele = new bazarTemplate($GLOBALS['_BAZAR_']['db']);
363 alexandre_ 178
    $html = $modele->getTemplate(BAZ_TEMPLATE_ACCUEIL_CARTE_GOOGLE, $GLOBALS['_BAZAR_']['langue'], $GLOBALS['_BAZAR_']['categorie_nature']);
179
    if (PEAR::isError($html)) return $html->getMessage();
355 alexandre_ 180
	$res = str_replace ('{CARTE}', '<div id="map" style="width: '.BAZ_GOOGLE_IMAGE_LARGEUR.
181
							'px; height: '.BAZ_GOOGLE_IMAGE_HAUTEUR.'px"></div>', $html);
274 alexandre_ 182
 
253 alexandre_ 183
	return $res;
184
}
185
 
186
 
187
/* +--Fin du code ----------------------------------------------------------------------------------------+
188
*
189
* $Log: not supported by cvs2svn $
376 alexandre_ 190
* Revision 1.5.2.3  2008-01-29 09:41:11  alexandre_tb
191
* utilisation des constantes BAZ_GOOGLE_FOND_KML
192
*
363 alexandre_ 193
* Revision 1.5.2.2  2007-12-14 09:57:15  alexandre_tb
194
* utilisation des constantes de la carte google
195
*
355 alexandre_ 196
* Revision 1.5.2.1  2007-12-04 16:19:32  jp_milcent
197
* Ajout de la prise en charge de l'applette body_attributs
198
*
348 jp_milcent 199
* Revision 1.5  2007-10-01 12:07:03  alexandre_tb
200
* utilisation de constantes du fichier de conf pour centrer la carte
201
*
313 alexandre_ 202
* Revision 1.4  2007-08-27 12:27:34  alexandre_tb
203
* mise en place d un icone personnalise
204
* et de l affichage de plusieurs donnees sur un meme point
205
*
283 alexandre_ 206
* Revision 1.3  2007-07-04 10:08:41  alexandre_tb
207
* Appel du template carte_google
208
*
274 alexandre_ 209
* Revision 1.2  2007-06-13 10:02:47  alexandre_tb
210
* le carte s adapte a la taille du conteneur
211
*
255 alexandre_ 212
* Revision 1.1  2007-06-04 15:26:57  alexandre_tb
213
* version initiale
214
*
253 alexandre_ 215
* +-- Fin du code ----------------------------------------------------------------------------------------+
216
*/