Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

Rev 314 Rev 315
1
<?php
1
<?php
2
class GeneralFormateur {	
2
class GeneralFormateur implements Formateur {
3
	public $dest_map = array();
3
	public $dest_map = array();
4
	public $img = array();
4
	public $img = array();
5
	public function __construct($parametres, $info) {
5
	public function __construct($info) {
6
		$this->param = $parametres;
-
 
7
		$this->info = $info;
6
		$this->info = $info;
8
	}
7
	}
9
	public function img() {
8
	public function img() {
10
		$qualite = 90;
9
		$qualite = 90;
11
		imagejpeg($this->img['general'], Config::get('cache.stockageChemin').$this->dest_map['general'], $qualite);
10
		imagejpeg($this->img['general'], Config::get('cache.stockageChemin').$this->dest_map['general'], $qualite);
12
	}
11
	}
13
	//+----------------------------------------------------------------------------------------------------------------+
12
	//+----------------------------------------------------------------------------------------------------------------+
14
	// Méthodes d'accès aux objets du Framework
13
	// Méthodes d'accès aux objets du Framework
15
	/**
14
	/**
16
	* Méthode de connection à la base de données sur demande.
15
	* Méthode de connection à la base de données sur demande.
17
	* 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.
18
	*/
17
	*/
19
	protected function getBdd() {
18
	protected function getBdd() {
20
	if (! isset($this->Bdd)) {
19
	if (! isset($this->Bdd)) {
21
	$this->Bdd = new Bdd();
20
	$this->Bdd = new Bdd();
22
	}
21
	}
23
	return $this->Bdd;
22
	return $this->Bdd;
24
	}
23
	}
25
	
24
	
26
	public function definirCouleurs() {
25
	public function definirCouleurs() {
27
		// green
26
		// green
28
		$couleur['green'] = imagecolorallocate($this->img['general'], 0, 255, 0);
27
		$couleur['green'] = imagecolorallocate($this->img['general'], 0, 255, 0);
29
		// red
28
		// red
30
		$couleur['red'] = imagecolorallocate($this->img['general'], 255, 0, 0);
29
		$couleur['red'] = imagecolorallocate($this->img['general'], 255, 0, 0);
31
		// blue
30
		// blue
32
		$couleur['blue'] = imagecolorallocate($this->img['general'], 0, 0, 255);
31
		$couleur['blue'] = imagecolorallocate($this->img['general'], 0, 0, 255);
33
		// purple
32
		// purple
34
		$couleur['purple'] = imagecolorallocate($this->img['general'], 255, 0, 255);
33
		$couleur['purple'] = imagecolorallocate($this->img['general'], 255, 0, 255);
35
		// black
34
		// black
36
		$couleur['black'] = imagecolorallocate($this->img['general'], 0, 0, 0);
35
		$couleur['black'] = imagecolorallocate($this->img['general'], 0, 0, 0);
37
		return $couleur;
36
		return $couleur;
38
	}
37
	}
39
	
38
	
40
	public function initialiserImage() {
39
	public function initialiserImage() {
41
		// Nom du fichier image en sortie
40
		// Nom du fichier image en sortie
42
		$this->cheminCartesBase = Config::get('Cartes.chemin');
41
		$this->cheminCartesBase = Config::get('Cartes.chemin');
43
		$this->dest_map['general'] = 'nt'.$this->info['nt'].'_'.$this->info['src_map'];
42
		$this->dest_map['general'] = 'nt'.$this->info['nt'].'_'.$this->info['src_map'];
44
		$this->img['general'] = imagecreatefromjpeg($this->cheminCartesBase.$this->info['src_map']);
43
		$this->img['general'] = imagecreatefromjpeg($this->cheminCartesBase.$this->info['src_map']);
45
	}
44
	}
46
	
45
	
47
	
46
	
48
	public function chargerDonnees() {
47
	public function chargerDonnees() {
49
		// Recherche nom correspondant au numero nomenclatural en cours (pour etablir le lien avec les donnees moissonnes).
48
		// Recherche nom correspondant au numero nomenclatural en cours (pour etablir le lien avec les donnees moissonnes).
50
	
49
	
51
		// R�cuperation donn�e inventaire
50
		// R�cuperation donn�e inventaire
52
		/*
51
		/*
53
		* Les donnees issues du carnet en ligne sont recuperes directement, sans passer par le mecanisme de moissonage car :
52
		* Les donnees issues du carnet en ligne sont recuperes directement, sans passer par le mecanisme de moissonage car :
54
		*   - pour l'instant le service de moissonage n'est pas automatise et donc il y a un decalage dans l'affichage des donnees transmises
53
		*   - pour l'instant le service de moissonage n'est pas automatise et donc il y a un decalage dans l'affichage des donnees transmises
55
		*   - la table contenant les donnees moissonees ne reprend pas tous les champs necessaires a l'exploitation par eflore (notamment pas de code localite, pas d'identifiant libre)
54
		*   - la table contenant les donnees moissonees ne reprend pas tous les champs necessaires a l'exploitation par eflore (notamment pas de code localite, pas d'identifiant libre)
56
		*
55
		*
57
		* A terme, utilser vraiment le moissonage, y compris pour les donnees issues du CEL, en utilisant ABCD et en modifiant le programme d'harvesting.
56
		* A terme, utilser vraiment le moissonage, y compris pour les donnees issues du CEL, en utilisant ABCD et en modifiant le programme d'harvesting.
58
		*/
57
		*/
59
		$queryCel = "SELECT 'cel' as collection_code,  location, id_location, date_observation,  ".
58
		$queryCel = "SELECT 'cel' as collection_code,  location, id_location, date_observation,  ".
60
		"	coord_y as y_utm, coord_x as x_utm, ref_geo as sector, identifiant FROM tb_cel.cel_inventory ".
59
		"	coord_y as y_utm, coord_x as x_utm, ref_geo as sector, identifiant FROM tb_cel.cel_inventory ".
61
							"WHERE num_taxon = '".$this->info['nt']."' ".
60
							"WHERE num_taxon = '".$this->info['nt']."' ".
62
							"	AND transmission = 1";
61
							"	AND transmission = 1";
63
		$inventoriesCel = $this->getBdd()->recupererTous($queryCel);
62
		$inventoriesCel = $this->getBdd()->recupererTous($queryCel);
64
			
63
			
65
		// Recuperation des donnees de moissonage
64
		// Recuperation des donnees de moissonage
66
		// Collection code = 'flore' (Cenlr)
65
		// Collection code = 'flore' (Cenlr)
67
		$queryCenlr = "SELECT collection_code, locality as location, county as id_location, ".
66
		$queryCenlr = "SELECT collection_code, locality as location, county as id_location, ".
68
							"	STR_TO_DATE(concat(year, '/',month, '/',day), '%Y/%m/%d') as date_observation, latitude as y_utm , ". 
67
							"	STR_TO_DATE(concat(year, '/',month, '/',day), '%Y/%m/%d') as date_observation, latitude as y_utm , ". 
69
					    	"	longitude as x_utm , max_altitude as sector,  collector_name as identifiant ".
68
					    	"	longitude as x_utm , max_altitude as sector,  collector_name as identifiant ".
70
							"FROM tb_hit_indexation.raw_occurrence_record ".
69
							"FROM tb_hit_indexation.raw_occurrence_record ".
71
							"WHERE scientific_name = ".$this->getBdd()->proteger($this->info['nom']).
70
							"WHERE scientific_name = ".$this->getBdd()->proteger($this->info['nom']).
72
							"	AND collection_code = 'flore' ".
71
							"	AND collection_code = 'flore' ".
73
							"	AND (deleted IS NULL OR deleted = '0000-00-00 00:00:00')";
72
							"	AND (deleted IS NULL OR deleted = '0000-00-00 00:00:00')";
74
		$inventoriesCenlr = $this->getBdd()->recupererTous($queryCenlr);
73
		$inventoriesCenlr = $this->getBdd()->recupererTous($queryCenlr);
75
	
74
	
76
	
75
	
77
		// Collection code = 'FLORE - VAR' (Cbnmed)
76
		// Collection code = 'FLORE - VAR' (Cbnmed)
78
		/*$queryCbnmed = "SELECT collection_code, locality as location, county as id_location, ".
77
		/*$queryCbnmed = "SELECT collection_code, locality as location, county as id_location, ".
79
							"	STR_TO_DATE(concat(ifnull(year,0),'/', ifnull(month,0), '/',ifnull(day,0)), '%Y/%m/%d') as date_observation, ".
78
							"	STR_TO_DATE(concat(ifnull(year,0),'/', ifnull(month,0), '/',ifnull(day,0)), '%Y/%m/%d') as date_observation, ".
80
							"	latitude as y_utm , longitude as x_utm , max_altitude as sector, collector_name as identifiant ".
79
							"	latitude as y_utm , longitude as x_utm , max_altitude as sector, collector_name as identifiant ".
81
							"FROM tb_hit_indexation.raw_occurrence_record ".
80
							"FROM tb_hit_indexation.raw_occurrence_record ".
82
							"WHERE scientific_name = ".$this->getBdd()->proteger($this->info['nom']).
81
							"WHERE scientific_name = ".$this->getBdd()->proteger($this->info['nom']).
83
							"	AND collection_code='FLORE - VAR' ".
82
							"	AND collection_code='FLORE - VAR' ".
84
							"	AND  (deleted IS NULL OR deleted = '0000-00-00 00:00:00')";
83
							"	AND  (deleted IS NULL OR deleted = '0000-00-00 00:00:00')";
85
		$inventoriesCbnmed = $this->getBdd()->recupererTous($queryCbnmed);*/
84
		$inventoriesCbnmed = $this->getBdd()->recupererTous($queryCbnmed);*/
86
	
85
	
87
		// Collection code = 'sophy'
86
		// Collection code = 'sophy'
88
		$querySophy = "SELECT 'sophy' as collection_code, lieu_station_nom as location, lieu_commune_code_insee as id_location, ".
87
		$querySophy = "SELECT 'sophy' as collection_code, lieu_station_nom as location, lieu_commune_code_insee as id_location, ".
89
								"	observation_date as date_observation, lieu_station_utm_est as x_utm , ". 
88
								"	observation_date as date_observation, lieu_station_utm_est as x_utm , ". 
90
						    	"	lieu_station_utm_nord as y_utm , lieu_station_utm_zone as sector,  observateur_nom_complet as identifiant ".
89
						    	"	lieu_station_utm_nord as y_utm , lieu_station_utm_zone as sector,  observateur_nom_complet as identifiant ".
91
								"FROM sophy_tapir ".
90
								"FROM sophy_tapir ".
92
								"WHERE nom_scientifique_complet = ".$this->getBdd()->proteger($this->info['nom_ss_auteur']);
91
								"WHERE nom_scientifique_complet = ".$this->getBdd()->proteger($this->info['nom_ss_auteur']);
93
		$inventoriesSophy = $this->getBdd()->recupererTous($querySophy);
92
		$inventoriesSophy = $this->getBdd()->recupererTous($querySophy);
94
		
93
		
95
		return array_merge($inventoriesCel, $inventoriesCenlr, $inventoriesSophy); //$inventoriesCbnmed,
94
		return array_merge($inventoriesCel, $inventoriesCenlr, $inventoriesSophy); //$inventoriesCbnmed,
96
	}
95
	}
97
	
96
	
98
 
97
 
99
	public function dessinerPoint($text, $merge, $couleurs) {
98
	public function dessinerPoint($text, $merge, $couleurs) {
100
		$usemap['general'] = '';
99
		$usemap['general'] = '';
101
	
100
	
102
		foreach ($text as $coord => $origines ) {
101
		foreach ($text as $coord => $origines ) {
103
			foreach ($origines as $origine => $maptext ) {
102
			foreach ($origines as $origine => $maptext ) {
104
				$maptext = preg_replace("/\"/", "\'", $maptext);
103
				$maptext = preg_replace("/\"/", "\'", $maptext);
105
					
104
					
106
				list($x,$y) = explode('|', $coord);
105
				list($x,$y) = explode('|', $coord);
107
	
106
	
108
				$tpl_area = '<area shape="%s" alt="" class="tooltip" coords="%s" title="%s"/>';
107
				$tpl_area = '<area shape="%s" alt="" class="tooltip" coords="%s" title="%s"/>';
109
				$rayon = 2;
108
				$rayon = 2;
110
				$type = 'circle';
109
				$type = 'circle';
111
				$coords = "$x,$y,5";
110
				$coords = "$x,$y,5";
112
				$on_mouseover = "this.ttBgColor='#99C242';this.ttFontColor='#000000';this.T_OFFSETX=-200;this.T_OFFSETY=-50;this.T_STICKY=1;return escape('$maptext')";
111
				$on_mouseover = "this.ttBgColor='#99C242';this.ttFontColor='#000000';this.T_OFFSETX=-200;this.T_OFFSETY=-50;this.T_STICKY=1;return escape('$maptext')";
113
	
112
	
114
				if (isset($merge[$coord]) && $merge[$coord]) {
113
				if (isset($merge[$coord]) && $merge[$coord]) {
115
					imagefilledrectangle($this->img['general'], ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $couleurs['black']);
114
					imagefilledrectangle($this->img['general'], ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $couleurs['black']);
116
				} elseif (isset ($text[$coord]['cel']) && ($text[$coord]['cel'])) {
115
				} elseif (isset ($text[$coord]['cel']) && ($text[$coord]['cel'])) {
117
					imagefilledrectangle($this->img['general'], ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $couleurs['green']);
116
					imagefilledrectangle($this->img['general'], ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $couleurs['green']);
118
				} elseif (isset ($text[$coord]['flore']) && ($text[$coord]['flore'])) {
117
				} elseif (isset ($text[$coord]['flore']) && ($text[$coord]['flore'])) {
119
					imagefilledrectangle($this->img['general'], ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $couleurs['red']);
118
					imagefilledrectangle($this->img['general'], ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $couleurs['red']);
120
				}/* elseif (isset ($text[$coord]['FLORE - VAR']) && ($text[$coord]['FLORE - VAR'])) {
119
				}/* elseif (isset ($text[$coord]['FLORE - VAR']) && ($text[$coord]['FLORE - VAR'])) {
121
					imagefilledrectangle($this->img['general'], ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $couleurs['blue']);
120
					imagefilledrectangle($this->img['general'], ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $couleurs['blue']);
122
				}*/ elseif (isset ($text[$coord]['sophy']) && ($text[$coord]['sophy'])) {
121
				}*/ elseif (isset ($text[$coord]['sophy']) && ($text[$coord]['sophy'])) {
123
					imagefilledrectangle($this->img['general'], ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $couleurs['purple']);
122
					imagefilledrectangle($this->img['general'], ($x - $rayon), ($y - $rayon), ($x + $rayon), ($y + $rayon), $couleurs['purple']);
124
				}
123
				}
125
				$usemap['general'] = $usemap['general'].sprintf($tpl_area, $type, $coords, $maptext);
124
				$usemap['general'] = $usemap['general'].sprintf($tpl_area, $type, $coords, $maptext);
126
			}
125
			}
127
		}
126
		}
128
		return $usemap;
127
		return $usemap;
129
	}
128
	}
130
	
129
	
131
	public function formaterCartes($usemap) {
130
	public function formaterCartes($usemap) {
132
		$retour =  "<img src=\"".(Config::get('Cartes.cel_dst').$this->dest_map['general'])."\" style=\"border:none; cursor:crosshair\" alt=\"\" usemap=\"#themap\" /><br />\n";
-
 
133
		$retour .=  "<map name=\"themap\" id=\"themap\">";
-
 
134
		$retour .=  $usemap['general'];
-
 
135
		$retour .=  "</map>";
-
 
136
		return $retour;
-
 
137
	}
-
 
138
	
-
 
139
	public function formaterCarteMiniature($retour, $usemap) {
-
 
140
		$retour['image'] = Config::get('Cartes.cel_dst').$this->dest_map['general'];
131
		$retour = Config::get('Cartes.cel_dst').$this->dest_map['general'];
141
		$retour['map'] = $usemap['general'];
-
 
142
	
-
 
143
		if (isset($this->param['retour']) && $this->param['retour'] == 'htm') {
132
		if ($this->info['retour'] == self::MIME_MAP) {
144
			$retour['image'] =  "<img src=\"".$retour['image']."\" style=\"border:none; cursor:crosshair\""
133
			$retour =  "<img src=\"".$retour."\" style=\"border:none; ".
145
			."alt=\"\" usemap=\"#themap\"></img><br />\n";
134
				"cursor:crosshair\" alt=\"\" usemap=\"#themap\" /><br />\n".
146
			$retour['map'] = "<map name=\"themap\" id=\"themap\">".$retour['map']."</map>";
135
				"<map name=\"themap\" id=\"themap\">".utf8_encode($usemap['general'])."</map>";
147
		}
136
		}
148
		return $retour;
137
		return $retour;
149
	}
138
	}
150
	
139
	
151
	//+----------------------------------------------------------------------------------------------------------------+
140
	//+----------------------------------------------------------------------------------------------------------------+
152
	// sous fonction de calculer répartition
141
	// sous fonction de calculer répartition
153
	public function chercherVille($inventory, $tab_code_insee = array()) {
142
	public function chercherVille($inventory, $tab_code_insee = array()) {
154
		$location_protege = $this->getBdd()->proteger($inventory['location']);
143
		$location_protege = $this->getBdd()->proteger($inventory['location']);
155
		$id_location_protege = '"'.$inventory['id_location'].'"';
144
		$id_location_protege = '"'.$inventory['id_location'].'"';
156
		$utm = array();
145
		$utm = array();
157
		if ($inventory['collection_code'] == 'FLORE - VAR') {
146
		if ($inventory['collection_code'] == 'FLORE - VAR') {
158
			if (isset($tab_code_insee[$location_protege])) {
147
			if (isset($tab_code_insee[$location_protege])) {
159
				$utm = array(0 => $tab_code_insee[$location_protege]);
148
				$utm = array(0 => $tab_code_insee[$location_protege]);
160
			}
149
			}
161
		} elseif ($inventory['collection_code'] == 'sophy') {
150
		} elseif ($inventory['collection_code'] == 'sophy') {
162
			if (strpos($inventory['id_location'], '20') === 0) {
151
			if (strpos($inventory['id_location'], '20') === 0) {
163
				$a = str_replace('20', '2A', $inventory['id_location']);
152
				$a = str_replace('20', '2A', $inventory['id_location']);
164
				if (isset($tab_code_insee[$a])) {
153
				if (isset($tab_code_insee[$a])) {
165
					$utm = array(0 => $tab_code_insee[$a]);
154
					$utm = array(0 => $tab_code_insee[$a]);
166
				} else {
155
				} else {
167
					$b = str_replace('20', '2B', $inventory['id_location']);
156
					$b = str_replace('20', '2B', $inventory['id_location']);
168
					if (isset($tab_code_insee[$b])) {
157
					if (isset($tab_code_insee[$b])) {
169
						$utm = array(0 => $tab_code_insee[$b]);
158
						$utm = array(0 => $tab_code_insee[$b]);
170
					}
159
					}
171
				}
160
				}
172
			} elseif (isset($tab_code_insee[$inventory['id_location']])) {
161
			} elseif (isset($tab_code_insee[$inventory['id_location']])) {
173
				$utm = array(0 => $tab_code_insee[$inventory['id_location']]);
162
				$utm = array(0 => $tab_code_insee[$inventory['id_location']]);
174
			} elseif (strpos($inventory['id_location'], '000') === 2) {
163
			} elseif (strpos($inventory['id_location'], '000') === 2) {
175
				$code = $this->getBdd()->proteger(str_replace('000', '', $inventory['id_location']));
164
				$code = $this->getBdd()->proteger(str_replace('000', '', $inventory['id_location']));
176
				$requete = "SELECT chef_lieu ".
165
				$requete = "SELECT chef_lieu ".
177
							"FROM tb_eflore.insee_d_v2011 ".
166
							"FROM tb_eflore.insee_d_v2011 ".
178
							"WHERE dep = $code ";
167
							"WHERE dep = $code ";
179
				$resultat = $this->getBdd()->recupererTous($requete);
168
				$resultat = $this->getBdd()->recupererTous($requete);
180
				if ($resultat != array() && isset($tab_code_insee[$resultat[0]['chef_lieu']])) {
169
				if ($resultat != array() && isset($tab_code_insee[$resultat[0]['chef_lieu']])) {
181
					$utm = $tab_code_insee[$resultat[0]['chef_lieu']];
170
					$utm = $tab_code_insee[$resultat[0]['chef_lieu']];
182
				}
171
				}
183
			}
172
			}
184
		} else {
173
		} else {
185
			if ($inventory['id_location'] != 'null') {
174
			if ($inventory['id_location'] != 'null') {
186
				if (isset($tab_code_insee[$id_location_protege])) {
175
				if (isset($tab_code_insee[$id_location_protege])) {
187
					$utm = array(0 => $tab_code_insee[$id_location_protege]);
176
					$utm = array(0 => $tab_code_insee[$id_location_protege]);
188
				} else {
177
				} else {
189
					$requete = "SELECT * ".
178
					$requete = "SELECT * ".
190
										"FROM tb_cel.locations ".
179
										"FROM tb_cel.locations ".
191
										"WHERE name LIKE $location_protege ".
180
										"WHERE name LIKE $location_protege ".
192
										"	AND code = $id_location_protege ";
181
										"	AND code = $id_location_protege ";
193
					$resultat = $this->getBdd()->recupererTous($requete);
182
					$resultat = $this->getBdd()->recupererTous($requete);
194
					$utm = $resultat;
183
					$utm = $resultat;
195
				}
184
				}
196
			} else {
185
			} else {
197
				$requete = "SELECT * FROM tb_cel.locations WHERE name LIKE $location_protege ";
186
				$requete = "SELECT * FROM tb_cel.locations WHERE name LIKE $location_protege ";
198
				$utm = $this->getBdd()->recupererTous($requete);
187
				$utm = $this->getBdd()->recupererTous($requete);
199
			}
188
			}
200
		}
189
		}
201
		return $utm;
190
		return $utm;
202
	}
191
	}
203
 
192
 
204
	public function formerCommentaire($utm, $inventory) {
193
	public function formerCommentaire($utm, $inventory) {
205
		$comment = '';
194
		$comment = '';
206
			
195
			
207
		if ($inventory['date_observation'] != '0000-00-00 00:00:00') {
196
		if ($inventory['date_observation'] != '0000-00-00 00:00:00') {
208
			$comment .= $this->formerDate($inventory);
197
			$comment .= $this->formerDate($inventory);
209
		}
198
		}
210
			
199
			
211
		if ($inventory['collection_code'] == 'cel') {
200
		if ($inventory['collection_code'] == 'cel') {
212
			list($identifiant) = explode("@", $inventory['identifiant']);
201
			list($identifiant) = explode("@", $inventory['identifiant']);
213
			$comment .= " par ".$identifiant."@...";
202
			$comment .= " par ".$identifiant."@...";
214
		} else {
203
		} else {
215
			$comment .= " par ".utf8_decode($inventory['identifiant']);
204
			$comment .= " par ".utf8_decode($inventory['identifiant']);
216
		}
205
		}
217
		return $comment;
206
		return $comment;
218
	}
207
	}
219
	
208
	
220
	public function formerDate($inventory) {
209
	public function formerDate($inventory) {
221
		if ($inventory['collection_code'] == 'sophy') {
210
		if ($inventory['collection_code'] == 'sophy') {
222
			$date = ', en '.$inventory['date_observation'];
211
			$date = ', en '.$inventory['date_observation'];
223
		} else {
212
		} else {
224
			list($year, $month, $day) = explode ('-',$inventory['date_observation']);
213
			list($year, $month, $day) = explode ('-',$inventory['date_observation']);
225
			list($day) = explode (' ',$day);
214
			list($day) = explode (' ',$day);
226
			if ($month == '00') {
215
			if ($month == '00') {
227
				$date = ', en '.$year;
216
				$date = ', en '.$year;
228
			} else {
217
			} else {
229
				$date = ', le '.$day.'/'.$month.'/'.$year;
218
				$date = ', le '.$day.'/'.$month.'/'.$year;
230
			}
219
			}
231
		}
220
		}
232
		return $date;
221
		return $date;
233
	}
222
	}
234
	/*
223
	/*
235
	 * Stockage commentaire associe a un point :
224
	 * Stockage commentaire associe a un point :
236
	 * 
225
	 * 
237
	 * Param : 
226
	 * Param : 
238
	 * @text : texte cumule
227
	 * @text : texte cumule
239
	 * @merge : indicateur de commentaire fusionne
228
	 * @merge : indicateur de commentaire fusionne
240
	 * @name : commune associee
229
	 * @name : commune associee
241
	 * @comment : commentaire
230
	 * @comment : commentaire
242
	 * @origine : origine de la donnee
231
	 * @origine : origine de la donnee
243
	 * 
232
	 * 
244
	 * 
233
	 * 
245
	 * TODO : rendre cette fonction independante des valeurs d'origine passee en parametre
234
	 * TODO : rendre cette fonction independante des valeurs d'origine passee en parametre
246
	 */
235
	 */
247
	public function stockerCommentaire($text, $merge, $name, $comment, $origine, $x, $y) {
236
	public function stockerCommentaire($text, $merge, $name, $comment, $origine, $x, $y) {
248
		if ($origine == 'cel') {
237
		if ($origine == 'cel') {
249
			$prefix = 'CEL : ';
238
			$prefix = 'CEL : ';
250
		} elseif ($origine == 'flore') {
239
		} elseif ($origine == 'flore') {
251
			$prefix = 'CEN LR : ';
240
			$prefix = 'CEN LR : ';
252
		} /*elseif ($origine == 'FLORE - VAR') {
241
		} /*elseif ($origine == 'FLORE - VAR') {
253
			$prefix = 'CBN MED : ';
242
			$prefix = 'CBN MED : ';
254
		}*/ elseif ($origine == 'sophy') {
243
		}*/ elseif ($origine == 'sophy') {
255
			$prefix = 'SOPHY : ';
244
			$prefix = 'SOPHY : ';
256
		}
245
		}
257
		
246
		
258
		// Cumul toute origine :   
247
		// Cumul toute origine :   
259
		if (isset($text[$x.'|'.$y]['tout']) && ($text[$x.'|'.$y])) {
248
		if (isset($text[$x.'|'.$y]['tout']) && ($text[$x.'|'.$y])) {
260
			$text[$x.'|'.$y]['tout'] = $text[$x.'|'.$y]['tout'].'<br>'.$prefix.$name.$comment;
249
			$text[$x.'|'.$y]['tout'] = $text[$x.'|'.$y]['tout'].'<br>'.$prefix.$name.$comment;
261
		} else {
250
		} else {
262
			// Nouveau commentaire
251
			// Nouveau commentaire
263
			$text[$x.'|'.$y]['tout']=$prefix.$name.$comment;
252
			$text[$x.'|'.$y]['tout']=$prefix.$name.$comment;
264
		}
253
		}
265
		 
254
		 
266
		// Deja present  pour cette origine ? on ajoute  
255
		// Deja present  pour cette origine ? on ajoute  
267
		if (isset ($text[$x.'|'.$y][$origine]) && ($text[$x.'|'.$y][$origine])) {
256
		if (isset ($text[$x.'|'.$y][$origine]) && ($text[$x.'|'.$y][$origine])) {
268
			$text[$x.'|'.$y][$origine] = $text[$x.'|'.$y][$origine].'<br>'.$name.$comment;
257
			$text[$x.'|'.$y][$origine] = $text[$x.'|'.$y][$origine].'<br>'.$name.$comment;
269
		} else { // Nouveau commentaire
258
		} else { // Nouveau commentaire
270
			$text[$x.'|'.$y][$origine] = $name.$comment;
259
			$text[$x.'|'.$y][$origine] = $name.$comment;
271
		}
260
		}
272
		
261
		
273
		
262
		
274
		// Detection superposition de donnee 
263
		// Detection superposition de donnee 
275
		if ($origine == 'cel') {
264
		if ($origine == 'cel') {
276
			if ((isset ($text[$x.'|'.$y]['sophy']) && ($text[$x.'|'.$y]['sophy'])) || (isset ($text[$x.'|'.$y]['flore']) && ($text[$x.'|'.$y]['flore'])) 
265
			if ((isset ($text[$x.'|'.$y]['sophy']) && ($text[$x.'|'.$y]['sophy'])) || (isset ($text[$x.'|'.$y]['flore']) && ($text[$x.'|'.$y]['flore'])) 
277
			|| (isset ($text[$x.'|'.$y]['FLORE - VAR']) && ($text[$x.'|'.$y]['FLORE - VAR']))) {
266
			|| (isset ($text[$x.'|'.$y]['FLORE - VAR']) && ($text[$x.'|'.$y]['FLORE - VAR']))) {
278
				$merge[$x.'|'.$y]=true;
267
				$merge[$x.'|'.$y]=true;
279
			}
268
			}
280
		} elseif ($origine == 'flore') {
269
		} elseif ($origine == 'flore') {
281
			if ((isset ($text[$x.'|'.$y]['sophy']) && ($text[$x.'|'.$y]['sophy'])) ||(isset ($text[$x.'|'.$y]['cel']) && ($text[$x.'|'.$y]['cel'])) || 
270
			if ((isset ($text[$x.'|'.$y]['sophy']) && ($text[$x.'|'.$y]['sophy'])) ||(isset ($text[$x.'|'.$y]['cel']) && ($text[$x.'|'.$y]['cel'])) || 
282
			(isset ($text[$x.'|'.$y]['FLORE - VAR']) && ($text[$x.'|'.$y]['FLORE - VAR']))) {
271
			(isset ($text[$x.'|'.$y]['FLORE - VAR']) && ($text[$x.'|'.$y]['FLORE - VAR']))) {
283
				$merge[$x.'|'.$y]=true;
272
				$merge[$x.'|'.$y]=true;
284
			}
273
			}
285
		} elseif ($origine == 'FLORE - VAR') {
274
		} elseif ($origine == 'FLORE - VAR') {
286
			if ((isset ($text[$x.'|'.$y]['sophy']) && ($text[$x.'|'.$y]['sophy'])) || (isset ($text[$x.'|'.$y]['cel']) && ($text[$x.'|'.$y]['cel'])) || 
275
			if ((isset ($text[$x.'|'.$y]['sophy']) && ($text[$x.'|'.$y]['sophy'])) || (isset ($text[$x.'|'.$y]['cel']) && ($text[$x.'|'.$y]['cel'])) || 
287
			(isset ($text[$x.'|'.$y]['flore']) && ($text[$x.'|'.$y]['flore']))) {
276
			(isset ($text[$x.'|'.$y]['flore']) && ($text[$x.'|'.$y]['flore']))) {
288
				$merge[$x.'|'.$y]=true;
277
				$merge[$x.'|'.$y]=true;
289
			}					
278
			}					
290
		} elseif ($origine == 'sophy') {
279
		} elseif ($origine == 'sophy') {
291
			if ((isset ($text[$x.'|'.$y]['cel']) && ($text[$x.'|'.$y]['cel'])) || (isset ($text[$x.'|'.$y]['flore']) && ($text[$x.'|'.$y]['flore'])|| 
280
			if ((isset ($text[$x.'|'.$y]['cel']) && ($text[$x.'|'.$y]['cel'])) || (isset ($text[$x.'|'.$y]['flore']) && ($text[$x.'|'.$y]['flore'])|| 
292
				(isset ($text[$x.'|'.$y]['FLORE - VAR']) && ($text[$x.'|'.$y]['FLORE - VAR'])))) {
281
				(isset ($text[$x.'|'.$y]['FLORE - VAR']) && ($text[$x.'|'.$y]['FLORE - VAR'])))) {
293
				$merge[$x.'|'.$y]=true;
282
				$merge[$x.'|'.$y]=true;
294
			}					
283
			}					
295
		}
284
		}
296
		
285
		
297
		return array($text, $merge);
286
		return array($text, $merge);
298
	}
287
	}
299
}
288
}
300
?>
289
?>