27,6 → 27,8 |
(ex id=12, basionyme num 25 est un synonyme) dans le service taxon */ |
protected $service_href = null; |
protected $erreursParametres = null; |
protected $sans_nom_sci = array('gen','sp','ssp','fam','au_ss','bib_ss'); |
private $bib_traitees = array(); |
|
//+------------------------------- PARAMÈTRES ---------------------------------------------------------------+ |
|
39,7 → 41,11 |
switch ($param) { |
case 'ns.structure' : |
$this->remplirTableCompositionNom($val); |
if (in_array($val,$this->sans_nom_sci)){ |
$this->requete_champ = implode(', ',$this->compo_nom); |
}else { |
$this->requete_champ .= ' ,'.implode(', ',$this->compo_nom); |
} |
break; |
case 'navigation.depart' : |
$this->limite_requete['depart'] = $val; |
63,11 → 69,13 |
if (empty($this->parametres['retour.format'])) { |
$this->parametres['retour.format'] = 'max'; |
} |
if (empty($this->parametres['ns.structure'])) { |
if (empty($this->parametres['ns.structure']) && |
$this->parametres['retour.format'] != 'oss') { |
$this->parametres['ns.structure'] = 'au,an,bib'; |
} |
} |
|
|
public function verifierParametres() { |
$this->verifierParametresAPI(); |
|
74,7 → 82,7 |
$this->verifierParametre('recherche', 'stricte|floue|etendue'); |
$this->verifierParametre('ns.format', 'htm|txt'); |
$this->verifierParametre('retour.format', 'min|max|oss|perso'); |
$this->verifierParametreAvecValeurMultipe('ns.structure', 'an|au|bib|ad'); |
$this->verifierParametreAvecValeurMultipe('ns.structure', 'an|au|bib|ad|gen|sp|ssp|fam|au_ss|bib_ss'); |
|
if (count($this->erreursParametres) > 0) { |
$m = 'Erreur dans votre requête : '.implode('<br/>', $this->erreursParametres); |
120,20 → 128,32 |
} |
|
public function ajouterFiltreMasque($nom_champ, $valeur) { |
$valeur = explode(',',$valeur); |
$conditions = array(); |
if ($nom_champ == 'annee' || $nom_champ == 'rang') { |
$this->requete_condition []= "$nom_champ = ".$this->getBdd()->proteger($valeur); |
foreach ($valeur as $val) { |
$conditions[] = "$nom_champ = ".$this->getBdd()->proteger($val); |
} |
} else { |
if ($this->parametres['recherche'] == 'etendue') { |
$valeur = $this->modifierValeur($valeur); |
$this->requete_condition[] = "$nom_champ LIKE ".$this->getBdd()->proteger($valeur); |
foreach ($valeur as $val) { |
$val = $this->modifierValeur($val); |
$conditions[] = "$nom_champ LIKE ".$this->getBdd()->proteger($val); |
} |
|
} elseif ($this->parametres['recherche'] == 'floue') { |
$valeur = $this->getBdd()->proteger($valeur); |
$this->requete_condition[] = "( SOUNDEX($nom_champ) = SOUNDEX($valeur))". |
" OR ( SOUNDEX(REVERSE($nom_champ)) = SOUNDEX(REVERSE($valeur)))"; |
foreach ($valeur as $val) { |
$val = $this->getBdd()->proteger($val); |
$conditions[] = "( SOUNDEX($nom_champ) = SOUNDEX($val))". |
" OR ( SOUNDEX(REVERSE($nom_champ)) = SOUNDEX(REVERSE($val)))"; |
} |
} else { |
$this->requete_condition[] = "$nom_champ LIKE ".$this->getBdd()->proteger($valeur); |
foreach ($valeur as $val) { |
$conditions[] = "$nom_champ LIKE ".$this->getBdd()->proteger($val); |
} |
} |
} |
$this->requete_condition[]= '('.implode(' OR ', $conditions ).')'; |
$this->masque[$nom_champ] = "$nom_champ=$valeur"; |
} |
|
223,8 → 243,13 |
public function remplirTableCompositionNom($valeur) { |
$structure_nom = explode(',', $valeur); |
foreach ($structure_nom as $structure) { |
$this->compo_nom[$structure] = str_replace(array('an', 'au', 'bib', 'ad'), |
array('annee', 'auteur', 'biblio_origine', 'nom_addendum'), $structure); |
//avec str_replace() 'sp' est inclu dans 'ssp', et la conversion pour 'ssp' est mauvaise |
$this->compo_nom[$structure] = |
preg_replace(array('/^an$/', '/^au$/', '/^bib$/', '/^ad$/', |
'/^sp$/', '/^gen$/', '/^ssp$/','/^fam$/','/^au_ss$/','/^bib_ss$/'), |
array('annee', 'auteur', 'biblio_origine', 'nom_addendum', |
'epithete_sp', 'genre', 'epithete_infra_sp','famille','auteur', 'biblio_origine'), |
$structure); |
} |
} |
|
267,10 → 292,17 |
if (isset($tab['nom_sci']) ) { |
if (!in_array($tab['nom_sci'], $table_nom)) { |
$table_nom[] = $tab['nom_sci']; |
$oss [] = $tab['nom_sci'].$this->ajouterCompositionNom($tab); |
$oss[] = $tab['nom_sci'].' '.$this->ajouterCompositionNom($tab); |
} |
}else { |
$res = $this->ajouterCompositionNom($tab); |
if($res) { |
$oss[] = $res; |
} |
} |
|
} |
|
if (isset($this->masque)) $masque = implode('&', $this->masque); |
else $masque = 'Pas de masque'; |
$table_retour_oss = array($masque, $oss); |
534,10 → 566,10 |
$champBdd = $this->trouverChampBddCorrespondant($champApi); |
if ($this->parametres['retour.format'] == 'min') { |
if ($champApi == 'nom_sci') { |
$valeur = $valeur.$this->ajouterCompositionNom($this->resultat_req); |
$valeur = $valeur.' '.$this->ajouterCompositionNom($this->resultat_req); |
} |
if ($champApi == 'nom_sci_html') { |
$valeur = $valeur.$this->ajouterCompositionNom($this->resultat_req, 'htm'); |
$valeur = $valeur.' '.$this->ajouterCompositionNom($this->resultat_req, 'htm'); |
} |
$this->table_retour[$champBdd] = $valeur; |
} else { |
573,7 → 605,7 |
|
} elseif ($nom_champ_api == 'nom_sci_html') { |
$this->table_retour['nom_sci_html'] = $valeur; |
$this->table_retour['nom_sci_html_complet'] = $valeur.$this->ajouterCompositionNom($this->resultat_req, 'htm'); |
$this->table_retour['nom_sci_html_complet'] = $valeur.' '.$this->ajouterCompositionNom($this->resultat_req, 'htm'); |
}elseif ($nom_champ_api != 'nom_sci') { |
$this->table_retour[$nom_champ_api] = $valeur; |
} |
721,8 → 753,8 |
if ($res) { |
$nom['nom_sci'] = $res['nom_sci']; |
$nom['nom_sci_html'] = $res['nom_sci_html']; |
$nom['nom_sci_complet'] = $res['nom_sci'].$this->ajouterCompositionNom($res); |
$nom['nom_sci_complet_html'] = $res['nom_sci_html'].$this->ajouterCompositionNom($res, 'htm'); |
$nom['nom_sci_complet'] = $res['nom_sci'].' '.$this->ajouterCompositionNom($res); |
$nom['nom_sci_complet_html'] = $res['nom_sci_html'].' '.$this->ajouterCompositionNom($res, 'htm'); |
$nom['service'] = ($res['num_nom_retenu'] == $id && $this->service == 'taxons') ? 'taxons' : 'noms'; |
} |
} |
733,6 → 765,7 |
* bibilio et addendum). A ajouter au nom scientifique */ |
public function ajouterCompositionNom($tab_res, $format = '') { |
$format = ($format == '') ? $this->parametres['ns.format'] : $format; |
|
$nom = ''; |
if (isset($this->compo_nom)) { |
if ($format == 'htm') { |
748,9 → 781,16 |
'an' => '[%s]', |
'an_bib' => '[%s, %s]', |
'bib' => '[%s]', |
'ad' => '[%s]'); |
'ad' => '[%s]', |
'gen' => '%s', |
'sp' => '%s', |
'ssp' => '%s', |
'fam' => '%s', |
'au_ss' => '%s', |
'bib_ss' => '%s'); |
} |
$compo_nom = array(); |
|
foreach ($this->compo_nom as $key => $champ) { |
if (isset($tab_res[$champ]) && !empty($tab_res[$champ])) { |
$compo_nom[$key] = $tab_res[$champ]; |
757,7 → 797,7 |
} |
} |
$nom_complet = $this->formerNomComplet($compo_nom, $format); |
$nom = ' '.implode(' ', $nom_complet); |
$nom = implode(' ', $nom_complet); |
} |
return rtrim($nom, ' '); |
} |
777,10 → 817,33 |
$nom_complet[] = sprintf($format['bib'], $bib); |
} |
if (isset($ad)) $nom_complet[] = sprintf($format['ad'], $ad); |
if (isset($gen)) $nom_complet[] = sprintf($format['gen'], $gen); |
if (isset($ssp)) $nom_complet[] = sprintf($format['ssp'], $ssp); |
if (isset($sp)) $nom_complet[] = sprintf($format['sp'], $sp); |
if (isset($fam)) $nom_complet[] = sprintf($format['fam'], $fam); |
if (isset($au_ss)) $nom_complet[] = sprintf($format['au_ss'], $au_ss); |
if (isset($bib_ss)) { |
$bibl = $this->tronquerBiblio($bib_ss); |
//simule un 'select distinct' sur les biblio tronquées |
if (!isset($this->bib_traitees[$bibl])) { |
$nom_complet[] = sprintf($format['bib_ss'],$bibl ); |
$this->bib_traitees[$bibl] = 1; |
} |
} |
return $nom_complet; |
} |
|
public function tronquerBiblio($valeur){ |
$bib = strstr($valeur,',', true); |
if(strpos($bib,';')) { |
$bib = strstr($bib,';'); |
$bib = str_replace('; ','',$bib); |
} |
return $bib; |
} |
|
|
|
public function correspondAUnCode($key) { |
return (strrpos($key, '.code') !== false) || (in_array($key.'.code', $this->correspondance_champs)); |
} |