Subversion Repositories eFlore/Applications.coel-consultation

Rev

Rev 169 | Rev 180 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
7 jpm 1
<?php
2
// declare(encoding='UTF-8');
3
/**
4
 * Modèle d'accès à la base de données des Collections pour la Recherche
5
 *
6
 * @package		Collection
7
 * @category	php5
8
 * @author		aurelien <aurelien@tela-botanica.org>
9
 * @copyright	2010 Tela-Botanica
10
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
11
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
12
 * @version		SVN: $Id: RechercheDao.php 172 2011-03-15 14:59:57Z delphine $
13
 *
14
 */
147 jpm 15
class RechercheDao extends Dao {
19 jpm 16
	const SERVICE = 'CoelRecherche';
17
 
7 jpm 18
	/**
19
	 * Recherche une collection en fonction de paramêtres
20
	 * @return array un tableau contenant des objets d'informations sur les collections
21
	 */
22
   public function chercherStructureNbre($parametres) {
20 jpm 23
		$url = $this->construireUrlRecherche('Nombre', $parametres, false);
147 jpm 24
		$json = $this->envoyerRequeteConsultation($url);
19 jpm 25
		$donnees = json_decode($json);
26
		return $donnees;
7 jpm 27
	}
28
 
29
	/**
30
	 * Recherche une collection en fonction de paramêtres
31
	 * @return array un tableau contenant des objets d'informations sur les collections
32
	 */
33
   public function chercher($parametres) {
20 jpm 34
		$url = $this->construireUrlRecherche('ParDefaut', $parametres);
147 jpm 35
   		$json = $this->envoyerRequeteConsultation($url);
36
   		$donnees = json_decode($json, true);
37
 
7 jpm 38
		return $donnees;
19 jpm 39
   }
20 jpm 40
 
41
   private function construireUrlRecherche($type, $parametres, $limitation = true) {
42
   		$url = $this->url_jrest.self::SERVICE.'/'.$type;
43
 
169 jpm 44
		$params_a_passer = array('mots', 'sci', 'bot', 'zg', 'p', 'pr', 'str-d', 'veg', 'projets');
20 jpm 45
		foreach ($params_a_passer as $param_cle) {
46
			if (isset($parametres[$param_cle]) && $parametres[$param_cle] != '') {
21 jpm 47
				$valeur = urlencode(trim($parametres[$param_cle]));
20 jpm 48
				$url .= '/'.$valeur;
49
			} else {
50
				$url .= '/*';
51
			}
52
		}
53
		return $url;
54
   }
7 jpm 55
}
56
?>