Subversion Repositories eFlore/Applications.coel-consultation

Compare Revisions

No changes between revisions

Ignore whitespace Rev 187 → Rev 188

/branches/v1.7-hermitage/bibliotheque/dao/RechercheDao.php
New file
0,0 → 1,103
<?php
// declare(encoding='UTF-8');
/**
* Modèle d'accès à la base de données des Collections pour la Recherche
*
* @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
* @version SVN: $Id$
*
*/
class RechercheDao extends Dao {
const SERVICE = 'CoelRecherche';
 
/** @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 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;
}
 
// 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;
} else {
$url .= '/*';
}
}
return $url;
}
}
?>
Property changes:
Added: svn:keywords
+Id Author Date Revision HeadURL
\ No newline at end of property