Subversion Repositories Applications.bazar

Rev

Rev 356 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 356 Rev 392
1
<?php
1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */ 
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */ 
3
// +------------------------------------------------------------------------------------------------------+
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 4.1                                                                                      |
4
// | PHP version 4.1                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
7
// +------------------------------------------------------------------------------------------------------+
8
// | This library is free software; you can redistribute it and/or                                        |
8
// | This library is free software; you can redistribute it and/or                                        |
9
// | modify it under the terms of the GNU Lesser General Public                                           |
9
// | modify it under the terms of the GNU Lesser General Public                                           |
10
// | License as published by the Free Software Foundation; either                                         |
10
// | License as published by the Free Software Foundation; either                                         |
11
// | version 2.1 of the License, or (at your option) any later version.                                   |
11
// | version 2.1 of the License, or (at your option) any later version.                                   |
12
// |                                                                                                      |
12
// |                                                                                                      |
13
// | This library is distributed in the hope that it will be useful,                                      |
13
// | This library is distributed in the hope that it will be useful,                                      |
14
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
14
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
15
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
15
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
16
// | Lesser General Public License for more details.                                                      |
16
// | Lesser General Public License for more details.                                                      |
17
// |                                                                                                      |
17
// |                                                                                                      |
18
// | You should have received a copy of the GNU Lesser General Public                                     |
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                                  |
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                            |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// +------------------------------------------------------------------------------------------------------+
21
// +------------------------------------------------------------------------------------------------------+
22
// CVS : $Id: bazar.carte_google.php,v 1.7 2007-12-14 09:59:15 alexandre_tb Exp $
22
// CVS : $Id: bazar.carte_google.php,v 1.8 2008-09-17 14:08:45 alexandre_tb Exp $
23
/**
23
/**
24
* 
24
* 
25
*@package bazar
25
*@package bazar
26
//Auteur original :
26
//Auteur original :
27
*@author        Alexandre GRANIER <alexandre@tela-botanica.org>
27
*@author        Alexandre GRANIER <alexandre@tela-botanica.org>
28
//Autres auteurs :
28
//Autres auteurs :
29
*@copyright     Tela-Botanica 2000-2007
29
*@copyright     Tela-Botanica 2000-2007
30
*@version       $Revision: 1.7 $
30
*@version       $Revision: 1.8 $
31
// +------------------------------------------------------------------------------------------------------+
31
// +------------------------------------------------------------------------------------------------------+
32
*/
32
*/
33
 
33
 
34
// +------------------------------------------------------------------------------------------------------+
34
// +------------------------------------------------------------------------------------------------------+
35
// |                                            ENTETE du PROGRAMME                                       |
35
// |                                            ENTETE du PROGRAMME                                       |
36
// +------------------------------------------------------------------------------------------------------+
36
// +------------------------------------------------------------------------------------------------------+
37
 
37
 
38
 
38
 
39
include_once 'configuration/baz_config.inc.php';
39
include_once 'configuration/baz_config.inc.php';
40
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazar.fonct.php';
40
include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazar.fonct.php';
41
// Inclusion d'une classe personnalise si elle existe
41
// Inclusion d'une classe personnalise si elle existe
42
 
42
 
43
GEN_stockerFichierScript('googleMapScript', 'http://maps.google.com/maps?file=api&amp;v=2&amp;key='.BAZ_GOOGLE_KEY);
43
GEN_stockerFichierScript('googleMapScript', 'http://maps.google.com/maps?file=api&amp;v=2&amp;key='.BAZ_GOOGLE_KEY);
44
 
44
 
45
if (defined('PAP_VERSION')) { //si on est dans Papyrus
45
if (defined('PAP_VERSION')) { //si on est dans Papyrus
46
	GEN_stockerStyleExterne( 'bazar_interne', 'client/bazar/bazar.interne.css');
46
	GEN_stockerStyleExterne( 'bazar_interne', 'client/bazar/bazar.interne.css');
47
}
47
}
48
$GLOBALS['_BAZAR_']['id_typeannonce']=$GLOBALS['_GEN_commun']['info_application']->id_nature;
48
$GLOBALS['_BAZAR_']['id_typeannonce']=$GLOBALS['_GEN_commun']['info_application']->id_nature;
49
 
