Subversion Repositories eFlore/Applications.eflore-consultation

Compare Revisions

Ignore whitespace Rev 1203 → Rev 1204

/tags/v5.3-cordier/modules/fiche/formateurs/Bibliographie.php
New file
0,0 → 1,131
<?php
// declare(encoding='UTF-8');
/**
* Classe mère du module Liste.
*
* @category PHP 5.2
* @package eflore-consultation
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
* @author Delphine CAUQUIL <delphine@tela-botanica.org>
* @copyright 2011 Tela-Botanica
* @license http://www.gnu.org/licenses/gpl.html Licence GNU-GPL-v3
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL-v2
* @version $Id$
*/
class Bibliographie extends aControleur {
private $apiBiblioBota;
private $conteneur;
private $nomCourant;
private $meta;
private $appUrls;
private $wikini;
private $referentiel = 'bdtfx';
private $donnees = array();
public function __construct(Conteneur $conteneur) {
$this->conteneur = $conteneur;
$this->nomCourant = $this->conteneur->getNomCourant();
$this->referentiel = $this->conteneur->getParametre('referentiel');
$this->wikini = $this->conteneur->getApiWikini();
$this->meta = $this->conteneur->getApiMetaDonnees();
$this->appUrls = $this->conteneur->getAppUrls();
}
public function obtenirDonnees() {
$this->getFlores();
$this->donnees['bibliobota']['references'] = $this->getBiblioBota();
$this->meta->setProjet('bibliobota');
$meta = $this->meta->getMetaDonnees();
$this->donnees['bibliobota']['meta'] = $meta[0];
$this->donnees['bibliobota']['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('bibliobota');
$this->donnees['wikini'] = $this->getWikini();
return $this->donnees;
}
public function getBloc() {
$this->getFloresBloc();
$references = $this->getBiblioBota();
$this->donnees['references'] = array_slice($references, 0, 3);
foreach ($this->donnees['references'] as $id=>$reference) {
preg_match('/.*<strong>(.*)<\/strong>.*/', $reference['reference_html'], $titre);
$this->donnees['references'][$id]['reference_html'] = $titre[1];
}
$this->donnees['autresReferences'] = count($references) - 3;
if ($this->donnees['flores'] == array() && $this->donnees['references'] == array()) {
$this->donnees['wikini'] = $this->getWikini();
}
return $this->donnees;
}
// Récupération des données flores présentes dans le référentiel
private function getFlores() {
if (Config::get($this->referentiel.'.baseFloresRef') != "") {
$flores = $this->nomCourant->getNomRetenu()->get('flores');
$flores = explode(',', $flores);
$this->donnees['flores']['liste_flores'] = $this->remplacerCorrespondancesFlores($flores);
$this->meta->setProjet($this->referentiel);
$meta = $this->meta->getMetaDonnees();
$this->donnees['flores']['meta'] = $meta[0];
$this->donnees['flores']['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($this->referentiel);
}
}
private function getFloresBloc() {
$flores = $this->nomCourant->getNomRetenu()->get('flores');
$flores = explode(',', $flores);
$flores = $this->remplacerCorrespondancesFlores($flores);
$this->donnees['flores'] = array_slice($flores, 0, 3);
$this->donnees['autresFlores'] = count($flores) - 3;
}
//Obtention des données issues de biblio_bota
private function getBiblioBota() {
$this->apiBiblioBota = $this->conteneur->getApiBiblioBota();
$this->apiBiblioBota->setProjet('bibliobota');
$interrogation = $this->nomCourant->getNomSelectionne()->get('nom_sci');
$references = $this->apiBiblioBota->getReferences($interrogation);
return $references['resultats'];
}
private function getWikini() {
$wikini = array();
$wikini['titre'] = 'Wikini';
$referentiel = $this->conteneur->getParametre('referentiel');
$num_tax = $this->nomCourant->getNomSelectionne()->get('num_taxonomique');
$page_wiki = $this->wikini->getPageWikiPourRefEtNumTax($referentiel, $num_tax);
$wikini['biblio'] = $this->wikini->getTexteFormate($page_wiki, 'biblio');
return $wikini;
}
//TODO: faire une ontologie mais pas de tache prévue dans ce sprint
private function getCorrespondancesBiblio() {
$correspondance = array(
'1' => 'BONNIER & LAYENS, 1894. Tables synoptiques des plantes vasculaires de la flore de France.',
'2' => 'COSTE, 1899-1906. Flore illustrée France, (3 vol.).',
'3' => 'FOURNIER, 1934-1940. Quatre Flores de France.',
'3*' => 'FOURNIER, additions dans l\'édition de 1961.',
'4' => 'TUTIN & al., 1964-1980. Flora Europaea, (5 vol.).',
'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).',
'5' => 'GUINOCHET & VILMORIN, 1973-1984. Flore de France, éd. C.N.R.S., (5 vol.).',
'6' => 'KERGUÉLEN, 1993. Liste synonymique de la flore de France.'
);
return $correspondance;
}
private function remplacerCorrespondancesFlores($flores) {
$correspondance_code_flores = $this->getCorrespondancesBiblio();
$flores_texte = array();
foreach($flores as $code_flore) {
$code_flore = trim($code_flore);
if(isset($correspondance_code_flores[$code_flore])) {
$flores_texte[] = $correspondance_code_flores[$code_flore];
}
}
return $flores_texte;
}
}
?>