Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 314 | Rev 316 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 314 Rev 315
Line 53... Line 53...
53
 
53
 
54
class Cartes {
54
class Cartes {
55
	private $tab_code_insee = array();
55
	private $tab_code_insee = array();
56
	public $src_map;
56
	public $src_map;
-
 
57
	private $cartesFormateur = null;
-
 
58
	const MIME_MAP = 'text/html';
Line 57... Line 59...
57
	private $cartesFormateur = null;
59
	const MIME_JPG = 'image/jpeg';
58
	
60
	
59
	public function consulter($ressources, $param) {
61
	public function consulter($ressources, $param) {
60
		// Initialisation des variables
62
		// Initialisation des variables
Line 75... Line 77...
75
			if ($text) {
77
			if ($text) {
76
				$usemap = $this->cartesFormateur->dessinerPoint($text, $merge, $couleurs);
78
				$usemap = $this->cartesFormateur->dessinerPoint($text, $merge, $couleurs);
77
			}
79
			}
78
			if (isset($usemap)) {
80
			if (isset($usemap)) {
79
				$this->cartesFormateur->img();
81
				$this->cartesFormateur->img();
80
				
-
 
81
				if ($this->info['miniature'] !== 'min')  {
-
 
82
					$retour = $this->cartesFormateur->formaterCartes($usemap);
82
				$retour = $this->cartesFormateur->formaterCartes($usemap);
83
				} else { // miniature
-
 
84
					$retour = $this->cartesFormateur->formaterCarteMiniature($retour, $usemap);
-
 
85
				}
-
 
86
			}
83
			}
87
		} else {
-
 
88
			$retour = $this->formaterCarteVide();
-
 
89
		}
84
		}
90
		if ($retour == '') {
85
		if ($retour == '') {
91
			$retour = $this->formaterCarteVide();
86
			$retour = $this->formaterCarteVide();
92
		}
87
		}
93
		
-
 
-
 
88
		$resultat = new ResultatService();
-
 
89
		$resultat->corps = ($this->info['retour'] == self::MIME_MAP) ? $retour : file_get_contents($retour);
-
 
90
		$resultat->mime = ($this->info['retour'] == self::MIME_MAP) ? self::MIME_MAP : self::MIME_JPG;
94
		print_r($retour);
91
		return $resultat;
95
	}
92
	}
Line 96... Line 93...
96
	
93
	
97
	public function creerFormateur(){
94
	public function creerFormateur(){
98
		$projet = ucwords($this->param['projet']);
95
		$projet = ucwords($this->info['projet']);
99
		$Classe = $projet.'Formateur';
96
		$Classe = $projet.'Formateur';
100
		$chemin = dirname(__FILE__).DS.'cartes'.DS;
97
		$chemin = dirname(__FILE__).DS.'cartes'.DS;
101
		$cheminClasse = $chemin.$Classe.'.php';
98
		$cheminClasse = $chemin.$Classe.'.php';
102
		$cheminInterface = $chemin.'Formateur.php';
99
		$cheminInterface = $chemin.'Formateur.php';
103
		if (file_exists($cheminInterface)) {
100
		if (file_exists($cheminInterface)) {
104
			include_once $cheminInterface;
101
			include_once $cheminInterface;
105
			if (file_exists($cheminClasse)) {
102
			if (file_exists($cheminClasse)) {
106
				include_once $cheminClasse;
103
				include_once $cheminClasse;
107
				$this->cartesFormateur = new $Classe($this->param, $this->info);
104
				$this->cartesFormateur = new $Classe($this->info);
108
			} else {
105
			} else {
109
				$message = "La classe '$Classe' est introuvable.";Debug::printr($message);
106
				$message = "La classe '$Classe' est introuvable.";Debug::printr($message);
110
				throw new Exception($message);
107
				throw new Exception($message);
111
			}
108
			}
112
		}
109
		}
Line 113... Line 110...
113
	}
110
	}
114
	
111
	
