Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

Rev 808 Rev 916
Line 1... Line 1...
1
<?php
1
<?php
Line 2... Line 2...
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>
Line 13... Line 13...
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
*/
Line 16... Line 16...
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 $hauteurSVG;
42
	protected $hauteurSVG;
43
	protected $valeurs_champs;
43
	protected $valeurs_champs;
44
	
44
 
45
	
45
 
46
	
46
 
47
	public function consulter($ressources, $parametres) {
47
	public function consulter($ressources, $parametres) {
48
		$this->ressources = $ressources;
48
		$this->ressources = $ressources;
49
		$this->parametres = $parametres;
49
		$this->parametres = $parametres;
50
		$this->verifierParametres();
50
		$this->verifierParametres();
Line 54... Line 54...
54
		$requete = $this->assemblerLaRequete();
54
		$requete = $this->assemblerLaRequete();
55
		$resultat = $this->resultat = $this->Bdd->recupererTous($requete);
55
		$resultat = $this->resultat = $this->Bdd->recupererTous($requete);
56
		$versionResultat = $this->obtenirResultat($resultat);
56
		$versionResultat = $this->obtenirResultat($resultat);
57
		return $versionResultat;
57
		return $versionResultat;
58
	}
58
	}
59
	
59
 
Line 60... Line 60...
60
 
60
 
61
	//+--------------------------initialisation de paramètres  -------------------------------------------+
61
	//+--------------------------initialisation de paramètres  -------------------------------------------+
62
	
62
 
63
	private function initialiserConfiguration() {
63
	private function initialiserConfiguration() {
64
		$conteneur = new Conteneur();
64
		$conteneur = new Conteneur();
65
		$this->Bdd = $conteneur->getBdd();
65
		$this->Bdd = $conteneur->getBdd();
66
		$this->config = $conteneur->getParametre('Graphiques');
66
		$this->config = $conteneur->getParametre('Graphiques');
67
		$this->convertisseur = $this->config['convertisseur'];
67
		$this->convertisseur = $this->config['convertisseur'];
68
		$this->graduations_id = $this->getParametreTableau('graduations_id');
68
		$this->graduations_id = $this->getParametreTableau('graduations_id');
69
		$this->champs_ontologiques = $this->getParametreTableau('champs_ontologiques');
69
		$this->champs_ontologiques = $this->getParametreTableau('champs_ontologiques');
70
		$this->cheminGraphBase = $this->config['chemin'];
70
		$this->cheminGraphBase = $this->config['chemin'];
71
		$cacheOptions = array('mise_en_cache' => $this->config['cache_miseEnCache'],
71
		$cacheOptions = array('mise_en_cache' => $this->config['cache_miseEnCache'],
72
								'stockage_chemin' => $this->config['cache_stockageChemin'],
72
			'stockage_chemin' => $this->config['cache_stockageChemin'],
73
								'duree_de_vie' => $this->config['cache_dureeDeVie']);
73
			'duree_de_vie' => $this->config['cache_dureeDeVie']);
74
		$this->cache = $conteneur->getCacheSimple($cacheOptions);
74
		$this->cache = $conteneur->getCacheSimple($cacheOptions);
75
		$this->definirVersion();
75
		$this->definirVersion();
76
		$this->definirFormat();
76
		$this->definirFormat();
77
		$this->definirTable($this->version);
77
		$this->definirTable($this->version);
78
	}
78
	}
79
	
79
 
80
	
80
 
81
	
81
 
82
	abstract function definirTable($version);
82
	abstract function definirTable($version);
83
	
83
 
84
	
84
 
85
	private function getParametreTableau($cle) {
85
	private function getParametreTableau($cle) {
86
		$tableau = array();
86
		$tableau = array();
87
		$parametre = Config::get($cle);
87
		$parametre = Config::get($cle);
88
		if (empty($parametre) === false) {
88
		if (empty($parametre) === false) {
Line 99... Line 99...
99
		}
99
		}
100
		return $tableau;
100
		return $tableau;
101
	}
101
	}
