Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 955 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 955 Rev 1130
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();
36
		$this->getFlores();
37
				
37
				
38
		$this->donnees['bibliobota']['references'] = $this->getBiblioBota();
38
		$this->donnees['bibliobota']['references'] = $this->getBiblioBota();
39
		$this->meta->setProjet('bibliobota');
39
		$this->meta->setProjet('bibliobota');
40
		$meta = $this->meta->getMetaDonnees();
40
		$meta = $this->meta->getMetaDonnees();
41
		$titreMeta = $meta[0]['titre'];
-
 
42
		$this->donnees['bibliobota']['meta']['titre'] = $titreMeta;
41
		$this->donnees['bibliobota']['meta'] = $meta[0];
43
		$this->donnees['bibliobota']['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('bibliobota');
42
		$this->donnees['bibliobota']['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('bibliobota');
44
		
43
		
45
		$this->donnees['wikini'] = $this->getWikini();
44
		$this->donnees['wikini'] = $this->getWikini();
46
		return $this->donnees;
45
		return $this->donnees;
47
	}
46
	}
48
	
47
	
49
	public function getBloc() {
48
	public function getBloc() {
50
		$this->getFloresBloc();
49
		$this->getFloresBloc();
51
		$references = $this->getBiblioBota();
50
		$references = $this->getBiblioBota();
52
		$this->donnees['references'] = array_slice($references, 0, 3);
51
		$this->donnees['references'] = array_slice($references, 0, 3);
53
		foreach ($this->donnees['references'] as $id=>$reference) {
52
		foreach ($this->donnees['references'] as $id=>$reference) {
54
			preg_match('/.*<strong>(.*)<\/strong>.*/', $reference['reference_html'], $titre);
53
			preg_match('/.*<strong>(.*)<\/strong>.*/', $reference['reference_html'], $titre);
55
			$this->donnees['references'][$id]['reference_html'] = $titre[1];
54
			$this->donnees['references'][$id]['reference_html'] = $titre[1];
56
		}
55
		}
57
		$this->donnees['autresReferences'] = count($references) - 3;
56
		$this->donnees['autresReferences'] = count($references) - 3;
58
		if ($this->donnees['flores'] == array() && $this->donnees['references'] == array()) {
57
		if ($this->donnees['flores'] == array() && $this->donnees['references'] == array()) {
59
			$this->donnees['wikini'] = $this->getWikini();
58
			$this->donnees['wikini'] = $this->getWikini();
60
		}
59
		}
61
		return $this->donnees;
60
		return $this->donnees;
62
	}
61
	}
63
	
62
	
64
	// Récupération des données flores présentes dans le référentiel
63
	// Récupération des données flores présentes dans le référentiel
