Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

Rev 629 Rev 656
Line 42... Line 42...
42
				switch ($param) {
42
				switch ($param) {
43
					case 'ns.structure' :
43
					case 'ns.structure' :
44
						$this->remplirTableCompositionNom($val);
44
						$this->remplirTableCompositionNom($val);
45
						if (in_array($val,$this->sans_nom_sci)){
45
						if (in_array($val,$this->sans_nom_sci)){
46
							$this->requete_champ = implode(', ',$this->compo_nom);
46
							$this->requete_champ = implode(', ',$this->compo_nom);
47
						}else {						
47
						}else {
48
							$this->requete_champ .= ' ,'.implode(', ',$this->compo_nom);
48
							$this->requete_champ .= ' ,'.implode(', ',$this->compo_nom);
49
						}
49
						}
50
						break;
50
						break;
51
					case 'navigation.depart' :
51
					case 'navigation.depart' :
52
							$this->limite_requete['depart'] = $val;
52
							$this->limite_requete['depart'] = $val;
Line 73... Line 73...
73
		if (empty($this->parametres['ns.structure']) &&
73
		if (empty($this->parametres['ns.structure']) &&
74
			$this->parametres['retour.format'] != 'oss') {
74
			$this->parametres['retour.format'] != 'oss') {
75
			$this->parametres['ns.structure'] = 'au,an,bib';
75
			$this->parametres['ns.structure'] = 'au,an,bib';
76
		}
76
		}
77
	}
77
	}
78
	
78
 
79
	
79
 
80
	public function verifierParametres() {
80
	public function verifierParametres() {
81
		//$this->verifierParametresAPI();
81
		//$this->verifierParametresAPI();
Line 82... Line 82...
82
 
82
 
83
		$this->verifierParametre('recherche', 'stricte|floue|etendue|complete');
83
		$this->verifierParametre('recherche', 'stricte|floue|etendue|complete');
Line 139... Line 139...
139
			if ($this->parametres['recherche'] == 'etendue') {
139
			if ($this->parametres['recherche'] == 'etendue') {
140
				foreach ($valeur as $val) {
140
				foreach ($valeur as $val) {
141
					$val = $this->modifierValeur($val);
141
					$val = $this->modifierValeur($val);
142
					$conditions[] = "$nom_champ LIKE ".$this->getBdd()->proteger($val);
142
					$conditions[] = "$nom_champ LIKE ".$this->getBdd()->proteger($val);
143
				}
143
				}
144
				
144
 
145
			} elseif ($this->parametres['recherche'] == 'floue') {
145
			} elseif ($this->parametres['recherche'] == 'floue') {
146
				foreach ($valeur as $val) {
146
				foreach ($valeur as $val) {
147
					$val = $this->getBdd()->proteger($val);
147
					$val = $this->getBdd()->proteger($val);
148
					$conditions[] = "( SOUNDEX($nom_champ) = SOUNDEX($val))".
148
					$conditions[] = "( SOUNDEX($nom_champ) = SOUNDEX($val))".
149
											" OR ( SOUNDEX(REVERSE($nom_champ)) = SOUNDEX(REVERSE($val)))";
149
											" OR ( SOUNDEX(REVERSE($nom_champ)) = SOUNDEX(REVERSE($val)))";
Line 241... Line 241...
241
 
241
 
242
	/** Permet de remplir le tableau compo_nom. Il comprendra en fct du paramètre ns.structure les éléments à rajouter
242
	/** Permet de remplir le tableau compo_nom. Il comprendra en fct du paramètre ns.structure les éléments à rajouter
243
	 * au nom_sci (annee, auteur, biblio ou addendum). */
243
	 * au nom_sci (annee, auteur, biblio ou addendum). */
244
	public function remplirTableCompositionNom($valeur) {
244
	public function remplirTableCompositionNom($valeur) {
-
 
245
		$structure_nom = explode(',', $valeur);
245
		$structure_nom = explode(',', $valeur);
246
 
246
		foreach ($structure_nom as $structure) {
-
 
247
			//avec str_replace() 'sp' est inclu dans 'ssp', et la conversion pour 'ssp' est mauvaise
247
		foreach ($structure_nom as $structure) {
248
			$this->compo_nom[$structure] = 
248
			$structure = trim($structure);
249
				preg_replace(array('/^an$/', '/^au$/', '/^bib$/', '/^ad$/',
249
			$patterns = array('/^an$/', '/^au$/', '/^bib$/', '/^ad$/', '/^sp$/', '/^gen$/', '/^ssp$/','/^fam$/',
250
				 '/^sp$/', '/^gen$/', '/^ssp$/','/^fam$/','/^au_ss$/','/^bib_ss$/'),
250
				'/^au_ss$/','/^bib_ss$/');
251
				array('annee', 'auteur', 'biblio_origine', 'nom_addendum', 
251
			$champs = array('annee', 'auteur', 'biblio_origine', 'nom_addendum', 'epithete_sp', 'genre',
-
 
252
				'epithete_infra_sp','famille','auteur', 'biblio_origine');
-
 
253
 
252
				'epithete_sp', 'genre', 'epithete_infra_sp','famille','auteur', 'biblio_origine'), 
254
			// avec str_replace() 'sp' est inclu dans 'ssp', et la conversion pour 'ssp' est mauvaise
253
				$structure);
255
			$this->compo_nom[$structure] = preg_replace($patterns, $champs, $structure);
254
		} 
256
		}
Line 255... Line 257...
255
	}
257
	}
256
 
258
 
257
	public function mettreAuFormat() {
259
	public function mettreAuFormat() {
Line 299... Line 301...
299
				$res = $this->ajouterCompositionNom($tab);
301
				$res = $this->ajouterCompositionNom($tab);
300
				if($res) {
302
				if($res) {
301
					$oss[] = $res;
303
					$oss[] = $res;
302
				}
304
				}
303
			}
305
			}
304
			
306
 
305
		}
307
		}
306
	
308
 
307
		if (isset($this->masque)) $masque = implode('&', $this->masque);
309
		if (isset($this->masque)) $masque = implode('&', $this->masque);
308
		else $masque = 'Pas de masque';
310
		else $masque = 'Pas de masque';
309
		$table_retour_oss = array($masque, $oss);
311
		$table_retour_oss = array($masque, $oss);
310
		return $table_retour_oss;
312
		return $table_retour_oss;
311
	}
313
	}
Line 334... Line 336...
334
			$retenu = ($tab['num_nom_retenu'] == $num) ? 'true' : 'false';
336
			$retenu = ($tab['num_nom_retenu'] == $num) ? 'true' : 'false';
335
		} else {
337
		} else {
336
			$retenu = 'absent';
338
			$retenu = 'absent';
337
		}
339
		}
