| Line 25... |
Line 25... |
| 25 |
protected $total_resultat = null;
|
25 |
protected $total_resultat = null;
|
| 26 |
/** Stocke le service appelé correspondant. Est utilisé principalement lors de l'affichage du href d'un synonyme
|
26 |
/** Stocke le service appelé correspondant. Est utilisé principalement lors de l'affichage du href d'un synonyme
|
| 27 |
(ex id=12, basionyme num 25 est un synonyme) dans le service taxon */
|
27 |
(ex id=12, basionyme num 25 est un synonyme) dans le service taxon */
|
| 28 |
protected $service_href = null;
|
28 |
protected $service_href = null;
|
| 29 |
protected $erreursParametres = null;
|
29 |
protected $erreursParametres = null;
|
| - |
|
30 |
protected $sans_nom_sci = array('gen','sp','ssp','fam','au_ss','bib_ss');
|
| - |
|
31 |
private $bib_traitees = array();
|
| Line 30... |
Line 32... |
| 30 |
|
32 |
|
| Line 31... |
Line 33... |
| 31 |
//+------------------------------- PARAMÈTRES ---------------------------------------------------------------+
|
33 |
//+------------------------------- PARAMÈTRES ---------------------------------------------------------------+
|
| 32 |
|
34 |
|
| Line 37... |
Line 39... |
| 37 |
if (isset($this->parametres) && count($this->parametres) > 0) {
|
39 |
if (isset($this->parametres) && count($this->parametres) > 0) {
|
| 38 |
foreach ($this->parametres as $param => $val) {
|
40 |
foreach ($this->parametres as $param => $val) {
|
| 39 |
switch ($param) {
|
41 |
switch ($param) {
|
| 40 |
case 'ns.structure' :
|
42 |
case 'ns.structure' :
|
| 41 |
$this->remplirTableCompositionNom($val);
|
43 |
$this->remplirTableCompositionNom($val);
|
| - |
|
44 |
if (in_array($val,$this->sans_nom_sci)){
|
| - |
|
45 |
$this->requete_champ = implode(', ',$this->compo_nom);
|
| - |
|
46 |
}else {
|
| 42 |
$this->requete_champ .= ' ,'.implode(', ',$this->compo_nom);
|
47 |
$this->requete_champ .= ' ,'.implode(', ',$this->compo_nom);
|
| - |
|
48 |
}
|
| 43 |
break;
|
49 |
break;
|
| 44 |
case 'navigation.depart' :
|
50 |
case 'navigation.depart' :
|
| 45 |
$this->limite_requete['depart'] = $val;
|
51 |
$this->limite_requete['depart'] = $val;
|
| 46 |
break;
|
52 |
break;
|
| 47 |
case 'navigation.limite' :
|
53 |
case 'navigation.limite' :
|
| Line 61... |
Line 67... |
| 61 |
$this->parametres['ns.format'] = 'txt';
|
67 |
$this->parametres['ns.format'] = 'txt';
|
| 62 |
}
|
68 |
}
|
| 63 |
if (empty($this->parametres['retour.format'])) {
|
69 |
if (empty($this->parametres['retour.format'])) {
|
| 64 |
$this->parametres['retour.format'] = 'max';
|
70 |
$this->parametres['retour.format'] = 'max';
|
| 65 |
}
|
71 |
}
|
| 66 |
if (empty($this->parametres['ns.structure'])) {
|
72 |
if (empty($this->parametres['ns.structure']) &&
|
| - |
|
73 |
$this->parametres['retour.format'] != 'oss') {
|
| 67 |
$this->parametres['ns.structure'] = 'au,an,bib';
|
74 |
$this->parametres['ns.structure'] = 'au,an,bib';
|
| 68 |
}
|
75 |
}
|
| 69 |
}
|
76 |
}
|
| - |
|
77 |
|
| 70 |
|
78 |
|
| 71 |
public function verifierParametres() {
|
79 |
public function verifierParametres() {
|
| 72 |
$this->verifierParametresAPI();
|
80 |
$this->verifierParametresAPI();
|
| Line 73... |
Line 81... |
| 73 |
|
81 |
|
| 74 |
$this->verifierParametre('recherche', 'stricte|floue|etendue');
|
82 |
$this->verifierParametre('recherche', 'stricte|floue|etendue');
|
| 75 |
$this->verifierParametre('ns.format', 'htm|txt');
|
83 |
$this->verifierParametre('ns.format', 'htm|txt');
|
| 76 |
$this->verifierParametre('retour.format', 'min|max|oss|perso');
|
84 |
$this->verifierParametre('retour.format', 'min|max|oss|perso');
|
| Line 77... |
Line 85... |
| 77 |
$this->verifierParametreAvecValeurMultipe('ns.structure', 'an|au|bib|ad');
|
85 |
$this->verifierParametreAvecValeurMultipe('ns.structure', 'an|au|bib|ad|gen|sp|ssp|fam|au_ss|bib_ss');
|
| 78 |
|
86 |
|
| 79 |
if (count($this->erreursParametres) > 0) {
|
87 |
if (count($this->erreursParametres) > 0) {
|
| 80 |
$m = 'Erreur dans votre requête : '.implode('<br/>', $this->erreursParametres);
|
88 |
$m = 'Erreur dans votre requête : '.implode('<br/>', $this->erreursParametres);
|
| Line 118... |
Line 126... |
| 118 |
public function traiterParametresCommuns() {
|
126 |
public function traiterParametresCommuns() {
|
| Line 119... |
Line 127... |
| 119 |
|
127 |
|
| Line 120... |
Line 128... |
| 120 |
}
|
128 |
}
|
| - |
|
129 |
|
| - |
|
130 |
public function ajouterFiltreMasque($nom_champ, $valeur) {
|
| 121 |
|
131 |
$valeur = explode(',',$valeur);
|
| - |
|
132 |
$conditions = array();
|
| 122 |
public function ajouterFiltreMasque($nom_champ, $valeur) {
|
133 |
if ($nom_champ == 'annee' || $nom_champ == 'rang') {
|
| - |
|
134 |
foreach ($valeur as $val) {
|
| 123 |
if ($nom_champ == 'annee' || $nom_champ == 'rang') {
|
135 |
$conditions[] = "$nom_champ = ".$this->getBdd()->proteger($val);
|
| 124 |
$this->requete_condition []= "$nom_champ = ".$this->getBdd()->proteger($valeur);
|
136 |
}
|
| - |
|
137 |
} else {
|
| 125 |
} else {
|
138 |
if ($this->parametres['recherche'] == 'etendue') {
|
| 126 |
if ($this->parametres['recherche'] == 'etendue') {
|
139 |
foreach ($valeur as $val) {
|
| - |
|
140 |
$val = $this->modifierValeur($val);
|
| - |
|
141 |
$conditions[] = "$nom_champ LIKE ".$this->getBdd()->proteger($val);
|
| 127 |
$valeur = $this->modifierValeur($valeur);
|
142 |
}
|
| - |
|
143 |
|
| 128 |
$this->requete_condition[] = "$nom_champ LIKE ".$this->getBdd()->proteger($valeur);
|
144 |
} elseif ($this->parametres['recherche'] == 'floue') {
|
| 129 |
} elseif ($this->parametres['recherche'] == 'floue') {
|
145 |
foreach ($valeur as $val) {
|
| 130 |
$valeur = $this->getBdd()->proteger($valeur);
|
146 |
$val = $this->getBdd()->proteger($val);
|
| - |
|
147 |
$conditions[] = "( SOUNDEX($nom_champ) = SOUNDEX($val))".
|
| 131 |
$this->requete_condition[] = "( SOUNDEX($nom_champ) = SOUNDEX($valeur))".
|
148 |
" OR ( SOUNDEX(REVERSE($nom_champ)) = SOUNDEX(REVERSE($val)))";
|
| - |
|
149 |
}
|
| 132 |
" OR ( SOUNDEX(REVERSE($nom_champ)) = SOUNDEX(REVERSE($valeur)))";
|
150 |
} else {
|
| - |
|
151 |
foreach ($valeur as $val) {
|
| 133 |
} else {
|
152 |
$conditions[] = "$nom_champ LIKE ".$this->getBdd()->proteger($val);
|
| 134 |
$this->requete_condition[] = "$nom_champ LIKE ".$this->getBdd()->proteger($valeur);
|
153 |
}
|
| - |
|
154 |
}
|
| 135 |
}
|
155 |
}
|
| 136 |
}
|
156 |
$this->requete_condition[]= '('.implode(' OR ', $conditions ).')';
|
| Line 137... |
Line 157... |
| 137 |
$this->masque[$nom_champ] = "$nom_champ=$valeur";
|
157 |
$this->masque[$nom_champ] = "$nom_champ=$valeur";
|
| 138 |
}
|
158 |
}
|
| Line 221... |
Line 241... |
| 221 |
/** Permet de remplir le tableau compo_nom. Il comprendra en fct du paramètre ns.structure les éléments à rajouter
|
241 |
/** Permet de remplir le tableau compo_nom. Il comprendra en fct du paramètre ns.structure les éléments à rajouter
|
| 222 |
* au nom_sci (annee, auteur, biblio ou addendum). */
|
242 |
* au nom_sci (annee, auteur, biblio ou addendum). */
|
| 223 |
public function remplirTableCompositionNom($valeur) {
|
243 |
public function remplirTableCompositionNom($valeur) {
|
| 224 |
$structure_nom = explode(',', $valeur);
|
244 |
$structure_nom = explode(',', $valeur);
|
| 225 |
foreach ($structure_nom as $structure) {
|
245 |
foreach ($structure_nom as $structure) {
|
| - |
|
246 |
//avec str_replace() 'sp' est inclu dans 'ssp', et la conversion pour 'ssp' est mauvaise
|
| - |
|
247 |
$this->compo_nom[$structure] =
|
| 226 |
$this->compo_nom[$structure] = str_replace(array('an', 'au', 'bib', 'ad'),
|
248 |
preg_replace(array('/^an$/', '/^au$/', '/^bib$/', '/^ad$/',
|
| - |
|
249 |
'/^sp$/', '/^gen$/', '/^ssp$/','/^fam$/','/^au_ss$/','/^bib_ss$/'),
|
| 227 |
array('annee', 'auteur', 'biblio_origine', 'nom_addendum'), $structure);
|
250 |
array('annee', 'auteur', 'biblio_origine', 'nom_addendum',
|
| - |
|
251 |
'epithete_sp', 'genre', 'epithete_infra_sp','famille','auteur', 'biblio_origine'),
|
| - |
|
252 |
$structure);
|
| 228 |
}
|
253 |
}
|
| 229 |
}
|
254 |
}
|
| Line 230... |
Line 255... |
| 230 |
|
255 |
|
| 231 |
public function mettreAuFormat() {
|
256 |
public function mettreAuFormat() {
|
| 232 |
if ($this->parametres['ns.format'] == 'htm') {
|
257 |
if ($this->parametres['ns.format'] == 'htm') {
|
| Line 265... |
Line 290... |
| 265 |
$oss = '';
|
290 |
$oss = '';
|
| 266 |
foreach ($resultat as $tab) {
|
291 |
foreach ($resultat as $tab) {
|
| 267 |
if (isset($tab['nom_sci']) ) {
|
292 |
if (isset($tab['nom_sci']) ) {
|
| 268 |
if (!in_array($tab['nom_sci'], $table_nom)) {
|
293 |
if (!in_array($tab['nom_sci'], $table_nom)) {
|
| 269 |
$table_nom[] = $tab['nom_sci'];
|
294 |
$table_nom[] = $tab['nom_sci'];
|
| 270 |
$oss [] = $tab['nom_sci'].$this->ajouterCompositionNom($tab);
|
295 |
$oss[] = $tab['nom_sci'].' '.$this->ajouterCompositionNom($tab);
|
| - |
|
296 |
}
|
| - |
|
297 |
}else {
|
| - |
|
298 |
$res = $this->ajouterCompositionNom($tab);
|
| - |
|
299 |
if($res) {
|
| - |
|
300 |
$oss[] = $res;
|
| 271 |
}
|
301 |
}
|
| 272 |
}
|
302 |
}
|
| - |
|
303 |
|
| 273 |
}
|
304 |
}
|
| - |
|
305 |
|
| 274 |
if (isset($this->masque)) $masque = implode('&', $this->masque);
|
306 |
if (isset($this->masque)) $masque = implode('&', $this->masque);
|
| 275 |
else $masque = 'Pas de masque';
|
307 |
else $masque = 'Pas de masque';
|
| 276 |
$table_retour_oss = array($masque, $oss);
|
308 |
$table_retour_oss = array($masque, $oss);
|
| 277 |
return $table_retour_oss;
|
309 |
return $table_retour_oss;
|
| 278 |
}
|
310 |
}
|
| Line 532... |
Line 564... |
| 532 |
|
564 |
|
| 533 |
public function afficherDonnees($champApi, $valeur) {
|
565 |
public function afficherDonnees($champApi, $valeur) {
|
| 534 |
$champBdd = $this->trouverChampBddCorrespondant($champApi);
|
566 |
$champBdd = $this->trouverChampBddCorrespondant($champApi);
|
| 535 |
if ($this->parametres['retour.format'] == 'min') {
|
567 |
if ($this->parametres['retour.format'] == 'min') {
|
| 536 |
if ($champApi == 'nom_sci') {
|
568 |
if ($champApi == 'nom_sci') {
|
| 537 |
$valeur = $valeur.$this->ajouterCompositionNom($this->resultat_req);
|
569 |
$valeur = $valeur.' '.$this->ajouterCompositionNom($this->resultat_req);
|
| 538 |
}
|
570 |
}
|
| 539 |
if ($champApi == 'nom_sci_html') {
|
571 |
if ($champApi == 'nom_sci_html') {
|
| 540 |
$valeur = $valeur.$this->ajouterCompositionNom($this->resultat_req, 'htm');
|
572 |
$valeur = $valeur.' '.$this->ajouterCompositionNom($this->resultat_req, 'htm');
|
| 541 |
}
|
573 |
}
|
| 542 |
$this->table_retour[$champBdd] = $valeur;
|
574 |
$this->table_retour[$champBdd] = $valeur;
|
| 543 |
} else {
|
575 |
} else {
|
| 544 |
$this->afficherToutesLesInfos($champBdd, $valeur);
|
576 |
$this->afficherToutesLesInfos($champBdd, $valeur);
|
| Line 571... |
Line 603... |
| 571 |
preg_match('/^([^.]+)(?:\.code)?$/', $nom_champ_api, $match);
|
603 |
preg_match('/^([^.]+)(?:\.code)?$/', $nom_champ_api, $match);
|
| 572 |
$this->afficherInfosPrecises($match[1], 'code,signification,href', $valeur);
|
604 |
$this->afficherInfosPrecises($match[1], 'code,signification,href', $valeur);
|
| Line 573... |
Line 605... |
| 573 |
|
605 |
|
| 574 |
} elseif ($nom_champ_api == 'nom_sci_html') {
|
606 |
} elseif ($nom_champ_api == 'nom_sci_html') {
|
| 575 |
$this->table_retour['nom_sci_html'] = $valeur;
|
607 |
$this->table_retour['nom_sci_html'] = $valeur;
|
| 576 |
$this->table_retour['nom_sci_html_complet'] = $valeur.$this->ajouterCompositionNom($this->resultat_req, 'htm');
|
608 |
$this->table_retour['nom_sci_html_complet'] = $valeur.' '.$this->ajouterCompositionNom($this->resultat_req, 'htm');
|
| 577 |
}elseif ($nom_champ_api != 'nom_sci') {
|
609 |
}elseif ($nom_champ_api != 'nom_sci') {
|
| 578 |
$this->table_retour[$nom_champ_api] = $valeur;
|
610 |
$this->table_retour[$nom_champ_api] = $valeur;
|
| 579 |
}
|
611 |
}
|
| Line 719... |
Line 751... |
| 719 |
}
|
751 |
}
|
| 720 |
$res = $this->getBdd()->recuperer($req);
|
752 |
$res = $this->getBdd()->recuperer($req);
|
| 721 |
if ($res) {
|
753 |
if ($res) {
|
| 722 |
$nom['nom_sci'] = $res['nom_sci'];
|
754 |
$nom['nom_sci'] = $res['nom_sci'];
|
| 723 |
$nom['nom_sci_html'] = $res['nom_sci_html'];
|
755 |
$nom['nom_sci_html'] = $res['nom_sci_html'];
|
| 724 |
$nom['nom_sci_complet'] = $res['nom_sci'].$this->ajouterCompositionNom($res);
|
756 |
$nom['nom_sci_complet'] = $res['nom_sci'].' '.$this->ajouterCompositionNom($res);
|
| 725 |
$nom['nom_sci_complet_html'] = $res['nom_sci_html'].$this->ajouterCompositionNom($res, 'htm');
|
757 |
$nom['nom_sci_complet_html'] = $res['nom_sci_html'].' '.$this->ajouterCompositionNom($res, 'htm');
|
| 726 |
$nom['service'] = ($res['num_nom_retenu'] == $id && $this->service == 'taxons') ? 'taxons' : 'noms';
|
758 |
$nom['service'] = ($res['num_nom_retenu'] == $id && $this->service == 'taxons') ? 'taxons' : 'noms';
|
| 727 |
}
|
759 |
}
|
| 728 |
}
|
760 |
}
|
| 729 |
return $nom;
|
761 |
return $nom;
|
| 730 |
}
|
762 |
}
|
| Line 731... |
Line 763... |
| 731 |
|
763 |
|
| 732 |
/** Permet de retourner une chaine de caractère composée des parametres du nom (ns.structure : annnée, auteur,
|
764 |
/** Permet de retourner une chaine de caractère composée des parametres du nom (ns.structure : annnée, auteur,
|
| 733 |
* bibilio et addendum). A ajouter au nom scientifique */
|
765 |
* bibilio et addendum). A ajouter au nom scientifique */
|
| 734 |
public function ajouterCompositionNom($tab_res, $format = '') {
|
766 |
public function ajouterCompositionNom($tab_res, $format = '') {
|
| - |
|
767 |
$format = ($format == '') ? $this->parametres['ns.format'] : $format;
|
| 735 |
$format = ($format == '') ? $this->parametres['ns.format'] : $format;
|
768 |
|
| 736 |
$nom = '';
|
769 |
$nom = '';
|
| 737 |
if (isset($this->compo_nom)) {
|
770 |
if (isset($this->compo_nom)) {
|
| 738 |
if ($format == 'htm') {
|
771 |
if ($format == 'htm') {
|
| 739 |
$format = array(
|
772 |
$format = array(
|
| Line 746... |
Line 779... |
| 746 |
$format = array(
|
779 |
$format = array(
|
| 747 |
'au' => '%s',
|
780 |
'au' => '%s',
|
| 748 |
'an' => '[%s]',
|
781 |
'an' => '[%s]',
|
| 749 |
'an_bib' => '[%s, %s]',
|
782 |
'an_bib' => '[%s, %s]',
|
| 750 |
'bib' => '[%s]',
|
783 |
'bib' => '[%s]',
|
| 751 |
'ad' => '[%s]');
|
784 |
'ad' => '[%s]',
|
| - |
|
785 |
'gen' => '%s',
|
| - |
|
786 |
'sp' => '%s',
|
| - |
|
787 |
'ssp' => '%s',
|
| - |
|
788 |
'fam' => '%s',
|
| - |
|
789 |
'au_ss' => '%s',
|
| - |
|
790 |
'bib_ss' => '%s');
|
| 752 |
}
|
791 |
}
|
| 753 |
$compo_nom = array();
|
792 |
$compo_nom = array();
|
| - |
|
793 |
|
| 754 |
foreach ($this->compo_nom as $key => $champ) {
|
794 |
foreach ($this->compo_nom as $key => $champ) {
|
| 755 |
if (isset($tab_res[$champ]) && !empty($tab_res[$champ])) {
|
795 |
if (isset($tab_res[$champ]) && !empty($tab_res[$champ])) {
|
| 756 |
$compo_nom[$key] = $tab_res[$champ];
|
796 |
$compo_nom[$key] = $tab_res[$champ];
|
| 757 |
}
|
797 |
}
|
| 758 |
}
|
798 |
}
|
| 759 |
$nom_complet = $this->formerNomComplet($compo_nom, $format);
|
799 |
$nom_complet = $this->formerNomComplet($compo_nom, $format);
|
| 760 |
$nom = ' '.implode(' ', $nom_complet);
|
800 |
$nom = implode(' ', $nom_complet);
|
| 761 |
}
|
801 |
}
|
| 762 |
return rtrim($nom, ' ');
|
802 |
return rtrim($nom, ' ');
|
| 763 |
}
|
803 |
}
|
| Line 775... |
Line 815... |
| 775 |
}
|
815 |
}
|
| 776 |
} elseif (isset($bib)) {
|
816 |
} elseif (isset($bib)) {
|
| 777 |
$nom_complet[] = sprintf($format['bib'], $bib);
|
817 |
$nom_complet[] = sprintf($format['bib'], $bib);
|
| 778 |
}
|
818 |
}
|
| 779 |
if (isset($ad)) $nom_complet[] = sprintf($format['ad'], $ad);
|
819 |
if (isset($ad)) $nom_complet[] = sprintf($format['ad'], $ad);
|
| - |
|
820 |
if (isset($gen)) $nom_complet[] = sprintf($format['gen'], $gen);
|
| - |
|
821 |
if (isset($ssp)) $nom_complet[] = sprintf($format['ssp'], $ssp);
|
| - |
|
822 |
if (isset($sp)) $nom_complet[] = sprintf($format['sp'], $sp);
|
| - |
|
823 |
if (isset($fam)) $nom_complet[] = sprintf($format['fam'], $fam);
|
| - |
|
824 |
if (isset($au_ss)) $nom_complet[] = sprintf($format['au_ss'], $au_ss);
|
| - |
|
825 |
if (isset($bib_ss)) {
|
| - |
|
826 |
$bibl = $this->tronquerBiblio($bib_ss);
|
| - |
|
827 |
//simule un 'select distinct' sur les biblio tronquées
|
| - |
|
828 |
if (!isset($this->bib_traitees[$bibl])) {
|
| - |
|
829 |
$nom_complet[] = sprintf($format['bib_ss'],$bibl );
|
| - |
|
830 |
$this->bib_traitees[$bibl] = 1;
|
| - |
|
831 |
}
|
| - |
|
832 |
}
|
| 780 |
return $nom_complet;
|
833 |
return $nom_complet;
|
| 781 |
}
|
834 |
}
|
| Line -... |
Line 835... |
| - |
|
835 |
|
| - |
|
836 |
public function tronquerBiblio($valeur){
|
| - |
|
837 |
$bib = strstr($valeur,',', true);
|
| - |
|
838 |
if(strpos($bib,';')) {
|
| - |
|
839 |
$bib = strstr($bib,';');
|
| - |
|
840 |
$bib = str_replace('; ','',$bib);
|
| - |
|
841 |
}
|
| - |
|
842 |
return $bib;
|
| - |
|
843 |
}
|
| - |
|
844 |
|
| Line 782... |
Line 845... |
| 782 |
|
845 |
|
| 783 |
|
846 |
|
| 784 |
public function correspondAUnCode($key) {
|
847 |
public function correspondAUnCode($key) {
|