Subversion Repositories eFlore/Applications.del

Rev

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

Rev 702 Rev 718
Line 12... Line 12...
12
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
12
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
13
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
13
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
14
* @version 0.1
14
* @version 0.1
15
* @copyright 1999-2011 Tela Botanica (accueil@tela-botanica.org)
15
* @copyright 1999-2011 Tela Botanica (accueil@tela-botanica.org)
16
*/
16
*/
17
class Projets extends RestService {
17
class Del extends RestService {
Line 18... Line -...
18
 
-
 
19
	/** Contients les paramètres.*/
18
 
20
	private $parametres = array();
-
 
21
	/** Contients les ressources.*/
19
	private $parametres = array();
22
	private $ressources = array();
-
 
23
 
-
 
24
	/** Nom du projet courrant. */
20
	private $ressources = array();
25
	private $projetNom = array();
-
 
26
	/** Nom du service demandé. */
21
	private $projetNom = array();
27
	private $serviceNom = array();
22
	private $serviceNom = array();
-
 
23
	private $cheminCourant = null;
28
	/** Chemin vers le dossier courrant. */
24
 
-
 
25
	private $conteneur;
29
	private $cheminCourrant = null;
26
	
30
	/** Indique si oui (true) ou non (false), on veut utiliser les paramètres brutes. */
27
	/** Indique si oui (true) ou non (false), on veut utiliser les paramètres bruts. */
Line 31... Line 28...
31
	protected $utilisationParametresBruts = true;
28
	protected $utilisationParametresBruts = true;
32
 
29
 
33
	public function __construct() {
-
 
34
		$this->cheminCourrant = dirname(__FILE__).DS;
30
	public function __construct() {
Line 35... Line 31...
35
		
31
		$this->cheminCourant = dirname(__FILE__).DS;
-
 
32
	}
36
	}
33
 
37
 
34
	public function consulter($ressources, $parametres) {
38
	public function consulter($ressources, $parametres) {
35
		
39
		$resultat = '';
36
		$resultat = '';
-
 
37
		$reponseHttp = new ReponseHttp();
40
		$reponseHttp = new ReponseHttp();
38
		try {
41
		try {
39
			$this->initialiserRessourcesEtParametres($ressources, $parametres);
42
			$this->initialiserRessourcesEtParametres($ressources, $parametres);
40
			$this->conteneur = new Conteneur($this->parametres);
43
			$resultat = $this->traiterRessources();
41
			$resultat = $this->traiterRessources();
44
			$reponseHttp->setResultatService($resultat);
42
			$reponseHttp->setResultatService($resultat);
Line 59... Line 57...
59
		$retour = '';
57
		$retour = '';
60
		if ($this->avoirRessources()) {
58
		if ($this->avoirRessources()) {
61
			if ($this->avoirRessourceProjet()) {
59
			if ($this->avoirRessourceProjet()) {
62
				$this->initialiserProjet();
60
				$this->initialiserProjet();
63
				if ($this->avoirRessourceService()) {
61
				if ($this->avoirRessourceService()) {
64
					
-
 
65
					$retour = $this->initialiserService();
62
					$retour = $this->initialiserService();
66
				}
63
				}
67
			}
64
			}
68
		}
65
		}
69
		return $retour;
66
		return $retour;
Line 124... Line 121...
124
			return null;
121
			return null;
125
		}
122
		}
Line 126... Line 123...
126
 
123
 
127
		$cheminBiblio = Config::get('chemin_bibliotheque');
124
		$cheminBiblio = Config::get('chemin_bibliotheque');
128
		$chemins = array();
125
		$chemins = array();
129
		$chemins[] = $this->cheminCourrant.$this->projetNom.DS;
126
		$chemins[] = $this->cheminCourant.$this->projetNom.DS;
130
		$chemins[] = $this->cheminCourrant.'commun'.DS;
127
		$chemins[] = $this->cheminCourant.'commun'.DS;
131
		$chemins[] = $cheminBiblio;
128
		$chemins[] = $cheminBiblio;
Line 132... Line 129...
132
		$chemins[] = $cheminBiblio.'robots'.DS;
129
		$chemins[] = $cheminBiblio.'robots'.DS;
133
 
130
 
Line 141... Line 138...
141
	}
138
	}
Line 142... Line 139...
142
 
139
 
143
	private function avoirRessourceService() {
140
	private function avoirRessourceService() {
144
		$presenceRessourceService = false;
141
		$presenceRessourceService = false;
-
 
142
		$servicesDispo = Outils::recupererTableauConfig('servicesDispo');
145
		$servicesDispo = Outils::recupererTableauConfig('servicesDispo');
143
	
146
		if (isset($this->ressources[1])) {
144
		if (isset($this->ressources[1])) {
147
			$service = $this->ressources[1];
145
			$service = $this->ressources[1];
148
			if (in_array($service, $servicesDispo)) {
146
			if (in_array($service, $servicesDispo)) {
149
				$presenceRessourceService = true;
147
				$presenceRessourceService = true;
Line 164... Line 162...
164
 
162
 
165
	private function initialiserService() {
163
	private function initialiserService() {
166
		$this->chargerNomDuService();
164
		$this->chargerNomDuService();
167
		$classe = $this->obtenirNomClasseService($this->serviceNom);
165
		$classe = $this->obtenirNomClasseService($this->serviceNom);
168
		$chemins = array();
166
		$chemins = array();
169
		$chemins[] = $this->cheminCourrant.$this->projetNom.DS.$classe.'.php';
167
		$chemins[] = $this->cheminCourant.$this->projetNom.DS.$classe.'.php';
Line 170... Line 168...
170
		$chemins[] = $this->cheminCourrant.'commun'.DS.$classe.'.php';
168
		$chemins[] = $this->cheminCourant.'commun'.DS.$classe.'.php';
171
 
169
 
172
		$retour = '';
170
		$retour = '';
173
		$service = null;
171
		$service = null;
-
 
172
		foreach ($chemins as $chemin) {
174
		foreach ($chemins as $chemin) {
173
			if (file_exists($chemin)) {
175
			if (file_exists($chemin)) {
174
				$this->conteneur->chargerConfiguration('config_'.$this->projetNom.'.ini');
176
				$service = new $classe($this->getBdd());
175
				$service = new $classe($this->conteneur, 'config_'.$this->projetNom.'.ini');
177
				$ressourcesPourService = $this->filtrerRessourcesPourService();
176
				$ressourcesPourService = $this->filtrerRessourcesPourService();
178
				$retour = $service->consulter($ressourcesPourService, $this->parametres);
177
				$retour = $service->consulter($ressourcesPourService, $this->parametres);
179
			}
178
			}