Subversion Repositories Applications.bazar

Rev

Rev 283 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 283 Rev 313
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.4 2007-08-27 12:27:34 alexandre_tb Exp $
22
// CVS : $Id: bazar.carte_google.php,v 1.5 2007-10-01 12:07:03 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.4 $
30
*@version       $Revision: 1.5 $
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
 
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 bf_statut_fiche=1';
56
			' and bf_statut_fiche=1';
56
$resultat = $GLOBALS['_BAZAR_']['db']->query ($requete);
57
$resultat = $GLOBALS['_BAZAR_']['db']->query ($requete);
57
 
58
 
58
if (DB::isError($resultat)) {
59
if (DB::isError($resultat)) {
59
	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;
60
}
61
}
61
 
62
 
62
// Le code complique avec ces 2 tableaux sert
63
// Le code complique avec ces 2 tableaux sert
63
// a ne pas mettre 2 points aux memes coordonnees
64
// a ne pas mettre 2 points aux memes coordonnees
64
// car dans ce cas la seul le second serait visible
65
// car dans ce cas la seul le second serait visible
65
 
66
 
66
$donnees = array();
67
$donnees = array();
67
 
68
 
68
if ($resultat->numRows() != 0) {
69
if ($resultat->numRows() != 0) {
69
	$script_marker = '';
70
	$script_marker = '';
70
	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
71
	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
71
		if ($ligne['bf_latitude'] == 0 && $ligne['bf_longitude'] == 0) continue;
72
		if ($ligne['bf_latitude'] == 0 && $ligne['bf_longitude'] == 0) continue;
72
		$cle = $ligne['bf_latitude'].'-'.$ligne['bf_longitude'];
73
		$cle = $ligne['bf_latitude'].'-'.$ligne['bf_longitude'];
73
		$donnees[$cle][] = $ligne; 
74
		$donnees[$cle][] = $ligne; 
74
	}
75
	}
