Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 998 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
44 jpm 1
<?php
2
// declare(encoding='UTF-8');
3
/**
4
 * Classe gérant les noms scientifiques.
5
 *
6
 * @category	PHP 5.2
7
 * @package		eflore-consultation
8
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
9
 * @author		Delphine CAUQUIL <delphine@tela-botanica.org>
10
 * @copyright	2011 Tela-Botanica
11
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL-v3
12
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL-v2
13
 * @version		$Id$
14
 */
15
class Noms extends Eflore {
291 jpm 16
 
17
	public function getSynonymes($nn) {
283 delphine 18
		$tpl = Config::get('nomsSynonymesTpl');
291 jpm 19
		$params = array('id' => $nn);
283 delphine 20
		$url = $this->formaterUrl($tpl, $params);
21
		return $this->chargerDonnees($url);
22
	}
336 aurelien 23
 
24
	public function getFlores($nn) {
25
		$tpl = Config::get('nomsFloresTpl');
26
		$params = array('id' => $nn);
27
		$url = $this->formaterUrl($tpl, $params);
28
		return $this->chargerDonnees($url);
29
	}
291 jpm 30
 
31
	public function getNom($nn) {
32
		$url = $this->getUrlNom($nn);
33
		return $this->chargerDonnees($url);
34
	}
370 aurelien 35
 
291 jpm 36
 
165 delphine 37
	public function getRechercheEtendue($nom, $type_resultat = '') {
38
		$methode = 'getUrlRecherche'.$type_resultat;
731 mathilde 39
 
165 delphine 40
		if (method_exists($this, $methode)) {
41
			$url = $this->$methode($nom, 'etendue');
42
		} else {
43
			$url = $this->getUrlRecherche($nom, 'etendue');
44
			Debug::printr("Le type de recherche demandé '$type_resultat' n'est pas disponible.");
45
		}
133 jpm 46
		return $this->chargerDonneesRecursivement($url);
53 delphine 47
	}
133 jpm 48
 
53 delphine 49
	public function getRechercheFloue($nom) {
50
		$url = $this->getUrlRecherche($nom, 'floue');
51
		return $this->chargerDonnees($url);
52
	}
731 mathilde 53
 
54
	public function getRechercheAvancee($parametres) {
55
		$url = $this->getUrlRechercheAvancee($parametres);
56
		return $this->chargerDonnees($url);
57
	}
58
 
59
	private function getUrlRechercheAvancee($parametres){
998 aurelien 60
		$tpl = Config::get('nomsRechercheAvanceeTpl');
61
		$masques =  $this->formaterMasquesRechercheAvancee($parametres);
62
		$url = '';
63
		if($masques != ''){
64
			$url = $this->formaterUrl($tpl,array('projet'=> $this->getProjet(), 'type' => 'etendue'));
65
			$url .= '&'.implode('&',$masques);
66
		}
67
		return $url;
731 mathilde 68
	}
69
 
70
	private function formaterMasquesRechercheAvancee($parametres) {
71
		$masques = '';
72
		foreach ($parametres as $masque => $valeur){
73
			if ($valeur != '' && in_array($valeur, I18n::get('Recherche-form-avancee')) == false){
74
				if ($masque == 'type') {
75
					$masques[] = 'masque='.urlencode('%'.$valeur);
76
				} elseif ($masque == 'au') {
77
					$masques[] = 'masque.au='.urlencode($valeur.',('.$valeur.'%),% '.$valeur);
78
				} elseif ($masque == 'bib'){
79
					$masques[] = 'masque.bib='.urlencode($valeur.',%; '.$valeur);
80
				} else {
81
					$valeur = ($valeur == '0') ? '' : $valeur;
82
					$masques[] = 'masque.'.$masque.'='.urlencode($valeur);
83
				}
84
			}
85
		}
86
		return $masques;
87
	}
88
 
291 jpm 89
	private function getUrlNom($nn) {
90
		$tpl = Config::get('nomTpl');
91
		$params = array('id' => $nn);
92
		$url = $this->formaterUrl($tpl, $params);
93
		return $url;
94
	}
95
 
165 delphine 96
	// retourne les champs par defaut
53 delphine 97
	private function getUrlRecherche($nom, $typeRech) {
98
		$tpl = Config::get('nomsRechercheTpl');
60 jpm 99
		$params = array('valeur' => $nom, 'type' => $typeRech);
53 delphine 100
		$url = $this->formaterUrl($tpl, $params);
101
		return $url;
731 mathilde 102
 
53 delphine 103
	}
291 jpm 104
 
169 delphine 105
	// retourne les champs par defaut
106
	private function getUrlRechercheAlphab($nom, $typeRech) {
107
		$tpl = Config::get('nomsRechercheAlphabTpl');
108
		$params = array('valeur' => $nom, 'type' => $typeRech);
109
		$url = $this->formaterUrl($tpl, $params);
110
		return $url;
111
	}
291 jpm 112
 
169 delphine 113
	// retourne les champs par defaut
114
	private function getUrlRechercheRetenu($nom, $typeRech) {
115
		$tpl = Config::get('nomsRechercheRetenuTpl');
116
		$params = array('valeur' => $nom, 'type' => $typeRech);
117
		$url = $this->formaterUrl($tpl, $params);
118
		return $url;
119
	}
291 jpm 120
 
169 delphine 121
	private function getUrlRechercheSynonyme($nom, $typeRech) {
122
		$tpl = Config::get('nomsRechercheSynonymeTpl');
123
		$params = array('valeur' => $nom, 'type' => $typeRech);
124
		$url = $this->formaterUrl($tpl, $params);
125
		return $url;
126
	}
291 jpm 127
 
165 delphine 128
	// retourne les champs par defaut + nom retenu
129
	private function getUrlRechercheDetermination($nom, $typeRech) {
130
		$tpl = Config::get('nomsRechercheDeterminationTpl');
131
		$params = array('valeur' => $nom, 'type' => $typeRech);
132
		$url = $this->formaterUrl($tpl, $params);
133
		return $url;
134
	}
291 jpm 135
 
165 delphine 136
	// retourne les champs par defaut + nom decompose (au, an et bib)
137
	private function getUrlRechercheDecompo($nom, $typeRech) {
138
		$tpl = Config::get('nomsRechercheDecompoTpl');
139
		$params = array('valeur' => $nom, 'type' => $typeRech);
140
		$url = $this->formaterUrl($tpl, $params);
141
		return $url;
142
	}
731 mathilde 143
 
44 jpm 144
}
145
?>