14,8 → 14,18 |
* @version 0.1 |
* @copyright 1999-2011 Tela Botanica (accueil@tela-botanica.org) |
*/ |
class Del extends RestService { |
class Images extends RestService { |
|
|
/* |
* url possibles : |
* http://localhost/del/services/0.1/images/ => toutes les images, appel à la classe ListeImages |
* http://localhost/del/services/0.1/images/#id => une image donnée => non utilisé sur DEL pour l'instant |
* http://localhost/del/services/0.1/images/#id/votes/ => tous les votes d'une image classés par protocole |
* http://localhost/del/services/0.1/images/#id/votes/protocole/#id => tous les votes d'une image et d'un protocole donné |
* http://localhost/del/services/0.1/images/#id/votes/#id => un vote donné pour une image donnée. |
* */ |
|
private $parametres = array(); |
private $ressources = array(); |
private $projetNom = array(); |
56,12 → 66,12 |
private function traiterRessources() { |
$retour = ''; |
if ($this->avoirRessources()) { |
if ($this->avoirRessourceProjet()) { |
//if ($this->avoirRessourceProjet()) { |
$this->initialiserProjet(); |
if ($this->avoirRessourceService()) { |
$retour = $this->initialiserService(); |
} |
} |
//} |
} |
return $retour; |
} |
79,21 → 89,6 |
return $presenceDeRessources; |
} |
|
private function avoirRessourceProjet() { |
$presenceRessourceProjet = false; |
$projet = $this->ressources[0]; |
$projetsDispo = Outils::recupererTableauConfig('projetsDispo'); |
if (in_array($projet, $projetsDispo)) { |
$presenceRessourceProjet = true; |
} else { |
$message = "La ressource '$projet' n'indique pas un projet existant.\n". |
"Les projets existant sont :\n".implode(', ', $projetsDispo); |
$code = RestServeur::HTTP_CODE_MAUVAISE_REQUETE; |
throw new Exception($message, $code); |
} |
return $presenceRessourceProjet; |
} |
|
private function initialiserProjet() { |
$this->chargerNomDuProjet(); |
$this->chargerConfigProjet(); |
107,7 → 102,7 |
} |
|
private function chargerNomDuProjet() { |
$this->projetNom = $this->ressources[0]; |
$this->projetNom = 'images'; |
} |
|
private function chargerConfigProjet() { |
141,8 → 136,8 |
$presenceRessourceService = false; |
$servicesDispo = Outils::recupererTableauConfig('servicesDispo'); |
|
if (isset($this->ressources[1])) { |
$service = $this->ressources[1]; |
if (isset($this->ressources[0])) { |
$service = $this->ressources[0]; |
if (in_array($service, $servicesDispo)) { |
$presenceRessourceService = true; |
} else { |
162,6 → 157,7 |
|
private function initialiserService() { |
$this->chargerNomDuService(); |
|
$classe = $this->obtenirNomClasseService($this->serviceNom); |
$chemins = array(); |
$chemins[] = $this->cheminCourant.$this->projetNom.DS.$classe.'.php'; |
177,6 → 173,7 |
$retour = $service->consulter($ressourcesPourService, $this->parametres); |
} |
} |
|
if (is_null($service)) { |
$message = "La service demandé '{$this->serviceNom}' n'existe pas dans le projet {$this->projetNom} !"; |
$code = RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE; |
186,7 → 183,7 |
} |
|
private function chargerNomDuService() { |
$this->serviceNom = $this->ressources[1]; |
$this->serviceNom = $this->ressources[0]; |
} |
|
private function obtenirNomClasseService($mot) { |