65
	private function getFlores() {
64
	private function getFlores() {
66
		if (Config::get($this->referentiel.'.baseFloresRef') != "") {
65
		if (Config::get($this->referentiel.'.baseFloresRef') != "") {
67
			$flores = $this->nomCourant->getNomRetenu()->get('flores');
66
			$flores = $this->nomCourant->getNomRetenu()->get('flores');
68
			$flores = explode(',', $flores);
67
			$flores = explode(',', $flores);
69
			$this->donnees['flores']['liste_flores'] =  $this->remplacerCorrespondancesFlores($flores);
68
			$this->donnees['flores']['liste_flores'] =  $this->remplacerCorrespondancesFlores($flores);
70
			$this->meta->setProjet($this->referentiel);
69
			$this->meta->setProjet($this->referentiel);
71
			$meta = $this->meta->getMetaDonnees();
70
			$meta = $this->meta->getMetaDonnees();
72
			$titreMeta = $meta[0]['titre'];
-
 
73
			$this->donnees['flores']['meta']['titre'] = $titreMeta;
71
			$this->donnees['flores']['meta'] = $meta[0];
74
			$this->donnees['flores']['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($this->referentiel);
72
			$this->donnees['flores']['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($this->referentiel);
75
		}
73
		}
76
	}
74
	}
77
	
75
	
78
	private function getFloresBloc() {
76
	private function getFloresBloc() {
79
		$flores = $this->nomCourant->getNomRetenu()->get('flores');
77
		$flores = $this->nomCourant->getNomRetenu()->get('flores');
80
		$flores = explode(',', $flores);
78
		$flores = explode(',', $flores);
81
		$flores =  $this->remplacerCorrespondancesFlores($flores);
79
		$flores =  $this->remplacerCorrespondancesFlores($flores);
82
		$this->donnees['flores'] = array_slice($flores, 0, 3);
80
		$this->donnees['flores'] = array_slice($flores, 0, 3);
83
		$this->donnees['autresFlores'] = count($flores) - 3;
81
		$this->donnees['autresFlores'] = count($flores) - 3;
84
	}
82
	}
85
	
83
	
86
	//Obtention des données issues de biblio_bota
84
	//Obtention des données issues de biblio_bota
87
	private function getBiblioBota() {
85
	private function getBiblioBota() {
88
		$this->apiBiblioBota = $this->conteneur->getApiBiblioBota();
86
		$this->apiBiblioBota = $this->conteneur->getApiBiblioBota();
89
		$this->apiBiblioBota->setProjet('bibliobota');
87
		$this->apiBiblioBota->setProjet('bibliobota');
90
		$interrogation = $this->nomCourant->getNomSelectionne()->get('nom_sci');
88
		$interrogation = $this->nomCourant->getNomSelectionne()->get('nom_sci');
91
		$references = $this->apiBiblioBota->getReferences($interrogation);
89
		$references = $this->apiBiblioBota->getReferences($interrogation);
92
		return $references['resultats'];
90
		return $references['resultats'];
93
	}
91
	}
94
	
92
	
95
	private function getWikini() {
93
	private function getWikini() {
96
		$wikini = array();
94
		$wikini = array();
97
		$wikini['titre'] = 'Wikini';
95
		$wikini['titre'] = 'Wikini';
98
		$referentiel = $this->conteneur->getParametre('referentiel');
96
		$referentiel = $this->conteneur->getParametre('referentiel');
99
		$num_tax = $this->nomCourant->getNomSelectionne()->get('num_taxonomique');
97
		$num_tax = $this->nomCourant->getNomSelectionne()->get('num_taxonomique');
100
		$page_wiki = $this->wikini->getPageWikiPourRefEtNumTax($referentiel, $num_tax);
98
		$page_wiki = $this->wikini->getPageWikiPourRefEtNumTax($referentiel, $num_tax);
101
		$wikini['biblio'] = $this->wikini->getTexteFormate($page_wiki, 'biblio');
99
		$wikini['biblio'] = $this->wikini->getTexteFormate($page_wiki, 'biblio');
102
		return $wikini;
100
		return $wikini;
103
	}
101
	}
104
	
102
	
105
	//TODO: faire une ontologie mais pas de tache prévue dans ce sprint
103
	//TODO: faire une ontologie mais pas de tache prévue dans ce sprint
106
	private function getCorrespondancesBiblio() {	
104
	private function getCorrespondancesBiblio() {	
107
		$correspondance = array(
105
		$correspondance = array(
108
		'1' => 'BONNIER & LAYENS, 1894. Tables synoptiques des plantes vasculaires de la flore de France.',
106
		'1' => 'BONNIER & LAYENS, 1894. Tables synoptiques des plantes vasculaires de la flore de France.',
109
		'2' => 'COSTE, 1899-1906. Flore illustrée France, (3 vol.).',
107
		'2' => 'COSTE, 1899-1906. Flore illustrée France, (3 vol.).',
110
		'3' => 'FOURNIER, 1934-1940. Quatre Flores de France.',
108
		'3' => 'FOURNIER, 1934-1940. Quatre Flores de France.',
111
		'3*' => 'FOURNIER, additions dans l\'édition de 1961.',
109
		'3*' => 'FOURNIER, additions dans l\'édition de 1961.',
112
		'4' =>  'TUTIN & al., 1964-1980. Flora Europaea, (5 vol.).',
110
		'4' =>  'TUTIN & al., 1964-1980. Flora Europaea, (5 vol.).',
113
		'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).',
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).',
114
		'5' => 'GUINOCHET & VILMORIN, 1973-1984. Flore de France, éd. C.N.R.S., (5 vol.).',
112
		'5' => 'GUINOCHET & VILMORIN, 1973-1984. Flore de France, éd. C.N.R.S., (5 vol.).',
115
		'6' => 'KERGUÉLEN, 1993. Liste synonymique de la flore de France.'
113
		'6' => 'KERGUÉLEN, 1993. Liste synonymique de la flore de France.'
116
		);		
114
		);		
117
		return $correspondance;
115
		return $correspondance;
118
	}
116
	}
119
	
117
	
120
	private function remplacerCorrespondancesFlores($flores) {
118
	private function remplacerCorrespondancesFlores($flores) {
121
		$correspondance_code_flores = $this->getCorrespondancesBiblio();
119
		$correspondance_code_flores = $this->getCorrespondancesBiblio();
122
		$flores_texte = array();
120
		$flores_texte = array();
123
	
121
	
124
		foreach($flores as $code_flore) {
122
		foreach($flores as $code_flore) {
125
			$code_flore = trim($code_flore);
123
			$code_flore = trim($code_flore);
126
			if(isset($correspondance_code_flores[$code_flore])) {
124
			if(isset($correspondance_code_flores[$code_flore])) {
127
				$flores_texte[] = $correspondance_code_flores[$code_flore];
125
				$flores_texte[] = $correspondance_code_flores[$code_flore];
128
			}
126
			}
129
		}
127
		}
130
		return $flores_texte;
128
		return $flores_texte;
131
	}
129
	}
132
}
130
}
133
?>
131
?>