Subversion Repositories eFlore/Applications.eflore-consultation

Compare Revisions

No changes between revisions

Ignore whitespace Rev 1403 → Rev 1427

/tags/v5.10-vilmorin/modules/fiche/formateurs/Illustrations.php
New file
0,0 → 1,369
<?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 Illustrations extends aControleur {
 
private $conteneur = null;
private $nomCourant = null;
private $images = null;
private $appUrls = null;
private $meta = null;
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->images = $this->conteneur->getApiImages();
$this->appUrls = $this->conteneur->getAppUrls();
$this->meta = $this->conteneur->getApiMetaDonnees();
}
 
public function obtenirDonnees() {
$this->donnees['nt'] = $this->nomCourant->getNt();
$this->donnees['nnr'] = $this->nomCourant->getNnr();
$this->donnees['referentiel'] = $this->referentiel;
$this->donnees['nomSciRetenu'] = $this->nomCourant->getNomRetenu()->get('nom_sci_html');
$infosNomRetenu = $this->nomCourant->getNomRetenu()->getInfos();
$this->donnees['nomComplet'] = $infosNomRetenu['nom_complet'];
$this->getPhotos();
$this->getDessin();
$this->getPhotosCaracteresIdentification();
$pso = $this->getPhotosSixOrganes();
// Le framework n'avait pas prévu l'inclusion de sous squelettes dans les modules
// en attendant, on utilise un chemin complet vers le fichier de squelette
$chemin_sous_squelette = Config::get('chemin_modules').AppControleur::getNomDossierDepuisClasse('Fiche').DS.Config::get('dossier_squelettes').DS;
$params = array('organes' => $pso, 'referentiel' => $this->referentiel,
'nnr' => $this->donnees['nnr'],
'nomComplet' => $this->donnees['nomComplet']);
$this->donnees['illustrationsOrganes'] = $this->getVue($chemin_sous_squelette.'fiche_illustrations_organes.tpl.html',$params);
$this->donnees['organes'] = $pso;
// chemins
$this->donnees['base_url_widget_saisie'] = Config::get('base_url_widget_saisie');
$this->donnees['base_url_pictoflora'] = Config::get('base_url_pictoflora');
return $this->donnees;
}
public function obtenirDonneesExport() {
$this->donnees['nt'] = $this->nomCourant->getNt();
$this->donnees['nomSciRetenu'] = $this->nomCourant->getNomRetenu()->get('nom_sci_html');
$this->donnees['cel'] = $this->getCelExport();
if ($this->referentiel == 'bdtfx') {
$this->donnees['coste'] = $this->getCoste();
}
return $this->donnees;
}
 
public function getBloc() {
$this->donnees = $this->images->getInfosMeilleureImageParPrioriteTags($nnr = $this->nomCourant->getNnr(), array(
'fleur', 'feuille', 'fruit', 'ecorce', 'port', 'rameau'));
if (empty($this->donnees)) {
$this->donnees = $this->getPhoto('cel');
if (empty($this->donnees)) {
$infos_image = $this->getDessin();
if (empty($infos_image) == false ) {
$this->donnees['imageUrl'] = array_shift($infos_image['images']);
}
}
} else {
// extraction de l'url
$this->donnees = array('imageUrl' => $this->donnees['binaire.href']);
}
// Photoflora (alias Copyrightflora alias Egoflora) n'est dispo que pour BDTFX
if (empty($this->donnees) && $this->referentiel == "bdtfx") {
$this->donnees = $this->getPhoto('photoflora');
}
return $this->donnees;
}
public function obtenirPhotoCelTpl() {
$images = $this->initialiserPhotos('cel');
$this->formaterListePhotos('cel', $images);
$this->formaterMetaPhotos('cel');
$chemin_sous_squelette = Config::get('chemin_modules').AppControleur::getNomDossierDepuisClasse('Fiche').DS.Config::get('dossier_squelettes').DS;
$donnees = array('cel' => array('images' => $this->donnees['cel']['images'], 'meta' => $this->donnees['cel']['meta'] ));
$html_tpl = $this->getVue($chemin_sous_squelette.'fiche_illustrations_cel.tpl.html', $donnees);
return $html_tpl;
}
//TODO: factoriser les deux fonctions ci dessous et ci dessus
public function obtenirTranchesCelTpl($projet) {
// On ne prend que la tranche des images (12)
$images = $this->initialiserTranchePhotos($projet);
$this->formaterListePhotos($projet, $images);
$this->formaterMetaPhotos($projet);
$chemin_sous_squelette = Config::get('chemin_modules').AppControleur::getNomDossierDepuisClasse('Fiche').DS.Config::get('dossier_squelettes').DS;
$donnees = array('cel' => array('images' => $this->donnees['cel']['images'], 'meta' => $this->donnees[$projet]['meta'] ));
$html_tpl = $this->getVue($chemin_sous_squelette.'fiche_illustrations_cel.tpl.html', $donnees);
$this->donnees[$projet]['illustrationsCel'] = $html_tpl;
$this->donnees[$projet]['cel_present'] = count($images) > 0;
// Ensuite on fait juste un lien qui permettra de les charger
$this->donnees[$projet]['ajax_url'] = $this->formaterUrlAjaxPhotoCel();
}
public function getPhoto($source) {
$donnees = array();
$this->images->setProjet($source);
$nnr = $this->nomCourant->getNnr();
$infos_image = $this->images->setApi(Eflore::API_EFLORE)->getInfosPremiereImageParIdsNoms(array($nnr));
if ($infos_image != array()) {
$image = array_shift($infos_image);
$donnees['imageUrl'] = $image['binaire.href'];
}
return $donnees;
}
 
