/tags/2014-04-14/modules/fiche/formateurs/Illustrations.php |
---|
New file |
0,0 → 1,300 |
<?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); |
// chemins |
$this->donnees['base_url_widget_saisie'] = Config::get('base_url_widget_saisie'); |
$this->donnees['base_url_del'] = Config::get('base_url_del'); |
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(); |
$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']); |
} |
if (empty($this->donnees)) { |
$this->donnees = $this->getPhoto('photoflora'); |
} |
return $this->donnees; |
} |
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") { |
$this->images->setApi(Eflore::API_EFLORE); // prêt à passer à API_DEL |
} else { |
$this->images->setApi(Eflore::API_EFLORE); |
} |
$images = $this->initialiserPhotos($projet); |
$this->formaterListePhotos($projet, $images); |
$this->formaterMetaPhotos($projet); |
} |
} |
} |
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) { |
$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['']; |
} |
$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 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['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; |
} |
} |
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 || $date == '0000-00-00' || $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/2014-04-14/modules/fiche/formateurs/Nomenclature.php |
---|
New file |
0,0 → 1,168 |
<?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['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'); |
$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/2014-04-14/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; |
} |
} |
?> |
/tags/2014-04-14/modules/fiche/formateurs/Repartition.php |
---|
New file |
0,0 → 1,177 |
<?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 $tailleBloc = "190x178"; |
private $serviceChorodep = null; |
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'); |
//TODO: démochir ce code |
// Chargement des nn des synonymes pour obtenir une carte plus complète |
$noms = $this->conteneur->getApiNoms(); |
$syns = $noms->getSynonymes($this->nomCourant->getNnr()); |
$nns_syns = array_keys($syns['resultat']); |
$nns_syns[] = $this->nomCourant->getNnr(); |
$id = 'nn:'.implode(',', $nns_syns); |
$this->cartes->setId($id); |
$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') { |
$syns = $this->conteneur->getApiNoms()->getSynonymes($this->nomCourant->getNnr()); |
$nns_syns = array_keys($syns['resultat']); |
$nns_syns[] = $this->nomCourant->getNnr(); |
$donnees['chorodep'] = Cartes::getCarteUrlPng(Config::get($this->referentiel.'.baseRepartition'), |
'nn:'.implode(',', $nns_syns), |
'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'); |
//TODO: démochir ce code |
// Chargement des nn des synonymes pour obtenir une carte plus complète |
$noms = $this->conteneur->getApiNoms(); |
$syns = $noms->getSynonymes($this->nomCourant->getNnr()); |
$nns_syns = array_keys($syns['resultat']); |
$nns_syns[] = $this->nomCourant->getNnr(); |
$id = 'nn:'.implode(',', $nns_syns); |
$this->cartes->setId($id); |
$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; |
} |
} |
?> |
/tags/2014-04-14/modules/fiche/formateurs/Synthese.php |
---|
New file |
0,0 → 1,64 |
<?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(); |
$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); |
$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/2014-04-14/modules/fiche/formateurs/Description.php |
---|
New file |
0,0 → 1,264 |
<?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); |
$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.nn:'.$this->nomCourant->getNnr()); |
$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']); |
} |
} |
} |
} |
?> |
/tags/2014-04-14/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/2014-04-14/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/2014-04-14/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; |
} |
} |
} |
?> |