338
		$this->table_retour['retenu'] = $retenu;
340
		$this->table_retour['retenu'] = $retenu;
-
 
341
		// Pourquoi ce unset ? JPM - 28-03-2013
339
		unset($this->table_retour['id']);
342
		unset($this->table_retour['id']);
340
	}
343
	}
Line 341... Line 344...
341
 
344
 
Line 378... Line 381...
378
			foreach ($champs as $champ) {
381
			foreach ($champs as $champ) {
379
				if ($this->verifierValiditeChamp($champ)) {
382
				if ($this->verifierValiditeChamp($champ)) {
380
					if (strrpos($champ, '.*') !== false) {
383
					if (strrpos($champ, '.*') !== false) {
381
						$this->afficherPointEtoile($champ, $reponse_id);
384
						$this->afficherPointEtoile($champ, $reponse_id);
382
					} elseif (in_array($champ, $champs_a_libeller)) {
385
					} elseif (in_array($champ, $champs_a_libeller)) {
383
						$this->table_retour[$champ.'.libelle'] = 
386
						$this->table_retour[$champ.'.libelle'] =
384
							(isset($reponse_id[$champ.'.libelle'])) ? $reponse_id[$champ.'.libelle'] : null;
387
							(isset($reponse_id[$champ.'.libelle'])) ? $reponse_id[$champ.'.libelle'] : null;
385
					} else {
388
					} else {
386
						$champ = $this->trouverChampBddCorrespondant($champ);
389
						$champ = $this->trouverChampBddCorrespondant($champ);
387
						$this->table_retour[$champ] = (isset($reponse_id[$champ])) ? $reponse_id[$champ] : null;
390
						$this->table_retour[$champ] = (isset($reponse_id[$champ])) ? $reponse_id[$champ] : null;
388
					}
391
					}
Line 721... Line 724...
721
			}
724
			}
722
		}
725
		}
723
	}
726
	}
Line 724... Line 727...
724
 
727
 
