/trunk/services/modules/0.1/commun/Commun.php |
---|
562,5 → 562,24 |
imagefill($img, 0, 0, $blanc); |
imagepng($img, $fichierPng, 9, PNG_ALL_FILTERS); |
} |
//+------------------------------------------------------------------------------------------------------+ |
// Fonctions appelées par plusieurs web services |
public function obtenirNumNomTaxonsSuperieurs($nn_demande) { |
$nn_taxons_sup = array(); |
// TODO: ceci ramène trop de champs alors que l'on a besoin que du numéro nomenclatural |
// et il y a peut-être un meilleur moyen que ramener la hierarchie des taxons supérieurs |
// mais pour le moment ça marche et c'est assez rapide |
$url = $this->ajouterHrefAutreProjet('taxons', $nn_demande, '/relations/superieurs',Config::get('referentiel')); |
$classification = $this->consulterHref($url); |
$classification = is_object($classification) ? get_object_vars($classification) : array(); |
if(isset($classification[$nn_demande])) { |
$classification_nn_demande = get_object_vars($classification[$nn_demande]); |
$tab_nn_demandes = array_keys($classification_nn_demande); |
$nn_taxons_sup = $tab_nn_demandes; |
} |
return $nn_taxons_sup; |
} |
} |
?> |
/trunk/services/modules/0.1/liste-rouge/Categorie.php |
---|
New file |
0,0 → 1,69 |
<?php |
// declare(encoding='UTF-8'); |
/** |
* Classe implémentant l'API d'eFlore concernant les statuts de protection |
* |
* @see http://www.tela-botanica.org/wikini/eflore/wakka.php?wiki=EfloreApi01ListeRouge |
* |
* @package eFlore/services |
* @author Aurélien PERONNET <aurelien@tela-botanica.org> |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt> |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt> |
* @version 1.0 |
* @copyright 1999-2011 Tela Botanica (accueil@tela-botanica.org) |
*/ |
class Categorie extends Commun { |
protected $parametres = array(); |
protected $ressources = array(); |
private $bdd; |
public function __construct($config = null) { |
$this->config = $config; |
$this->bdd = $this->getBdd(); |
} |
public function consulter($ressources, $parametres) { |
$this->parametres = $parametres; |
$this->ressources = $ressources; |
$this->verifierParametres(); |
$resultat = new ResultatService(); |
$resultat->corps = $this->obtenirCategorieListeRouge(); |
return $resultat; |
} |
private function verifierParametres() { |
$erreurs = array(); |
if (empty($this->parametres['masque.nn'])) { |
$erreurs[] = 'renseignez une valeur pour masque.nn'; |
} |
if(!is_numeric($this->parametres['masque.nn'])) { |
$erreurs[] = 'la valeur pour masque.nn doit être un entier'; |
} |
if (count($erreurs) > 0) { |
$message = implode('<br />', $erreurs); |
$code = RestServeur::HTTP_CODE_MAUVAISE_REQUETE; |
throw new Exception($message, $code); |
} |
} |
public function obtenirCategorieListeRouge() { |
$nn = $this->parametres['masque.nn']; |
$nns = $this->obtenirNumNomTaxonsSuperieurs($nn); |
$nns[] = $nn; |
$nns = array_map(array($this->bdd, 'proteger') ,$nns); |
$requete = "SELECT * FROM ".Config::get('bdd_table_liste_rouge').' '. |
"WHERE num_nom_retenu IN (".implode(',',$nns).") "; |
return $this->bdd->recupererTous($requete); |
} |
} |
/trunk/services/modules/0.1/sptb/Statuts.php |
---|
99,25 → 99,7 |
$statuts = $this->bdd->recuperer($requete); |
$statuts = $this->formaterRetour($statuts); |
return $statuts; |
} |
private function obtenirNumNomTaxonsSuperieurs($nn_demande) { |
$nn_taxons_sup = array(); |
// TODO: ceci ramène trop de champs alors que l'on a besoin que du numéro nomenclatural |
// et il y a peut-être un meilleur moyen que ramener la hierarchie des taxons supérieurs |
// mais pour le moment ça marche et c'est assez rapide |
$url = $this->ajouterHrefAutreProjet('taxons', $nn_demande, '/relations/superieurs',Config::get('referentiel')); |
$classification = $this->consulterHref($url); |
$classification = is_object($classification) ? get_object_vars($classification) : array(); |
if(isset($classification[$nn_demande])) { |
$classification_nn_demande = get_object_vars($classification[$nn_demande]); |
$tab_nn_demandes = array_keys($classification_nn_demande); |
$nn_taxons_sup = array_map(array($this->bdd,'proteger'), $tab_nn_demandes); |
} |
return $nn_taxons_sup; |
} |
} |
//+---------------------------FONCTIONS DE FORMATAGE---------------------------------------------------------+ |
private function formaterRetour($statuts_taxon) { |
/trunk/services/modules/0.1/sptba/Statuts.php |
---|
99,25 → 99,7 |
$statuts = $this->bdd->recuperer($requete); |
$statuts = $this->formaterRetour($statuts); |
return $statuts; |
} |
private function obtenirNumNomTaxonsSuperieurs($nn_demande) { |
$nn_taxons_sup = array(); |
// TODO: ceci ramène trop de champs alors que l'on a besoin que du numéro nomenclatural |
// et il y a peut-être un meilleur moyen que ramener la hierarchie des taxons supérieurs |
// mais pour le moment ça marche et c'est assez rapide |
$url = $this->ajouterHrefAutreProjet('taxons', $nn_demande, '/relations/superieurs',Config::get('referentiel')); |
$classification = $this->consulterHref($url); |
$classification = is_object($classification) ? get_object_vars($classification) : array(); |
if(isset($classification[$nn_demande])) { |
$classification_nn_demande = get_object_vars($classification[$nn_demande]); |
$tab_nn_demandes = array_keys($classification_nn_demande); |
$nn_taxons_sup = array_map(array($this->bdd,'proteger'), $tab_nn_demandes); |
} |
return $nn_taxons_sup; |
} |
} |
//+---------------------------FONCTIONS DE FORMATAGE---------------------------------------------------------+ |
private function formaterRetour($statuts_taxon) { |