Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

Rev 320 Rev 362
1
<?php
1
<?php
2
class CenlrFormateur implements Formateur {
2
class CenlrFormateur implements Formateur {
3
	public $dest_map = array();
3
	public $dest_map = array();
4
	public $img = array();
4
	public $img = array();
5
	public function __construct($info) {
5
	public function __construct($info) {
6
		$this->info = $info;
6
		$this->info = $info;
7
	}
7
	}
8
	public function img() {
8
	public function img() {
9
		$qualite = 9;
9
		$qualite = 9;
10
		imagepng($this->img['cenlr'], Config::get('cache.stockageChemin').$this->dest_map['cenlr'], $qualite);
10
		imagepng($this->img['cenlr'], Config::get('cache.stockageChemin').$this->dest_map['cenlr'], $qualite);
11
	}
11
	}
12
	//+----------------------------------------------------------------------------------------------------------------+
12
	//+----------------------------------------------------------------------------------------------------------------+
13
	// Méthodes d'accès aux objets du Framework
13
	// Méthodes d'accès aux objets du Framework
14
	/**
14
	/**
15
	* Méthode de connection à la base de données sur demande.
15
	* Méthode de connection à la base de données sur demande.
16
	* Tous les services web n'ont pas besoin de s'y connecter.
16
	* Tous les services web n'ont pas besoin de s'y connecter.
17
	*/
17
	*/
18
	protected function getBdd() {
18
	protected function getBdd() {
19
	if (! isset($this->Bdd)) {
19
	if (! isset($this->Bdd)) {
20
	$this->Bdd = new Bdd();
20
	$this->Bdd = new Bdd();
21
	}
21
	}
22
	return $this->Bdd;
22
	return $this->Bdd;
23
	}
23
	}
24
	
24
	
25
	public function definirCouleurs() {
25
	public function definirCouleurs() {
26
	// green
26
	// green
27
	$couleur['green'] = imagecolorallocate($this->img['cenlr'], 0, 255, 0);
27
	$couleur['green'] = imagecolorallocate($this->img['cenlr'], 0, 255, 0);
28
	// red
28
	// red
29
	$couleur['red'] = imagecolorallocate($this->img['cenlr'], 255, 0, 0);
29
	$couleur['red'] = imagecolorallocate($this->img['cenlr'], 255, 0, 0);
30
	// blue
30
	// blue
31
	$couleur['blue'] = imagecolorallocate($this->img['cenlr'], 0, 0, 255);
31
	$couleur['blue'] = imagecolorallocate($this->img['cenlr'], 0, 0, 255);
32
	// purple
32
	// purple
33
	$couleur['purple'] = imagecolorallocate($this->img['cenlr'], 255, 0, 255);
33
	$couleur['purple'] = imagecolorallocate($this->img['cenlr'], 255, 0, 255);
34
	// black
34
	// black
35
	$couleur['black'] = imagecolorallocate($this->img['cenlr'], 0, 0, 0);
35
	$couleur['black'] = imagecolorallocate($this->img['cenlr'], 0, 0, 0);
36
	return $couleur;
36
	return $couleur;
37
	}
37
	}
38
	public function initialiserImage() {
38
	public function initialiserImage() {
39
		// Nom du fichier image en sortie
39
		// Nom du fichier image en sortie
40
		$this->cheminCartesBase = Config::get('Cartes.chemin');
40
		$this->cheminCartesBase = Config::get('Cartes.chemin');
41
		$this->dest_map['cenlr'] = 'cenlr_nt'.$this->info['nt'].'_'.$this->info['src_map'];
41
		$this->dest_map['cenlr'] = 'cenlr_nt'.$this->info['nt'].'_'.$this->info['src_map'];
42
		$this->img['cenlr'] = imagecreatefrompng($this->cheminCartesBase.$this->info['src_map']);
42
		$this->img['cenlr'] = imagecreatefrompng($this->cheminCartesBase.$this->info['src_map']);
43
	}
43
	}
-
 
44
	
-
 
45
	public function testerParametresProjets() {
-
 
46
		$test = true;
-
 
47
		if ($this->info['nom'] == '') {
-
 
48
			$test = false;
-
 
49
		}
-
 
50
		return $test;
-
 
51
	}
44
	
52
	
45
	public function chargerDonnees() {
53
	public function chargerDonnees() {
46
		// Collection code = 'flore' (Cenlr)
54
		// Collection code = 'flore' (Cenlr)
47
		$queryCenlr = "SELECT collection_code, locality as location, county as id_location, ".
55
		$queryCenlr = "SELECT collection_code, locality as location, county as id_location, ".
48
							"	STR_TO_DATE(concat(year, '/',month, '/',day), '%Y/%m/%d') as date_observation, latitude as y_utm , ". 
56
							"	STR_TO_DATE(concat(year, '/',month, '/',day), '%Y/%m/%d') as date_observation, latitude as y_utm , ". 
49
					    	"	longitude as x_utm , max_altitude as sector,  collector_name as identifiant ".
57
					    	"	longitude as x_utm , max_altitude as sector,  collector_name as identifiant ".
50
							"FROM tb_hit_indexation.raw_occurrence_record ".
58
							"FROM tb_hit_indexation.raw_occurrence_record ".
51
							"WHERE scientific_name = ".$this->getBdd()->proteger($this->info['nom']).
59
							"WHERE scientific_name = ".$this->getBdd()->proteger($this->info['nom']).
52
							"	AND collection_code = 'flore' ".
60
							"	AND collection_code = 'flore' ".
53
							"	AND (deleted IS NULL OR deleted = '0000-00-00 00:00:00')";
61
							"	AND (deleted IS NULL OR deleted = '0000-00-00 00:00:00')";
54
		$inventoriesCenlr = $this->getBdd()->recupererTous($queryCenlr);
62
		$inventoriesCenlr = $this->getBdd()->recupererTous($queryCenlr);
55
		return $inventoriesCenlr;
63
		return $inventoriesCenlr;
56
	}
64
	}
57
	
65
	
58
 
66
 
59
	public function dessinerPoint($text, $merge, $couleurs) {
67
	public function dessinerPoint($text, $merge, $couleurs) {
60
		$usemap['cenlr'] = '';
68
		$usemap['cenlr'] = '';
61
	
69
	
62
		foreach ($text as $coord => $origines ) {
70
		foreach ($text as $coord => $origines ) {
63
			foreach ($origines as $origine => $maptext ) {
71
			foreach ($origines as $origine => $maptext ) {
64
				$maptext = preg_replace("/\"/", "\'", $maptext);
72
				$maptext = preg_replace("/\"/", "\'", $maptext);
65
					
73
					
66
				list($x,$y) = explode('|', $coord);
74
				list($x,$y) = explode('|', $coord);
67
	
75
	
68
				$tpl_area = '<area shape="%s" alt="" class="tooltip" coords="%s" title="%s"/>';
76
				$tpl_area = '<area shape="%s" alt="" class="tooltip" coords="%s" title="%s"/>';
69
				$rayon = 2;
77
				$rayon = 2;
70
				$type = 'circle';
78
				$type = 'circle';
71
				$coords = "$x,$y,5";
79
				$coords = "$x,$y,5";
72
				$on_mouseover = "this.ttBgColor='#99C242';this.ttFontColor='#000000';this.T_OFFSETX=-200;this.T_OFFSETY=-50;this.T_STICKY=1;return escape('$maptext')";
80
				$on_mouseover = "this.ttBgColor='#99C242';this.ttFontColor='#000000';this.T_OFFSETX=-200;this.T_OFFSETY=-50;this.T_STICKY=1;return escape('$maptext')";
73
	
81
	
74
				imagefilledellipse($this->img['cenlr'], $x, $y, 7, 7, $couleurs['red']);
82
				imagefilledellipse($this->img['cenlr'], $x, $y, 7, 7, $couleurs['red']);
75
				$usemap['cenlr'] = $usemap['cenlr'].sprintf($tpl_area, $type, $coords, $maptext);
83
				$usemap['cenlr'] = $usemap['cenlr'].sprintf($tpl_area, $type, $coords, $maptext);
76
			}
84
			}
77
		}
85
		}
78
		return $usemap;
86
		return $usemap;
79
	}
87
	}
80
	
88
	
81
	public function formaterCartes($usemap) {
89
	public function formaterCartes($usemap) {
82
		$retour = Config::get('Cartes.cel_dst').$this->dest_map['cenlr'];
90
		$retour = Config::get('Cartes.cel_dst').$this->dest_map['cenlr'];
83
		if ($this->info['retour'] == self::MIME_MAP) {
91
		if ($this->info['retour'] == self::MIME_MAP) {
84
			$retour =  "<img src=\"".$retour."\" style=\"border:none; ".
92
			$retour =  "<img src=\"".$retour."\" style=\"border:none; ".
85
					"cursor:crosshair\" alt=\"\" usemap=\"#themap\" /><br />\n".
93
					"cursor:crosshair\" alt=\"\" usemap=\"#themap\" /><br />\n".
86
					"<map name=\"themap\" id=\"themap\">".utf8_encode($usemap['cenlr'])."</map>";
94
					"<map name=\"themap\" id=\"themap\">".utf8_encode($usemap['cenlr'])."</map>";
87
		}
95
		}
88
		return $retour;
96
		return $retour;
89
	}
97
	}
90
	
98
	
91
	//+----------------------------------------------------------------------------------------------------------------+
99
	//+----------------------------------------------------------------------------------------------------------------+
92
	// sous fonction de calculer répartition
100
	// sous fonction de calculer répartition
93
	public function chercherVille($inventory, $tab_code_insee = array()) {
101
	public function chercherVille($inventory, $tab_code_insee = array()) {
94
		return $utm = '';
102
		return $utm = '';
95
	}
103
	}
96
 
104
 
97
	public function formerCommentaire($utm, $inventory) {
105
	public function formerCommentaire($utm, $inventory) {
98
		$comment = '';
106
		$comment = '';
99
			
107
			
100
		if ($inventory['date_observation'] != '0000-00-00 00:00:00') {
108
		if ($inventory['date_observation'] != '0000-00-00 00:00:00') {
101
			$comment .= $this->formerDate($inventory);
109
			$comment .= $this->formerDate($inventory);
102
		}
110
		}
103
			
111
			
104
		$comment .= " par ".utf8_decode($inventory['identifiant']);
112
		$comment .= " par ".utf8_decode($inventory['identifiant']);
105
		return $comment;
113
		return $comment;
106
	}
114
	}
107
	
115
	
108
	public function formerDate($inventory) {
116
	public function formerDate($inventory) {
109
		list($year, $month, $day) = explode ('-',$inventory['date_observation']);
117
		list($year, $month, $day) = explode ('-',$inventory['date_observation']);
110
		list($day) = explode (' ',$day);
118
		list($day) = explode (' ',$day);
111
		if ($month == '00') {
119
		if ($month == '00') {
112
			$date = ', en '.$year;
120
			$date = ', en '.$year;
113
		} else {
121
		} else {
114
			$date = ', le '.$day.'/'.$month.'/'.$year;
122
			$date = ', le '.$day.'/'.$month.'/'.$year;
115
		}
123
		}
116
		return $date;
124
		return $date;
117
	}
125
	}
118
	
126
	
119
	public function stockerCommentaire($text, $merge, $name, $comment, $origine, $x, $y) {
127
	public function stockerCommentaire($text, $merge, $name, $comment, $origine, $x, $y) {
120
		$prefix = 'CEN LR : ';
128
		$prefix = 'CEN LR : ';
121
		
129
		
122
		// Deja present  pour cette origine ? on ajoute  
130
		// Deja present  pour cette origine ? on ajoute  
123
		if (isset ($text[$x.'|'.$y][$origine]) && ($text[$x.'|'.$y][$origine])) {
131
		if (isset ($text[$x.'|'.$y][$origine]) && ($text[$x.'|'.$y][$origine])) {
124
			$text[$x.'|'.$y][$origine] = $text[$x.'|'.$y][$origine].'<br>'.$name.$comment;
132
			$text[$x.'|'.$y][$origine] = $text[$x.'|'.$y][$origine].'<br>'.$name.$comment;
125
		} else { // Nouveau commentaire
133
		} else { // Nouveau commentaire
126
			$text[$x.'|'.$y][$origine] = $name.$comment;
134
			$text[$x.'|'.$y][$origine] = $name.$comment;
127
		}
135
		}
128
		
136
		
129
		
137
		
130
		// Detection superposition de donnee 
138
		// Detection superposition de donnee 
131
		if ((isset ($text[$x.'|'.$y]['sophy']) && ($text[$x.'|'.$y]['sophy'])) ||(isset ($text[$x.'|'.$y]['cel']) && ($text[$x.'|'.$y]['cel'])) || 
139
		if ((isset ($text[$x.'|'.$y]['sophy']) && ($text[$x.'|'.$y]['sophy'])) ||(isset ($text[$x.'|'.$y]['cel']) && ($text[$x.'|'.$y]['cel'])) || 
132
			(isset ($text[$x.'|'.$y]['FLORE - VAR']) && ($text[$x.'|'.$y]['FLORE - VAR']))) {
140
			(isset ($text[$x.'|'.$y]['FLORE - VAR']) && ($text[$x.'|'.$y]['FLORE - VAR']))) {
133
				$merge[$x.'|'.$y]=true;
141
				$merge[$x.'|'.$y]=true;
134
		}
142
		}
135
		
143
		
136
		return array($text, $merge);
144
		return array($text, $merge);
137
	}
145
	}
138
	
146
	
139
 
147
 
140
 
148
 
141
}
149
}
142
?>
150
?>