725
	public function ajouterSignificationCode($champ, $valeur) {
728
	public function ajouterSignificationCode($champ, $valeur) {
726
		$categorie = $champ;	
729
		$categorie = $champ;
727
		if($this->termeOntologieEstEnCache($categorie, $valeur)) {
730
		if($this->termeOntologieEstEnCache($categorie, $valeur)) {
728
			$nom_code = $this->obtenirTermeOntologieParCache($categorie, $valeur);
731
			$nom_code = $this->obtenirTermeOntologieParCache($categorie, $valeur);
729
		} else {		
732
		} else {
730
			$champ = ($champ == 'rang') ? 'rangTaxo' : rtrim($champ, '_Co,_Ga');
733
			$champ = ($champ == 'rang') ? 'rangTaxo' : rtrim($champ, '_Co,_Ga');
731
			if (preg_match('/^([^_-]+)(?:_|-)([^_-]+)$/', $champ, $match)) {
734
			if (preg_match('/^([^_-]+)(?:_|-)([^_-]+)$/', $champ, $match)) {
732
				$champ = $match[1].ucfirst($match[2]);
735
				$champ = $match[1].ucfirst($match[2]);
733
			}
736
			}
Line 830... Line 833...
830
		if (isset($fam)) $nom_complet[] = sprintf($format['fam'], $fam);
833
		if (isset($fam)) $nom_complet[] = sprintf($format['fam'], $fam);
831
		if (isset($au_ss)) $nom_complet[] = sprintf($format['au_ss'], $au_ss);
834
		if (isset($au_ss)) $nom_complet[] = sprintf($format['au_ss'], $au_ss);
832
		if (isset($bib_ss)) {
835
		if (isset($bib_ss)) {
833
			$bibl = $this->tronquerBiblio($bib_ss);
836
			$bibl = $this->tronquerBiblio($bib_ss);
834
			//simule un 'select distinct' sur les biblio tronquées
837
			//simule un 'select distinct' sur les biblio tronquées
835
			if (!isset($this->bib_traitees[$bibl])) { 
838
			if (!isset($this->bib_traitees[$bibl])) {
836
				$nom_complet[] = sprintf($format['bib_ss'],$bibl );
839
				$nom_complet[] = sprintf($format['bib_ss'],$bibl );
837
				$this->bib_traitees[$bibl] = 1;
840
				$this->bib_traitees[$bibl] = 1;
838
			}
841
			}
839
		}
842
		}
840
		return $nom_complet;
843
		return $nom_complet;
Line 844... Line 847...
844
		$bib = '';
847
		$bib = '';
845
		if(strpos($valeur,',') !== false) {
848
		if(strpos($valeur,',') !== false) {
846
			$bib = explode(',',$valeur);
849
			$bib = explode(',',$valeur);
847
		}
850
		}
848
		if(strpos($bib[0],';') !== false) {
851
		if(strpos($bib[0],';') !== false) {
849
			
852
 
850
			$bib[0] = strstr($bib[0],';');
853
			$bib[0] = strstr($bib[0],';');
851
			$bib[0] = str_replace('; ','',$bib[0]);
854
			$bib[0] = str_replace('; ','',$bib[0]);
852
		}
855
		}
853
		return $bib[0];
856
		return $bib[0];
854
	}
857
	}
855
	
858
 
Line 856... Line 859...
856
 
859
 
857
 
860
 
858
	public function correspondAUnCode($key) {
861
	public function correspondAUnCode($key) {
Line 898... Line 901...
898
            }
901
            }
899
        }
902
        }
900
        $this->masque = $liste_masque;
903
        $this->masque = $liste_masque;
901
        return $masque;
904
        return $masque;
902
	}
905
	}
903
	
906
 
904
	private function mettreEnCacheOntologie($categorie, $valeur, $correspondance) {
907
	private function mettreEnCacheOntologie($categorie, $valeur, $correspondance) {
905
		if(!isset($this->ontologie[$categorie])) {
908
		if(!isset($this->ontologie[$categorie])) {
906
			$this->ontologie[$categorie] = array();
909
			$this->ontologie[$categorie] = array();
907
		}
910
		}
908
		if(!isset($this->ontologie[$categorie][$valeur])) {
911
		if(!isset($this->ontologie[$categorie][$valeur])) {
909
			$this->ontologie[$categorie][$valeur] = array();
912
			$this->ontologie[$categorie][$valeur] = array();
910
		}
913
		}
911
		$this->ontologie[$categorie][$valeur] = $correspondance;
914
		$this->ontologie[$categorie][$valeur] = $correspondance;
912
	}
915
	}
913
	
916
 
914
	private function termeOntologieEstEnCache($categorie, $valeur) {
917
	private function termeOntologieEstEnCache($categorie, $valeur) {
915
		return array_key_exists($categorie, $this->ontologie) && array_key_exists($valeur, $this->ontologie[$categorie]);
918
		return array_key_exists($categorie, $this->ontologie) && array_key_exists($valeur, $this->ontologie[$categorie]);
916
	}
919
	}
917
	
920
 
918
	private function obtenirTermeOntologieParCache($categorie, $valeur) {
921
	private function obtenirTermeOntologieParCache($categorie, $valeur) {
919
		return $this->ontologie[$categorie][$valeur];
922
		return $this->ontologie[$categorie][$valeur];
920
	}
923
	}
921
}
924
}
922
?>
925
?>
923
926