Line 102... Line 102...
102
 
102
 
103
	//+--------------------------traitement ressources ou paramètres  -------------------------------------------+
103
	//+--------------------------traitement ressources ou paramètres  -------------------------------------------+
104
	
104
 
105
	//+---- paramètres ----+
105
	//+---- paramètres ----+
106
	
106
 
107
	private function verifierParametres() {
107
	private function verifierParametres() {
108
		if (isset($this->parametres)) {
108
		if (isset($this->parametres)) {
109
			$parametres_dispo = array('retour', 'retour.format', 'version.projet');
109
			$parametres_dispo = array('retour', 'retour.format', 'version.projet');
110
			$parametres = array_keys($this->parametres);
110
			$parametres = array_keys($this->parametres);
Line 114... Line 114...
114
					$code = RestServeur::HTTP_CODE_MAUVAISE_REQUETE;
114
					$code = RestServeur::HTTP_CODE_MAUVAISE_REQUETE;
115
					throw new Exception($erreur, $code);
115
					throw new Exception($erreur, $code);
116
				}
116
				}
117
			}
117
			}
118
		}
118
		}
119
		
119
 
120
	}
120
	}
121
	
121
 
122
	//on n'affiche qu'une version de graphique à la fois ( la dernière ou celle demandée )
122
	//on n'affiche qu'une version de graphique à la fois ( la dernière ou celle demandée )
123
	private function definirVersion() { 
123
	private function definirVersion() {
124
		$this->chargerVersions();
124
		$this->chargerVersions();
125
		if (!isset($this->parametres['version.projet']) ) {
125
		if (!isset($this->parametres['version.projet']) ) {
126
			$this->version = $this->metadonnees[0]['version'];
126
			$this->version = $this->metadonnees[0]['version'];
127
		} elseif ($this->parametres['version.projet'] == '+') {
127
		} elseif ($this->parametres['version.projet'] == '+') {
128
				 $this->version = $this->metadonnees[0]['version'];
128
				 $this->version = $this->metadonnees[0]['version'];
Line 134... Line 134...
134
				$code = RestServeur::HTTP_CODE_MAUVAISE_REQUETE;
134
				$code = RestServeur::HTTP_CODE_MAUVAISE_REQUETE;
135
				throw new Exception($erreur, $code);
135
				throw new Exception($erreur, $code);
136
			}
136
			}
137
		}
137
		}
138
	}
138
	}
139
	
139
 
140
	private function verifierVersion($version){
140
	private function verifierVersion($version){
141
		$retour = false;
141
		$retour = false;
142
		foreach ($this->metadonnees as $vers) {
142
		foreach ($this->metadonnees as $vers) {
143
			if ($vers['version'] == $version ) {
143
			if ($vers['version'] == $version ) {
144
				$retour = true;
144
				$retour = true;
Line 162... Line 162...
162
				throw new Exception($erreur, $code);
162
				throw new Exception($erreur, $code);
163
			}
163
			}
164
		}
164
		}
165
		if (!isset($this->parametres['retour']) ){
165
		if (!isset($this->parametres['retour']) ){
166
			$this->parametres['retour'] = 'image/svg+xml';
166
			$this->parametres['retour'] = 'image/svg+xml';
167
		
167
 
168
		}else {
168
		}else {
169
			if (( $this->parametres['retour'] != 'image/svg+xml')&& ( $this->parametres['retour'] != 'image/png')){
169
			if (( $this->parametres['retour'] != 'image/svg+xml')&& ( $this->parametres['retour'] != 'image/png')){
170
				$erreur = "Erreur : valeur inconnue. Choisissez le format de retour pour le paramètre retour : image/svg%2Bxml ou image/png.";
170
				$erreur = "Erreur : valeur inconnue. Choisissez le format de retour pour le paramètre retour : image/svg%2Bxml ou image/png.";
171
				$code = RestServeur::HTTP_CODE_MAUVAISE_REQUETE;
171
				$code = RestServeur::HTTP_CODE_MAUVAISE_REQUETE;
172
				throw new Exception($erreur, $code);
172
				throw new Exception($erreur, $code);
173
			}
173
			}
174
		}
174
		}
175
	}
175
	}