115
	private function traiterParametres() {
-
 
116
		$this->info['miniature'] = (isset($this->param['retour.format'])) ? $this->param['retour.format'] : false;
112
	private function traiterParametres() {
117
		if ($this->info['miniature'] == 'min') {
-
 
118
			$this->info['src_map'] = 'france_utm_miniature.jpg';
113
		$this->info['miniature'] = (isset($this->param['retour.format'])) ? $this->param['retour.format'] : false;
119
		} else {
-
 
120
			$this->info['src_map'] = 'france_utm_600x564.jpg';
114
		$this->info['src_map'] = ($this->info['miniature'] == 'min') ? 'france_utm_miniature.jpg' : 'france_utm_600x564.jpg';
121
		}
115
		$this->info['retour'] = (isset($this->param['retour'])) ? $this->param['retour'] : self::MIME_JPG ;
122
		// Ajout du code du r�f�rentiel
116
		// Ajout du code du r�f�rentiel
123
		$this->info['referentiel'] = 'bdtfx';
-
 
124
		$projets = array('cenlr', 'cel', 'cbnmed', 'sophy');
117
		$this->info['referentiel'] = 'bdtfx';
125
		if (isset($this->param['projet'])) {
118
		$projets = array('cenlr', 'cel', 'cbnmed', 'sophy');
126
			if (!in_array($this->param['projet'], $projets)) {
-
 
127
				$this->param['projet'] = 'general';
119
		if (isset($this->param['projet']) && in_array($this->param['projet'], $projets)) {
128
			}
120
			$this->info['projet'] = $this->param['projet'];
129
		} else {
121
		} else {
130
			$this->param['projet'] = 'general';
122
			$this->info['projet'] = 'general';
131
		}
123
		}
132
		// R�cup�ration d'infos g�n�rales
124
		// R�cup�ration d'infos g�n�rales
133
		// donnees exemple nn = 141; nt = 8522; nom = 'Acer campestre L.'; nom_ss_auteur = 'Acer campestre';
125
		// donnees exemple nn = 141; nt = 8522; nom = 'Acer campestre L.'; nom_ss_auteur = 'Acer campestre';
Line 196... Line 188...
196
					
188
					
197
					
189
					
198
				if ($utm['name'] != null) {
190
				if ($utm['name'] != null) {
199
					$name = utf8_decode($utm['name']);
191
					$name = utf8_decode($utm['name']);
200
				}
192
				}
201
				$comment = $this->cartesFormateur->formerCommentaire($utm, $inventory);
193
				$comment = ($this->info['retour'] == self::MIME_MAP) ? $this->cartesFormateur->formerCommentaire($utm, $inventory) : '';
202
				// On stocke les commentaires pour affichage dans les tooltips
194
				// On stocke les commentaires pour affichage dans les tooltips
203
				// Commentaire deja pr�sent ? : on ajoute � la suite
195
				// Commentaire deja pr�sent ? : on ajoute � la suite
204
				list($text, $merge) = $this->cartesFormateur->stockerCommentaire($text, $merge, $name, $comment, $inventory['collection_code'],$x,$y); 
196
				list($text, $merge) = $this->cartesFormateur->stockerCommentaire($text, $merge, $name, $comment, $inventory['collection_code'],$x,$y); 
Line 213... Line 205...
213
	private function formaterCarteVide() {
205
	private function formaterCarteVide() {
214
		$this->cheminCartesBase = Config::get('Cartes.chemin');
206
		$this->cheminCartesBase = Config::get('Cartes.chemin');
215
		$dest_map['vide'] = 'vide_'.$this->info['src_map'];
207
		$dest_map['vide'] = 'vide_'.$this->info['src_map'];
216
		$img['vide'] = imagecreatefromjpeg($this->cheminCartesBase.$this->info['src_map']);
208
		$img['vide'] = imagecreatefromjpeg($this->cheminCartesBase.$this->info['src_map']);
217
		imagejpeg($img['vide'], Config::get('cache.stockageChemin').$dest_map['vide'], 90);
209
		imagejpeg($img['vide'], Config::get('cache.stockageChemin').$dest_map['vide'], 90);
-
 
210
		$retour = Config::get('cel_dst').$dest_map['vide'];
-
 
211
		if ($this->info['retour'] == self::MIME_MAP) {
218
		$retour =  "<img src=\"".Config::get('cel_dst').$dest_map['vide']."\" style=\"border:none; cursor:crosshair\" alt=\"\" />\n";
212
			$retour =  "<img src=\"".$retour."\" style=\"border:none; cursor:crosshair\" alt=\"\" />\n";
-
 
213
		}
219
		return $retour;
214
		return $retour;
220
	}
215
	}