Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 1130 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1130 Rev 1387
1
<?php
1
<?php
2
// declare(encoding='UTF-8');
2
// declare(encoding='UTF-8');
3
/**
3
/**
4
 * Classe mère du module Liste.
4
 * Classe mère du module Liste.
5
 *
5
 *
6
 * @category	PHP 5.2
6
 * @category	PHP 5.2
7
 * @package		eflore-consultation
7
 * @package		eflore-consultation
8
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
8
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
9
 * @author		Delphine CAUQUIL <delphine@tela-botanica.org>
9
 * @author		Delphine CAUQUIL <delphine@tela-botanica.org>
10
 * @copyright	2011 Tela-Botanica
10
 * @copyright	2011 Tela-Botanica
11
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL-v3
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
12
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL-v2
13
 * @version		$Id$
13
 * @version		$Id$
14
 */
14
 */
15
class Bibliographie extends aControleur {
15
class Bibliographie extends aControleur {
16
		
16
		
17
	private $apiBiblioBota;
17
	private $apiBiblioBota;
18
	private $conteneur;
18
	private $conteneur;
19
	private $nomCourant;
19
	private $nomCourant;
20
	private $meta;
20
	private $meta;
21
	private $appUrls;
21
	private $appUrls;
22
	private $wikini;
22
	private $wikini;
23
	private $referentiel = 'bdtfx';
23
	private $referentiel = 'bdtfx';
24
	private $donnees = array();
24
	private $donnees = array();
25
	
25
	
26
	public function __construct(Conteneur $conteneur) {
26
	public function __construct(Conteneur $conteneur) {
27
		$this->conteneur = $conteneur;
27
		$this->conteneur = $conteneur;
28
		$this->nomCourant = $this->conteneur->getNomCourant();
28
		$this->nomCourant = $this->conteneur->getNomCourant();
29
		$this->referentiel = $this->conteneur->getParametre('referentiel');
29
		$this->referentiel = $this->conteneur->getParametre('referentiel');
30
		$this->wikini = $this->conteneur->getApiWikini();
30
		$this->wikini = $this->conteneur->getApiWikini();
31
		$this->meta = $this->conteneur->getApiMetaDonnees();
31
		$this->meta = $this->conteneur->getApiMetaDonnees();
32
		$this->appUrls = $this->conteneur->getAppUrls();
32
		$this->appUrls = $this->conteneur->getAppUrls();
33
	}
33
	}
34
	
34
	
35
	public function obtenirDonnees() {
35
	public function obtenirDonnees() {
36
		$this->getFlores();
-
 
37
				
-
 
38
		$this->donnees['bibliobota']['references'] = $this->getBiblioBota();
36
		$this->donnees['bibliobota']['references'] = $this->getBiblioBota();
39
		$this->meta->setProjet('bibliobota');
37
		$this->meta->setProjet('bibliobota');
40
		$meta = $this->meta->getMetaDonnees();
38
		$meta = $this->meta->getMetaDonnees();
41
		$this->donnees['bibliobota']['meta'] = $meta[0];
39
		$this->donnees['bibliobota']['meta'] = $meta[0];
42
		$this->donnees['bibliobota']['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('bibliobota');
40
		$this->donnees['bibliobota']['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('bibliobota');
43
		
41
		
44
		$this->donnees['wikini'] = $this->getWikini();
42
		$this->donnees['wikini'] = $this->getWikini();
45
		return $this->donnees;
43
		return $this->donnees;
46
	}
44
	}
47
	
45
	
48
	public function getBloc() {
46
	public function getBloc() {
49
		$this->getFloresBloc();
-
 
50
		$references = $this->getBiblioBota();
47
		$references = $this->getBiblioBota();
51
		$this->donnees['references'] = array_slice($references, 0, 3);
48
		$this->donnees['references'] = array_slice($references, 0, 3);
52
		foreach ($this->donnees['references'] as $id=>$reference) {
49
		foreach ($this->donnees['references'] as $id=>$reference) {
53
			preg_match('/.*<strong>(.*)<\/strong>.*/', $reference['reference_html'], $titre);
50
			preg_match('/.*<strong>(.*)<\/strong>.*/', $reference['reference_html'], $titre);
54
			$this->donnees['references'][$id]['reference_html'] = $titre[1];
51
			$this->donnees['references'][$id]['reference_html'] = $titre[1];
55
		}
52
		}
56
		$this->donnees['autresReferences'] = count($references) - 3;
53
		$this->donnees['autresReferences'] = count($references) - 3;
57
		if ($this->donnees['flores'] == array() && $this->donnees['references'] == array()) {
54
		if ($this->donnees['references'] == array()) {
58
			$this->donnees['wikini'] = $this->getWikini();
55
			$this->donnees['wikini'] = $this->getWikini();
59
		}
56
		}
60
		return $this->donnees;
57
		return $this->donnees;
61
	}
58
	}
62
	
-
 
63
	// Récupération des données flores présentes dans le référentiel
-
 
64
	private function getFlores() {
-
 
65
		if (Config::get($this->referentiel.'.baseFloresRef') != "") {
-
 
66
			$flores = $this->nomCourant->getNomRetenu()->get('flores');
-
 
67
			$flores = explode(',', $flores);
-
 
68
			$this->donnees['flores']['liste_flores'] =  $this->remplacerCorrespondancesFlores($flores);
-
 
69
			$this->meta->setProjet($this->referentiel);
-
 
70
			$meta = $this->meta->getMetaDonnees();
-
 
71
			$this->donnees['flores']['meta'] = $meta[0];
-
 
72
			$this->donnees['flores']['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($this->referentiel);
-
 
73
		}
-
 
74
	}
-
 
75
	
-
 
76
	private function getFloresBloc() {
-
 
77
		$flores = $this->nomCourant->getNomRetenu()->get('flores');
-
 
78
		$flores = explode(',', $flores);
-
 
79
		$flores =  $this->remplacerCorrespondancesFlores($flores);
-
 
80
		$this->donnees['flores'] = array_slice($flores, 0, 3);
-
 
81
		$this->donnees['autresFlores'] = count($flores) - 3;
-
 
82
	}
59
	
83
	
60
	
84
	//Obtention des données issues de biblio_bota
61
	//Obtention des données issues de biblio_bota
85
	private function getBiblioBota() {
62
	private function getBiblioBota() {
86
		$this->apiBiblioBota = $this->conteneur->getApiBiblioBota();
63
		$this->apiBiblioBota = $this->conteneur->getApiBiblioBota();
87
		$this->apiBiblioBota->setProjet('bibliobota');
64
		$this->apiBiblioBota->setProjet('bibliobota');
88
		$interrogation = $this->nomCourant->getNomSelectionne()->get('nom_sci');
65
		$interrogation = $this->nomCourant->getNomSelectionne()->get('nom_sci');
89
		$references = $this->apiBiblioBota->getReferences($interrogation);
66
		$references = $this->apiBiblioBota->getReferences($interrogation);
90
		return $references['resultats'];
67
		return $references['resultats'];
91
	}
68
	}
92
	
69
	
93
	private function getWikini() {
70
	private function getWikini() {
94
		$wikini = array();
71
		$wikini = array();
95
		$wikini['titre'] = 'Wikini';
72
		$wikini['titre'] = 'Wikini';
96
		$referentiel = $this->conteneur->getParametre('referentiel');
73
		$referentiel = $this->conteneur->getParametre('referentiel');
97
		$num_tax = $this->nomCourant->getNomSelectionne()->get('num_taxonomique');
74
		$num_tax = $this->nomCourant->getNomSelectionne()->get('num_taxonomique');
98
		$page_wiki = $this->wikini->getPageWikiPourRefEtNumTax($referentiel, $num_tax);
75
		$page_wiki = $this->wikini->getPageWikiPourRefEtNumTax($referentiel, $num_tax);
99
		$wikini['biblio'] = $this->wikini->getTexteFormate($page_wiki, 'biblio');
76
		$wikini['biblio'] = $this->wikini->getTexteFormate($page_wiki, 'biblio');
100
		return $wikini;
77
		return $wikini;
101
	}
78
	}
102
	
-
 
103
	//TODO: faire une ontologie mais pas de tache prévue dans ce sprint
-
 
104
	private function getCorrespondancesBiblio() {	
-
 
105
		$correspondance = array(
-
 
106
		'1' => 'BONNIER & LAYENS, 1894. Tables synoptiques des plantes vasculaires de la flore de France.',
-
 
107
		'2' => 'COSTE, 1899-1906. Flore illustrée France, (3 vol.).',
-
 
108
		'3' => 'FOURNIER, 1934-1940. Quatre Flores de France.',
-
 
109
		'3*' => 'FOURNIER, additions dans l\'édition de 1961.',
-
 
110
		'4' =>  'TUTIN & al., 1964-1980. Flora Europaea, (5 vol.).',
-
 
111
		'4*' => 'Flora Europaea, édition 2 (Vol. 1), voir TUTIN & al. (1993), abrégée en FE2. L\'indication est surtout donnée quand la citation n\'a pas été faite dans 4 (supplémentaire ou modifiée).',
-
 
112
		'5' => 'GUINOCHET & VILMORIN, 1973-1984. Flore de France, éd. C.N.R.S., (5 vol.).',
-
 
113
		'6' => 'KERGUÉLEN, 1993. Liste synonymique de la flore de France.'
-
 
114
		);		
-
 
115
		return $correspondance;
-
 
116
	}
79
	
117
	
-
 
118
	private function remplacerCorrespondancesFlores($flores) {
-
 
119
		$correspondance_code_flores = $this->getCorrespondancesBiblio();
-
 
120
		$flores_texte = array();
80
 
121
	
-
 
122
		foreach($flores as $code_flore) {
-
 
123
			$code_flore = trim($code_flore);
-
 
124
			if(isset($correspondance_code_flores[$code_flore])) {
-
 
125
				$flores_texte[] = $correspondance_code_flores[$code_flore];
-
 
126
			}
-
 
127
		}
-
 
128
		return $flores_texte;
-
 
129
	}
81
 
130
}
82
}
131
?>
83
?>