Subversion Repositories eFlore/Applications.coel-consultation

Rev

Rev 19 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 19 Rev 20
Line 7... Line 7...
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 19 2010-03-24 18:22:25Z jpm $
12
 * @version		SVN: $Id: RechercheDao.php 20 2010-03-29 17:28:43Z jpm $
13
 *
13
 *
14
 */
14
 */
15
class RechercheDao extends ColModele {
15
class RechercheDao extends ColModele {
16
	const SERVICE = 'CoelRecherche';
16
	const SERVICE = 'CoelRecherche';
Line 17... Line 17...
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) {
-
 
23
		$mots = urlencode($parametres['mots']);
22
   public function chercherStructureNbre($parametres) {
-
 
23
		$url = $this->construireUrlRecherche('Nombre', $parametres, false);
24
   		$url = $this->url_jrest.self::SERVICE."/Nombre/$mots";
24
		
25
   		$json = file_get_contents($url);
25
   		$json = file_get_contents($url);
26
		$donnees = json_decode($json);
26
		$donnees = json_decode($json);
27
		return $donnees;
27
		return $donnees;
Line 28... Line 28...
28
	}
28
	}
29
	
29
	
30
	/**
30
	/**
31
	 * Recherche une collection en fonction de paramêtres
31
	 * Recherche une collection en fonction de paramêtres
32
	 * @return array un tableau contenant des objets d'informations sur les collections
32
	 * @return array un tableau contenant des objets d'informations sur les collections
33
	 */
-
 
34
   public function chercher($parametres) {
33
	 */
35
		$mots = urlencode($parametres['mots']);
34
   public function chercher($parametres) {
36
   		$url = $this->url_jrest.self::SERVICE."/ParDefaut/$mots";
35
		$url = $this->construireUrlRecherche('ParDefaut', $parametres);
37
		$url .= ($this->avoirLimitation() ? "?start={$this->getLimiteDebut()}&limit={$this->getLimiteNbre()}" : '');
36
		Debug::printr($url);
38
   		$json = file_get_contents($url);
37
   		$json = file_get_contents($url);
39
		$donnees = json_decode($json, true);
38
		$donnees = json_decode($json, true);
-
 
39
		return $donnees;
-
 
40
   }
-
 
41
   
-
 
42
   private function construireUrlRecherche($type, $parametres, $limitation = true) {
-
 
43
   		$url = $this->url_jrest.self::SERVICE.'/'.$type;
-
 
44
		
-
 
45
		$params_a_passer = array('mots', 'sci', 'bot', 'zg', 'p', 'pr');
-
 
46
		foreach ($params_a_passer as $param_cle) {
-
 
47
			if (isset($parametres[$param_cle]) && $parametres[$param_cle] != '') {
-
 
48
				$valeur = urlencode($parametres[$param_cle]);
-
 
49
				$url .= '/'.$valeur;
-
 
50
			} else {
-
 
51
				$url .= '/*';
-
 
52
			}
-
 
53
		}	
-
 
54
		
-
 
55
		if ($limitation) {
-
 
56
			$url .= ($this->avoirLimitation() ? "?start={$this->getLimiteDebut()}&limit={$this->getLimiteNbre()}" : '');
-
 
57
			$url .= "&distinct={$this->getDistinction()}";
-
 
58
		} else {
-
 
59
			$url .= "?distinct={$this->getDistinction()}";
-
 
60
		}
-
 
61
		
40
		return $donnees;
62
		return $url;
41
   }
63
   }
42
}
64
}