Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

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