* @author aurelien * @copyright 2010 Tela-Botanica * @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL * @license http://www.gnu.org/licenses/gpl.html Licence GNU-GPL * @version SVN: $Id$ * */ class RechercheDao extends Dao { const SERVICE = 'Recherche'; /** * Recherche un référentiel en fonction de paramètres * @return le nombre de résultats répondant à la requête */ public function chercherStructureNbre($type, $parametres) { $url = $this->construireUrlRecherche($type, $parametres, false); $json = $this->envoyerRequeteConsultation($url); $donnees = json_decode($json); return $donnees; } /** * Recherche un référentiel en fonction de paramètres * @return array un tableau contenant des objets d'informations sur les taxons */ public function chercher($type, $parametres, $limit = '150') { $this->ordre['nom_sci'] = 'ASC'; $this->limite_nbre = $limit; $url = $this->construireUrlRecherche($type, $parametres); $json = $this->envoyerRequeteConsultation($url); $donnees = json_decode($json, true); return $donnees; } private function construireUrlRecherche($type, $parametres, $limitation = true) { $url = $this->url_jrest.self::SERVICE.'/'.$type; $params_a_passer = array('ref', 'mots', 'sg', 'gen', 'sp', 'ssp', 'au', 'an', 'nn', 'bib', 'nr', 'tax', 'pre', 'taxref', 'classif', 'rg'); foreach ($params_a_passer as $param_cle) { if (isset($parametres[$param_cle]) && $parametres[$param_cle] != '') { $valeur = urlencode(trim($parametres[$param_cle])); $url .= '/'.$valeur; } else { $url .= '/*'; } } return $url; } } ?>