New file |
0,0 → 1,57 |
<?php |
// declare(encoding='UTF-8'); |
/** |
* Modèle d'accès à la base de données des Référentiels. |
* Permet d'accèder au méta-données des référentiels. |
* |
* @package Referentiel |
* @category Php 5.2 |
* @author Delphine CAUQUIL <delphine@tela-botanica.org> |
* @author aurelien <aurelien@tela-botanica.org> |
* @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) { |
$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'); |
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; |
} |
} |
?> |