Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

Rev 958 Rev 968
Line 49... Line 49...
49
		$this->parametres = $parametres;
49
		$this->parametres = $parametres;
50
		$this->verifierParametres();
50
		$this->verifierParametres();
51
		$this->initialiserConfiguration();
51
		$this->initialiserConfiguration();
52
		$resultats = '';
52
		$resultats = '';
53
		$this->traiterRessources();
53
		$this->traiterRessources();
54
		$requete = $this->assemblerLaRequete();
-
 
-
 
54
 
55
		$resultat = $this->resultat = $this->Bdd->recupererTous($requete);
55
		$resultat = $this->resultat = $this->Bdd->recupererTous($this->assemblerLaRequete());
56
		$versionResultat = $this->obtenirResultat($resultat);
56
		$versionResultat = $this->obtenirResultat($resultat);
57
		return $versionResultat;
57
		return $versionResultat;
58
	}
58
	}
Line 63... Line 63...
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('Paramètres.graduations_id');
69
		$this->champs_ontologiques = $this->getParametreTableau('Paramètres.champs_ontologiques');
69
		$this->champs_ontologiques = $this->getParametreTableau('Paramètres.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']);
Line 207... Line 207...
207
	abstract function traiterTypeGraphique();
207
	abstract function traiterTypeGraphique();
Line 208... Line 208...
208
 
208
 
Line 209... Line 209...
209
	//+--------------------------FONCTIONS D'ASSEMBLAGE DE LA REQUETE-------------------------------------------+
209
	//+--------------------------FONCTIONS D'ASSEMBLAGE DE LA REQUETE-------------------------------------------+
210
 
210
 
211
	public function assemblerLaRequete() {
-
 
212
		$requete = 	' SELECT '.$this->requete_champs.'  FROM '.$this->table.' '.$this->retournerRequeteCondition();
211
	public function assemblerLaRequete() {
Line 213... Line 212...
213
		return $requete;
212
		return ' SELECT '.$this->requete_champs.'  FROM '.$this->table.' '.Informations::retournerRequeteCondition($this->requete_condition);
214
	}
213
	}
215
 
214
 
Line 222... Line 221...
222
	}
221
	}
Line 223... Line 222...
223
 
222
 
Line 224... Line 223...
224
	//+-------------------------- formatage du résultat  -------------------------------------------+
223
	//+-------------------------- formatage du résultat  -------------------------------------------+
225
 
224
 
-
 
225
	public function obtenirResultat($resultat) {
226
	public function obtenirResultat($resultat) {
226
		if ($resultat == '') {
227
		if ($resultat == ""){
227
			throw new Exception(
228
			$message = 'La requête SQL formée comporte une erreur!';
-
 
229
			$code = RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE;
228
                'La requête SQL formée comporte une erreur!',
230
			throw new Exception($message, $code);
229
                RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE);
231
		}elseif ($resultat) {
230
		} elseif ($resultat) {
232
			if ((count($this->ressources)) != 0) {
231
			if ((count($this->ressources)) != 0) {
233
				//$Atraiter = array_filter($resultat[0],function($var){return ($var != '');});
232
				//$Atraiter = array_filter($resultat[0],function($var){return ($var != '');});
234
				foreach ($resultat[0] as $champs => $valeur) {
233
				foreach ($resultat[0] as $champs => $valeur) {
235
					if ($valeur !== '') {
234
					if ($valeur !== '') {
236
						$Atraiter[$champs] = $valeur;
235
						$Atraiter[$champs] = $valeur;
237
					}
236
					}
238
				}
237
				}
239
				if (!empty($Atraiter)) {
238
				if (!empty($Atraiter)) {
240
					$this->traiterValeursEcologiques($Atraiter);
239
					$this->traiterValeursEcologiques($Atraiter);
241
					$svg = $this->genererSVG();
240
					$svg = $this->genererSVG($this->cheminGraphBase.$this->nomGraphique.".svg");
242
					$resultat = new ResultatService();
241
					$resultat = new ResultatService();
243
					$resultat->corps = ($this->parametres['retour'] == 'image/png') ? $this->convertirEnPNG($svg) : $svg;
242
					$resultat->corps = ($this->parametres['retour'] == 'image/png') ? $this->convertirEnPNG($svg) : $svg;
244
					$resultat->mime = $this->parametres['retour'];
243
					$resultat->mime = $this->parametres['retour'];
Line 290... Line 289...
290
		$svg->setAttribute('width',round($this->largeurSVG).'px');
289
		$svg->setAttribute('width',round($this->largeurSVG).'px');
291
		$svg->setAttribute('height',round($this->hauteurSVG).'px');
290
		$svg->setAttribute('height',round($this->hauteurSVG).'px');
Line 292... Line 291...
292
 
291
 
Line 293... Line 292...
293
	}
292
	}
294
 
293
 
295
	public function genererSVG(){
294
	public function genererSVG($fichierSvg){
296
		$svg = null;
295
		$svg = null;
297
		$this->dom = new DOMDocument('1.0', 'UTF-8');
-
 
298
		$this->dom->validateOnParse = true;
296
		$this->dom = new DOMDocument('1.0', 'UTF-8');
299
		$fichierSvg = $this->cheminGraphBase."".$this->nomGraphique.".svg";
297
		$this->dom->validateOnParse = true;
300
		$this->dom->load($fichierSvg);
298
		$this->dom->load($fichierSvg);
301
		$this->changerValeursSVG();
-
 
302
		$svg = $this->dom->saveXML();
299
		$this->changerValeursSVG();
Line 303... Line 300...
303
		return $svg;
300
		return $this->dom->saveXML();
Line 304... Line 301...
304
	}
301
	}