Subversion Repositories eFlore/Applications.coel-consultation

Rev

Rev 147 | Rev 172 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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