Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

Rev 272 Rev 306
Line 434... Line 434...
434
		} else {Debug::printr($resultat);
434
		} else {Debug::printr($resultat);
435
			$retour_id_hom = null; 
435
			$retour_id_hom = null; 
436
		}
436
		}
437
		return $retour_id_hom;
437
		return $retour_id_hom;
438
	}
438
	}
-
 
439
	
-
 
440
	public function obtenirSynonymesParNumNomAvecInfosFlore($num_nom, $version='1_02') {
-
 
441
		
-
 
442
		$champs_flore = 'flore_bonnier_num, flore_bonnier_rem,'. 
-
 
443
						'flore_cnrs_num, flore_cnrs_rem '.
-
 
444
						'flore_fe_num, flore_fe_rem '.
-
 
445
						'flore_coste_num, flore_coste_rem '. 	
-
 
446
						'flore_fh_num, flore_fh_rem '.	
-
 
447
						'flore_fournier_num, flore_fournier_rem';
-
 
448
		
-
 
449
		$requete = 'SELECT num_nom, nom_sci, '.$champs_flore.' '.
-
 
450
						'FROM bdtfx_v'.$version.' '.
-
 
451
						'WHERE num_nom_retenu = '.
-
 
452
						'('.
-
 
453
						'SELECT num_nom_retenu FROM bdtfx_v1_02 WHERE num_nom = "'.$num_nom.'"'.
-
 
454
						')';
-
 
455
		
-
 
456
		return $this->getBdd()->recupererTous($requete);			
-
 
457
	}
Line 439... Line 458...
439
		
458
		
440
	public function formaterIdFlores($resultat) {
459
	public function formaterIdFlores($resultat) {
441
		$this->recupererTableSignification('correspondance_champs,champs_api,champs_comp,noms_projets');
460
		$this->recupererTableSignification('correspondance_champs,champs_api,champs_comp,noms_projets');
442
		$this->resultat_req = $resultat;	
461
		$this->resultat_req = $resultat;	
443
		$id = array_shift($resultat);
462
		$id = array_shift($resultat);
-
 
463
		$reponse['entete']['id'] = $id;
-
 
464
		$synonymes_flores = $this->obtenirSynonymesParNumNomAvecInfosFlore($this->ressources[0]);
-
 
465
		if(is_array($synonymes_flores)) {
-
 
466
			foreach ($synonymes_flores as $synonyme) {
-
 
467
				$nom_sci = $synonyme['nom_sci'];
-
 
468
				$num_nom = $synonyme['num_nom'];
-
 
469
				unset($synonyme['nom_sci']);
444
		$reponse['entete']['id'] = $id;
470
				unset($synonyme['num_nom']);
445
		foreach ($resultat as $flores => $valeur) {
471
				foreach ($synonyme as $flores => $valeur) {
446
			if ($valeur != '' && $valeur != '0') {
472
					if ($valeur != '' && $valeur != '0') {
-
 
473
						$this->afficherInfosFlore($synonyme, $flores, $valeur, $nom_sci, $num_nom);
-
 
474
					}
447
				$this->afficherInfosFlore($resultat, $flores, $valeur);
475
				}
448
			}
476
			}
-
 
477
		}
449
		}
478
 
450
		if ($this->table_retour != array()) {
479
		if ($this->table_retour != array()) {
451
			$reponse['resultat'] = $this->table_retour;
480
			$reponse['resultat'] = $this->table_retour;
452
			$this->table_retour = array();
481
			$this->table_retour = array();
453
		} else { 
482
		} else { 
454
			$reponse = null; 
483
			$reponse = null; 
455
		}
484
		}
456
		return $reponse;
485
		return $reponse;
-
 
486
	}
-
 
487
	
-
 
488
	public function getNomCompletFlore($flore) {
-
 
489
		return Config::get($flore.'_texte');
Line 457... Line 490...
457
	}
490
	}
458
		
491
		
