Subversion Repositories eFlore/Applications.coel-consultation

Compare Revisions

Ignore whitespace Rev 179 → Rev 180

/trunk/bibliotheque/dao/RechercheDao.php
6,6 → 6,7
* @package Collection
* @category php5
* @author aurelien <aurelien@tela-botanica.org>
* @author mathias <mathias@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
14,35 → 15,81
*/
class RechercheDao extends Dao {
const SERVICE = 'CoelRecherche';
/**
* Recherche une collection en fonction de paramêtres
* @return array un tableau contenant des objets d'informations sur les collections
*/
public function chercherStructureNbre($parametres) {
$url = $this->construireUrlRecherche('Nombre', $parametres, false);
$json = $this->envoyerRequeteConsultation($url);
$donnees = json_decode($json);
 
/** @deprecated retro-compatibilité */
public function chercherStructureNbre($parametres) {
return $this->chercherCollectionsNbre($parametres);
}
/** @deprecated retro-compatibilité */
public function chercher($parametres) {
return $this->chercherCollections($parametres);
}
 
// recherche du nombre de collections : nouveau
public function chercherCollectionsNbre($parametres) {
$url = $this->construireUrlRechercheCollections('NombreCollections', $parametres, false);
$json = $this->envoyerRequeteConsultation($url);
$donnees = json_decode($json, true);
 
return $donnees;
}
/**
* Recherche une collection en fonction de paramêtres
* @return array un tableau contenant des objets d'informations sur les collections
*/
public function chercher($parametres) {
$url = $this->construireUrlRecherche('ParDefaut', $parametres);
 
// recherche du nombre de personnes : nouveau
public function chercherPersonnesNbre($parametres) {
$url = $this->construireUrlRecherchePersonnes('NombrePersonnes', $parametres, false);
$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('mots', 'sci', 'bot', 'zg', 'p', 'pr', 'str-d', 'veg', 'projets');
foreach ($params_a_passer as $param_cle) {
}
 
// recherche de collections : nouveau
public function chercherCollections($parametres) {
$url = $this->construireUrlRechercheCollections('Collections', $parametres);
$json = $this->envoyerRequeteConsultation($url);
$donnees = json_decode($json, true);
 
return $donnees;
}
 
// recherche de personnes : nouveau
public function chercherPersonnes($parametres) {
$url = $this->construireUrlRecherchePersonnes('Personnes', $parametres);
$json = $this->envoyerRequeteConsultation($url);
$donnees = json_decode($json, true);
 
return $donnees;
}
 
// construit l'URL du service CoelRecherche pour obtenir des collections
// Attention au nombre et à l'ordre des paramètres !
private function construireUrlRechercheCollections($type, $parametres, $limitation = true) {
return $this->construireUrlRecherche(
$type,
$parametres,
$limitation,
array('mots', 'sci', 'bot', 'lieu-stockage', 'zg', 'p', 'pr', 'str-d', 'veg', 'projets')
);
}
 
// construit l'URL du service CoelRecherche pour obtenir des personnes
// Attention au nombre et à l'ordre des paramètres !
private function construireUrlRecherchePersonnes($type, $parametres, $limitation = true) {
return $this->construireUrlRecherche(
$type,
$parametres,
$limitation,
array('nom-famille', 'adresse', 'date-vivant')
);
}
 
// fabrique une URL pour le service CoelRecherche en collant les paramètres fournis (sinon "*")
// dans l'ordre attendu par le service demandé ($type)
private function construireUrlRecherche($type, $parametres, $limitation, $paramsAPasser) {
 
$url = $this->url_jrest . self::SERVICE . '/' . $type;
 
foreach ($paramsAPasser as $param_cle) {
if (isset($parametres[$param_cle]) && $parametres[$param_cle] != '') {
$valeur = urlencode(trim($parametres[$param_cle]));
$url .= '/'.$valeur;