| Line 7... |
Line 7... |
| 7 |
*
|
7 |
*
|
| 8 |
* Cas d'utilisation et documentation :
|
8 |
* Cas d'utilisation et documentation :
|
| 9 |
* @link http://www.tela-botanica.org/wikini/eflore/wakka.php?wiki=AideCELWidgetSaisie
|
9 |
* @link http://www.tela-botanica.org/wikini/eflore/wakka.php?wiki=AideCELWidgetSaisie
|
| 10 |
*
|
10 |
*
|
| 11 |
* Paramètres :
|
11 |
* Paramètres :
|
| 12 |
* ===> projet = chaine [par défaut : Biodiversite34]
|
12 |
* ===> projet = chaine [par défaut : defaut] : indique le widgetde saisie à charger.
|
| - |
|
13 |
* ===> mission = chaine [par défaut : vide] : permet de charger un "sous-widget" vis à vis du projet.
|
| 13 |
* Indique quel projet nous voulons charger
|
14 |
* Indique quel projet nous voulons charger
|
| 14 |
*
|
15 |
*
|
| - |
|
16 |
* @author Mathias CHOUET <mathias@tela-botanica.org>
|
| 15 |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
17 |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
| - |
|
18 |
* @author Aurelien PERONNET <aurelien@tela-botanica.org>
|
| 16 |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
|
19 |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
|
| 17 |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
|
20 |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
|
| 18 |
* @version $Id$
|
- |
|
| 19 |
* @copyright Copyright (c) 2010, Tela Botanica (accueil@tela-botanica.org)
|
21 |
* @copyright 1999-2014 Tela Botanica <accueil@tela-botanica.org>
|
| 20 |
*/
|
22 |
*/
|
| 21 |
class Saisie extends WidgetCommun {
|
23 |
class Saisie extends WidgetCommun {
|
| Line 22... |
Line 24... |
| 22 |
|
24 |
|
| 23 |
const DS = DIRECTORY_SEPARATOR;
|
25 |
const DS = DIRECTORY_SEPARATOR;
|
| 24 |
const PROJET_DEFAUT = 'defaut';
|
26 |
const PROJET_DEFAUT = 'defaut';
|
| 25 |
const WS_SAISIE = 'CelWidgetSaisie';
|
27 |
const WS_SAISIE = 'CelWidgetSaisie';
|
| 26 |
const WS_UPLOAD = 'CelWidgetUploadImageTemp';
|
28 |
const WS_UPLOAD = 'CelWidgetUploadImageTemp';
|
| 27 |
const WS_OBS = 'CelObs';
|
29 |
const WS_OBS = 'CelObs';
|
| 28 |
const WS_NOM = 'noms';
|
- |
|
| 29 |
private $NS_PROJET_VERSION = '1.01';
|
30 |
const WS_NOM = 'noms';
|
| 30 |
const EFLORE_API_VERSION = '0.1';
|
- |
|
| Line 31... |
Line 31... |
| 31 |
private $NS_PROJET = 'bdtfx';
|
31 |
const EFLORE_API_VERSION = '0.1';
|
| 32 |
|
32 |
|
| 33 |
private $projetsVersions = array();
|
33 |
private $ns_referentiel = 'bdtfx';
|
| - |
|
34 |
private $projet = null;
|
| Line 34... |
Line 35... |
| 34 |
private $projet = null;
|
35 |
private $configProjet = null;
|
| 35 |
private $configProjet = null;
|
36 |
private $configMission = null;
|
| 36 |
|
37 |
|
| 37 |
/**
|
38 |
/**
|
| 38 |
* Méthode appelée par défaut pour charger ce widget.
|
39 |
* Méthode appelée par défaut pour charger ce widget.
|
| 39 |
*/
|
40 |
*/
|
| Line 40... |
Line 41... |
| 40 |
public function executer() {
|
41 |
public function executer() {
|
| 41 |
$retour = null;
|
42 |
$retour = null;
|
| 42 |
extract($this->parametres);
|
- |
|
| Line 43... |
Line 43... |
| 43 |
|
43 |
extract($this->parametres);
|
| 44 |
$this->projet = isset($projet) ? $projet : self::PROJET_DEFAUT;
|
44 |
|
| 45 |
$this->chargerConfigProjet();
|
45 |
$this->projet = isset($projet) ? $projet : self::PROJET_DEFAUT;
|
| 46 |
$this->chargerProjetsVersion();
|
46 |
$this->chargerConfigProjet();
|
| Line 75... |
Line 75... |
| 75 |
}
|
75 |
}
|
| Line 76... |
Line 76... |
| 76 |
|
76 |
|
| 77 |
private function chargerConfigProjet() {
|
77 |
private function chargerConfigProjet() {
|
| 78 |
$fichier_config = dirname(__FILE__).self::DS.'configurations'.self::DS.$this->projet.'.ini';
|
78 |
$fichier_config = dirname(__FILE__).self::DS.'configurations'.self::DS.$this->projet.'.ini';
|
| 79 |
if (file_exists($fichier_config)) {
|
79 |
if (file_exists($fichier_config)) {
|
| - |
|
80 |
if ($this->configProjet = parse_ini_file($fichier_config, true)) {
|
| - |
|
81 |
if (isset($_GET['mission'])) {
|
| - |
|
82 |
$mission = strtolower(trim($_GET['mission']));
|
| - |
|
83 |
if (isset($this->configProjet[$mission])) {
|
| - |
|
84 |
$this->configMission = $this->configProjet[$mission];
|
| - |
|
85 |
}
|
| - |
|
86 |
}
|
| 80 |
if (!$this->configProjet = parse_ini_file($fichier_config)) {
|
87 |
} else {
|
| 81 |
$this->messages[] = "Le fichier ini '$fichier_config' du projet n'a pu être chargé.";
|
88 |
$this->messages[] = "Le fichier ini '$fichier_config' du projet n'a pu être chargé.";
|
| 82 |
}
|
89 |
}
|
| 83 |
} else {
|
90 |
} else {
|
| 84 |
$this->debug[] = "Le fichier ini '$fichier_config' du projet n'existe pas.";
|
91 |
$this->debug[] = "Le fichier ini '$fichier_config' du projet n'existe pas.";
|
| 85 |
}
|
92 |
}
|
| Line 86... |
Line 93... |
| 86 |
}
|
93 |
}
|
| 87 |
|
- |
|
| 88 |
private function chargerProjetsVersion() {
|
94 |
|
| 89 |
if (isset($this->configProjet)) {
|
95 |
private function projetASquelette() {
|
| 90 |
foreach ($this->configProjet as $config => $valeur) {
|
96 |
// fonction très simple qui ne teste que si le dossier du projet courant
|
| 91 |
if(strstr($config,'.version')) {
|
- |
|
| 92 |
$this->projetsVersions[str_replace('.version', '', $config)] = $valeur;
|
- |
|
| 93 |
}
|
- |
|
| 94 |
}
|
97 |
// existe, mais elle suffit pour le moment.
|
| Line 95... |
Line 98... |
| 95 |
}
|
98 |
return file_exists(dirname(__FILE__).self::DS.'squelettes'.self::DS.$this->projet);
|
| 96 |
}
|
99 |
}
|
| 97 |
|
100 |
|
| 98 |
public function executerWidget() {
|
101 |
public function executerWidget() {
|
| 99 |
$referentiel_impose = false;
|
- |
|
| 100 |
if (isset($_GET['referentiel']) && $_GET['referentiel'] != '' && $_GET['referentiel'] != "autre") {
|
102 |
$referentiel_impose = false;
|
| 101 |
$this->NS_PROJET = isset($_GET['referentiel']) && $_GET['referentiel'] != '' ? $_GET['referentiel'] : $this->NS_PROJET;
|
103 |
if (isset($_GET['referentiel']) && $_GET['referentiel'] != '' && $_GET['referentiel'] != "autre") {
|
| Line 102... |
Line 104... |
| 102 |
$this->NS_PROJET_VERSION = $this->projetsVersions[$this->NS_PROJET];
|
104 |
$this->ns_referentiel = isset($_GET['referentiel']) && $_GET['referentiel'] != '' ? $_GET['referentiel'] : $this->ns_referentiel;
|
| 103 |
$referentiel_impose = true;
|
105 |
$referentiel_impose = true;
|
| Line 111... |
Line 113... |
| 111 |
$widget['donnees']['url_ws_upload'] = sprintf($this->config['chemins']['baseURLServicesCelTpl'], self::WS_UPLOAD);
|
113 |
$widget['donnees']['url_ws_upload'] = sprintf($this->config['chemins']['baseURLServicesCelTpl'], self::WS_UPLOAD);
|
| 112 |
$widget['donnees']['url_ws_annuaire'] = sprintf($this->config['chemins']['baseURLServicesAnnuaireTpl'], 'utilisateur/identite-par-courriel/');
|
114 |
$widget['donnees']['url_ws_annuaire'] = sprintf($this->config['chemins']['baseURLServicesAnnuaireTpl'], 'utilisateur/identite-par-courriel/');
|
| 113 |
$widget['donnees']['url_remarques'] = $this->config['chemins']['widgetRemarquesUrl'];
|
115 |
$widget['donnees']['url_remarques'] = $this->config['chemins']['widgetRemarquesUrl'];
|
| Line 114... |
Line 116... |
| 114 |
|
116 |
|
| 115 |
$widget['donnees']['logo'] = isset($_GET['logo']) ? $_GET['logo'] : 'defaut';
|
117 |
$widget['donnees']['logo'] = isset($_GET['logo']) ? $_GET['logo'] : 'defaut';
|
| 116 |
$widget['donnees']['titre'] = isset($_GET['titre']) ? $_GET['titre'] : 'defaut';
|
- |
|
| Line 117... |
Line 118... |
| 117 |
$widget['donnees']['titre'] = ($widget['donnees']['titre'] == '0') ? '' : $widget['donnees']['titre'];
|
118 |
$widget['donnees']['titre'] = $this->getTitrePage();
|
| 118 |
|
119 |
|
| 119 |
$projetsAutorises = $this->transformerEnTableau($this->config['projets']['autorises']);
|
120 |
$projetsAutorises = $this->transformerEnTableau($this->config['projets']['autorises']);
|
| 120 |
if (in_array($this->projet, $projetsAutorises)) {
|
121 |
if (in_array($this->projet, $projetsAutorises)) {
|
| 121 |
$urlWsNsTpl = $this->config['chemins']['baseURLServicesEfloreTpl'];
|
122 |
$urlWsNsTpl = $this->config['chemins']['baseURLServicesEfloreTpl'];
|
| 122 |
$urlWsNs = sprintf($urlWsNsTpl, self::EFLORE_API_VERSION, $this->NS_PROJET, self::WS_NOM);
|
123 |
$urlWsNs = sprintf($urlWsNsTpl, self::EFLORE_API_VERSION, $this->ns_referentiel, self::WS_NOM);
|
| 123 |
$urlWsNsSansRef = sprintf($urlWsNsTpl, self::EFLORE_API_VERSION, '{referentiel}', self::WS_NOM);
|
124 |
$urlWsNsSansRef = sprintf($urlWsNsTpl, self::EFLORE_API_VERSION, '{referentiel}', self::WS_NOM);
|
| 124 |
$widget['donnees']['url_ws_autocompletion_ns'] = $urlWsNs;
|
- |
|
| 125 |
$widget['donnees']['url_ws_autocompletion_ns_tpl'] = $urlWsNsSansRef;
|
125 |
$widget['donnees']['url_ws_autocompletion_ns'] = $urlWsNs;
|
| 126 |
$widget['donnees']['ns_referentiel'] = $this->NS_PROJET.':'.$this->NS_PROJET_VERSION;
|
- |
|
| 127 |
$widget['donnees']['ns_projet'] = $this->NS_PROJET;
|
126 |
$widget['donnees']['url_ws_autocompletion_ns_tpl'] = $urlWsNsSansRef;
|
| 128 |
$widget['donnees']['ns_version'] = $this->NS_PROJET_VERSION;
|
- |
|
| 129 |
$widget['donnees']['referentiel_impose'] = $referentiel_impose;
|
127 |
$widget['donnees']['ns_referentiel'] = $this->ns_referentiel;
|
| 130 |
$widget['donnees']['projets_versions'] = $this->projetsVersions;
|
128 |
$widget['donnees']['referentiel_impose'] = $referentiel_impose;
|
| 131 |
$widget['donnees']['espece_imposee'] = false;
|
129 |
$widget['donnees']['espece_imposee'] = false;
|
| 132 |
$widget['donnees']['nn_espece_defaut'] = '';
|
130 |
$widget['donnees']['nn_espece_defaut'] = '';
|
| Line 160... |
Line 158... |
| 160 |
}
|
158 |
}
|
| Line 161... |
Line 159... |
| 161 |
|
159 |
|
| 162 |
return $widget;
|
160 |
return $widget;
|
| Line 163... |
Line 161... |
| 163 |
}
|
161 |
}
|
| - |
|
162 |
|
| - |
|
163 |
private function getTitrePage() {
|
| 164 |
|
164 |
$titre = 'defaut';
|
| - |
|
165 |
if (isset($this->configProjet['titre_page'])) {
|
| 165 |
private function projetASquelette() {
|
166 |
$titre = $this->configProjet['titre_page'];
|
| 166 |
// fonction très simple qui ne teste que si le dossier du projet courant
|
167 |
}
|
| - |
|
168 |
if (isset($this->configMission['titre_page'])) {
|
| - |
|
169 |
$titre = $this->configMission['titre_page'];
|
| - |
|
170 |
}
|
| - |
|
171 |
if (isset($_GET['titre'])) {
|
| - |
|
172 |
$titre = $_GET['titre'];
|
| - |
|
173 |
}
|
| - |
|
174 |
if ($titre === 0) {
|
| - |
|
175 |
$titre = '';
|
| 167 |
// existe, mais elle suffit pour le moment.
|
176 |
}
|
| Line 168... |
Line 177... |
| 168 |
return file_exists(dirname(__FILE__).self::DS.'squelettes'.self::DS.$this->projet);
|
177 |
return $titre;
|
| 169 |
}
|
178 |
}
|
| 170 |
|
179 |
|
| Line 275... |
Line 284... |
| 275 |
return $infosMilieux;
|
284 |
return $infosMilieux;
|
| 276 |
}
|
285 |
}
|
| Line 277... |
Line 286... |
| 277 |
|
286 |
|
| 278 |
private function especeEstImposee() {
|
287 |
private function especeEstImposee() {
|
| 279 |
return (isset($_GET['num_nom']) && $_GET['num_nom'] != ''
|
288 |
return (isset($_GET['num_nom']) && $_GET['num_nom'] != ''
|
| 280 |
|| isset($this->configProjet['sp_imposee']));
|
289 |
|| isset($this->configProjet['sp_imposee']) || isset($this->configMission['sp_imposee']));
|
| Line 281... |
Line 290... |
| 281 |
}
|
290 |
}
|
| 282 |
|
291 |
|
| 283 |
private function getNnEspeceImposee() {
|
292 |
private function getNnEspeceImposee() {
|
| 284 |
$nn = null;
|
293 |
$nn = null;
|
| 285 |
if (isset($_GET['num_nom']) && is_numeric($_GET['num_nom'])) {
|
294 |
if (isset($_GET['num_nom']) && is_numeric($_GET['num_nom'])) {
|
| 286 |
$nn = $_GET['num_nom'];
|
295 |
$nn = $_GET['num_nom'];
|
| - |
|
296 |
} else if (isset($this->configProjet['sp_imposee'])) {
|
| - |
|
297 |
$nn = $this->configProjet['sp_imposee'];
|
| 287 |
} else if (isset($this->configProjet['sp_imposee'])) {
|
298 |
} else if (isset($this->configMission['sp_imposee'])) {
|
| 288 |
$nn = $this->configProjet['sp_imposee'];
|
299 |
$nn = $this->configMission['sp_imposee'];
|
| 289 |
}
|
300 |
}
|
| Line 290... |
Line 301... |
| 290 |
return $nn;
|
301 |
return $nn;
|
| 291 |
}
|
302 |
}
|
| 292 |
|
303 |
|
| 293 |
private function executerChargementInfosTaxon($num_nom) {
|
304 |
private function executerChargementInfosTaxon($num_nom) {
|
| 294 |
$url_service_infos = sprintf($this->config['chemins']['infosTaxonUrl'], $this->NS_PROJET, $num_nom);
|
305 |
$url_service_infos = sprintf($this->config['chemins']['infosTaxonUrl'], $this->ns_referentiel, $num_nom);
|
| 295 |
$infos = json_decode(file_get_contents($url_service_infos));
|
306 |
$infos = json_decode(file_get_contents($url_service_infos));
|
| 296 |
// trop de champs injectés dans les infos espèces peut
|
307 |
// trop de champs injectés dans les infos espèces peut
|