Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 2407 → Rev 2408

/trunk/widget/modules/saisie/Saisie.php
9,14 → 9,16
* @link http://www.tela-botanica.org/wikini/eflore/wakka.php?wiki=AideCELWidgetSaisie
*
* Paramètres :
* ===> projet = chaine [par défaut : Biodiversite34]
* ===> projet = chaine [par défaut : defaut] : indique le widgetde saisie à charger.
* ===> mission = chaine [par défaut : vide] : permet de charger un "sous-widget" vis à vis du projet.
* Indique quel projet nous voulons charger
*
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
* @version $Id$
* @copyright Copyright (c) 2010, Tela Botanica (accueil@tela-botanica.org)
* @author Mathias CHOUET <mathias@tela-botanica.org>
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
* @author Aurelien PERONNET <aurelien@tela-botanica.org>
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
* @copyright 1999-2014 Tela Botanica <accueil@tela-botanica.org>
*/
class Saisie extends WidgetCommun {
 
26,13 → 28,12
const WS_UPLOAD = 'CelWidgetUploadImageTemp';
const WS_OBS = 'CelObs';
const WS_NOM = 'noms';
private $NS_PROJET_VERSION = '1.01';
const EFLORE_API_VERSION = '0.1';
private $NS_PROJET = 'bdtfx';
 
private $projetsVersions = array();
private $ns_referentiel = 'bdtfx';
private $projet = null;
private $configProjet = null;
private $configMission = null;
 
/**
* Méthode appelée par défaut pour charger ce widget.
43,7 → 44,6
 
$this->projet = isset($projet) ? $projet : self::PROJET_DEFAUT;
$this->chargerConfigProjet();
$this->chargerProjetsVersion();
 
$service = isset($service) ? $service : 'widget';
$methode = $this->traiterNomMethodeExecuter($service);
77,7 → 77,14
private function chargerConfigProjet() {
$fichier_config = dirname(__FILE__).self::DS.'configurations'.self::DS.$this->projet.'.ini';
if (file_exists($fichier_config)) {
if (!$this->configProjet = parse_ini_file($fichier_config)) {
if ($this->configProjet = parse_ini_file($fichier_config, true)) {
if (isset($_GET['mission'])) {
$mission = strtolower(trim($_GET['mission']));
if (isset($this->configProjet[$mission])) {
$this->configMission = $this->configProjet[$mission];
}
}
} else {
$this->messages[] = "Le fichier ini '$fichier_config' du projet n'a pu être chargé.";
}
} else {
85,21 → 92,16
}
}
 
private function chargerProjetsVersion() {
if (isset($this->configProjet)) {
foreach ($this->configProjet as $config => $valeur) {
if(strstr($config,'.version')) {
$this->projetsVersions[str_replace('.version', '', $config)] = $valeur;
}
}
}
private function projetASquelette() {
// fonction très simple qui ne teste que si le dossier du projet courant
// existe, mais elle suffit pour le moment.
return file_exists(dirname(__FILE__).self::DS.'squelettes'.self::DS.$this->projet);
}
 
public function executerWidget() {
$referentiel_impose = false;
if (isset($_GET['referentiel']) && $_GET['referentiel'] != '' && $_GET['referentiel'] != "autre") {
$this->NS_PROJET = isset($_GET['referentiel']) && $_GET['referentiel'] != '' ? $_GET['referentiel'] : $this->NS_PROJET;
$this->NS_PROJET_VERSION = $this->projetsVersions[$this->NS_PROJET];
$this->ns_referentiel = isset($_GET['referentiel']) && $_GET['referentiel'] != '' ? $_GET['referentiel'] : $this->ns_referentiel;
$referentiel_impose = true;
}
 
113,21 → 115,17
$widget['donnees']['url_remarques'] = $this->config['chemins']['widgetRemarquesUrl'];
 
$widget['donnees']['logo'] = isset($_GET['logo']) ? $_GET['logo'] : 'defaut';
$widget['donnees']['titre'] = isset($_GET['titre']) ? $_GET['titre'] : 'defaut';
$widget['donnees']['titre'] = ($widget['donnees']['titre'] == '0') ? '' : $widget['donnees']['titre'];
$widget['donnees']['titre'] = $this->getTitrePage();
 
$projetsAutorises = $this->transformerEnTableau($this->config['projets']['autorises']);
if (in_array($this->projet, $projetsAutorises)) {
$urlWsNsTpl = $this->config['chemins']['baseURLServicesEfloreTpl'];
$urlWsNs = sprintf($urlWsNsTpl, self::EFLORE_API_VERSION, $this->NS_PROJET, self::WS_NOM);
$urlWsNs = sprintf($urlWsNsTpl, self::EFLORE_API_VERSION, $this->ns_referentiel, self::WS_NOM);
$urlWsNsSansRef = sprintf($urlWsNsTpl, self::EFLORE_API_VERSION, '{referentiel}', self::WS_NOM);
$widget['donnees']['url_ws_autocompletion_ns'] = $urlWsNs;
$widget['donnees']['url_ws_autocompletion_ns_tpl'] = $urlWsNsSansRef;
$widget['donnees']['ns_referentiel'] = $this->NS_PROJET.':'.$this->NS_PROJET_VERSION;
$widget['donnees']['ns_projet'] = $this->NS_PROJET;
$widget['donnees']['ns_version'] = $this->NS_PROJET_VERSION;
$widget['donnees']['ns_referentiel'] = $this->ns_referentiel;
$widget['donnees']['referentiel_impose'] = $referentiel_impose;
$widget['donnees']['projets_versions'] = $this->projetsVersions;
$widget['donnees']['espece_imposee'] = false;
$widget['donnees']['nn_espece_defaut'] = '';
$widget['donnees']['nom_sci_espece_defaut'] = '';
162,10 → 160,21
return $widget;
}
 
private function projetASquelette() {
// fonction très simple qui ne teste que si le dossier du projet courant
// existe, mais elle suffit pour le moment.
return file_exists(dirname(__FILE__).self::DS.'squelettes'.self::DS.$this->projet);
private function getTitrePage() {
$titre = 'defaut';
if (isset($this->configProjet['titre_page'])) {
$titre = $this->configProjet['titre_page'];
}
if (isset($this->configMission['titre_page'])) {
$titre = $this->configMission['titre_page'];
}
if (isset($_GET['titre'])) {
$titre = $_GET['titre'];
}
if ($titre === 0) {
$titre = '';
}
return $titre;
}
 
public function executerTaxons() {
277,7 → 286,7
 
private function especeEstImposee() {
return (isset($_GET['num_nom']) && $_GET['num_nom'] != ''
|| isset($this->configProjet['sp_imposee']));
|| isset($this->configProjet['sp_imposee']) || isset($this->configMission['sp_imposee']));
}
 
private function getNnEspeceImposee() {
286,12 → 295,14
$nn = $_GET['num_nom'];
} else if (isset($this->configProjet['sp_imposee'])) {
$nn = $this->configProjet['sp_imposee'];
} else if (isset($this->configMission['sp_imposee'])) {
$nn = $this->configMission['sp_imposee'];
}
return $nn;
}
 
private function executerChargementInfosTaxon($num_nom) {
$url_service_infos = sprintf($this->config['chemins']['infosTaxonUrl'], $this->NS_PROJET, $num_nom);
$url_service_infos = sprintf($this->config['chemins']['infosTaxonUrl'], $this->ns_referentiel, $num_nom);
$infos = json_decode(file_get_contents($url_service_infos));
// trop de champs injectés dans les infos espèces peut
// faire planter javascript