176
	
176
 
177
	
177
 
178
	
178
 
179
	private function chargerVersions() {
179
	private function chargerVersions() {
180
		$requete = "SELECT version ".
180
		$requete = "SELECT version ".
181
							"FROM ".Config::get('bdd_table_meta')." ".
181
							"FROM ".Config::get('bdd_table_meta')." ".
182
							"ORDER BY date_creation DESC ";
182
							"ORDER BY date_creation DESC ";
183
		$resultats = $this->Bdd->recupererTous($requete);
183
		$resultats = $this->Bdd->recupererTous($requete);
184
		if (!is_array($resultats) || count($resultats) <= 0) {
184
		if (!is_array($resultats) || count($resultats) <= 0) {
185
			$message = "Les méta-données n'ont pu être chargée pour la ressource demandée";
185
			$message = "Les méta-données n'ont pu être chargée pour la ressource demandée";
186
			$code = RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE;
186
			$code = RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE;
187
			throw new Exception($message, $code);
187
			throw new Exception($message, $code);
188
		}
188
		}
189
	
189
 
190
		$this->metadonnees = $resultats;
190
		$this->metadonnees = $resultats;
191
	}
191
	}
192
	
192
 
193
	//+----- ressources -----+
193
	//+----- ressources -----+
194
	
194
 
195
	
195
 
196
	public function traiterRessources() {
196
	public function traiterRessources() {
197
		if(isset($this->ressources)) {
197
		if(isset($this->ressources)) {
198
			$this->traiterTypeGraphique();
198
			$this->traiterTypeGraphique();
199
			$this->traiterReferentielEtNum();
199
			$this->traiterReferentielEtNum();
200
		} else {
200
		} else {
201
			$e = 'Erreur dans l\'url de votre requête : </br> ressources insuffisantes.';
201
			$e = 'Erreur dans l\'url de votre requête : </br> ressources insuffisantes.';
202
			throw new Exception( $e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
202
			throw new Exception( $e, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
203
		}
203
		}
204
	}
204
	}
205
	
205
 
206
	abstract function traiterReferentielEtNum();
206
	abstract function traiterReferentielEtNum();
207
	abstract function traiterTypeGraphique();
207
	abstract function traiterTypeGraphique();
208
	
208
 
209
	//+--------------------------FONCTIONS D'ASSEMBLAGE DE LA REQUETE-------------------------------------------+
209
	//+--------------------------FONCTIONS D'ASSEMBLAGE DE LA REQUETE-------------------------------------------+
210
	
210
 
211
	public function assemblerLaRequete() {
211
	public function assemblerLaRequete() {
212
		$requete = 	' SELECT '.$this->requete_champs.'  FROM '.$this->table.' '.$this->retournerRequeteCondition();
212
		$requete = 	' SELECT '.$this->requete_champs.'  FROM '.$this->table.' '.$this->retournerRequeteCondition();
213
		return $requete;
213
		return $requete;
214
	}
214
	}
215
	
215
 
216
	public  function retournerRequeteCondition() {
216
	public  function retournerRequeteCondition() {
217
		$condition = '';
217
		$condition = '';
218
		if ($this->requete_condition !== "") {
218
		if ($this->requete_condition !== "") {
219
			$condition = ' WHERE '.implode(' AND ', $this->requete_condition);
219
			$condition = ' WHERE '.implode(' AND ', $this->requete_condition);
220
		}
220
		}
221
		return $condition;
221
		return $condition;
222
	}
222
	}
223
	
223
 
224
	//+-------------------------- formatage du résultat  -------------------------------------------+
224
	//+-------------------------- formatage du résultat  -------------------------------------------+
Line 225... Line 225...
225
 
225
 
226
	public function obtenirResultat($resultat) {
226
	public function obtenirResultat($resultat) {
227
		if ($resultat == ""){
227
		if ($resultat == ""){
Line 241... Line 241...
241
					$svg = $this->genererSVG();
241
					$svg = $this->genererSVG();
242
					$resultat = new ResultatService();
242
					$resultat = new ResultatService();
243
					$resultat->corps = ($this->parametres['retour'] == 'image/png') ? $this->convertirEnPNG($svg) : $svg;
243
					$resultat->corps = ($this->parametres['retour'] == 'image/png') ? $this->convertirEnPNG($svg) : $svg;
244
					$resultat->mime = $this->parametres['retour'];
244
					$resultat->mime = $this->parametres['retour'];
245
				} else {
245
				} else {
246
					$resultat = null; 
246
					$resultat = null;
247
				}
247
				}
248
			}
248
			}
249
		} else {
249
		} else {
250
			$resultat = null;
250
			$resultat = null;
251
		}
251
		}