459
	public function afficherInfosFlore(&$resultat, $flores, $valeur) {
492
	public function afficherInfosFlore(&$resultat, $flores, $valeur, $nom_sci, $num_nom) {
-
 
493
		$flore = substr($flores,0,strrpos($flores, '_')); 
-
 
494
		$projet = $this->noms_projets[$flore];
-
 
495
		
460
		$flore = substr($flores,0,strrpos($flores, '_')); 
496
		//TODO voir si l'on peut factoriser les affectations à la table retour
461
		$projet = $this->noms_projets[$flore];
497
		// et simplifier ce gros pavé
462
		if (strrpos($flores, 'num') !== false) { 
498
		if (strrpos($flores, 'num') !== false) { 
463
			if (preg_match('/^([0-9]+)(?:[.]syn[^a-z]*|(.*))?$/', $valeur, $match)) { 
499
			if (preg_match('/^([0-9]+)(?:[.]syn[^a-z]*|(.*))?$/', $valeur, $match)) { 
464
				$this->table_retour[$flore]['id'] = $match[1];
500
				$this->table_retour[$num_nom][$flore]['id'] = $match[1];
465
				if ($projet == 'coste') {
501
				if ($projet == 'coste') {
466
					$this->table_retour[$flore]['href'] = $this->ajouterHrefAutreProjet('noms', 'nn_coste:', $match[1], $projet);
502
					$this->table_retour[$num_nom][$flore]['href'] = $this->ajouterHrefAutreProjet('noms', 'nn_coste:', $match[1], $projet);
-
 
503
				}
-
 
504
				if (isset($match[2]) && $match[2] != '') $this->table_retour[$num_nom][$flore]['cle'] = $match[2];
467
				}
505
				$this->table_retour[$num_nom][$flore]['nom_flore'] = $this->getNomCompletFlore($flore);
468
				if (isset($match[2]) && $match[2] != '') $this->table_retour[$flore]['cle'] = $match[2];
506
				$this->table_retour[$num_nom][$flore]['nom_sci'] = $nom_sci;
469
			} 
507
			} 
-
 
508
			if (isset($resultat[$flore.'_rem']) && !empty($resultat[$flore.'_rem'])) {
-
 
509
				$this->table_retour[$num_nom][$flore]['remarque'] = $resultat[$flore.'_rem'];
470
			if (isset($resultat[$flore.'_rem']) && !empty($resultat[$flore.'_rem'])) {
510
				$this->table_retour[$num_nom][$flore]['nom_flore'] = $this->getNomCompletFlore($flore);
471
				$this->table_retour[$flore]['remarque'] = $resultat[$flore.'_rem'];
511
				$this->table_retour[$num_nom][$flore]['nom_sci'] = $nom_sci;
472
				unset($resultat[$flore.'_rem']);
512
				unset($resultat[$flore.'_rem']);
473
			}
513
			}
474
		} elseif (strrpos($flores,'belge') !== false) {
514
		} elseif (strrpos($flores,'belge') !== false) {
475
			if (preg_match('/^([0-9]+) (R|S)?$/', $valeur, $match)) {
515
			if (preg_match('/^([0-9]+) (R|S)?$/', $valeur, $match)) {
476
				if (isset($match[2])) $type = ($match[2] == 'R') ? 'taxons' : 'synonyme';
516
				if (isset($match[2])) $type = ($match[2] == 'R') ? 'taxons' : 'synonyme';
-
 
517
				$this->table_retour[$num_nom][$flore]['page'] = $match[1];
-
 
518
				$this->table_retour[$num_nom][$flore]['type'] = $type;
477
				$this->table_retour[$flore]['page'] = $match[1];
519
				$this->table_retour[$num_nom][$flore]['nom_flore'] = $this->getNomCompletFlore($flore);
478
				$this->table_retour[$flore]['type'] = $type;
520
				$this->table_retour[$num_nom][$flore]['nom_sci'] = $nom_sci;
479
			}
521
			}
480
		}
-
 
481
	}
-
 
Line 482... Line 522...
482
	
522
		}
Line 483... Line 523...
483
	
523
	}	
484
	
524