-
 
-
 
49
$GLOBALS['_BAZAR_']['categorie_nature']=$GLOBALS['_GEN_commun']['info_application']->categorie_nature;
50
// requete sur le bazar pour recuperer les evenements
50
// requete sur le bazar pour recuperer les evenements
51
 
51
 
52
$requete = 'select * from bazar_fiche where ';
52
$requete = 'select * from bazar_fiche where ';
53
if ($GLOBALS['_BAZAR_']['id_typeannonce'] != '') $requete .= 'bf_ce_nature in ('.$GLOBALS['_BAZAR_']['id_typeannonce'].') and ' ;
53
if ($GLOBALS['_BAZAR_']['id_typeannonce'] != '') $requete .= 'bf_ce_nature in ('.$GLOBALS['_BAZAR_']['id_typeannonce'].') and ' ;
54
$requete .= ' ((bf_date_debut_validite_fiche<=now() and bf_date_fin_validite_fiche>=now()) or (bf_date_fin_validite_fiche="0000-00-00"' .
54
$requete .= ' ((bf_date_debut_validite_fiche<=now() and bf_date_fin_validite_fiche>=now()) or (bf_date_fin_validite_fiche="0000-00-00"' .
55
		' and date_add(bf_date_fin_evenement,interval 15 day)>now()))'.
55
		' and date_add(bf_date_fin_evenement,interval 15 day)>now()))'.
56
			' and bf_statut_fiche=1';
56
			' and bf_statut_fiche=1';
57
$resultat = $GLOBALS['_BAZAR_']['db']->query ($requete);
57
$resultat = $GLOBALS['_BAZAR_']['db']->query ($requete);
58
 
58
 
59
if (DB::isError($resultat)) {
59
if (DB::isError($resultat)) {
60
	return BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage().'<br />'.$resultat->getDebugInfo(), $requete);echo $requete;
60
	return BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage().'<br />'.$resultat->getDebugInfo(), $requete);echo $requete;
61
}
61
}
62
 
62
 
63
// Le code complique avec ces 2 tableaux sert
63
// Le code complique avec ces 2 tableaux sert
64
// a ne pas mettre 2 points aux memes coordonnees
64
// a ne pas mettre 2 points aux memes coordonnees
65
// car dans ce cas la seul le second serait visible
65
// car dans ce cas la seul le second serait visible
66
 
66
 
67
$donnees = array();
67
$donnees = array();
68
 
68
 
69
if ($resultat->numRows() != 0) {
69
if ($resultat->numRows() != 0) {
70
	$script_marker = '';
70
	$script_marker = '';
71
	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
71
	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
72
		if ($ligne['bf_latitude'] == 0 && $ligne['bf_longitude'] == 0) continue;
72
		if ($ligne['bf_latitude'] == 0 && $ligne['bf_longitude'] == 0) continue;
73
		$cle = $ligne['bf_latitude'].'-'.$ligne['bf_longitude'];
73
		$cle = $ligne['bf_latitude'].'-'.$ligne['bf_longitude'];
74
		$donnees[$cle][] = $ligne; 
74
		$donnees[$cle][] = $ligne; 
75
	}
75
	}