252
		return $resultat;
252
		return $resultat;
253
	}
253
	}
254
	
254
 
255
	
255
 
256
	
256
 
257
	
257
 
258
	//+----- modification svg -----+
258
	//+----- modification svg -----+
259
	
259
 
260
	
260
 
Line 261... Line 261...
261
 
261
 
262
	public function traiterValeursEcologiques($valeur){
262
	public function traiterValeursEcologiques($valeur){
263
		$this->valeurs_champs = $valeur; 
263
		$this->valeurs_champs = $valeur;
264
	
264
 
265
		foreach($this->valeurs_champs as $cle => $val){
265
		foreach($this->valeurs_champs as $cle => $val){
266
				if (preg_match("/ve_humidite_edaph/", $cle)) {
266
				if (preg_match("/ve_humidite_edaph/", $cle)) {
267
					$this->valeurs_en_pourcentage[$cle] = round($val/13,1);
267
					$this->valeurs_en_pourcentage[$cle] = round($val/13,1);
268
				} elseif (preg_match("/ve_salinite/", $cle)) {
268
				} elseif (preg_match("/ve_salinite/", $cle)) {
269
					$this->valeurs_en_pourcentage[$cle] = round(($val+1)/11,1);
269
					$this->valeurs_en_pourcentage[$cle] = round(($val+1)/11,1);
270
				} else {
270
				} else {
271
					$this->valeurs_en_pourcentage[$cle] = round($val/10,1);
271
					$this->valeurs_en_pourcentage[$cle] = round($val/10,1);
272
				}
272
				}
273
		}
273
		}
274
	}
274
	}
275
	
275
 
276
	public function donnerHauteur($ancienne_largeur, $ancienne_hauteur) {
276
	public function donnerHauteur($ancienne_largeur, $ancienne_hauteur) {
277
		$nouvelle_largeur = $this->largeurSVG;
277
		$nouvelle_largeur = $this->largeurSVG;
278
		$ancienne_largeur = str_replace('px','',$ancienne_largeur);
278
		$ancienne_largeur = str_replace('px','',$ancienne_largeur);
279
		$ancienne_hauteur = str_replace('px','',$ancienne_hauteur);
279
		$ancienne_hauteur = str_replace('px','',$ancienne_hauteur);
280
		$rapport =   $nouvelle_largeur / $ancienne_largeur ;
280
		$rapport =   $nouvelle_largeur / $ancienne_largeur ;
281
		$nouvelle_hauteur = $ancienne_hauteur * $rapport;
281
		$nouvelle_hauteur = $ancienne_hauteur * $rapport;
282
		$this->hauteurSVG = $nouvelle_hauteur;
282
		$this->hauteurSVG = $nouvelle_hauteur;
283
	}
283
	}
284
	
284
 