75
	foreach ($donnees as $valeur) {
76
	foreach ($donnees as $valeur) {
76
		// cas un : une seule entree pour le point de coordonnees
77
		// cas un : une seule entree pour le point de coordonnees
77
		if (count ($valeur) == 1) {
78
		if (count ($valeur) == 1) {
78
			$chaine = $valeur[0];
79
			$chaine = $valeur[0];
79
			$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"
80
				."\t".'map.addOverlay(createMarker(point, \''.'<div class="BAZ_cadre_map">'.
81
				."\t".'map.addOverlay(createMarker(point, \''.'<div class="BAZ_cadre_map">'.
81
				preg_replace ('/\n/', '', str_replace ("\r\n", '', 
82
				preg_replace ('/\n/', '', str_replace ("\r\n", '', 
82
					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";
83
		} else { // Cas 2 plusieurs entrees
84
		} else { // Cas 2 plusieurs entrees
84
			$tableau_id = array();
85
			$tableau_id = array();
85
			foreach ($valeur as $val) {
86
			foreach ($valeur as $val) {
86
				array_push ($tableau_id, $val['bf_id_fiche']);
87
				array_push ($tableau_id, $val['bf_id_fiche']);
87
			}
88
			}
88
			$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"
89
				."\t".'map.addOverlay(createMarker(point, \''.'<div class="BAZ_cadre_map">'.
90
				."\t".'map.addOverlay(createMarker(point, \''.'<div class="BAZ_cadre_map">'.
90
				preg_replace ('/\n/', '', str_replace ("\r\n", '', 
91
				preg_replace ('/\n/', '', str_replace ("\r\n", '', 
91
					str_replace ("'", "\'", baz_voir_fiches(0, $tableau_id)))).'</div>\'));'."\n";
92
					str_replace ("'", "\'", baz_voir_fiches(0, $tableau_id)))).'</div>\'));'."\n";
92
		}	
93
		}	
93
	}
94
	}
94
} else {
95
} else {
95
	$script_marker = '';
96
	$script_marker = '';
96
}
97
}
97
 
98
 
98
$script = '
99
$script = '
99
    // Variables globales
100
    // Variables globales
100
    var map = null;
101
    var map = null;
101
	var lat = document.getElementById("latitude");
102
	var lat = document.getElementById("latitude");
102
    var lon = document.getElementById("longitude");
103
    var lon = document.getElementById("longitude");
103
    // Pour gerer la taille  
104
    // Pour gerer la taille  
104
    var winW = 630, winH = 560;
105
    var winW = 630, winH = 560;
105
    var deltaH = 220;
106
    var deltaH = 220;
106
    var deltaW = 270;
107
    var deltaW = 270;
107
    
108
    
108
    function setWinHW() {
109
    function setWinHW() {
109
	if (window.innerHeight) {
110
	if (window.innerHeight) {
110
	    winW = window.innerWidth  - deltaW;
111
	    winW = window.innerWidth  - deltaW;
111
	    winH = window.innerHeight - deltaH;
112
	    winH = window.innerHeight - deltaH;
112
        } else {
113
        } else {
113
	    winW = document.documentElement.offsetWidth  - 20 - deltaW;
114
	    winW = document.documentElement.offsetWidth  - 20 - deltaW;
114
	    winH = document.documentElement.offsetHeight - 20 - deltaH ; 
115
	    winH = document.documentElement.offsetHeight - 20 - deltaH ; 
115
        }
116
        }
116
        
117
        
117
	var me = document.getElementById("map");
118
	var me = document.getElementById("map");
118
	if (me != null) {
119
	if (me != null) {
119
	    me.style.width= \'\' + winW + \'px\';
120
	    me.style.width= \'\' + winW + \'px\';
120
	    me.style.height= \'\' + winH + \'px\';
121
	    me.style.height= \'\' + winH + \'px\';
121
        }
122
        }
122
    }
123
    }
123
 
124
 
124
    window.onresize = function () {
125
    window.onresize = function () {
125
	setWinHW();
126
	setWinHW();
126
	if (map)  map.checkResize();
127
	if (map)  map.checkResize();
127
    }
128
    }
128
    
129
    
129
    function createMarker(point, chaine) {
130
    function createMarker(point, chaine) {
130
	  	var icon = new GIcon();
131
	  	var icon = new GIcon();
131
		icon.image = "http://connaisciences.fr/sites/connaisc/fr/images/marker.png";
132
		icon.image = "http://connaisciences.fr/sites/connaisc/fr/images/marker.png";
132
		icon.shadow = "http://www.google.com/mapfiles/shadow50.png";
133
		icon.shadow = "http://www.google.com/mapfiles/shadow50.png";
133
		icon.iconSize = new GSize(20, 34);
134
		icon.iconSize = new GSize(20, 34);
134
		icon.shadowSize = new GSize(37, 34);
135
		icon.shadowSize = new GSize(37, 34);
135
		icon.iconAnchor = new GPoint(6, 34);
136
		icon.iconAnchor = new GPoint(6, 34);
136
		icon.infoWindowAnchor = new GPoint(5, 1);
137
		icon.infoWindowAnchor = new GPoint(5, 1);
137
	  	var marker = new GMarker(point, icon);
138
	  	var marker = new GMarker(point, icon);
138
	  	GEvent.addListener(marker, "click", function() {
139
	  	GEvent.addListener(marker, "click", function() {
139
	    	marker.openInfoWindowHtml(chaine);
140
	    	marker.openInfoWindowHtml(chaine);
140
	  	});
141
	  	});
141
	  	return marker;
142
	  	return marker;
142
	}
143
	}
143
    function load() {
144
    function load() {
144
    setWinHW();
145
    setWinHW();
145
    if (GBrowserIsCompatible()) {
146
    if (GBrowserIsCompatible()) {
146
      map = new GMap2(document.getElementById("map"));
147
      map = new GMap2(document.getElementById("map"));
147
      map.addControl(new GSmallMapControl());
148
      map.addControl(new GSmallMapControl());
148
	  map.addControl(new GMapTypeControl());
149
	  map.addControl(new GMapTypeControl());
149
	  map.addControl(new GScaleControl());
150
	  map.addControl(new GScaleControl());
150
	  map.enableContinuousZoom();
151
	  map.enableContinuousZoom();
151
	
152
	
152
	  // On centre la carte sur le languedoc roussillon
153
	  // On centre la carte sur le languedoc roussillon
153
	  center = new GLatLng(43.84245116699036, 3.768310546875);
154
	  center = new GLatLng('.BAZ_GOOGLE_CENTRE_LAT.', '.BAZ_GOOGLE_CENTRE_LON.');
154
      map.setCenter(center, 7);
155
      map.setCenter(center, '.BAZ_GOOGLE_ALTITUDE.');
155
	  map.setMapType(G_HYBRID_MAP);
156
	  map.setMapType(G_HYBRID_MAP);
156
      ' .
157
      ' .
157
      $script_marker.'
158
      $script_marker.'
158
    }
159
    }
159
	};
160
	};
160
	// Creates a marker at the given point with the given number label
161
	// Creates a marker at the given point with the given number label
161
	
162
	
162
';
163
';
163
GEN_stockerCodeScript($script);
164
GEN_stockerCodeScript($script);
164
 
165
 
165
function afficherContenuCorps() {
166
function afficherContenuCorps() {
166
	
167
	
167
	include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazarTemplate.class.php';
168
	include_once BAZ_CHEMIN_APPLI.'bibliotheque/bazarTemplate.class.php';
168
    $modele = new bazarTemplate($GLOBALS['_BAZAR_']['db']);
169
    $modele = new bazarTemplate($GLOBALS['_BAZAR_']['db']);
169
    $html = $modele->getTemplate(BAZ_TEMPLATE_ACCUEIL_CARTE_GOOGLE, $GLOBALS['_BAZAR_']['langue']);
170
    $html = $modele->getTemplate(BAZ_TEMPLATE_ACCUEIL_CARTE_GOOGLE, $GLOBALS['_BAZAR_']['langue']);
170
	$res = str_replace ('{CARTE}', '<div id="map" style="width: 600px; height: 450px"></div>', $html);
171
	$res = str_replace ('{CARTE}', '<div id="map" style="width: 600px; height: 450px"></div>', $html);
171
 
172
 
172
	return $res;
173
	return $res;
173
}
174
}
174
 
175
 
175
 
176
 
176
/* +--Fin du code ----------------------------------------------------------------------------------------+
177
/* +--Fin du code ----------------------------------------------------------------------------------------+
177
*
178
*
178
* $Log: not supported by cvs2svn $
179
* $Log: not supported by cvs2svn $
-
 
180
* Revision 1.4  2007-08-27 12:27:34  alexandre_tb
-
 
181
* mise en place d un icone personnalise
-
 
182
* et de l affichage de plusieurs donnees sur un meme point
-
 
183
*
179
* Revision 1.3  2007-07-04 10:08:41  alexandre_tb
184
* Revision 1.3  2007-07-04 10:08:41  alexandre_tb
180
* Appel du template carte_google
185
* Appel du template carte_google
181
*
186
*
182
* Revision 1.2  2007-06-13 10:02:47  alexandre_tb
187
* Revision 1.2  2007-06-13 10:02:47  alexandre_tb
183
* le carte s adapte a la taille du conteneur
188
* le carte s adapte a la taille du conteneur
184
*
189
*
185
* Revision 1.1  2007-06-04 15:26:57  alexandre_tb
190
* Revision 1.1  2007-06-04 15:26:57  alexandre_tb
186
* version initiale
191
* version initiale
187
*
192
*
188
* +-- Fin du code ----------------------------------------------------------------------------------------+
193
* +-- Fin du code ----------------------------------------------------------------------------------------+
189
*/
194
*/