76
	foreach ($donnees as $valeur) {
76
	foreach ($donnees as $valeur) {
77
		// cas un : une seule entree pour le point de coordonnees
77
		// cas un : une seule entree pour le point de coordonnees
78
		if (count ($valeur) == 1) {
78
		if (count ($valeur) == 1) {
79
			$chaine = $valeur[0];
79
			$chaine = $valeur[0];
80
			$script_marker .= "\t".'point = new GLatLng('.$chaine['bf_latitude'].','.$chaine['bf_longitude'].');'."\n"
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">'.
81
				."\t".'map.addOverlay(createMarker(point, \''.'<div class="BAZ_cadre_map">'.
82
				preg_replace ('/\n/', '', str_replace ("\r\n", '', 
82
				preg_replace ('/\n/', '', str_replace ("\r\n", '', 
83
					str_replace ("'", "\'", baz_voir_fiche(0, $chaine['bf_id_fiche'])))).'</div>\'));'."\n";
83
					str_replace ("'", "\'", baz_voir_fiche(0, $chaine['bf_id_fiche'])))).'</div>\'));'."\n";
84
		} else { // Cas 2 plusieurs entrees
84
		} else { // Cas 2 plusieurs entrees
85
			$tableau_id = array();
85
			$tableau_id = array();
86
			foreach ($valeur as $val) {
86
			foreach ($valeur as $val) {
87
				array_push ($tableau_id, $val['bf_id_fiche']);
87
				array_push ($tableau_id, $val['bf_id_fiche']);
88
			}
88
			}
89
			$script_marker .= "\t".'point = new GLatLng('.$val['bf_latitude'].','.$val['bf_longitude'].');'."\n"
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">'.
90
				."\t".'map.addOverlay(createMarker(point, \''.'<div class="BAZ_cadre_map">'.
91
				preg_replace ('/\n/', '', str_replace ("\r\n", '', 
91
				preg_replace ('/\n/', '', str_replace ("\r\n", '', 
92
					str_replace ("'", "\'", baz_voir_fiches(0, $tableau_id)))).'</div>\'));'."\n";
92
					str_replace ("'", "\'", baz_voir_fiches(0, $tableau_id)))).'</div>\'));'."\n";
93
		}	
93
		}	
94
	}
94
	}
95
} else {
95
} else {
96
	$script_marker = '';
96
	$script_marker = '';
97
}
97
}
98
 
98
 
99
$script = '
99
$script = '
100
    // Variables globales
100
    // Variables globales
101
    var map = null;
101
    var map = null;
102
	var lat = document.getElementById("latitude");
102
	var lat = document.getElementById("latitude");
103
    var lon = document.getElementById("longitude");';
103
    var lon = document.getElementById("longitude");';
104
if (BAZ_GOOGLE_MAXIMISE_TAILLE) $script .= '
104
if (BAZ_GOOGLE_MAXIMISE_TAILLE) $script .= '
105
    // Pour gerer la taille  
105
    // Pour gerer la taille  
106
    var winW = 630, winH = 560;
106
    var winW = 630, winH = 560;
107
    var deltaH = 220;
107
    var deltaH = 220;
108
    var deltaW = 270;
108
    var deltaW = 270;
109
    
109
    
110
    function setWinHW() {
110
    function setWinHW() {
111
	if (window.innerHeight) {
111
	if (window.innerHeight) {
112
	    winW = window.innerWidth  - deltaW;
112
	    winW = window.innerWidth  - deltaW;
113
	    winH = window.innerHeight - deltaH;
113
	    winH = window.innerHeight - deltaH;
114
        } else {
114
        } else {
115
	    winW = document.documentElement.offsetWidth  - 20 - deltaW;
115
	    winW = document.documentElement.offsetWidth  - 20 - deltaW;
116
	    winH = document.documentElement.offsetHeight - 20 - deltaH ; 
116
	    winH = document.documentElement.offsetHeight - 20 - deltaH ; 
117
        }
117
        }
118
        
118
        
119
	var me = document.getElementById("map");
119
	var me = document.getElementById("map");
120
	if (me != null) {
120
	if (me != null) {
121
	    me.style.width= \'\' + winW + \'px\';
121
	    me.style.width= \'\' + winW + \'px\';
122
	    me.style.height= \'\' + winH + \'px\';
122
	    me.style.height= \'\' + winH + \'px\';
123
        }
123
        }
124
    }
124
    }
125
 
125
 
126
    window.onresize = function () {
126
    window.onresize = function () {
127
	setWinHW();
127
	setWinHW();
128
	if (map)  map.checkResize();
128
	if (map)  map.checkResize();
129
    }';
129
    }';
130
$script .= '
130
$script .= '
131
    
131
    