285
	public function ajusterFormatSVG(){
285
	public function ajusterFormatSVG(){
286
		$svg = $this->dom->getElementsByTagName("svg")->item(0);
286
		$svg = $this->dom->getElementsByTagName("svg")->item(0);
287
		$largeur = $svg->getAttribute('width');
287
		$largeur = $svg->getAttribute('width');
288
		$hauteur = $svg->getAttribute('height');
288
		$hauteur = $svg->getAttribute('height');
289
		$this->donnerHauteur($largeur , $hauteur);
289
		$this->donnerHauteur($largeur , $hauteur);
290
		$svg->setAttribute('width',round($this->largeurSVG).'px');
290
		$svg->setAttribute('width',round($this->largeurSVG).'px');
291
		$svg->setAttribute('height',round($this->hauteurSVG).'px');
291
		$svg->setAttribute('height',round($this->hauteurSVG).'px');
292
		
292
 
293
	}
293
	}
294
	
294
 
295
	public function genererSVG(){
295
	public function genererSVG(){
296
		$svg = null;
296
		$svg = null;
297
		$this->dom = new DOMDocument('1.0', 'UTF-8');
297
		$this->dom = new DOMDocument('1.0', 'UTF-8');
298
		$this->dom->validateOnParse = true;
298
		$this->dom->validateOnParse = true;
299
		$fichierSvg = $this->cheminGraphBase."".$this->nomGraphique.".svg";
299
		$fichierSvg = $this->cheminGraphBase."".$this->nomGraphique.".svg";
300
		$this->dom->load($fichierSvg);
300
		$this->dom->load($fichierSvg);
301
		$this->changerValeursSVG();
301
		$this->changerValeursSVG();
302
		$svg = $this->dom->saveXML();
302
		$svg = $this->dom->saveXML();
303
		return $svg;
303
		return $svg;
304
	}
304
	}
305
	
305
 
306
	abstract function changerValeursSVG();
306
	abstract function changerValeursSVG();
307
	
307
 
