Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

Rev 449 Rev 458
1
<?php
1
<?php
2
 
2
 
3
/**
3
/**
4
* Classe CommunGraphiques.php regroupement de fonctions pour les graphiques
4
* Classe CommunGraphiques.php regroupement de fonctions pour les graphiques
5
*  graphiques/#typegraphique/#bdnt.nn:#num_nomen --> renvoie un graphique avec les données connues
5
*  graphiques/#typegraphique/#bdnt.nn:#num_nomen --> renvoie un graphique avec les données connues
6
*   
6
*   
7
*
7
*
8
* @package eflore-projets
8
* @package eflore-projets
9
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
9
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
10
* @author Mathilde SALTHUN-LASSALLE <mathilde@tela-botanica.org>
10
* @author Mathilde SALTHUN-LASSALLE <mathilde@tela-botanica.org>
11
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
11
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
12
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
12
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
13
* @version 1.0
13
* @version 1.0
14
* @copyright 1999-2011 Tela Botanica (accueil@tela-botanica.org)
14
* @copyright 1999-2011 Tela Botanica (accueil@tela-botanica.org)
15
*/
15
*/
16
 
16
 
17
abstract class CommunGraphiques extends Commun{
17
abstract class CommunGraphiques extends Commun{
18
	
18
	
19
	protected $parametres = array();
19
	protected $parametres = array();
20
	protected $ressources = array();
20
	protected $ressources = array();
21
	
21
	
22
	protected $Bdd;
22
	protected $Bdd;
23
	protected $config;
23
	protected $config;
24
	protected $cache;
24
	protected $cache;
25
	protected $metadonnees;
25
	protected $metadonnees;
26
	protected $version;
26
	protected $version;
27
	protected $serviceNom = 'Graphiques';
27
	protected $serviceNom = 'Graphiques';
28
	
28
	
29
	protected $graduations_id = array();
29
	protected $graduations_id = array();
30
	protected  $champs_ontologiques =  array();
30
	protected  $champs_ontologiques =  array();
31
	protected $nomGraphique = array();
31
	protected $nomGraphique = array();
32
	
32
	
33
	protected $table = '';
33
	protected $table = '';
34
	protected $requete_condition = "";
34
	protected $requete_condition = "";
35
	protected $requete_champs;
35
	protected $requete_champs;
36
	
36
	
37
	protected $convertisseur;
37
	protected $convertisseur;
38
	protected $cheminGraphBase;
38
	protected $cheminGraphBase;
39
	protected $valeurs_en_pourcentage = array();
39
	protected $valeurs_en_pourcentage = array();
40
	protected $dom;
40
	protected $dom;
41
	protected $largeurSVG = "500";
41
	protected $largeurSVG = "500";
42
	protected $valeurs_champs;
42
	protected $valeurs_champs;
43
	
43
	
44
	
44
	
45
	public function consulter($ressources, $parametres) {
45
	public function consulter($ressources, $parametres) {
46
		$this->ressources = $ressources;
46
		$this->ressources = $ressources;
47
		$this->parametres = $parametres;
47
		$this->parametres = $parametres;
48
		$this->initialiserConfiguration();
48
		$this->initialiserConfiguration();
49
		$resultats = '';
49
		$resultats = '';
50
		$this->traiterRessources();
50
		$this->traiterRessources();
51
		$requete = $this->assemblerLaRequete();
51
		$requete = $this->assemblerLaRequete();
52
		$resultat = $this->resultat = $this->Bdd->recupererTous($requete);
52
		$resultat = $this->resultat = $this->Bdd->recupererTous($requete);
53
		$versionResultat = $this->obtenirResultat($resultat);
53
		$versionResultat = $this->obtenirResultat($resultat);
54
		return $versionResultat;
54
		return $versionResultat;
55
	}
55
	}
56
	
56
	
57
 
57
 
58
	//+--------------------------initialisation de paramètres  -------------------------------------------+
58
	//+--------------------------initialisation de paramètres  -------------------------------------------+
59
	
59
	
60
	private function initialiserConfiguration() {
60
	private function initialiserConfiguration() {
61
		$conteneur = new Conteneur();
61
		$conteneur = new Conteneur();
62
		$this->Bdd = $conteneur->getBdd();
62
		$this->Bdd = $conteneur->getBdd();
63
		$this->config = $conteneur->getParametre('Graphiques');
63
		$this->config = $conteneur->getParametre('Graphiques');
64
		$this->convertisseur = $this->config['convertisseur'];
64
		$this->convertisseur = $this->config['convertisseur'];
65
		$this->graduations_id = $this->getParametreTableau('graduations_id');
65
		$this->graduations_id = $this->getParametreTableau('graduations_id');
66
		$this->champs_ontologiques = $this->getParametreTableau('champs_ontologiques');
66
		$this->champs_ontologiques = $this->getParametreTableau('champs_ontologiques');
67
		$this->cheminGraphBase = $this->config['chemin'];
67
		$this->cheminGraphBase = $this->config['chemin'];
68
		$cacheOptions = array('mise_en_cache' => $this->config['cache']['miseEnCache'],
68
		$cacheOptions = array('mise_en_cache' => $this->config['cache']['miseEnCache'],
69
								'stockage_chemin' => $this->config['cache']['stockageChemin'],
69
								'stockage_chemin' => $this->config['cache']['stockageChemin'],
70
								'duree_de_vie' => $this->config['cache']['dureeDeVie']);
70
								'duree_de_vie' => $this->config['cache']['dureeDeVie']);
71
		$this->cache = $conteneur->getCacheSimple($cacheOptions);
71
		$this->cache = $conteneur->getCacheSimple($cacheOptions);
72
		$this->definirVersion();
72
		$this->definirVersion();
73
		$this->definirFormat();
73
		$this->definirFormat();
74
		$this->definirTable($this->version);
74
		$this->definirTable($this->version);
75
	}
75
	}
76
	
76
	
77
	abstract function definirTable($version);
77
	abstract function definirTable($version);
78
	
78
	
79
	
79
	
80
	private function getParametreTableau($cle) {
80
	private function getParametreTableau($cle) {
81
		$tableau = array();
81
		$tableau = array();
82
		$parametre = Config::get($cle);
82
		$parametre = Config::get($cle);
83
		if (empty($parametre) === false) {
83
		if (empty($parametre) === false) {
84
			$tableauPartiel = explode(',', $parametre);
84
			$tableauPartiel = explode(',', $parametre);
85
			$tableauPartiel = array_map('trim', $tableauPartiel);
85
			$tableauPartiel = array_map('trim', $tableauPartiel);
86
			foreach ($tableauPartiel as $champ) {
86
			foreach ($tableauPartiel as $champ) {
87
				if (strpos($champ, '=') !== false && strlen($champ) >= 3) {
87
				if (strpos($champ, '=') !== false && strlen($champ) >= 3) {
88
					list($cle, $val) = explode('=', $champ);
88
					list($cle, $val) = explode('=', $champ);
89
					$tableau[trim($cle)] = trim($val);
89
					$tableau[trim($cle)] = trim($val);
90
				} else {
90
				} else {
91
					$tableau[] = trim($champ);
91
					$tableau[] = trim($champ);
92
				}
92
				}
93
			}
93
			}
94
		}
94
		}
95
		return $tableau;
95
		return $tableau;
96
	}
96
	}
97
	
97
	
98
	//+--------------------------traitement ressources ou paramètres  -------------------------------------------+
98
	//+--------------------------traitement ressources ou paramètres  -------------------------------------------+
99
	
99
	
100
	//+---- paramètres ----+
100
	//+---- paramètres ----+
101
	
101
	
102
	//on n'affiche qu'une version de graphique à la fois ( la dernière ou celle demandée )
102
	//on n'affiche qu'une version de graphique à la fois ( la dernière ou celle demandée )
103
	private function definirVersion() { 
103
	private function definirVersion() { 
104
		$this->chargerVersions();
104
		$this->chargerVersions();
105
		if( (!isset($this->parametres['version.projet']) ) || ((isset($this->parametres['version.projet']) )&&
105
		if( (!isset($this->parametres['version.projet']) ) || ((isset($this->parametres['version.projet']) )&&
106
		(($this->parametres['version.projet'] == '+') || ($this->parametres['version.projet'] == '')))){
106
		(($this->parametres['version.projet'] == '+') || ($this->parametres['version.projet'] == '')))){
107
			$this->version = $this->metadonnees[0]['version'];
107
			$this->version = $this->metadonnees[0]['version'];
108
		} else {
108
		} else {
109
			$this->version = $this->parametres['version.projet'];
109
			$this->version = $this->parametres['version.projet'];
110
		}
110
		}
111
	}
111
	}
112
	
112
	
113
	private function definirFormat() {
113
	private function definirFormat() {
114
		if (isset($this->parametres['retour.format']) ){
114
		if (isset($this->parametres['retour.format']) ){
115
			if (preg_match("/^[0-9]+$/", $this->parametres['retour.format'])){
115
			if (preg_match("/^[0-9]+$/", $this->parametres['retour.format'])){
116
				$this->largeurSVG = $this->parametres['retour.format'];
116
				$this->largeurSVG = $this->parametres['retour.format'];
117
			}else {
117
			}else {
118
				$erreur = "Erreur : Entrez la largeur voulue (en pixels) pour le paramètre retour.format.";
118
				$erreur = "Erreur : Entrez la largeur voulue (en pixels) pour le paramètre retour.format.";
119
				$code = RestServeur::HTTP_CODE_MAUVAISE_REQUETE;
119
				$code = RestServeur::HTTP_CODE_MAUVAISE_REQUETE;
120
				throw new Exception($erreur, $code);
120
				throw new Exception($erreur, $code);
121
			}
121
			}
122
		}
122
		}
123
		if (!isset($this->parametres['retour']) ){
123
		if (!isset($this->parametres['retour']) ){
124
			$this->parametres['retour'] = 'image/svg+xml';
124
			$this->parametres['retour'] = 'image/svg+xml';
125
		
125
		
126
		}else {
126
		}else {
127
			if (( $this->parametres['retour'] != 'image/svg+xml')&& ( $this->parametres['retour'] != 'image/png')){
127
			if (( $this->parametres['retour'] != 'image/svg+xml')&& ( $this->parametres['retour'] != 'image/png')){
128
				$erreur = "Erreur : choisissez le format de retour pour le paramètre retour : image/svg%2Bxml ou image/png.";
128
				$erreur = "Erreur : choisissez le format de retour pour le paramètre retour : image/svg%2Bxml ou image/png.";
129
				$code = RestServeur::HTTP_CODE_MAUVAISE_REQUETE;
129
				$code = RestServeur::HTTP_CODE_MAUVAISE_REQUETE;
130
				throw new Exception($erreur, $code);
130
				throw new Exception($erreur, $code);
131
			}
131
			}
132
		}
132
		}
133
	}
133
	}
134
	
134
	
135
	
135
	
136
	
136
	
137
	private function chargerVersions() {
137
	private function chargerVersions() {
138
		$requete = "SELECT version ".
138
		$requete = "SELECT version ".
139
							"FROM ".Config::get('bdd_table_meta')." ".
139
							"FROM ".Config::get('bdd_table_meta')." ".
140
							"ORDER BY date_creation DESC ";
140
							"ORDER BY date_creation DESC ";
141
		$resultats = $this->Bdd->recupererTous($requete);
141
		$resultats = $this->Bdd->recupererTous($requete);
142
		if (!is_array($resultats) || count($resultats) <= 0) {
142
		if (!is_array($resultats) || count($resultats) <= 0) {
143
			$message = "Les méta-données n'ont pu être chargée pour la ressource demandée";
143
			$message = "Les méta-données n'ont pu être chargée pour la ressource demandée";
144
			$code = RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE;
144
			$code = RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE;
145
			throw new Exception($message, $code);
145
			throw new Exception($message, $code);
146
		}
146
		}
147
	
147
	
148
		$this->metadonnees = $resultats;
148
		$this->metadonnees = $resultats;
149
	}
149
	}
150
	
150
	
151
	//+----- ressources -----+
151
	//+----- ressources -----+
152
	
152
	
153
	
153
	
154
	public function traiterRessources() {
154
	public function traiterRessources() {
155
	
155
	
156
		$this->traiterReferentielEtNum();
156
		$this->traiterReferentielEtNum();
157
		$this->traiterTypeGraphique();
157
		$this->traiterTypeGraphique();
158
	}
158
	}
159
	
159
	
160
	abstract function traiterReferentielEtNum();
160
	abstract function traiterReferentielEtNum();
161
	abstract function traiterTypeGraphique();
161
	abstract function traiterTypeGraphique();
162
	
162
	
163
	//+--------------------------FONCTIONS D'ASSEMBLAGE DE LA REQUETE-------------------------------------------+
163
	//+--------------------------FONCTIONS D'ASSEMBLAGE DE LA REQUETE-------------------------------------------+
164
	
164
	
165
	public function assemblerLaRequete() {
165
	public function assemblerLaRequete() {
166
		$requete = 	' SELECT '.$this->requete_champs.'  FROM '.$this->table.' '.$this->retournerRequeteCondition();
166
		$requete = 	' SELECT '.$this->requete_champs.'  FROM '.$this->table.' '.$this->retournerRequeteCondition();
167
		return $requete;
167
		return $requete;
168
	}
168
	}
169
	
169
	
170
	public  function retournerRequeteCondition() {
170
	public  function retournerRequeteCondition() {
171
		$condition = '';
171
		$condition = '';
172
		if ($this->requete_condition !== "") {
172
		if ($this->requete_condition !== "") {
173
			$condition = ' WHERE '.implode(' AND ', $this->requete_condition);
173
			$condition = ' WHERE '.implode(' AND ', $this->requete_condition);
174
		}
174
		}
175
		return $condition;
175
		return $condition;
176
	}
176
	}
177
	
177
	
178
	//+-------------------------- formatage du résultat  -------------------------------------------+
178
	//+-------------------------- formatage du résultat  -------------------------------------------+
179
 
179
 
180
	public function obtenirResultat($resultat) {
180
	public function obtenirResultat($resultat) {
181
		if ($resultat == ""){
181
		if ($resultat == ""){
182
			$message = 'La requête SQL formée comporte une erreur!';
182
			$message = 'La requête SQL formée comporte une erreur!';
183
			$code = RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE;
183
			$code = RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE;
184
			throw new Exception($message, $code);
184
			throw new Exception($message, $code);
185
		}elseif ($resultat) {
185
		}elseif ($resultat) {
186
			if ((count($this->ressources)) != 0) {
186
			if ((count($this->ressources)) != 0) {
187
				$Atraiter = array_filter($resultat[0],function($var){return ($var != '');});
187
				//$Atraiter = array_filter($resultat[0],function($var){return ($var != '');});
-
 
188
				foreach ($resultat[0] as $champs => $valeur) {
-
 
189
					if ($valeur !== '') {
-
 
190
						$Atraiter[$champs] = $valeur;
-
 
191
					}
-
 
192
				}
188
				if (!empty($Atraiter)) {
193
				if (!empty($Atraiter)) {
189
					$this->traiterValeursEcologiques($Atraiter);
194
					$this->traiterValeursEcologiques($Atraiter);
190
					$svg = $this->genererSVG();
195
					$svg = $this->genererSVG();
191
					$resultat = new ResultatService();
196
					$resultat = new ResultatService();
192
					$resultat->corps = ($this->parametres['retour'] == 'image/png') ? $this->convertirEnPNG($svg) : $svg;
197
					$resultat->corps = ($this->parametres['retour'] == 'image/png') ? $this->convertirEnPNG($svg) : $svg;
193
					$resultat->mime = $this->parametres['retour'];
198
					$resultat->mime = $this->parametres['retour'];
194
				} else {
199
				} else {
195
					$resultat = null; 
200
					$resultat = null; 
196
				}
201
				}
197
			}
202
			}
198
		} else {
203
		} else {
199
			$resultat = null;
204
			$resultat = null;
200
		}
205
		}
201
		return $resultat;
206
		return $resultat;
202
	}
207
	}
203
	
208
	
204
	
209
	
205
	
210
	
206
	
211
	
207
	//+----- modification svg -----+
212
	//+----- modification svg -----+
208
	
213
	
209
	
214
	
210
 
215
 
211
	public function traiterValeursEcologiques($valeur){
216
	public function traiterValeursEcologiques($valeur){
212
		$this->valeurs_champs = $valeur; 
217
		$this->valeurs_champs = $valeur; 
213
	
218
	
214
		foreach($this->valeurs_champs as $cle => $val){
219
		foreach($this->valeurs_champs as $cle => $val){
215
				if (preg_match("/ve_humidite_edaph/", $cle)) {
220
				if (preg_match("/ve_humidite_edaph/", $cle)) {
216
					$this->valeurs_en_pourcentage[$cle] = round($val/13,1);
221
					$this->valeurs_en_pourcentage[$cle] = round($val/13,1);
217
				} elseif (preg_match("/ve_salinite/", $cle)) {
222
				} elseif (preg_match("/ve_salinite/", $cle)) {
218
					$this->valeurs_en_pourcentage[$cle] = round(($val+1)/11,1);
223
					$this->valeurs_en_pourcentage[$cle] = round(($val+1)/11,1);
219
				} else {
224
				} else {
220
					$this->valeurs_en_pourcentage[$cle] = round($val/10,1);
225
					$this->valeurs_en_pourcentage[$cle] = round($val/10,1);
221
				}
226
				}
222
		}
227
		}
223
	}
228
	}
224
	
229
	
225
	
230
	
226
	
231
	
227
	public function genererSVG(){
232
	public function genererSVG(){
228
		$svg = null;
233
		$svg = null;
229
		$this->dom = new DOMDocument('1.0', 'UTF-8');
234
		$this->dom = new DOMDocument('1.0', 'UTF-8');
230
		$this->dom->validateOnParse = true;
235
		$this->dom->validateOnParse = true;
231
		$fichierSvg = $this->cheminGraphBase."".$this->nomGraphique.".svg";
236
		$fichierSvg = $this->cheminGraphBase."".$this->nomGraphique.".svg";
232
		$this->dom->load($fichierSvg);
237
		$this->dom->load($fichierSvg);
233
		$this->changerValeursSVG();
238
		$this->changerValeursSVG();
234
			$svg = $this->dom->saveXML();
239
			$svg = $this->dom->saveXML();
235
		return $svg;
240
		return $svg;
236
	}
241
	}
237
	
242
	
238
	abstract function changerValeursSVG();
243
	abstract function changerValeursSVG();
239
	
244
	
240
	public function recupererOntologies($valeur, $champs){
245
	public function recupererOntologies($valeur, $champs){
241
		$url = $this->ajouterHref('ontologies',$this->champs_ontologiques[$champs].':'.urlencode(urlencode($valeur)));
246
		$url = $this->ajouterHref('ontologies',$this->champs_ontologiques[$champs].':'.urlencode(urlencode($valeur)));
242
		$val = $this->consulterHref($url);
247
		$val = $this->consulterHref($url);
243
		return $val;
248
		return $val;
244
	}
249
	}
245
	
250
	
246
	/// +---- convertir png ----+
251
	/// +---- convertir png ----+
247
	
252
	
248
	public function convertirEnPNG($svg) {
253
	public function convertirEnPNG($svg) {
249
		$png = null;
254
		$png = null;
250
	
255
	
251
		if (isset($this->convertisseur)) {
256
		if (isset($this->convertisseur)) {
252
			if ($this->convertisseur == 'imagick') {
257
			if ($this->convertisseur == 'imagick') {
253
				if (extension_loaded('imagick')) {
258
				if (extension_loaded('imagick')) {
254
					$png = $this->convertirEnPNGAvecImageMagick($svg);
259
					$png = $this->convertirEnPNGAvecImageMagick($svg);
255
				} else {
260
				} else {
256
					$message = "Impossible de générer l'image sur le serveur. Extension ImageMagick absente.";
261
					$message = "Impossible de générer l'image sur le serveur. Extension ImageMagick absente.";
257
					$code = RestServeur::HTTP_CODE_ERREUR;
262
					$code = RestServeur::HTTP_CODE_ERREUR;
258
					throw new Exception($message, $code);
263
					throw new Exception($message, $code);
259
				}
264
				}
260
			} else if ($this->convertisseur == 'rsvg') {
265
			} else if ($this->convertisseur == 'rsvg') {
261
				$png = $this->convertirEnPNGAvecRsvg($svg);
266
				$png = $this->convertirEnPNGAvecRsvg($svg);
262
			} else {
267
			} else {
263
				$message = "Le convertisseur indiqué '{$this->convertisseur}' ne fait pas partie de la liste ".
268
				$message = "Le convertisseur indiqué '{$this->convertisseur}' ne fait pas partie de la liste ".
264
								"des convertisseurs disponibles : imagick, rsvg.";
269
								"des convertisseurs disponibles : imagick, rsvg.";
265
				$code = RestServeur::HTTP_CODE_ERREUR;
270
				$code = RestServeur::HTTP_CODE_ERREUR;
266
				throw new Exception($message, $code);
271
				throw new Exception($message, $code);
267
			}
272
			}
268
		} else {
273
		} else {
269
			$message = "Veuillez indiquer le convertisseur de svg à utiliser pour le service.";
274
			$message = "Veuillez indiquer le convertisseur de svg à utiliser pour le service.";
270
			$code = RestServeur::HTTP_CODE_ERREUR;
275
			$code = RestServeur::HTTP_CODE_ERREUR;
271
			throw new Exception($message, $code);
276
			throw new Exception($message, $code);
272
		}
277
		}
273
		return $png;
278
		return $png;
274
	}
279
	}
275
	
280
	
276
	public function convertirEnPNGAvecImageMagick($svg) {
281
	public function convertirEnPNGAvecImageMagick($svg) {
277
		$convertisseur = new Imagick();
282
		$convertisseur = new Imagick();
278
		$convertisseur->setBackgroundColor(new ImagickPixel('#F8F8F8'));
283
		$convertisseur->setBackgroundColor(new ImagickPixel('#F8F8F8'));
279
		$convertisseur->readImageBlob($svg);
284
		$convertisseur->readImageBlob($svg);
280
		$convertisseur->setImageFormat('png32');
285
		$convertisseur->setImageFormat('png32');
281
		$convertisseur->resizeImage($this->largeurSVG, 0 , imagick::FILTER_LANCZOS, 0, true);
286
		$convertisseur->resizeImage($this->largeurSVG, 0 , imagick::FILTER_LANCZOS, 0, true);
282
		$png = $convertisseur->getImageBlob();
287
		$png = $convertisseur->getImageBlob();
283
		$convertisseur->clear();
288
		$convertisseur->clear();
284
		$convertisseur->destroy();
289
		$convertisseur->destroy();
285
		return $png;
290
		return $png;
286
	}
291
	}
287
	
292
	
288
	public function convertirEnPNGAvecRsvg($svg) {
293
	public function convertirEnPNGAvecRsvg($svg) {
289
		$idFichier = $this->getIdFichier();
294
		$idFichier = $this->getIdFichier();
290
		$fichierPng = $this->config['cache']['stockageChemin']."".$idFichier.'.png';
295
		$fichierPng = $this->config['cache']['stockageChemin']."".$idFichier.'.png';
291
		$fichierSvg = $this->config['cache']['stockageChemin']."".$idFichier.'.svg';
296
		$fichierSvg = $this->config['cache']['stockageChemin']."".$idFichier.'.svg';
292
		file_put_contents($fichierSvg, $svg);
297
		file_put_contents($fichierSvg, $svg);
293
		$commande = "rsvg-convert  $fichierSvg -b #F8F8F8 -w $this->largeurSVG -a -o $fichierPng";
298
		$commande = "rsvg-convert  $fichierSvg -b #F8F8F8 -w $this->largeurSVG -a -o $fichierPng";
294
		$rsvg = exec($commande);
299
		$rsvg = exec($commande);
295
		$this->indexerFichierPng($fichierPng);
300
		$this->indexerFichierPng($fichierPng);
296
		$png = file_get_contents($fichierPng);
301
		$png = file_get_contents($fichierPng);
297
		return $png;
302
		return $png;
298
	}
303
	}
299
	
304
	
300
	public function indexerFichierPng($fichierPng) {
305
	public function indexerFichierPng($fichierPng) {
301
		$img = imagecreatefrompng($fichierPng);
306
		$img = imagecreatefrompng($fichierPng);
302
		imagetruecolortopalette($img, false, 32);
307
		imagetruecolortopalette($img, false, 32);
303
		imagepng($img, $fichierPng, 9, PNG_ALL_FILTERS);
308
		imagepng($img, $fichierPng, 9, PNG_ALL_FILTERS);
304
	}
309
	}
305
	
310
	
306
	public function getIdFichier(){
311
	public function getIdFichier(){
307
		$idfichier = str_replace(".","-",$this->ressources[1]);
312
		$idfichier = str_replace(".","-",$this->ressources[1]);
308
		$idfichier = str_replace(':','-',$idfichier);
313
		$idfichier = str_replace(':','-',$idfichier);
309
		$idfichier .= "-".$this->ressources[0];
314
		$idfichier .= "-".$this->ressources[0];
310
		return $idfichier;
315
		return $idfichier;
311
	}
316
	}
312
}
317
}
313
?>
318
?>