132
    function createMarker(point, chaine) {
132
    function createMarker(point, chaine) {
133
	  	var icon = new GIcon();
133
	  	var icon = new GIcon();
134
		icon.image = "http://connaisciences.fr/sites/connaisc/fr/images/marker.png";
134
		icon.image = "http://connaisciences.fr/sites/connaisc/fr/images/marker.png";
135
		icon.shadow = "http://www.google.com/mapfiles/shadow50.png";
135
		icon.shadow = "http://www.google.com/mapfiles/shadow50.png";
136
		icon.iconSize = new GSize(20, 34);
136
		icon.iconSize = new GSize(20, 34);
137
		icon.shadowSize = new GSize(37, 34);
137
		icon.shadowSize = new GSize(37, 34);
138
		icon.iconAnchor = new GPoint(6, 34);
138
		icon.iconAnchor = new GPoint(6, 34);
139
		icon.infoWindowAnchor = new GPoint(5, 1);
139
		icon.infoWindowAnchor = new GPoint(5, 1);
140
	  	var marker = new GMarker(point, icon);
140
	  	var marker = new GMarker(point, icon);
141
	  	GEvent.addListener(marker, "click", function() {
141
	  	GEvent.addListener(marker, "click", function() {
142
	    	marker.openInfoWindowHtml(chaine);
142
	    	marker.openInfoWindowHtml(chaine);
143
	  	});
143
	  	});
144
	  	return marker;
144
	  	return marker;
145
	}
145
	}
146
    function load() {';
146
    function load() {';
147
if (BAZ_GOOGLE_MAXIMISE_TAILLE) $script .= '
147
if (BAZ_GOOGLE_MAXIMISE_TAILLE) $script .= '
148
    setWinHW();';
148
    setWinHW();';
149
$script .= '
149
$script .= '
150
    if (GBrowserIsCompatible()) {
150
    if (GBrowserIsCompatible()) {
151
      map = new GMap2(document.getElementById("map"));
151
      map = new GMap2(document.getElementById("map"));
152
      map.addControl(new GSmallMapControl());
152
      map.addControl(new GSmallMapControl());
153
	  map.addControl(new GMapTypeControl());
153
	  map.addControl(new GMapTypeControl());
154
	  map.addControl(new GScaleControl());
154
	  map.addControl(new GScaleControl());
155
	  map.enableContinuousZoom();
155
	  map.enableContinuousZoom();
156
	
156
	
157
	  // On centre la carte sur le languedoc roussillon
157
	  // On centre la carte sur le languedoc roussillon
158
	  center = new GLatLng('.BAZ_GOOGLE_CENTRE_LAT.', '.BAZ_GOOGLE_CENTRE_LON.');
158
	  center = new GLatLng('.BAZ_GOOGLE_CENTRE_LAT.', '.BAZ_GOOGLE_CENTRE_LON.');
159
      map.setCenter(center, '.BAZ_GOOGLE_ALTITUDE.');
159
      map.setCenter(center, '.BAZ_GOOGLE_ALTITUDE.');
160
	  map.setMapType(G_HYBRID_MAP);
160
	  map.setMapType(G_HYBRID_MAP);' ;
-
 
161
	  if (BAZ_GOOGLE_FOND_KML != '') {
-
 
162
	  	$script .= 'var geoXml = new GGeoXml("'.BAZ_GOOGLE_FOND_KML.'");';
161
      ' .
163
	  }
-
 
164
      
162
      $script_marker.'
165
      $script .= $script_marker;
-
 
166
	  if (BAZ_GOOGLE_FOND_KML != '') {
-
 
167
	  	$script .= 'map.addOverlay(geoXml);';
-
 
168
	  }
-
 
169
	  $script .= '
163
    }
170
   }
164
	};
171
	};	
165
	// Creates a marker at the given point with the given number label
-
 
166
	
-
 
167
';
172
';
168
GEN_stockerCodeScript($script);
173
GEN_stockerCodeScript($script);
169
// On ajoute l attribut load a la balise body
174
// On ajoute l attribut load a la balise body
170
GEN_AttributsBody('onload', 'load()');
175
GEN_AttributsBody('onload', 'load()');
171
 
176
 