308
	public function recupererOntologies($valeur, $champs){
308
	public function recupererOntologies($valeur, $champs){
309
		$url = $this->ajouterHref('ontologies',$this->champs_ontologiques[$champs].':'.urlencode(urlencode($valeur)));
309
		$url = $this->ajouterHref('ontologies',$this->champs_ontologiques[$champs].':'.urlencode(urlencode($valeur)));
310
		try {
310
		try {
311
			$val = $this->getBdd()->recuperer(sprintf(
311
			$val = $this->getBdd()->recuperer(sprintf(
Line 317... Line 317...
317
		} catch (Exception $e) {
317
		} catch (Exception $e) {
318
			$val = "";
318
			$val = "";
319
		}
319
		}
320
		return $val;
320
		return $val;
321
	}
321
	}
322
	
322
 
323
	public function traiterIntermediaires($valeurTexte,$champsOntologie, $champsTable){
323
	public function traiterIntermediaires($valeurTexte,$champsOntologie, $champsTable){
324
		if (preg_match("/(?:I|i)nterm(?:é|e)diaire(?:s)*/", $valeurTexte )) {
324
		if (preg_match("/(?:I|i)nterm(?:é|e)diaire(?:s)*/", $valeurTexte )) {
325
			$prec = $this->recupererOntologies(($this->valeurs_champs[$champsTable]-1), $champsOntologie );
325
			$prec = $this->recupererOntologies(($this->valeurs_champs[$champsTable]-1), $champsOntologie );
326
			$suiv = $this->recupererOntologies(($this->valeurs_champs[$champsTable]+1), $champsOntologie );
326
			$suiv = $this->recupererOntologies(($this->valeurs_champs[$champsTable]+1), $champsOntologie );
327
			$valeurTexte = "Intermédiaires entre $prec->nom et $suiv->nom ";
327
			$valeurTexte = "Intermédiaires entre $prec->nom et $suiv->nom ";
328
		}
328
		}
329
		return $valeurTexte;
329
		return $valeurTexte;
330
	}
330
	}
331
	
331
 
332
	/// +---- convertir png ----+
332
	/// +---- convertir png ----+
333
	
333
 
334
	public function convertirEnPNG($svg) {
334
	public function convertirEnPNG($svg) {
335
		$png = null;
335
		$png = null;
336
	
336
 
337
		if (isset($this->convertisseur)) {
337
		if (isset($this->convertisseur)) {
338
			if ($this->convertisseur == 'imagick') {
338
			if ($this->convertisseur == 'imagick') {
339
				if (extension_loaded('imagick')) {
339
				if (extension_loaded('imagick')) {
340
					$png = $this->convertirEnPNGAvecImageMagick($svg);
340
					$png = $this->convertirEnPNGAvecImageMagick($svg);
341
				} else {
341
				} else {
Line 356... Line 356...
356
			$code = RestServeur::HTTP_CODE_ERREUR;
356
			$code = RestServeur::HTTP_CODE_ERREUR;
357
			throw new Exception($message, $code);
357
			throw new Exception($message, $code);
358
		}
358
		}
359
		return $png;
359
		return $png;
360
	}
360
	}
361
	
361
 
362
	public function convertirEnPNGAvecImageMagick($svg) {
362
	public function convertirEnPNGAvecImageMagick($svg) {
363
		$convertisseur = new Imagick();
363
		$convertisseur = new Imagick();
364
		$convertisseur->setBackgroundColor(new ImagickPixel('#F8F8F8'));
364
		$convertisseur->setBackgroundColor(new ImagickPixel('#F8F8F8'));
365
		$convertisseur->readImageBlob($svg);
365
		$convertisseur->readImageBlob($svg);
366
		$convertisseur->setImageFormat('png32');
366
		$convertisseur->setImageFormat('png32');
Line 368... Line 368...
368
		$png = $convertisseur->getImageBlob();
368
		$png = $convertisseur->getImageBlob();
369
		$convertisseur->clear();
369
		$convertisseur->clear();
370
		$convertisseur->destroy();
370
		$convertisseur->destroy();
371
		return $png;
371
		return $png;
372
	}
372
	}
373
	
373
 
374
	public function convertirGraphiqueEnPNGAvecRsvg($svg) {
374
	public function convertirGraphiqueEnPNGAvecRsvg($svg) {
375
		$idFichier = $this->getIdFichier();
375
		$idFichier = $this->getIdFichier();
376
		$fichierPng = $this->config['cache_stockageChemin'].$idFichier.'.png';
376
		$fichierPng = $this->config['cache_stockageChemin'].$idFichier.'.png';
377
		$fichierSvg = $this->config['cache_stockageChemin'].$idFichier.'.svg';
377
		$fichierSvg = $this->config['cache_stockageChemin'].$idFichier.'.svg';
378
		file_put_contents($fichierSvg, $svg);
378
		file_put_contents($fichierSvg, $svg);
Line 381... Line 381...
381
		$rsvg = exec($commande);
381
		$rsvg = exec($commande);
382
		$this->indexerGraphiqueFichierPng($fichierPng);
382
		$this->indexerGraphiqueFichierPng($fichierPng);
383
		$png = file_get_contents($fichierPng);
383
		$png = file_get_contents($fichierPng);
384
		return $png;
384
		return $png;
385
	}
385
	}
386
	
386
 
387
	public function indexerGraphiqueFichierPng($fichierPng) {
387
	public function indexerGraphiqueFichierPng($fichierPng) {
388
		$img = imagecreatefrompng($fichierPng);
388
		$img = imagecreatefrompng($fichierPng);
389
		imagetruecolortopalette($img, false, 32);
389
		imagetruecolortopalette($img, false, 32);
390
		imagepng($img, $fichierPng, 9, PNG_ALL_FILTERS);
390
		imagepng($img, $fichierPng, 9, PNG_ALL_FILTERS);
391
	}
391
	}
392
	
392
 
393
	public function getIdFichier(){
393
	public function getIdFichier(){
394
		$idfichier = str_replace(".","-",$this->ressources[1]);
394
		$idfichier = str_replace(".","-",$this->ressources[1]);
395
		$idfichier = str_replace(':','-',$idfichier);
395
		$idfichier = str_replace(':','-',$idfichier);
396
		$idfichier .= "-".$this->ressources[0];
396
		$idfichier .= "-".$this->ressources[0];
397
		return $idfichier;
397
		return $idfichier;