Subversion Repositories eFlore/Applications.del

Rev

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

Rev 1795 Rev 1881
Line 18... Line 18...
18
class PlantNet extends RestService {
18
class PlantNet extends RestService {
Line 19... Line 19...
19
 
19
 
20
	private $parametres = array();
20
	private $parametres = array();
21
	private $ressources = array();
21
	private $ressources = array();
22
	private $methode = null;
22
	private $methode = null;
23
	private $projetNom = array();
23
	private $projetNom = 'plantnet';
24
	private $serviceNom = array();
24
	private $serviceNom = 'changements';
Line 25... Line 25...
25
	private $cheminCourant = null;
25
	private $cheminCourant = null;
Line 26... Line 26...
26
 
26
 
Line 33... Line 33...
33
		$this->cheminCourant = dirname(__FILE__).DS;
33
		$this->cheminCourant = dirname(__FILE__).DS;
34
	}
34
	}
Line 35... Line 35...
35
 
35
 
36
	public function consulter($ressources, $parametres) {
36
	public function consulter($ressources, $parametres) {
37
		$this->methode = 'consulter';
-
 
38
		$resultat = '';
37
		$this->methode = 'consulter';
39
		$reponseHttp = new ReponseHttp();
38
		$reponseHttp = new ReponseHttp();
40
		try {
39
		try {
41
                        $this->ressources = $ressources;
40
			$this->ressources = $ressources;
42
                        $this->parametres = $parametres;
-
 
Line 43... Line 41...
43
 
41
			$this->parametres = $parametres;
Line 44... Line -...
44
 
-
 
45
			$this->conteneur = new Conteneur($this->parametres);
-
 
46
 
-
 
47
                        $this->projetNom = 'plantnet';
-
 
48
                        $this->serviceNom = 'changements';
-
 
49
 
-
 
50
                        // init projet
-
 
51
                        $projet = $this->projetNom;
-
 
52
                        $chemin = Config::get('chemin_configurations')."config_$projet.ini";
42
 
53
                        Config::charger($chemin);
-
 
54
 
43
			$this->conteneur = new Conteneur($this->parametres);
55
                        $resultat = $this->initialiserService();
-
 
56
 
44
 
57
			$reponseHttp->setResultatService($resultat);
45
			$resultat = $this->initialiserService();
58
 
46
			$reponseHttp->setResultatService($resultat);
59
		} catch (Exception $e) {
47
		} catch (Exception $e) {
60
			$reponseHttp->ajouterErreur($e);
48
			$reponseHttp->ajouterErreur($e);
61
		}
-
 
62
		$reponseHttp->emettreLesEntetes();
49
		}
Line 63... Line -...
63
		$corps = $reponseHttp->getCorps();
-
 
64
		return $corps;
-
 
65
	}
-
 
66
 
-
 
67
 
50
		$reponseHttp->emettreLesEntetes();
68
 
51
		return $reponseHttp->getCorps();
69
 
52
	}
70
 
-
 
71
	/*------------------------------------------------------------------------------------------------------------------
-
 
72
								CONFIGURATION DU SERVICE
-
 
73
	------------------------------------------------------------------------------------------------------------------*/
53
 
74
 
-
 
75
 
54
	/*------------------------------------------------------------------------------------------------------------------
76
 
55
								CONFIGURATION DU SERVICE
77
	private function initialiserService() {
56
	------------------------------------------------------------------------------------------------------------------*/
78
 
57
	private function initialiserService() {
79
		$classe = $this->obtenirNomClasseService($this->serviceNom);
58
		$classe = $this->obtenirNomClasseService($this->serviceNom);
80
		$chemins = array();
59
		$chemins = array();
81
		$chemins[] = $this->cheminCourant.$this->projetNom.DS.$classe.'.php';
60
		$chemins[] = $this->cheminCourant.$this->projetNom.DS.$classe.'.php';
82
		$retour = '';
-
 
83
		$service = null;
-
 
84
		foreach ($chemins as $chemin) {
-
 
85
                  if (file_exists($chemin)) {
61
		$retour = '';
86
 
-
 
87
 
62
		$service = null;
88
                    $this->conteneur->chargerConfiguration('config_'.$this->projetNom.'.ini');
63
		foreach ($chemins as $chemin) {
89
                    require_once $chemin;
64
			if (file_exists($chemin)) {
90
 
-
 
91
                    $service = new $classe($this->conteneur);
65
				require_once $chemin;
Line 92... Line 66...
92
                    $retour = $service->consulter($this->ressources, $this->parametres);
66
				$service = new $classe($this->conteneur);
93
 
67
				$retour = $service->consulter($this->ressources, $this->parametres);
94
                  }
68
			}
Line 104... Line 78...
104
 
78
 
105
	private function obtenirNomClasseService($mot) {
79
	private function obtenirNomClasseService($mot) {
106
		$classeNom = str_replace(' ', '', ucwords(strtolower(str_replace('-', ' ', $mot))));
80
		$classeNom = str_replace(' ', '', ucwords(strtolower(str_replace('-', ' ', $mot))));
107
		return $classeNom;
81
		return $classeNom;
108
	}
-
 
109
}
-
 
110
?>
82
	}
-
 
83
}
111
84