172
function afficherContenuCorps() {
177
function afficherContenuCorps() {
173
	
178
	
174
	include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazarTemplate.class.php';
179
	include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazarTemplate.class.php';
175
    $modele = new bazarTemplate($GLOBALS['_BAZAR_']['db']);
180
    $modele = new bazarTemplate($GLOBALS['_BAZAR_']['db']);
176
    $html = $modele->getTemplate(BAZ_TEMPLATE_ACCUEIL_CARTE_GOOGLE, $GLOBALS['_BAZAR_']['langue']);
181
   $html = $modele->getTemplate(BAZ_TEMPLATE_ACCUEIL_CARTE_GOOGLE, $GLOBALS['_BAZAR_']['langue'], $GLOBALS['_BAZAR_']['categorie_nature']);
-
 
182
    if (PEAR::isError($html)) return $html->getMessage();
177
	$res = str_replace ('{CARTE}', '<div id="map" style="width: '.BAZ_GOOGLE_IMAGE_LARGEUR.
183
	$res = str_replace ('{CARTE}', '<div id="map" style="width: '.BAZ_GOOGLE_IMAGE_LARGEUR.
178
							'px; height: '.BAZ_GOOGLE_IMAGE_HAUTEUR.'px"></div>', $html);
184
							'px; height: '.BAZ_GOOGLE_IMAGE_HAUTEUR.'px"></div>', $html);
179
 
185
 
180
	return $res;
186
	return $res;
181
}
187
}
182
 
188
 
183
 
189
 
184
/* +--Fin du code ----------------------------------------------------------------------------------------+
190
/* +--Fin du code ----------------------------------------------------------------------------------------+
185
*
191
*
186
* $Log: not supported by cvs2svn $
192
* $Log: not supported by cvs2svn $
-
 
193
* Revision 1.7  2007-12-14 09:59:15  alexandre_tb
-
 
194
* Fusion avec la livraison AHA : 14 decembre 2007
-
 
195
*
187
* Revision 1.6  2007-12-04 16:20:23  jp_milcent
196
* Revision 1.6  2007-12-04 16:20:23  jp_milcent
188
* Fusion avec la livraison AHA : 4 décembre 2007
197
* Fusion avec la livraison AHA : 4 décembre 2007
189
*
198
*
190
* Revision 1.5.2.1  2007-12-04 16:19:32  jp_milcent
199
* Revision 1.5.2.1  2007-12-04 16:19:32  jp_milcent
191
* Ajout de la prise en charge de l'applette body_attributs
200
* Ajout de la prise en charge de l'applette body_attributs
192
*
201
*
193
* Revision 1.5  2007-10-01 12:07:03  alexandre_tb
202
* Revision 1.5  2007-10-01 12:07:03  alexandre_tb
194
* utilisation de constantes du fichier de conf pour centrer la carte
203
* utilisation de constantes du fichier de conf pour centrer la carte
195
*
204
*
196
* Revision 1.4  2007-08-27 12:27:34  alexandre_tb
205
* Revision 1.4  2007-08-27 12:27:34  alexandre_tb
197
* mise en place d un icone personnalise
206
* mise en place d un icone personnalise
198
* et de l affichage de plusieurs donnees sur un meme point
207
* et de l affichage de plusieurs donnees sur un meme point
199
*
208
*
200
* Revision 1.3  2007-07-04 10:08:41  alexandre_tb
209
* Revision 1.3  2007-07-04 10:08:41  alexandre_tb
201
* Appel du template carte_google
210
* Appel du template carte_google
202
*
211
*
203
* Revision 1.2  2007-06-13 10:02:47  alexandre_tb
212
* Revision 1.2  2007-06-13 10:02:47  alexandre_tb
204
* le carte s adapte a la taille du conteneur
213
* le carte s adapte a la taille du conteneur
205
*
214
*
206
* Revision 1.1  2007-06-04 15:26:57  alexandre_tb
215
* Revision 1.1  2007-06-04 15:26:57  alexandre_tb
207
* version initiale
216
* version initiale
208
*
217
*
209
* +-- Fin du code ----------------------------------------------------------------------------------------+
218
* +-- Fin du code ----------------------------------------------------------------------------------------+
210
*/
219
*/