Subversion Repositories Applications.referentiel

Rev

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

Rev 232 Rev 235
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 Référentiels.
4
 * Modèle d'accès à la base de données des Référentiels.
5
 * Permet d'accèder au méta-données des référentiels.
5
 * Permet d'accèder au méta-données des référentiels.
6
 *
6
 *
7
 * @package	Referentiel
7
 * @package	Referentiel
8
 * @category	Php 5.2
8
 * @category	Php 5.2
9
 * @author		Delphine CAUQUIL <delphine@tela-botanica.org>
9
 * @author		Delphine CAUQUIL <delphine@tela-botanica.org>
10
 * @author		aurelien <aurelien@tela-botanica.org>
10
 * @author		aurelien <aurelien@tela-botanica.org>
11
 * @copyright	2010 Tela-Botanica
11
 * @copyright	2010 Tela-Botanica
12
 * @license	http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
12
 * @license	http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
13
 * @license	http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
13
 * @license	http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
14
 * @version	SVN: $Id$
14
 * @version	SVN: $Id$
15
 *
15
 *
16
 */
16
 */
17
class RechercheDao extends Dao {
17
class RechercheDao extends Dao {
18
	const SERVICE = 'Recherche';
18
	const SERVICE = 'Recherche';
19
	
19
	
20
	/**
20
	/**
21
	 * Recherche un référentiel en fonction de paramètres
21
	 * Recherche un référentiel en fonction de paramètres
22
	 * @return le nombre de résultats répondant à la requête
22
	 * @return le nombre de résultats répondant à la requête
23
	 */
23
	 */
24
   public function chercherStructureNbre($type, $parametres) {
24
   public function chercherStructureNbre($type, $parametres) {
25
		$url = $this->construireUrlRecherche($type, $parametres, false);
25
		$url = $this->construireUrlRecherche($type, $parametres, false);
26
		$json = $this->envoyerRequeteConsultation($url);
26
		$json = $this->envoyerRequeteConsultation($url);
27
		$donnees = json_decode($json);
27
		$donnees = json_decode($json);
28
		return $donnees;
28
		return $donnees;
29
	}
29
	}
30
	
30
	
31
	/**
31
	/**
32
	 * Recherche un référentiel en fonction de paramêtres
32
	 * Recherche un référentiel en fonction de paramêtres
33
	 * @return array un tableau contenant des objets d'informations sur les taxons
33
	 * @return array un tableau contenant des objets d'informations sur les taxons
34
	 */
34
	 */
35
   public function chercher($type, $parametres) {
35
   public function chercher($type, $parametres) {
36
   		$this->ordre['nom_sci'] = 'ASC';
36
   		$this->ordre['nom_sci'] = 'ASC';
37
		$url = $this->construireUrlRecherche($type, $parametres);		
37
		$url = $this->construireUrlRecherche($type, $parametres);
38
   		$json = $this->envoyerRequeteConsultation($url);
38
   		$json = $this->envoyerRequeteConsultation($url);
39
   		$donnees = json_decode($json, true);		
39
   		$donnees = json_decode($json, true);
40
		return $donnees;
40
		return $donnees;
41
   }
41
   }
42
   
42
   
43
   private function construireUrlRecherche($type, $parametres, $limitation = true) {
43
   private function construireUrlRecherche($type, $parametres, $limitation = true) {
44
   		$url = $this->url_jrest.self::SERVICE.'/'.$type;
44
   		$url = $this->url_jrest.self::SERVICE.'/'.$type;
45
		
45
		
46
		$params_a_passer = array('ref', 'mots', 'sg', 'gen', 'sp', 'ssp', 'au', 'an', 'nn', 'bib', 'nr', 'tax');
46
		$params_a_passer = array('ref', 'mots', 'sg', 'gen', 'sp', 'ssp', 'au', 'an', 'nn', 'bib', 'nr', 'tax', 'pre', 'taxref');
47
		foreach ($params_a_passer as $param_cle) {
47
		foreach ($params_a_passer as $param_cle) {
48
			if (isset($parametres[$param_cle]) && $parametres[$param_cle] != '') {
48
			if (isset($parametres[$param_cle]) && $parametres[$param_cle] != '') {
49
				$valeur = urlencode(trim($parametres[$param_cle]));
49
				$valeur = urlencode(trim($parametres[$param_cle]));
50
				$url .= '/'.$valeur;
50
				$url .= '/'.$valeur;
51
			} else {
51
			} else {
52
				$url .= '/*';
52
				$url .= '/*';
53
			}
53
			}
54
		}
54
		}
55
		return $url;
55
		return $url;
56
   }
56
   }
57
}
57
}
58
?>
58
?>