Subversion Repositories eFlore/Applications.coel-consultation

Rev

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

Rev Author Line No. Line
25 jpm 1
<?php
2
// declare(encoding='UTF-8');
3
/**
4
 * classe Controleur du module Carte.
5
 *
6
 * @package		Collection
7
 * @category	Php5
8
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
9
 * @copyright	2010 Tela-Botanica
10
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
11
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
12
 * @version		SVN: $Id$
13
 */
14
class Carte extends ColControleur {
15
 
16
	//+----------------------------------------------------------------------------------------------------------------+
17
	// Méthodes
18
	/**
19
	 * Fonction d'affichage par défaut, elle appelle la liste des administrateurs
20
	 */
21
	public function executerActionParDefaut() {
22
		return $this->cartographier();
23
	}
24
 
25
	/**
26
	 * Cartographier les collections.
27
	 * @return string la vue correspondante
28
	 */
29
	public function cartographier() {
30
		// Initialisation de variable
31
		$donnees = array();
32
 
33
		// Création de la carte
34
		$options = array(
30 jpm 35
			'carte_nom' => 'col_str_dep',
36
			'formule' => Cartographie::FORMULE_PROPORTIONNEL,
37
			'couleur_claire' => Config::get('carte_couleur_claire'),
38
			'couleur_foncee' => Config::get('carte_couleur_foncee'),
25 jpm 39
			'fond_fichier' => Config::get('carte_base_nom'),
30 jpm 40
			'fond_dossier' => Application::getChemin().Config::get('carte_fonds_chemin'),
41
			'stock_dossier' => Config::get('carte_sotckage_chemin'),
42
			'stock_url' => Config::get('carte_sotckage_url'),
43
			'debug' => Config::get('carte_mode_debug'));
25 jpm 44
		$cartographie = Composant::fabrique('cartographie', $options);
30 jpm 45
		// Construction des données nécessaires à la cartographie
46
		$zones = $cartographie->getCarteZones();
47
		$this->chargerZonesNbre($zones);
48
		$this->chargerZonesUrls($zones);
49
		$cartographie->setCarteZones($zones);
50
		//Debug::printr($zones);
51
 
25 jpm 52
		$cartographie->creerCarte();
53
		$donnees['map'] = $cartographie->getImageMap();
53 jpm 54
		$donnees['i18n'] = I18n::get('carte');
25 jpm 55
 
56
		$resultat = $this->getVue('carte', $donnees);
57
		$this->setSortie(self::RENDU_CORPS, $resultat);
58
	}
59
 
30 jpm 60
	private function chargerZonesNbre(&$zones) {
61
		$structureDao = $this->getModele('StructureDao');
62
		$zones_infos = $structureDao->getStructureParZoneGeo('FRD');
25 jpm 63
		foreach ($zones as $id => &$infos) {
64
			if (isset($zones_infos[$id])) {
65
				$nbre = $zones_infos[$id];
30 jpm 66
				$infos['info_nombre'] = $nbre;
25 jpm 67
			} else {
30 jpm 68
				$infos['info_nombre'] = 0;
25 jpm 69
			}
70
		}
71
	}
72
 
30 jpm 73
	private function chargerZonesUrls(&$zones) {
25 jpm 74
		$this->url->setVariableRequete('module', 'Recherche');
75
		$this->url->setVariableRequete('action', 'rechercher');
30 jpm 76
		$this->url->setVariableRequete('recherche', 'str-d:%s');
25 jpm 77
		$url = $this->url->getURL();
78
		foreach ($zones as $id => &$infos) {
79
			$infos['url'] = sprintf($url, $id);
80
		}
81
		$this->url->unsetVariablesRequete(array('module', 'action', 'recherche'));
82
	}
83
}
84
?>