Subversion Repositories eFlore/Applications.del

Rev

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

Rev 813 Rev 1795
Line 1... Line 1...
1
<?php
1
<?php
2
/**
2
/**
3
* Description :
-
 
4
* Classe principale de chargement des services d'eFlore.
3
 * Classe principale de chargement des sous-services de Protocoles.
5
*
4
 *
6
* Encodage en entrée : utf8
5
 * @category   DEL
7
* Encodage en sortie : utf8
6
 * @package    Services
8
* @package eflore-projets
7
 * @subpackage Protocoles
-
 
8
 * @version    0.1
9
* @author Jennifer DHÉ <jennifer.dhe@tela-botanica.org>
9
 * @author     Mathias CHOUET <mathias@tela-botanica.org>
10
* @author Delphine CAUQUIL <delphine@tela-botanica.org>
10
 * @author     Jean-Pascal MILCENT <jpm@tela-botanica.org>
11
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
11
 * @author     Aurelien PERONNET <aurelien@tela-botanica.org>
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
-
 
15
* @copyright 1999-2011 Tela Botanica (accueil@tela-botanica.org)
14
 * @copyright  1999-2014 Tela Botanica <accueil@tela-botanica.org>
16
*/
15
 */
17
class Protocoles extends RestService {
16
class Protocoles extends RestService {
Line 18... Line 17...
18
 
17
 
19
	
18
 
20
	/*
19
	/*
21
	* url possibles :
20
	* url possibles :
22
	* http://localhost/del/services/0.1/observations/ => toutes les observations (infos obs, infos images, infos propositions, infos nb commentaires)
21
	* http://localhost/del/services/0.1/observations/ => toutes les observations (infos obs, infos images, infos propositions, infos nb commentaires)
23
	* http://localhost/del/services/0.1/observations/#id => une observation donnée et ses images, SANS LES propositions & nombre de commentaire
22
	* http://localhost/del/services/0.1/observations/#id => une observation donnée et ses images, SANS LES propositions & nombre de commentaire
24
	* */
23
	* */
25
	
24
 
26
	private $parametres = array();
25
	private $parametres = array();
27
	private $ressources = array();
26
	private $ressources = array();
28
	private $methode = null;
27
	private $methode = null;
29
	private $projetNom = array();
28
	private $projetNom = array();
30
	private $serviceNom = array();
29
	private $serviceNom = array();
Line 31... Line 30...
31
	private $cheminCourant = null;
30
	private $cheminCourant = null;
32
 
31
 
33
	private $conteneur;
32
	private $conteneur;
34
	
33
 
Line 35... Line 34...
35
	/** Indique si oui (true) ou non (false), on veut utiliser les paramètres bruts. */
34
	/** Indique si oui (true) ou non (false), on veut utiliser les paramètres bruts. */
36
	protected $utilisationParametresBruts = true;
35
	protected $utilisationParametresBruts = true;
Line 53... Line 52...
53
		}
52
		}
54
		$reponseHttp->emettreLesEntetes();
53
		$reponseHttp->emettreLesEntetes();
55
		$corps = $reponseHttp->getCorps();
54
		$corps = $reponseHttp->getCorps();
56
		return $corps;
55
		return $corps;
57
	}
56
	}
58
	
57
 
59
	public function ajouter($ressources, $requeteDonnees) {
58
	public function ajouter($ressources, $requeteDonnees) {
60
		$this->methode = 'ajouter';
59
		$this->methode = 'ajouter';
61
		$resultat = '';
60
		$resultat = '';
62
		try {
61
		try {
63
			$this->initialiserRessourcesEtParametres($ressources, $requeteDonnees);
62
			$this->initialiserRessourcesEtParametres($ressources, $requeteDonnees);
Line 79... Line 78...
79
		if ($this->avoirRessourceService()) {
78
		if ($this->avoirRessourceService()) {
80
			$retour = $this->initialiserService();
79
			$retour = $this->initialiserService();
81
		}
80
		}
82
		return $retour;
81
		return $retour;
83
	}
82
	}
84
	
83
 
85
	private function avoirRessourceIdentifiant($num) {
84
	private function avoirRessourceIdentifiant($num) {
86
		$presenceId = false;
85
		$presenceId = false;
87
			if (is_numeric($this->ressources[$num])) {
86
			if (is_numeric($this->ressources[$num])) {
88
				$presenceId = true;
87
				$presenceId = true;
89
			} else {
88
			} else {
Line 129... Line 128...
129
					$this->serviceNom = 'observation';
128
					$this->serviceNom = 'observation';
130
				} else {
129
				} else {
131
					if (isset($this->ressources[1])) {
130
					if (isset($this->ressources[1])) {
132
						$presenceRessourceService = $this->avoirRessourceSousService();
131
						$presenceRessourceService = $this->avoirRessourceSousService();
133
					}
132
					}
134
				} 
133
				}
135
			} 
134
			}
136
		} else {
135
		} else {
137
			$presenceRessourceService = true;
136
			$presenceRessourceService = true;
138
			$this->serviceNom = 'liste-protocoles';
137
			$this->serviceNom = 'liste-protocoles';
139
		}
138
		}
140
		return $presenceRessourceService;
139
		return $presenceRessourceService;
141
	}
140
	}
142
	
141
 
143
	private function avoirRessourceSousService() {
142
	private function avoirRessourceSousService() {
144
		$presenceRessourceService = false;
143
		$presenceRessourceService = false;
145
		$servicesDispo = Outils::recupererTableauConfig('servicesDispo');
144
		$servicesDispo = Outils::recupererTableauConfig('servicesDispo');
146
		if ($this->avoirRessourceIdentifiant(1)) {
145
		if ($this->avoirRessourceIdentifiant(1)) {
147
			$service = $this->ressources[2];
146
			$service = $this->ressources[2];
Line 158... Line 157...
158
		return $presenceRessourceService;
157
		return $presenceRessourceService;
159
	}
158
	}
Line 160... Line 159...
160
 
159
 
161
	private function initialiserService() {
160
	private function initialiserService() {
162
		//$this->chargerNomDuService();
161
		//$this->chargerNomDuService();
163
		
162
 
164
		$classe = $this->obtenirNomClasseService($this->serviceNom);
163
		$classe = $this->obtenirNomClasseService($this->serviceNom);
165
		$chemins = array();
164
		$chemins = array();
166
		$chemins[] = $this->cheminCourant.$this->projetNom.DS.$classe.'.php';
165
		$chemins[] = $this->cheminCourant.$this->projetNom.DS.$classe.'.php';
167
		$chemins[] = $this->cheminCourant.'commun'.DS.$classe.'.php';
166
		$chemins[] = $this->cheminCourant.'commun'.DS.$classe.'.php';
Line 177... Line 176...
177
				} elseif ($this->methode == 'ajouter') {
176
				} elseif ($this->methode == 'ajouter') {
178
					$retour = $service->ajouter($this->ressources, $this->parametres);
177
					$retour = $service->ajouter($this->ressources, $this->parametres);
179
				}
178
				}
180
			}
179
			}
181
		}
180
		}
182
		
181
 
183
		if (is_null($service)) {
182
		if (is_null($service)) {
184
			$message = "Le service demandé '{$this->serviceNom}' n'existe pas dans le projet {$this->projetNom} !";
183
			$message = "Le service demandé '{$this->serviceNom}' n'existe pas dans le projet {$this->projetNom} !";
185
			$code = RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE;
184
			$code = RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE;
186
			throw new Exception($message, $code);
185
			throw new Exception($message, $code);
187
		}
186
		}