public function getCoste() {
$coste = array();
$tax = $this->nomCourant->getNomRetenu()->get('num_taxonomique');
$this->images->setProjet('coste');
$this->images->setNnTaxon($tax);
$costeImg = $this->images->setApi(Eflore::API_EFLORE)->getInfosImagesTaxons();
foreach ($costeImg as $infos) {
$coste['images'][] = $infos['binaire.href'];
}
$this->meta->setProjet('coste');
$meta = $this->meta->getMetaDonnees();
$coste['meta'] = $meta[0];
$coste['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('coste');
return $coste;
}
 
public function getDessin() {
$projet = Config::get($this->referentiel.'.baseDessins');
if ($projet != "") {
$dessin = array();
$tax = $this->nomCourant->getNomRetenu()->get('num_taxonomique');
$this->images->setProjet($projet);
$this->images->setNnTaxon($tax);
$costeImg = $this->images->setApi(Eflore::API_EFLORE)->getInfosImagesTaxons();
foreach ($costeImg as $infos) {
$dessin['images'][] = $infos['binaire.href'];
}
$this->meta->setProjet($projet);
$meta = $this->meta->getMetaDonnees();
$dessin['meta'] = $meta[0];
$dessin['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projet);
$this->donnees[$projet] = $dessin;
}
}
public function getPhotos() {
$projets[] = Config::get($this->referentiel.'.baseImages');
$projets[] = Config::get($this->referentiel.'.baseImagesSupp');
foreach ($projets as $projet) {
if ($projet != "") {
if ($projet == "cel") {
// Chargement des 10 premieres images + un lien pour en afficher plus
$this->obtenirTranchesCelTpl($projet);
} else {
$this->images->setApi(Eflore::API_EFLORE);
$images = $this->initialiserPhotos($projet);
$this->formaterListePhotos($projet, $images);
$this->formaterMetaPhotos($projet);
}
}
}
}
private function formaterUrlAjaxPhotoCel() {
$infos = array('referentiel' => $this->referentiel,
'module' => 'fiche',
'action' => 'templateAjax',
'sous_action' => 'photoCelTpl',
'num_nom' => $this->nomCourant->getNnr(),
'onglet' => 'illustrations');
return Config::get('base_url_application_onglets').'?'.http_build_query($infos);
}
public function getPhotosSixOrganes() {
$organes = $this->getOrganes();
$nnr = $this->nomCourant->getNnr();
$infosOrganes = $this->images->getInfosMeilleuresImagesParTag($nnr, array_keys($organes), Eflore::PROTOCOLE_CAPITALISATION, 6, 'CRX2S');
$vide = true;
foreach ($infosOrganes as $tag => $organe) {
foreach ($organe as $id_image => &$image) {
$image['urlMauvaiseIdentification'] = $this->appUrls->obtenirUrlMauvaiseIdentification($image['observation']['id_observation']);
}
$organes[$tag] = $organe;
$nbImages = count($organe);
if ($nbImages != 0) {
$vide = false;
for ($i = 6; $i > $nbImages; $i--) {
$organes[$tag][] = null;
}
}
}
if ($vide) {
$organes = array();
}
return $organes;
}
public function getPhotosOrganes() {
$organes = $this->getOrganes();
$nnr = $this->nomCourant->getNnr();
$infosOrganes = $this->images->getInfosMeilleuresImagesParTag($nnr, array_keys($organes), Eflore::PROTOCOLE_CAPITALISATION, 1);
$vide = true;
foreach ($infosOrganes as $tag => $organe) {
$nbImages = count($organe);
// une image par organe seulement
$organes[$tag] = array_pop($organe);
if ($nbImages != 0) {
$vide = false;
}
}
if ($vide) {
$organes = array();
}
$this->donnees['organes'] = $organes;
}
public function getPhotosCaracteresIdentification() {
$caracteres = array();
$nnr = $this->nomCourant->getNnr();
// pas de tag: on cherche les mieux votées pour ce protocole sans tenir compte des tags
$infosCaracteres = $this->images->getInfosMeilleuresImagesParTag($nnr, '', Eflore::PROTOCOLE_CARACTERES, 3);
if (! empty($infosCaracteres) && ! empty($infosCaracteres[''])) { // le tag est vide, ici
$caracteres = $infosCaracteres[''];
}
foreach($caracteres as $id_image => &$caractere) {
$caractere['urlDetailImg'] = $this->appUrls->obtenirUrlPopUpIllustrations($id_image);
$caractere['urlImgGrandFormat'] = $this->obtenirUrlImageGrandFormatCel($id_image);
$caractere['urlContact'] = $this->appUrls->obtenirUrlPopUpContact($caractere['auteur.id'], $id_image);
$caractere['urlProfil'] = $this->appUrls->obtenirUrlProfilAnnuaire($caractere['auteur.id']);
$caractere['urlMauvaiseIdentification'] = $this->appUrls->obtenirUrlMauvaiseIdentification($caractere['observation']['id_observation']);
}
$this->donnees['caracteres'] = $caracteres;
}
private function getOrganes() {
return array(
'fleur' => array(),
'feuille' => array(),
'fruit' => array(),
'ecorce' => array(),
'port' => array(),
'rameau' => array());
}
 
// XXX: webservice:
// /service:eflore:0.1/cel/images?masque.nn=XXX&referentiel=bdtfx&retour.format=CS&navigation.limite=801
private function initialiserPhotos($projet) {
$this->images->setProjet($projet);
$nnr = $this->nomCourant->getNnr();
$ret = $this->images->getInfosImagesParIdsNoms(array($nnr));
return $ret;
}
private function initialiserTranchePhotos($projet) {
$this->images->setProjet($projet);
$nnr = $this->nomCourant->getNnr();
$ret = $this->images->getInfosTrancheImagesParIdsNoms(array($nnr), Config::get('nbTrancheImagesResultatsDeterminationAffichees'));
return $ret;
}
private function formaterListePhotos($projet, $images) {
foreach ($images as $idImg => $img) {
$infosImg = array();
$infosImg['src'] = $img['binaire.href'];
$infosImg['nomSci'] = $img['determination.nom_sci'];
$infosImg['station'] = $img['station.libelle'];
$infosImg['date'] = $this->formaterDateImg($img['date']);
$infosImg['auteur'] = $img['auteur.libelle'];
$infosImg['auteur.id'] = $img['auteur.id'];
if ($projet == "cel") {
$infosImg['urlDetailImg'] = $this->appUrls->obtenirUrlPopUpIllustrations($idImg);
$infosImg['urlImgGrandFormat'] = $this->obtenirUrlImageGrandFormatCel($idImg);
$infosImg['urlContact'] = $this->appUrls->obtenirUrlPopUpContact($img['auteur.id'], $idImg);
$infosImg['urlProfil'] = $this->appUrls->obtenirUrlProfilAnnuaire($img['auteur.id']);
$infosImg['urlMauvaiseIdentification'] = $this->appUrls->obtenirUrlMauvaiseIdentification($img['observation.id']);
}
$this->donnees[$projet]['images'][$idImg] = $infosImg;
}
}
public static function obtenirUrlImageGrandFormatCel($id, $format = "O") {
$tpl = Config::get('baseUrlImageCelTpl');
return sprintf($tpl, str_pad($id, 9, '0', STR_PAD_LEFT).$format.'.jpg');
}
// XXX: public static pour être injecté dans le squelette d'entete
public static function obtenirTemplateUrlImageGrandFormatOrganes($format = "O") {
return $tpl = sprintf(Config::get('baseUrlImageCelTpl').$format.'.jpg', '{id_image}');
}
private function formaterMetaPhotos($projet) {
$this->meta->setProjet($projet);
$meta = $this->meta->getMetaDonnees();
$titreMeta = $meta[0];
$this->donnees[$projet]['meta'] = $titreMeta;
$this->donnees[$projet]['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projet);
}
public function getCelExport() {
$cel = array();
$this->images->setProjet('cel');
$nnr = $this->nomCourant->getNnr();
$img = $this->images->getUrlPremiereImageParIdsNoms(array($nnr));
if($img) {
$img = array_values($img);
$cel['images']['src'] = $img[0]['binaire.href'];
$cel['images']['nomSci'] = $img[0]['determination.nom_sci'];
$cel['images']['station'] = $img[0]['station.libelle'];
$cel['images']['date'] = $this->formaterDateImg($img[0]['date']);
$cel['images']['auteur'] = $img[0]['auteur.libelle'];
$this->meta->setProjet('cel');
$meta = $this->meta->getMetaDonnees();
$cel['meta'] = $meta[0];
$cel['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('cel');
}
return $cel;
}
 
private function formaterDateImg($date) {
$dateFmt = $date;
if ($date == '' || $date == null || strpos($date, '0000-00-00') !== false || $date == '1970-01-01 01:01:01') {
return 'inconnue';
}
$time = strtotime($date);
if(!$time) {
/* TODO: php -r "echo strtotime('1891-00-00 00:00:00');"
TODO: fixer le template pour affiche "en l'année X", plutôt que "le X"
si FALSE pour avant 1901: problème php
On retourne alors simplement l'année.
si correction, ne pas oublier modules/popup_illustrations/PopupIllustrations.php */
$dateFmt = explode('-', $date);
return $dateFmt[0];
}
return strftime('%e %B %Y', strtotime($date));
}
 
private function formaterNomSci($nom) {
$nomFmt = $nom;
if (is_null($nom) || $nom == '') {
$nomFmt = 'inconnu';
}
return $nomFmt;
}
}
?>
/tags/v5.10-vilmorin/modules/fiche/formateurs/Nomenclature.php
New file
0,0 → 1,170
<?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 Nomenclature extends aControleur {
 
private $conteneur = null;
private $nomCourant = null;
private $noms = null;
private $meta = null;
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->taxons = $this->conteneur->getApiTaxons();
$this->noms = $this->conteneur->getApiNoms();
$this->meta = $this->conteneur->getApiMetaDonnees();
$this->appUrls = $this->conteneur->getAppUrls();
$this->wikini = $this->conteneur->getApiWikini();
//print_r($_GET['niveau']);
//Registre::set('parametres.niveau', 2);
}
 
public function obtenirDonnees() {
$this->donnees['baseUrlIco'] = $this->appUrls->obtenirUrlBaseDossier();
$this->donnees['referentiel'] = $this->referentiel;
$this->getFlores();
$this->donnees['synonymes']['noms'] = $this->trierSynonymesParBasionyme($this->getSynonymes());
$this->donnees['date_maj'] = $this->nomCourant->getNomRetenu()->get('maj_modif');
$meta = $this->meta->getMetaDonnees();
$this->donnees['synonymes']['meta'] = $meta[0];
$this->donnees['synonymes']['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($this->referentiel);
$this->donnees['num_type'] = $this->nomCourant->getNomSelectionne()->get('num_type');
$this->donnees['urls'] = $this->appUrls;
$this->donnees['nom_retenu_formate'] = $this->nomCourant->getNomRetenu()->get('nom_sci_html_complet');
$this->donnees['nom_retenu_nn'] = $this->nomCourant->getNomRetenu()->get('nom_retenu.id');
$this->donnees['nom_retenu_source'] = $this->nomCourant->getNomRetenu()->get('source_biblio');
$this->donnees['basionyme_nom_retenu'] = $this->nomCourant->getNomRetenu()->get('basionyme_html_complet');
$this->donnees['basionyme_nom_retenu_nn'] = $this->nomCourant->getNomRetenu()->get('basionyme.id');
$this->donnees['nom_selectionne'] = $this->nomCourant->getNomSelectionne()->get('nom_sci_html_complet');
$this->donnees['nom_retenu'] = $this->nomCourant->getNomRetenu()->get('nom_sci');
$this->donnees['wikini'] = $this->getWikini();
$this->donnees['hybride_parent_01'] = $this->nomCourant->getNomRetenu()->get('hybride.parent_01_html_complet');
$this->donnees['hybride_parent_02'] = $this->nomCourant->getNomRetenu()->get('hybride.parent_02_html_complet');
$this->donnees['hybride_parent_01_nn'] = $this->nomCourant->getNomRetenu()->get('hybride.parent_01.id');
$this->donnees['hybride_parent_02_nn'] = $this->nomCourant->getNomRetenu()->get('hybride.parent_02.id');
$this->donnees['taxons_sup'] = $this->nomCourant->taxons_sup;
$this->donnees['taxon_courant']['rang.libelle'] = $this->nomCourant->getNomRetenu()->get('rang.libelle');
$this->donnees['taxon_courant']['nom_sci'] = $this->nomCourant->getNomRetenu()->get('nom_sci');
$this->donnees['taxon_courant']['num_nom'] = $this->nomCourant->getNomRetenu()->get('id');
$this->donnees['taxons_inf'] = $this->getTaxonsInferieurs();
return $this->donnees;
}
private function trierSynonymesParBasionyme($synonymes) {
$synonymes_t = array();
$basionyme_inconnu = array();
foreach($synonymes as $num_nom => $syn) {
if($syn['num_type'] != "") {
$index = $syn['num_type'];
// regroupement sous le 1er basionyme (num_type == num_nom)
if(!isset($synonymes_t[$index]['infos_basionyme'])) {
$synonymes_t[$index]['infos_basionyme'] = $this->extraireInfosBasionymeDuSynonyme($syn);
}
$synonymes_t[$index]['synonymes'][$num_nom] = $syn;
} else {
$basionyme_inconnu['synonymes'][$num_nom] = $syn;
}
}
// mise à la fin du tableau des noms sans basionymes
if(!empty($basionyme_inconnu)) {
$synonymes_t['basionyme_inconnu'] = $basionyme_inconnu;
}
 
return $synonymes_t;
}
private function extraireInfosBasionymeDuSynonyme($synonyme) {
return array(
'basionyme.id' => $synonyme['basionyme.id'],
'basionyme.libelle' => $synonyme['basionyme.libelle'],
'basionyme_html' => $synonyme['basionyme_html'],
'basionyme_complet' => $synonyme['basionyme_complet'],
'basionyme_html_complet' => $synonyme['basionyme_html_complet'],
'basionyme.href' => $synonyme['basionyme.href']
);
}
private function getTaxonsInferieurs() {
$num_nom = $this->nomCourant->getNomRetenu()->get('id');
$resultat = $this->taxons->getTaxonsInf($num_nom);
// TODO: le webservice retourne le taxon demandé comme l'un des taxon inférieurs
// workaround: on le supprime ici car l'on ignore si d'autre app' dépendent de ce comportement
unset($resultat[$num_nom][$num_nom]);
return $resultat[$num_nom];
}
public function obtenirVersionDonnees() {
$meta = $this->meta->getMetaDonnees();
$this->donnees['version'] = $meta[0]['code'].' v.'.$meta[0]['version'];
return $this->donnees;
}
 
public function getBloc() {
$this->donnees['urls'] = $this->appUrls;
$this->donnees['nom_selectionne'] = $this->nomCourant->getNomSelectionne()->get('nom_sci_html_complet');
$this->donnees['nom_retenu_formate'] = $this->nomCourant->getNomRetenu()->get('nom_sci_html_complet');
$this->donnees['basionyme_nom_retenu'] = $this->nomCourant->getNomRetenu()->get('basionyme_html_complet');
$synonymes = $this->getSynonymes();
$this->donnees['synonymes'] = array_slice($synonymes, 0, 3);
$this->donnees['autresSynonymesNbre'] = count($synonymes) - 3;
$this->donnees['taxons_sup'] = $this->nomCourant->taxons_sup;
$this->donnees['taxons_inf'] = $this->getTaxonsInferieurs();
$this->donnees['taxons_sup'] = is_array($this->donnees['taxons_sup']) ? array_slice($this->donnees['taxons_sup'], -3 , 3) : array();
$this->donnees['taxons_inf'] = is_array($this->donnees['taxons_inf']) ? array_slice($this->donnees['taxons_inf'], 0 , 3) : array();
return $this->donnees;
}
 
private function getFlores() {
if (Config::get($this->referentiel.'.baseFloresRef') != "") {
$nnr = $this->nomCourant->getNnr();
$flores = $this->noms->getFlores($nnr);
$this->donnees['flores_synonymes'] = (isset($flores['resultat']) && is_array($flores['resultat'])) ? $flores['resultat'] : array();
}
}
 
private function getSynonymes() {
$nns = $this->nomCourant->getNns();
$synonymesReponse = $this->noms->getSynonymes($nns);
 
$synonymes = array();
if (isset($synonymesReponse['resultat']) && is_array($synonymesReponse['resultat'])) {
$synonymes = $synonymesReponse['resultat'];
if (array_key_exists($this->nomCourant->getNnr(), $synonymes)) {
unset($synonymes[$this->nomCourant->getNnr()]);
}
}
return $synonymes;
}
 
private function getWikini() {
$wikini = array();
$wikini['titre'] = 'Wikini';
$num_tax = $this->nomCourant->getNomSelectionne()->get('num_taxonomique');
$page_wiki = $this->wikini->getPageWikiPourRefEtNumTax($this->referentiel, $num_tax);
$wikini['nomenclature'] = $this->wikini->getTexteFormate($page_wiki, 'nomenclature');
return $wikini;
}
}
?>
/tags/v5.10-vilmorin/modules/fiche/formateurs/Bibliographie.php
New file
0,0 → 1,83
<?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->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() {
$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['references'] == array()) {
$this->donnees['wikini'] = $this->getWikini();
}
return $this->donnees;
}
//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;
}
 
 
}
?>
/tags/v5.10-vilmorin/modules/fiche/formateurs/Repartition.php
New file
0,0 → 1,162
<?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 Repartition extends aControleur {
 
private $conteneur = null;
private $nomCourant = null;
private $referentiel = 'bdtfx';
private $donnees = array();
private $cartes;
private $meta;
private $appUrls;
 
public function __construct(Conteneur $conteneur) {
$this->conteneur = $conteneur;
$this->nomCourant = $this->conteneur->getNomCourant();
$this->referentiel = $this->conteneur->getParametre('referentiel');
$this->cartes = $this->conteneur->getApiCartes();
$this->meta = $this->conteneur->getApiMetaDonnees();
$this->appUrls = $this->conteneur->getAppUrls();
}
 
public function obtenirDonnees() {
$this->getRepartition();
$this->getMoissonnage();
$this->getFloreProbable();
$this->donnees['widget']['nt'] = $this->nomCourant->getNt();
$this->donnees['widget']['nn'] = $this->nomCourant->getNnr();
$this->donnees['widget']['referentiel'] = $this->referentiel;
return $this->donnees;
}
 
public function obtenirDonneesExport() {
$this->getRepartition();
$donnees['chorodep'] = $this->donnees['repartition'];
$this->getMoissonnageExport();
// TODO: renommer l'index "eflore" en moissonnage
// et renommer dans pdf_export/squelettes/pdf_repartition.tpl.html
$donnees['eflore'] = $this->donnees['moissonnage'];
return $donnees;
}
 
private function getRepartition() {
$projetRepartition = Config::get("{$this->referentiel}.baseRepartition");
// eg: eflore ou chorodep
// cf: bdtfx.ini, bdtxa.ini
if ($projetRepartition != '') {
$this->cartes->setProjet($projetRepartition);
$this->cartes->setLargeur('630');
$nt = $this->nomCourant->getNt();
$this->cartes->setId("{$this->referentiel}.nt:$nt");
$repartition['svgUrl'] = $this->cartes->getUrlDataSvg();
$repartition['pngUrl'] = $this->cartes->getUrlPng();
$repartition['legende'] = $this->cartes->getLegendeId();
$this->meta->setProjet($projetRepartition);
$meta = $this->meta->getMetaDonnees();
$repartition['meta'] = $meta[0];
$repartition['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projetRepartition);
$this->donnees['repartition'] = $repartition;
}
}
 
private function getMoissonnage() {
$projetMoissonnage = Config::get($this->referentiel.'.baseMoissonnage');
if (! $projetMoissonnage) return;
$this->cartes->setProjet('moissonnage');
$this->cartes->setLargeur('600');
$this->cartes->setInfoNom($this->nomCourant->getNt());
$this->cartes->setInfoReferentiel($this->referentiel);
$eflore['mapUrl'] = $this->cartes->getUrlMapSvg();
$eflore['mapTelechargementUrls'] = array('png' => $this->cartes->getUrlTelechargementMapPng(),
'html' => $this->cartes->getUrlTelechargementMapHtml());
$eflore['legende'] = $this->cartes->getLegende();
$this->donnees['moissonnage'] = $eflore;
}
 
private function getMoissonnageExport() {
$projetMoissonnage = Config::get($this->referentiel.'.baseMoissonnage');
if (! $projetMoissonnage) return;
$this->cartes->setProjet($projetMoissonnage);
$this->cartes->setLargeur('min');
$this->cartes->setInfoNom($this->nomCourant->getNomRetenu());
$eflore['min'] = $this->cartes->getUrlEflorePng();
$eflore['legende'] = $this->cartes->getLegende();
$this->donnees['moissonnage'] = $eflore;
}
 
private function getFloreProbable() {
$projetFloreProbable = Config::get($this->referentiel.'.baseFloreProbable');
if (! $projetFloreProbable) return;
$this->cartes->setProjet($projetFloreProbable);
$this->meta->setProjet($projetFloreProbable);
$this->cartes->setId($this->referentiel.'.nt:'.$this->nomCourant->getNt());
// TODO: url téléchargement de la carte lorsqu'on sera sur que c'est possible
// dans ['carte']['telechargement'] par exemple
$this->donnees['flore_probable'] = array('carte' => array(), 'meta' => array());
$this->meta->setProjet($projetFloreProbable);
$meta = $this->meta->getMetaDonnees();
$this->donnees['flore_probable']['meta'] = $meta[0];
$this->donnees['flore_probable']['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projetFloreProbable);
$this->donnees['flore_probable']['carte']['url'] = $this->cartes->getUrlFloreProbablePng();
}
 
public function getBloc() {
$donnees['chorodep'] = $this->getChorodepMiniature();
$donnees['eflore'] = $this->getMoissonnageMiniature();
 
// TODO: moche, comment gérer le fait que l'onglet "synthèse", en "bdtxa", doive
// afficher la carte chorologie, et non la carte chorodep.
// workaround: écrasement de l'URL dans ['répartition']['chorodep']:
if ($this->referentiel == 'bdtxa') {
$nt = $this->nomCourant->getNt();
$idCarte = "{$this->referentiel}.nt:$nt";
$urlCarte = Config::get("{$this->referentiel}.baseRepartition");
 
$donnees['chorodep'] = Cartes::getCarteUrlPng($urlCarte, $idCarte, '190x178');
}
 
return $donnees;
}
 
private function getChorodepMiniature() {
$projetRepartition = Config::get("{$this->referentiel}.baseRepartition");
$url = null;
if ($projetRepartition != '') {
$this->cartes->setProjet($projetRepartition);
$this->cartes->setProjet('chorodep');
$this->cartes->setLargeur('190x178');
 
$nt = $this->nomCourant->getNt();
$this->cartes->setId("{$this->referentiel}.nt:$nt");
 
$url = $this->cartes->getUrlPng();
}
return $url;
}
 
private function getMoissonnageMiniature() {
$projetMoissonnage = Config::get($this->referentiel.'.baseMoissonnage');
$url = null;
if ($projetMoissonnage != '') {
$this->cartes->setProjet('moissonnage');
$this->cartes->setLargeur('190');
$this->cartes->setInfoReferentiel($this->referentiel);
$this->cartes->setInfoNom($this->nomCourant->getNt());
$url = $this->cartes->getUrlMapPng();
}
return $url;
}
}
?>
Property changes:
Added: svnkit:entry:sha1-checksum
+14e91034608691b894071e3f1724d66014a9373f
\ No newline at end of property
/tags/v5.10-vilmorin/modules/fiche/formateurs/Synthese.php
New file
0,0 → 1,66
<?php
// declare(encoding='UTF-8');
/**
* Classe Onglet Synthese.
*
* @category PHP 5.2
* @package eflore-consultation
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
* @author Delphine CAUQUIL <delphine@tela-botanica.org>
* @author Grégoire DUCHÉ <gregoire@tela-botanica.org>
* @author Raphaël Droz <raphael@tela-botanica.org>
* @copyright 2011, 2013 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
* @used by modules/fiche/Fiche.php::obtenirDonnees()
*/
class Synthese /* aControleur inutilisé à ce jour */ {
 
private $conteneur = null;
private $nomCourant = null;
 
public function __construct(Conteneur $conteneur) {
$this->conteneur = $conteneur;
$this->nomCourant = $this->conteneur->getNomCourant();
}
 
public function obtenirDonnees() {
$donnees = array();
$num_nom = $this->nomCourant->getNns();
 
$nom = $this->conteneur->getApiNoms()->getNom($num_nom);
$blocs = array(
'illustrations', // grep-friendly: new Illustrations()
'repartition', // grep-friendly: new Repartition()
'nomenclature', // grep-friendly: new Nomenclature()
'description', // grep-friendly: new Description()
'ethnobotanique', // grep-friendly: new Ethnobotanique()
'bibliographie', // grep-friendly: new Bibliographie()
'statut', // grep-friendly: new Statut()
'ecologie' // grep-friendly: new Ecologie()
);
$cache = array();
$nt = $this->conteneur->getNomCourant()->getNomRetenu()->get('num_taxonomique');
$donnees['infos'] = array('referentiel' => $this->conteneur->getParametre('referentiel'), 'num_tax' => $nt, 'nom_sci' => $nom['nom_complet']);
$referentiel = $this->conteneur->getParametre('referentiel');
foreach ($blocs as $bloc) {
// TODO: unserialize() pourrait aussi légitimement retourner FALSE
$cache_bloc = unserialize($this->conteneur->getCache()->charger($bloc.'/bloc/'.$referentiel.'_'.$num_nom));
if($cache_bloc) {
$donnees[$bloc] = $cache_bloc;
} else {
$nom_classe = ucfirst($bloc);
$classe = new $nom_classe($this->conteneur);
$donnees[$bloc] = $classe->getBloc();
if($donnees[$bloc]) {
$this->conteneur->getCache()->sauver(serialize($donnees[$bloc]),
$bloc.'/bloc/'.$referentiel.'_'.$num_nom);
}
}
}
return $donnees;
}
}
?>
/tags/v5.10-vilmorin/modules/fiche/formateurs/Description.php
New file
0,0 → 1,266
<?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 Description extends aControleur {
 
private $conteneur = null;
private $nomCourant = null;
private $textes = null;
private $meta = null;
private $wikini = null;
private $informations = null;
static $mois = array(
'janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet',
'août', 'septembre', 'octobre', 'novembre', 'décembre');
private $CosteFormate;
private $CosteTexte;
 
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->textes = $this->conteneur->getApiTextes();
$this->wikini = $this->conteneur->getApiWikini();
$this->meta = $this->conteneur->getApiMetaDonnees();
$this->informations = $this->conteneur->getApiInformations();
$this->appUrls = $this->conteneur->getAppUrls();
}
 
public function obtenirDonnees() {
$donnees = array();
$this->getWikipedia();
$this->getWikini();
$this->getDescriptionsDependantesReferentiel($this->referentiel);
if ($this->referentiel == 'bdtfx') {
$this->getCoste();
}
return $this->donnees;
}
 
public function obtenirDonneesExport() {
$donnees = array();
$this->getWikini();
$this->getDescriptionsDependantesReferentiel($this->referentiel);
return $this->donnees;
}
 
private function getDescriptionsDependantesReferentiel($ref) {
if(trim(Config::get($ref . '.baseDescription')) != "") {
// eg: [bdtfx]baseDescription = coste,baseflor dans bdtfx.ini
$bases_descriptions = explode(',', Config::get($ref . '.baseDescription'));
foreach ($bases_descriptions as $base) {
$fonction = 'get'.ucfirst($base);
$this->$fonction();
}
}
}
 
public function getBloc() {
// prend la première description disponible dans l'ordre indiqué dans le fichier
// de config, et prend la description wiki sinon
if(Config::get($this->referentiel.'.baseDescription') != "") {
$bases_descriptions = explode(',', Config::get($this->referentiel.'.baseDescription'));
foreach ($bases_descriptions as $base) {
$fonction = 'get'.ucfirst($base);
$this->$fonction();
if(empty($this->donnees[$base]['description'])) {
unset($this->donnees[$base]);
continue;
}
 
$this->donnees['type'] = $base;
$this->donnees['titre'] = "Description de ".ucfirst($base);
$this->donnees['description'] = $this->donnees[$base]['description'];
unset($this->donnees[$base]);
return $this->donnees;
}
}
 
if (empty($this->donnees['description'])) {
$this->getWikini();
$this->donnees['description'] = $this->donnees['wikini']['description'];
$this->donnees['titre'] = "Description collaborative";
$this->donnees['type'] = 'wikini';
unset($this->donnees['wikini']);
}
 
return $this->donnees;
}
 
private function getBaseflor() {
$baseflor = array();
$this->informations ->setProjet('baseflor');
$this->informations ->setBdnt($this->conteneur->getParametre('referentiel'));
$this->informations ->setNum_nom($this->nomCourant->getNnr());
$informations = $this->informations->getInformationsDescription();
if ($informations){
$baseflor['chorologie'] = isset($informations['chorologie']) ? $informations['chorologie'] : '';
$baseflor['inflorescence'] = isset($informations['inflorescence']) ? $informations['inflorescence'] : '';
$baseflor['sexualite'] = isset($informations['sexualite']) ? $informations['sexualite'] : '';
$baseflor['ordre_maturation'] = isset($informations['ordre_maturation']) ? $informations['ordre_maturation'] : '';
$baseflor['pollinisation'] = isset($informations['pollinisation']) ? $informations['pollinisation'] : '';
$baseflor['dissemination'] = isset($informations['dissemination']) ? $informations['dissemination'] : '';
$baseflor['fruit'] = isset($informations['fruit']) ? $informations['fruit'] : '';
$baseflor['couleur_fleur'] = isset($informations['couleur_fleur']) ? $informations['couleur_fleur'] : '';
$baseflor['macule'] = isset($informations['macule']) ? $informations['macule'] : '';
$baseflor['floraison'] = isset($informations['floraison']) ? self::changerFloraisonEnChaine($informations['floraison']) : '';
//récupérer dans ontologies
$baseflor['type_bio'] = isset($informations['type_bio.libelle']) ? $informations['type_bio.libelle'] : '';
$baseflor['form_vegetale'] = isset($informations['form_vegetale']) ? $informations['form_vegetale'] : '';
$baseflor['description']=$baseflor;
$this->meta->setProjet('baseflor');
$meta = $this->meta->getMetaDonnees();
$baseflor['meta'] = $meta[0];
$baseflor['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('baseflor');
}
$this->donnees['baseflor'] = $baseflor;
}
 
static function changerFloraisonEnChaine($floraison){
$chaine = "";
if ($floraison != ""){
$mois_fleurs=preg_match('/-/',$floraison) ? preg_split('/-/',$floraison) : $floraison;
if (is_array($mois_fleurs)){
$chaine = "de ".self::$mois[(int)$mois_fleurs[0]]." à ".self::$mois[(int)$mois_fleurs[1]];
 
}else { $chaine = "en ".self::$mois[(int)$mois_fleurs];
}
}
return $chaine;
}
 
public function getUrlWikipedia() {
if(!isset($this->donnees['wp'])) {
$this->getWikipedia();
}
return $this->donnees['wp'];
}
 
public function getWikipedia() {
$wp = array();
$this->textes->setProjet('wikipedia');
$this->textes->setId(self::getIdWp($this->nomCourant->getNomRetenu()->get('nom_sci')));
$wp['titre'] = $donnees['titre'] = "Description de wikipedia";
$wp['lien'] = $this->textes->getPageUrl();
$wp['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('wikipedia');
$this->donnees['wp'] = $wp;
}
 
private static function getIdWp($nomSci) {
return urlencode(str_replace(' ', '_', $nomSci));
}
 
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['description'] = $this->wikini->getTexteFormate($page_wiki, 'description');
$this->donnees['wikini'] = $wikini;
}
 
public function getLienWikini() {
$referentiel = $this->conteneur->getParametre('referentiel');
$num_tax = $this->nomCourant->getNomSelectionne()->get('num_taxonomique');
return $this->wikini->getUrlPageWiki($referentiel, $num_tax);
}
 
private function getCoste() {
$coste = array();
$this->textes->setProjet('coste');
$this->textes->setId('bdtfx.nt:'.$this->nomCourant->getNt());
$texte = $this->textes->getTexte();
$texte = array_pop($texte['resultats']);
if ($texte) {
$coste['titre'] = $texte['titre'];
$coste['description'] = self::mettreEnFormeCoste($texte['texte']);
}
$this->meta->setProjet('coste');
$meta = $this->meta->getMetaDonnees();
$coste['meta'] = $meta[0];
$coste['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('coste');
$this->donnees['coste'] = $coste;
}
 
static function mettreEnFormeCoste($texte) {
$txt_fmt = array();
//decouper elements remarquables avant le texte
self::separerNomScientifique_a_NomCommun($texte, $txt_fmt);
$texte = preg_replace('/\//','',$texte);
//decouper elements remarquables après le texte
self::separerEcologie_a_Usages($texte, $txt_fmt);
//le morceau qui reste est le gros de la description
$texte = str_replace(';','</br> -','- '.$texte);
$texte = str_replace('–','',$texte);
$txt_fmt['texte'] = $texte;
return $txt_fmt;
}
 
 
static function separerNomScientifique_a_NomCommun(&$txt, &$txt_fmt){
if ( preg_match('/\*\*(.+)\*\*([^–]*)–/', $txt, $retour)){
/* !! attention on enlève un tiret cadratin – pas un trait d'union - !! */
$a_enlever = array('/–/','/\./' );
$txt_fmt['nom_scientifique'] = preg_replace($a_enlever,'',$retour[1]);
if(preg_match('/\((.+)\)/',$retour[2],$synonymes)){
$txt_fmt['synonymes'] = $synonymes[1];
} else {
$txt_fmt['nom_scientifique'] .= $retour[2];
}
$txt = str_replace($retour[0],'',$txt);
}
/* !! attention il y a un espace avant les // du début !! */
if ( preg_match('/^ \/\/([^\/\/]+)\/\//', $txt, $retour)){
$a_enlever = array('/–/','/\./' );
$txt_fmt['nom_commun'] = preg_replace($a_enlever,'',$retour[1]);
$txt = str_replace($retour[0],'',$txt);
}
}
 
 
static function separerEcologie_a_Usages(&$txt, &$txt_fmt) {
if (preg_match('/\.\s*([A-ZÉÀÈ].+)$/',$txt, $retour)) {
$txt_fmt['ecologie'] = $retour[1];
$txt = str_replace($retour[0],'.',$txt);
if (isset($txt_fmt['ecologie']) && preg_match('/–(.+)/', $txt_fmt['ecologie'] , $retour)){
$txt_fmt['repartition'] = $retour[1];
$txt_fmt['ecologie'] = str_replace($retour[0],'',$txt_fmt['ecologie']);
}
if (isset($txt_fmt['repartition']) && preg_match('/=(.+)$/', $txt_fmt['repartition'], $retour)){
$txt_fmt['floraison'] = $retour[1];
$txt_fmt['repartition'] = str_replace($retour[0],'',$txt_fmt['repartition']);
}
if (isset($txt_fmt['floraison']) && preg_match('/–(.+)$|\n(.+)$/',$txt_fmt['floraison'], $retour)){
$txt_fmt['usages'] = isset($retour[1]) ? $retour[1] : $retour[2];
$txt_fmt['floraison'] = str_replace($retour[0],'.',$txt_fmt['floraison']);
}
if (isset($txt_fmt['floraison']) && preg_match('/([Ff]l\.) (.+)/',$txt_fmt['floraison'], $retour)){
$txt_fmt['floraison'] = $retour[2];
$txt_fmt['floraison'] = str_replace($retour[1],'',$txt_fmt['floraison']);
}
if (isset($txt_fmt['floraison']) && preg_match('/([Ff]r\.) (.+)/',$txt_fmt['floraison'], $retour)){
$txt_fmt['fructification'] = $retour[2];
$txt_fmt['floraison'] = str_replace($retour[0],'',$txt_fmt['floraison']);
$txt_fmt['floraison'] = str_replace(',','',$txt_fmt['floraison']);
$txt_fmt['fructification'] = str_replace($retour[1],'',$txt_fmt['fructification']);
$txt_fmt['fructification'] = str_replace('.','',$txt_fmt['fructification']);
}
}
}
}
?>
Property changes:
Added: svn:mergeinfo
Merged /branches/v5.4-decaisne/modules/fiche/formateurs/Description.php:r1226-1227
Merged /branches/v5.2-lasegue/modules/fiche/formateurs/Description.php:r1183
Merged /branches/v5.7-duchartre/modules/fiche/formateurs/Description.php:r1286,1294,1296,1325,1333-1334
Merged /branches/v5.3-cordier/modules/fiche/formateurs/Description.php:r1206
Merged /branches/v5.8-seynes/modules/fiche/formateurs/Description.php:r1344-1345,1347,1351,1356
/tags/v5.10-vilmorin/modules/fiche/formateurs/Statut.php
New file
0,0 → 1,104
<?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 Statut extends aControleur {
private $conteneur = null;
private $nomCourant = null;
private $wikini = null;
private $statuts = null;
private $meta;
private $referentiel = null;
private $appUrls;
public function __construct(Conteneur $conteneur) {
$this->conteneur = $conteneur;
$this->nomCourant = $this->conteneur->getNomCourant();
$this->wikini = $this->conteneur->getApiWikini();
$this->statuts = $this->conteneur->getApiStatuts();
$this->meta = $this->conteneur->getApiMetaDonnees();
$this->referentiel = $this->conteneur->getParametre('referentiel');
$this->appUrls = $this->conteneur->getAppUrls();
}
public function getBloc() {
$donnees = array();
$donnees['statuts'] = $this->getStatutsZoneGeo();
if(empty($donnees['statuts'])) {
$donnees['wikini'] = $this->getWikini();
}
$donnees['liste_rouge'] = $this->getCategorieListeRouge();
return $donnees;
}
public function obtenirDonnees() {
$donnees = array();
$donnees['wikini'] = $this->getWikini();
$donnees['statuts'] = $this->getStatuts();
$donnees['liste_rouge'] = $this->getCategorieListeRouge();
return $donnees;
}
private function getStatuts() {
$statuts = "";
$projet = Config::get($this->referentiel.'.baseStatuts');
if ($projet != "") {
$nnr = $this->nomCourant->getNnr();
$statuts = $this->statuts->getStatuts($projet, $nnr);
$this->meta->setProjet($projet);
$meta = $this->meta->getMetaDonnees();
$statuts['meta'] = $meta[0];
$statuts['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projet);
}
return $statuts;
}
private function getStatutsZoneGeo() {
$statuts = "";
$projet = Config::get($this->referentiel.'.baseStatuts');
if ($projet != "") {
$nnr = $this->nomCourant->getNnr();
$statuts = $this->statuts->getStatutsZoneGeo($projet, $nnr);
$this->meta->setProjet($projet);
$meta = $this->meta->getMetaDonnees();
$statuts['meta'] = $meta[0];
$statuts['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projet);
}
return $statuts;
}
private function getCategorieListeRouge() {
$liste_rouge = "";
$projet = Config::get($this->referentiel.'.baseListeRouge');
if ($projet != "") {
$nnr = $this->nomCourant->getNnr();
$liste_rouge = $this->statuts->getCategorieListeRouge($projet, $nnr);
$this->meta->setProjet($projet);
$meta = $this->meta->getMetaDonnees();
$liste_rouge['meta'] = $meta[0];
$liste_rouge['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projet);
}
return $liste_rouge;
}
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['statuts_de_protection'] = $this->wikini->getTexteFormate($page_wiki, 'statuts de protection');
return $wikini;
}
}
?>
/tags/v5.10-vilmorin/modules/fiche/formateurs/Ethnobotanique.php
New file
0,0 → 1,160
<?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 Ethnobotanique extends aControleur {
 
private $conteneur = null;
private $nomCourant = null;
private $nomsVernaculaires = null;
private $wikini;
private $referentiel = 'bdtfx';
private $donnees = array();
 
public function __construct(Conteneur $conteneur) {
$this->conteneur = $conteneur;
$this->nomCourant = $this->conteneur->getNomCourant();
$this->nomsVernaculaires = $this->conteneur->getApiNomsVernaculaires();
$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->getNomsVernaculaires('.referentielVerna');
$this->getNomsVernaculaires('.referentielVernaGrec');
$this->getChorologie();
$this->donnees['wikini'] = $this->getWikini();
return $this->donnees;
}
 
private function getNomsVernaculaires($projet) {
$projet = Config::get($this->referentiel.$projet);
if ($projet != "") {
$nt = $this->nomCourant->getNomRetenu()->get('num_taxonomique');
$nomsVerna = $this->nomsVernaculaires->getRechercheComplete($projet, $nt);
$this->donnees[$projet]['noms'] = $nomsVerna['resultat'];
$this->meta->setProjet($projet);
$meta = $this->meta->getMetaDonnees();
$this->donnees[$projet]['meta'] = $meta[0];
$this->donnees[$projet]['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projet);
}
}
public function getBloc() {
$nt = $this->nomCourant->getNomRetenu()->get('num_taxonomique');
$projet = Config::get($this->referentiel.'.referentielVerna');
if ($projet != "") {
$nomsVerna = $this->nomsVernaculaires->getRechercheLimitee($projet, $nt);
$this->donnees['nomsVerna'] = (isset($nomsVerna['resultat']) && is_array($nomsVerna['resultat'])) ? array_slice($nomsVerna['resultat'], 0, 3) : array();
$this->donnees['autresNomsVerna'] = count($nomsVerna['resultat']) - 3;
}
$this->donnees['wikini'] = $this->getWikini();
return $this->donnees;
}
private function getChorologie() {
$infos_choro = $this->nomCourant->getNomRetenu()->getInfos();
$this->donnees['chorologie'] = $this->traiterTableauChorologie($infos_choro);
$this->meta->setProjet($this->referentiel);
$meta = $this->meta->getMetaDonnees();
$this->donnees['chorologie']['meta'] = $meta[0];
$this->donnees['chorologie']['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($this->referentiel);
}
private function traiterTableauChorologie($infos_choro) {
$donnees_choro = array();
$colonnes = array();
foreach ($infos_choro as $param => $valeur) {
if(strncmp($param, 'presence', 8) == 0) {
$lieu = self::obtenirLieuPourCodePresence($this->referentiel, $param);
if($lieu) {
$donnees_choro['Présence'][$lieu] = $valeur;
$colonnes[] = $lieu;
}
} else {
$donnees_choro = self::traiterChampsStatuts($this->referentiel, $donnees_choro, $param, $valeur);
}
}
 
ksort($donnees_choro);
$donnees = array('colonnes' => array_unique($colonnes), 'donnees' => $donnees_choro);
return $donnees;
}
static function traiterChampsStatuts($ref, $tableau_donnees, $code, $valeur) {
if ($code == 'statut_origine.libelle') {
$tableau_donnees['Statut d\'origine'][self::obtenirIntituleLieuPourReferentiel($ref)] = $valeur;
} elseif ($code == 'statut_introduction.libelle') {
$tableau_donnees['Statut d\'introduction'][self::obtenirIntituleLieuPourReferentiel($ref)] = $valeur;
} elseif ($code == 'statut_culture.libelle') {
$tableau_donnees['Statut de culture'][self::obtenirIntituleLieuPourReferentiel($ref)] = $valeur;
}
return $tableau_donnees;
}
 
/* eg:
* - presence.libelle
* - presence_Guadeloupe.code */
static function obtenirLieuPourCodePresence($ref, $str) {
// ignore les paramètres JSON de présence qui ne contiennent pas le libellé
// (= présence en toutes lettres)
if(substr($str, -7) != 'libelle') return NULL;
@list($prefixe, $lieu) = explode('_', $str, 2);
 
if($str == 'presence.libelle') {
return self::obtenirIntituleLieuPourReferentiel($ref);
}
 
list($lieu, $param) = explode('.', $lieu, 2);
if (strtolower($lieu) == 'ga') {
return 'France (Hors Corse)';
} elseif (strtolower($lieu) == 'co') {
return 'France (Corse)';
} elseif($lieu) {
return $lieu;
}
return NULL;
}
private static function obtenirIntituleLieuPourReferentiel($ref) {
$lieu = '';
switch($ref) {
case 'bdtfx':
$lieu = 'France';
break;
case 'bdtxa':
$lieu = 'Antilles';
case 'isfan':
$lieu = 'Afrique du Nord';
break;
}
return $lieu;
}
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['noms_communs'] = $this->wikini->getTexteFormate($page_wiki, 'noms communs');
$wikini['culture_et_arts'] = $this->wikini->getTexteFormate($page_wiki, 'culture et arts');
$wikini['usage'] = $this->wikini->getTexteFormate($page_wiki, 'usage');
return $wikini;
}
}
?>
/tags/v5.10-vilmorin/modules/fiche/formateurs/Ecologie.php
New file
0,0 → 1,210
<?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>
* @author Mathilde Salthun-lassalle <mathilde@tela-botanica.org>
* @author Raphaël Droz <raphael@tela-botanica.org>
* @copyright 2011, 2013 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
* @used by modules/pdf_export/PdfExport.php::initialiser()
* @used by modules/fiche/formateurs/Synthese.php::obtenirDonnees()
*/
class Ecologie extends aControleur {
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->informations = $this->conteneur->getApiInformations();
$this->meta = $this->conteneur->getApiMetaDonnees();
$this->wikini = $this->conteneur->getApiWikini();
$this->appUrls = $this->conteneur->getAppUrls();
$this->graphique = $this->conteneur->getApiGraphiques();
$this->syntaxons = $this->conteneur->getApiSyntaxons();
parent::__construct();
}
public function obtenirDonnees() {
$donnees = array();
$this->getWikini();
$this->getBaseflor();
$this->getBaseveg();
$this->donnees['urls'] = $this->appUrls;
return $this->donnees;
}
public function obtenirDonneesExport() {
$donnees['wikini'] = $this->getWikini();
$donnees['baseflor'] = $this->getBaseflorExport();
$donnees['baseveg'] = $this->getBaseveg();
return $donnees;
}
public function getBaseflorCatminat($depart, $limite) {
$baseflorCatminat = array();
$this->informations->setProjet('baseflor');
$this->informations->setBdnt($this->conteneur->getParametre('referentiel'));
$this->informations->setNum_nom($this->nomCourant->getNnr());
$this->informations->setDepart($depart);
$this->informations->setLimite($limite);
$informations = $this->informations->getInformationsRelationCatminat();
if($informations != ""){
$baseflorCatminat['catminat'] = $informations['resultat'][0]['catminat_code'];
$baseflorCatminat['lien-liste-fancy'] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_taxons',$this->conteneur->getParametre('referentiel'),$this->nomCourant->getNnr(),$baseflorCatminat['catminat']);
} else {
$baseflorCatminat['aucune'] = 'Aucune donnée';
}
return $baseflorCatminat;
}
private function getBaseveg() {
if (Config::get($this->referentiel.'.basePhytosocio') != "") {
$baseveg = array();
$baseflor = $this->getBaseflorCatminat(0,500);
$baseveg['baseflor'] = $baseflor;
if (isset($baseflor['catminat'])) {
$this->syntaxons->setProjet('baseveg');
$catminat = str_replace('/','-',$baseflor['catminat']);
$this->syntaxons->setCatminat($catminat);
$syntaxonsSup = $this->syntaxons->getSyntaxonsSuperieurs();
$baseveg['syntaxons-sup'] = $syntaxonsSup['resultat'];
$syntaxonsCourant = $this->syntaxons->getSyntaxonsCatminat();
$baseveg['syntaxon-courant'] = $syntaxonsCourant['resultat'];
foreach ($baseveg['syntaxons-sup'] as $cle => $valeurs) {
$catminat_sup = str_replace('/','-',$valeurs['code_catminat']);
$baseveg['synonymes']['lien-liste-fancy'][$valeurs['code_catminat']] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_synonymes',$this->conteneur->getParametre('referentiel'),$this->nomCourant->getNnr(),$catminat_sup);
$baseveg['ref']['lien-liste-fancy'][$valeurs['code_catminat']] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_ref',$this->conteneur->getParametre('referentiel'),$this->nomCourant->getNnr(),$catminat_sup);
$baseveg['taxons']['lien-liste-fancy'][$valeurs['code_catminat']] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_taxons_sup',$this->conteneur->getParametre('referentiel'),$this->nomCourant->getNnr(),$catminat_sup);
}
$baseveg['synonymes']['lien-liste-fancy'][$baseflor['catminat']] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_synonymes',$this->conteneur->getParametre('referentiel'),$this->nomCourant->getNnr(),$catminat);
$baseveg['ref']['lien-liste-fancy'][$baseflor['catminat']] = $this->appUrls->obtenirUrlListeFancyBoxPhytosocio('catminat_ref',$this->conteneur->getParametre('referentiel'),$this->nomCourant->getNnr(),$catminat);
$this->meta->setProjet('baseveg');
$meta = $this->meta->getMetaDonnees();
$baseveg['meta'] = $meta[0];
$baseveg['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('baseveg');
}else {
$baseveg['aucune'] = 'Aucune donnée';
}
$this->donnees['baseveg'] = $baseveg;
}
}
private function getBasevegSyntaxonCourant() {
$baseveg = array();
$baseflor = $this->getBaseflorCatminat(0,500);
if (isset($baseflor['catminat'])) {
$this->syntaxons->setProjet('baseveg');
$catminat = str_replace('/','-',$baseflor['catminat']);
$this->syntaxons->setCatminat($catminat);
$syntaxonsCourant = $this->syntaxons->getSyntaxonsCatminat();
$baseveg['description'] = $syntaxonsCourant['resultat'];
}
return $baseveg;
}
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['ecologie'] = $this->wikini->getTexteFormate($page_wiki, 'ecologie');
$this->donnees['wikini'] = $wikini;
}
public function getBloc() {
$donnees = array();
$this->getBaseflor(false);
$this->donnees['graph'] = $this->donnees['baseflor'];
$this->donnees['graph']['titre'] = 'Optimum écologique';
$this->donnees['phytosocio'] = $this->getBasevegSyntaxonCourant();
return $this->donnees;
}
private function getBaseflorExport() {
$baseflor = array();
$this->informations ->setProjet('baseflor');
$this->informations ->setBdnt($this->conteneur->getParametre('referentiel'));
$this->informations ->setNum_nom($this->nomCourant->getNnr());
$informations = $this->informations->getInformationsEcologie();
if(is_array($informations)){
$baseflor['climat_url'] = $informations['graphique_climat']['href']."?retour.format=500";
$baseflor['sol_url'] = $informations['graphique_sol']['href']."?retour.format=500";
$baseflor['climat_url_png'] = $informations['graphique_climat']['href']."?retour=image/png";
$baseflor['sol_url_png'] = $informations['graphique_sol']['href']."?retour=image/png";
$this->graphique -> setProjet('baseflor');
$baseflor['legende_eco'] = $this->urls->obtenirUrlBaseDossier() . Config::get('dossier_images') . '/legende_formes.png';
$this->meta->setProjet('baseflor');
$meta = $this->meta->getMetaDonnees();
$baseflor['meta']= $meta[0];
}else {
$baseflor['aucune'] = 'Aucune donnée';
}
return $baseflor;
}
private function getBaseflor($inclure_legende = true) {
if (Config::get($this->referentiel.'.baseEcologie')) {
$referentiel = $this->conteneur->getParametre('referentiel');
$num_nom = $this->nomCourant->getNnr();
 
// TODO: unserialize() pourrait aussi légitimement retourner FALSE
$cache = unserialize($this->conteneur->getCache()->charger('baseflor/graphique/'.$referentiel.'_'.$num_nom));
if($cache) {
$baseflor = $cache;
$this->graphique ->setProjet('baseflor');
$graphique = $this->graphique->getLegendeGraphique();
$baseflor['legende'] = $graphique ;
} else {
$baseflor = array();
$this->informations ->setProjet('baseflor');
$this->informations ->setBdnt($this->conteneur->getParametre('referentiel'));
$this->informations ->setNum_nom($this->nomCourant->getNnr());
$informations = $this->informations->getInformationsEcologie();
if(is_array($informations)){
if (isset($informations['graphique_climat'])) {
$baseflor['climat_url'] = $informations['graphique_climat']['href']."?retour.format=500";
$baseflor['climat_url_png'] = $informations['graphique_climat']['href']."?retour=image/png";
$baseflor['description']['climat_url'] = $informations['graphique_climat']['href']."?retour.format=420";
$baseflor['description']['climat_url_png'] = $informations['graphique_climat']['href']."?retour.format=420&retour=image/png";
}
if (isset($informations['graphique_sol'])) {
$baseflor['sol_url'] = $informations['graphique_sol']['href']."?retour.format=500";
$baseflor['sol_url_png'] = $informations['graphique_sol']['href']."?retour=image/png";
$baseflor['description']['sol_url'] = $informations['graphique_sol']['href']."?retour.format=420";
$baseflor['description']['sol_url_png'] = $informations['graphique_sol']['href']."?retour.format=420&retour=image/png";
}
if($inclure_legende) {
$this->graphique ->setProjet('baseflor');
$graphique = $this->graphique->getLegendeGraphique();
$baseflor['legende'] = $graphique ;
}
$this->meta->setProjet('baseflor');
$meta = $this->meta->getMetaDonnees();
$baseflor['meta'] = $meta[0];
$baseflor['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('baseflor');
$this->conteneur->getCache()->sauver(serialize($baseflor),
'baseflor/graphique/'.$referentiel.'_'.$num_nom);
} else {
$baseflor['aucune'] = 'Aucune donnée';
}
}
$this->donnees['baseflor'] = $baseflor;
}
}
}
?>