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) {
|
1145 |
raphael |
32 |
return $this->chargerDonnees($this->getUrlNom($nn));
|
291 |
jpm |
33 |
}
|
370 |
aurelien |
34 |
|
291 |
jpm |
35 |
|
165 |
delphine |
36 |
public function getRechercheEtendue($nom, $type_resultat = '') {
|
|
|
37 |
$methode = 'getUrlRecherche'.$type_resultat;
|
731 |
mathilde |
38 |
|
165 |
delphine |
39 |
if (method_exists($this, $methode)) {
|
|
|
40 |
$url = $this->$methode($nom, 'etendue');
|
|
|
41 |
} else {
|
|
|
42 |
$url = $this->getUrlRecherche($nom, 'etendue');
|
|
|
43 |
Debug::printr("Le type de recherche demandé '$type_resultat' n'est pas disponible.");
|
|
|
44 |
}
|
133 |
jpm |
45 |
return $this->chargerDonneesRecursivement($url);
|
53 |
delphine |
46 |
}
|
133 |
jpm |
47 |
|
53 |
delphine |
48 |
public function getRechercheFloue($nom) {
|
|
|
49 |
$url = $this->getUrlRecherche($nom, 'floue');
|
|
|
50 |
return $this->chargerDonnees($url);
|
|
|
51 |
}
|
731 |
mathilde |
52 |
|
|
|
53 |
public function getRechercheAvancee($parametres) {
|
|
|
54 |
$url = $this->getUrlRechercheAvancee($parametres);
|
|
|
55 |
return $this->chargerDonnees($url);
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
private function getUrlRechercheAvancee($parametres){
|
998 |
aurelien |
59 |
$tpl = Config::get('nomsRechercheAvanceeTpl');
|
|
|
60 |
$masques = $this->formaterMasquesRechercheAvancee($parametres);
|
|
|
61 |
$url = '';
|
|
|
62 |
if($masques != ''){
|
|
|
63 |
$url = $this->formaterUrl($tpl,array('projet'=> $this->getProjet(), 'type' => 'etendue'));
|
|
|
64 |
$url .= '&'.implode('&',$masques);
|
|
|
65 |
}
|
|
|
66 |
return $url;
|
731 |
mathilde |
67 |
}
|
|
|
68 |
|
|
|
69 |
private function formaterMasquesRechercheAvancee($parametres) {
|
|
|
70 |
$masques = '';
|
|
|
71 |
foreach ($parametres as $masque => $valeur){
|
|
|
72 |
if ($valeur != '' && in_array($valeur, I18n::get('Recherche-form-avancee')) == false){
|
|
|
73 |
if ($masque == 'type') {
|
|
|
74 |
$masques[] = 'masque='.urlencode('%'.$valeur);
|
|
|
75 |
} elseif ($masque == 'au') {
|
|
|
76 |
$masques[] = 'masque.au='.urlencode($valeur.',('.$valeur.'%),% '.$valeur);
|
|
|
77 |
} elseif ($masque == 'bib'){
|
|
|
78 |
$masques[] = 'masque.bib='.urlencode($valeur.',%; '.$valeur);
|
|
|
79 |
} else {
|
|
|
80 |
$valeur = ($valeur == '0') ? '' : $valeur;
|
|
|
81 |
$masques[] = 'masque.'.$masque.'='.urlencode($valeur);
|
|
|
82 |
}
|
|
|
83 |
}
|
|
|
84 |
}
|
|
|
85 |
return $masques;
|
|
|
86 |
}
|
|
|
87 |
|
291 |
jpm |
88 |
private function getUrlNom($nn) {
|
|
|
89 |
$tpl = Config::get('nomTpl');
|
|
|
90 |
$params = array('id' => $nn);
|
|
|
91 |
$url = $this->formaterUrl($tpl, $params);
|
|
|
92 |
return $url;
|
|
|
93 |
}
|
|
|
94 |
|
165 |
delphine |
95 |
// retourne les champs par defaut
|
53 |
delphine |
96 |
private function getUrlRecherche($nom, $typeRech) {
|
|
|
97 |
$tpl = Config::get('nomsRechercheTpl');
|
60 |
jpm |
98 |
$params = array('valeur' => $nom, 'type' => $typeRech);
|
53 |
delphine |
99 |
$url = $this->formaterUrl($tpl, $params);
|
|
|
100 |
return $url;
|
731 |
mathilde |
101 |
|
53 |
delphine |
102 |
}
|
291 |
jpm |
103 |
|
169 |
delphine |
104 |
// retourne les champs par defaut
|
|
|
105 |
private function getUrlRechercheAlphab($nom, $typeRech) {
|
|
|
106 |
$tpl = Config::get('nomsRechercheAlphabTpl');
|
|
|
107 |
$params = array('valeur' => $nom, 'type' => $typeRech);
|
|
|
108 |
$url = $this->formaterUrl($tpl, $params);
|
|
|
109 |
return $url;
|
|
|
110 |
}
|
291 |
jpm |
111 |
|
169 |
delphine |
112 |
// retourne les champs par defaut
|
|
|
113 |
private function getUrlRechercheRetenu($nom, $typeRech) {
|
|
|
114 |
$tpl = Config::get('nomsRechercheRetenuTpl');
|
|
|
115 |
$params = array('valeur' => $nom, 'type' => $typeRech);
|
|
|
116 |
$url = $this->formaterUrl($tpl, $params);
|
|
|
117 |
return $url;
|
|
|
118 |
}
|
291 |
jpm |
119 |
|
169 |
delphine |
120 |
private function getUrlRechercheSynonyme($nom, $typeRech) {
|
|
|
121 |
$tpl = Config::get('nomsRechercheSynonymeTpl');
|
|
|
122 |
$params = array('valeur' => $nom, 'type' => $typeRech);
|
|
|
123 |
$url = $this->formaterUrl($tpl, $params);
|
|
|
124 |
return $url;
|
|
|
125 |
}
|
291 |
jpm |
126 |
|
165 |
delphine |
127 |
// retourne les champs par defaut + nom retenu
|
|
|
128 |
private function getUrlRechercheDetermination($nom, $typeRech) {
|
|
|
129 |
$tpl = Config::get('nomsRechercheDeterminationTpl');
|
|
|
130 |
$params = array('valeur' => $nom, 'type' => $typeRech);
|
|
|
131 |
$url = $this->formaterUrl($tpl, $params);
|
|
|
132 |
return $url;
|
|
|
133 |
}
|
291 |
jpm |
134 |
|
165 |
delphine |
135 |
// retourne les champs par defaut + nom decompose (au, an et bib)
|
|
|
136 |
private function getUrlRechercheDecompo($nom, $typeRech) {
|
|
|
137 |
$tpl = Config::get('nomsRechercheDecompoTpl');
|
|
|
138 |
$params = array('valeur' => $nom, 'type' => $typeRech);
|
|
|
139 |
$url = $this->formaterUrl($tpl, $params);
|
|
|
140 |
return $url;
|
|
|
141 |
}
|
731 |
mathilde |
142 |
|
44 |
jpm |
143 |
}
|
|
|
144 |
?>
|