1 |
<?php
|
1 |
<?php
|
2 |
// declare(encoding='UTF-8');
|
2 |
// declare(encoding='UTF-8');
|
3 |
/**
|
3 |
/**
|
4 |
* Widget fournissant des interfaces de saisies simplifiée pour différent projets.
|
4 |
* Widget fournissant des interfaces de saisies simplifiée pour différent projets.
|
5 |
* Encodage en entrée : utf8
|
5 |
* Encodage en entrée : utf8
|
6 |
* Encodage en sortie : utf8
|
6 |
* Encodage en sortie : utf8
|
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 : defaut] : indique le widgetde saisie à charger.
|
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 |
* ===> mission = chaine [par défaut : vide] : permet de charger un "sous-widget" vis à vis du projet.
|
14 |
* Indique quel projet nous voulons charger
|
14 |
* Indique quel projet nous voulons charger
|
15 |
*
|
15 |
*
|
16 |
* @author Mathias CHOUET <mathias@tela-botanica.org>
|
16 |
* @author Mathias CHOUET <mathias@tela-botanica.org>
|
17 |
* @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>
|
18 |
* @author Aurelien PERONNET <aurelien@tela-botanica.org>
|
19 |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
|
19 |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
|
20 |
* @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>
|
21 |
* @copyright 1999-2014 Tela Botanica <accueil@tela-botanica.org>
|
21 |
* @copyright 1999-2014 Tela Botanica <accueil@tela-botanica.org>
|
22 |
*/
|
22 |
*/
|
23 |
class Saisie extends WidgetCommun {
|
23 |
class Saisie extends WidgetCommun {
|
24 |
|
24 |
|
25 |
const DS = DIRECTORY_SEPARATOR;
|
25 |
const DS = DIRECTORY_SEPARATOR;
|
26 |
const PROJET_DEFAUT = 'defaut';
|
26 |
const PROJET_DEFAUT = 'defaut';
|
27 |
const WS_SAISIE = 'CelWidgetSaisie';
|
27 |
const WS_SAISIE = 'CelWidgetSaisie';
|
28 |
const WS_UPLOAD = 'CelWidgetUploadImageTemp';
|
28 |
const WS_UPLOAD = 'CelWidgetUploadImageTemp';
|
29 |
const WS_OBS = 'CelObs';
|
29 |
const WS_OBS = 'CelObs';
|
30 |
const WS_NOM = 'noms';
|
30 |
const WS_NOM = 'noms';
|
31 |
const EFLORE_API_VERSION = '0.1';
|
31 |
const EFLORE_API_VERSION = '0.1';
|
32 |
|
32 |
|
33 |
private $ns_referentiel = 'bdtfx';
|
33 |
private $ns_referentiel = 'bdtfx';
|
34 |
private $projet = null;
|
34 |
private $projet = null;
|
35 |
private $configProjet = null;
|
35 |
private $configProjet = null;
|
36 |
private $configMission = null;
|
36 |
private $configMission = null;
|
37 |
|
37 |
|
38 |
/**
|
38 |
/**
|
39 |
* Méthode appelée par défaut pour charger ce widget.
|
39 |
* Méthode appelée par défaut pour charger ce widget.
|
40 |
*/
|
40 |
*/
|
41 |
public function executer() {
|
41 |
public function executer() {
|
42 |
$retour = null;
|
42 |
$retour = null;
|
43 |
extract($this->parametres);
|
43 |
extract($this->parametres);
|
- |
|
44 |
|
44 |
|
45 |
$this->projet = self::PROJET_DEFAUT;
|
- |
|
46 |
if (isset($projet) && trim($projet) != "") {
|
- |
|
47 |
$projets = explode(',', $projet);
|
- |
|
48 |
$this->projet = $projets[0];
|
45 |
$this->projet = (isset($projet) && trim($projet) != "") ? explode(',', $projet)[0] : self::PROJET_DEFAUT;
|
49 |
}
|
46 |
$this->chargerConfigProjet();
|
50 |
$this->chargerConfigProjet();
|
47 |
|
51 |
|
48 |
$service = isset($service) ? $service : 'widget';
|
52 |
$service = isset($service) ? $service : 'widget';
|
49 |
$methode = $this->traiterNomMethodeExecuter($service);
|
53 |
$methode = $this->traiterNomMethodeExecuter($service);
|
50 |
if (method_exists($this, $methode)) {
|
54 |
if (method_exists($this, $methode)) {
|
51 |
$retour = $this->$methode();
|
55 |
$retour = $this->$methode();
|
52 |
} else {
|
56 |
} else {
|
53 |
$this->messages[] = "Ce type de service '$methode' n'est pas disponible.";
|
57 |
$this->messages[] = "Ce type de service '$methode' n'est pas disponible.";
|
54 |
}
|
58 |
}
|
55 |
|
59 |
|
56 |
$contenu = null;
|
60 |
$contenu = null;
|
57 |
$mime = null;
|
61 |
$mime = null;
|
58 |
if (is_array($retour) && array_key_exists('squelette', $retour)) {
|
62 |
if (is_array($retour) && array_key_exists('squelette', $retour)) {
|
59 |
$ext = (isset($retour['squelette_ext'])) ? $retour['squelette_ext'] : '.tpl.html';
|
63 |
$ext = (isset($retour['squelette_ext'])) ? $retour['squelette_ext'] : '.tpl.html';
|
60 |
if ($this->projetASquelette()) {
|
64 |
if ($this->projetASquelette()) {
|
61 |
$squelette = dirname(__FILE__).self::DS.'squelettes'.self::DS.$this->projet.self::DS.$retour['squelette'].$ext;
|
65 |
$squelette = dirname(__FILE__).self::DS.'squelettes'.self::DS.$this->projet.self::DS.$retour['squelette'].$ext;
|
62 |
} else {
|
66 |
} else {
|
63 |
$squelette = dirname(__FILE__).self::DS.'squelettes'.self::DS.'defaut'.self::DS.'defaut'.$ext;
|
67 |
$squelette = dirname(__FILE__).self::DS.'squelettes'.self::DS.'defaut'.self::DS.'defaut'.$ext;
|
64 |
}
|
68 |
}
|
65 |
$contenu = $this->traiterSquelettePhp($squelette, $retour['donnees']);
|
69 |
$contenu = $this->traiterSquelettePhp($squelette, $retour['donnees']);
|
66 |
$mime = isset($retour['mime']) ? $retour['mime'] : null;
|
70 |
$mime = isset($retour['mime']) ? $retour['mime'] : null;
|
67 |
} else {
|
71 |
} else {
|
68 |
if (count($this->messages) == 0) {
|
72 |
if (count($this->messages) == 0) {
|
69 |
$this->messages[] = "La méthode du sous-service ne renvoie pas les données dans le bon format.";
|
73 |
$this->messages[] = "La méthode du sous-service ne renvoie pas les données dans le bon format.";
|
70 |
}
|
74 |
}
|
71 |
$contenu = 'Un problème est survenu : '.print_r($this->messages, true);
|
75 |
$contenu = 'Un problème est survenu : '.print_r($this->messages, true);
|
72 |
}
|
76 |
}
|
73 |
|
77 |
|
74 |
$this->envoyer($contenu, $mime);
|
78 |
$this->envoyer($contenu, $mime);
|
75 |
}
|
79 |
}
|
76 |
|
80 |
|
77 |
private function chargerConfigProjet() {
|
81 |
private function chargerConfigProjet() {
|
78 |
$fichier_config = dirname(__FILE__).self::DS.'configurations'.self::DS.$this->projet.'.ini';
|
82 |
$fichier_config = dirname(__FILE__).self::DS.'configurations'.self::DS.$this->projet.'.ini';
|
79 |
if (file_exists($fichier_config)) {
|
83 |
if (file_exists($fichier_config)) {
|
80 |
if ($this->configProjet = parse_ini_file($fichier_config, true)) {
|
84 |
if ($this->configProjet = parse_ini_file($fichier_config, true)) {
|
81 |
if (isset($_GET['mission'])) {
|
85 |
if (isset($_GET['mission'])) {
|
82 |
$mission = strtolower(trim($_GET['mission']));
|
86 |
$mission = strtolower(trim($_GET['mission']));
|
83 |
if (isset($this->configProjet[$mission])) {
|
87 |
if (isset($this->configProjet[$mission])) {
|
84 |
$this->configMission = $this->configProjet[$mission];
|
88 |
$this->configMission = $this->configProjet[$mission];
|
85 |
}
|
89 |
}
|
86 |
}
|
90 |
}
|
87 |
} else {
|
91 |
} else {
|
88 |
$this->messages[] = "Le fichier ini '$fichier_config' du projet n'a pu être chargé.";
|
92 |
$this->messages[] = "Le fichier ini '$fichier_config' du projet n'a pu être chargé.";
|
89 |
}
|
93 |
}
|
90 |
} else {
|
94 |
} else {
|
91 |
$this->debug[] = "Le fichier ini '$fichier_config' du projet n'existe pas.";
|
95 |
$this->debug[] = "Le fichier ini '$fichier_config' du projet n'existe pas.";
|
92 |
}
|
96 |
}
|
93 |
}
|
97 |
}
|
94 |
|
98 |
|
95 |
private function projetASquelette() {
|
99 |
private function projetASquelette() {
|
96 |
// fonction très simple qui ne teste que si le dossier du projet courant
|
100 |
// fonction très simple qui ne teste que si le dossier du projet courant
|
97 |
// existe, mais elle suffit pour le moment.
|
101 |
// existe, mais elle suffit pour le moment.
|
98 |
return file_exists(dirname(__FILE__).self::DS.'squelettes'.self::DS.$this->projet);
|
102 |
return file_exists(dirname(__FILE__).self::DS.'squelettes'.self::DS.$this->projet);
|
99 |
}
|
103 |
}
|
100 |
|
104 |
|
101 |
public function executerWidget() {
|
105 |
public function executerWidget() {
|
102 |
$referentiel_impose = false;
|
106 |
$referentiel_impose = false;
|
103 |
if (isset($_GET['referentiel']) && $_GET['referentiel'] != '' && $_GET['referentiel'] != "autre") {
|
107 |
if (isset($_GET['referentiel']) && $_GET['referentiel'] != '' && $_GET['referentiel'] != "autre") {
|
104 |
$this->ns_referentiel = isset($_GET['referentiel']) && $_GET['referentiel'] != '' ? $_GET['referentiel'] : $this->ns_referentiel;
|
108 |
$this->ns_referentiel = isset($_GET['referentiel']) && $_GET['referentiel'] != '' ? $_GET['referentiel'] : $this->ns_referentiel;
|
105 |
$referentiel_impose = true;
|
109 |
$referentiel_impose = true;
|
106 |
}
|
110 |
}
|
107 |
|
111 |
|
108 |
$widget['squelette'] = $this->projet;
|
112 |
$widget['squelette'] = $this->projet;
|
109 |
$widget['donnees'] = array();
|
113 |
$widget['donnees'] = array();
|
110 |
$widget['donnees']['url_base'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], '');
|
114 |
$widget['donnees']['url_base'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], '');
|
111 |
$widget['donnees']['url_ws_saisie'] = sprintf($this->config['chemins']['baseURLServicesCelTpl'], self::WS_SAISIE);
|
115 |
$widget['donnees']['url_ws_saisie'] = sprintf($this->config['chemins']['baseURLServicesCelTpl'], self::WS_SAISIE);
|
112 |
$widget['donnees']['url_ws_obs'] = sprintf($this->config['chemins']['baseURLServicesCelTpl'], self::WS_OBS);
|
116 |
$widget['donnees']['url_ws_obs'] = sprintf($this->config['chemins']['baseURLServicesCelTpl'], self::WS_OBS);
|
113 |
$widget['donnees']['url_ws_upload'] = sprintf($this->config['chemins']['baseURLServicesCelTpl'], self::WS_UPLOAD);
|
117 |
$widget['donnees']['url_ws_upload'] = sprintf($this->config['chemins']['baseURLServicesCelTpl'], self::WS_UPLOAD);
|
114 |
$widget['donnees']['url_ws_annuaire'] = sprintf($this->config['chemins']['baseURLServicesAnnuaireTpl'], 'utilisateur/identite-par-courriel/');
|
118 |
$widget['donnees']['url_ws_annuaire'] = sprintf($this->config['chemins']['baseURLServicesAnnuaireTpl'], 'utilisateur/identite-par-courriel/');
|
115 |
$widget['donnees']['url_remarques'] = $this->config['chemins']['widgetRemarquesUrl'];
|
119 |
$widget['donnees']['url_remarques'] = $this->config['chemins']['widgetRemarquesUrl'];
|
116 |
|
120 |
|
117 |
$widget['donnees']['logo'] = isset($_GET['logo']) ? $_GET['logo'] : 'defaut';
|
121 |
$widget['donnees']['logo'] = isset($_GET['logo']) ? $_GET['logo'] : 'defaut';
|
118 |
$widget['donnees']['titre'] = $this->getTitrePage();
|
122 |
$widget['donnees']['titre'] = $this->getTitrePage();
|
119 |
|
123 |
|
120 |
$widget['donnees']['referentiel_impose'] = $referentiel_impose;
|
124 |
$widget['donnees']['referentiel_impose'] = $referentiel_impose;
|
121 |
$widget['donnees']['espece_imposee'] = false;
|
125 |
$widget['donnees']['espece_imposee'] = false;
|
122 |
$widget['donnees']['nn_espece_defaut'] = '';
|
126 |
$widget['donnees']['nn_espece_defaut'] = '';
|
123 |
$widget['donnees']['nom_sci_espece_defaut'] = '';
|
127 |
$widget['donnees']['nom_sci_espece_defaut'] = '';
|
124 |
$widget['donnees']['infos_espece'] = '{}';
|
128 |
$widget['donnees']['infos_espece'] = '{}';
|
125 |
|
129 |
|
126 |
$projetsAutorises = $this->transformerEnTableau($this->config['projets']['autorises']);
|
130 |
$projetsAutorises = $this->transformerEnTableau($this->config['projets']['autorises']);
|
127 |
|
131 |
|
128 |
$urlWsNsTpl = $this->config['chemins']['baseURLServicesEfloreTpl'];
|
132 |
$urlWsNsTpl = $this->config['chemins']['baseURLServicesEfloreTpl'];
|
129 |
$urlWsNs = sprintf($urlWsNsTpl, self::EFLORE_API_VERSION, $this->ns_referentiel, self::WS_NOM);
|
133 |
$urlWsNs = sprintf($urlWsNsTpl, self::EFLORE_API_VERSION, $this->ns_referentiel, self::WS_NOM);
|
130 |
$urlWsNsSansRef = sprintf($urlWsNsTpl, self::EFLORE_API_VERSION, '{referentiel}', self::WS_NOM);
|
134 |
$urlWsNsSansRef = sprintf($urlWsNsTpl, self::EFLORE_API_VERSION, '{referentiel}', self::WS_NOM);
|
131 |
$widget['donnees']['url_ws_autocompletion_ns'] = $urlWsNs;
|
135 |
$widget['donnees']['url_ws_autocompletion_ns'] = $urlWsNs;
|
132 |
$widget['donnees']['url_ws_autocompletion_ns_tpl'] = $urlWsNsSansRef;
|
136 |
$widget['donnees']['url_ws_autocompletion_ns_tpl'] = $urlWsNsSansRef;
|
133 |
$widget['donnees']['ns_referentiel'] = $this->ns_referentiel;
|
137 |
$widget['donnees']['ns_referentiel'] = $this->ns_referentiel;
|
134 |
|
138 |
|
135 |
if ($this->especeEstImposee()) {
|
139 |
if ($this->especeEstImposee()) {
|
136 |
$nnEspeceImposee = $this->getNnEspeceImposee();
|
140 |
$nnEspeceImposee = $this->getNnEspeceImposee();
|
137 |
$nom = $this->executerChargementInfosTaxon($nnEspeceImposee);
|
141 |
$nom = $this->executerChargementInfosTaxon($nnEspeceImposee);
|
138 |
$widget['donnees']['espece_imposee'] = true;
|
142 |
$widget['donnees']['espece_imposee'] = true;
|
139 |
$widget['donnees']['nn_espece_defaut'] = $nnEspeceImposee;
|
143 |
$widget['donnees']['nn_espece_defaut'] = $nnEspeceImposee;
|
140 |
$widget['donnees']['nom_sci_espece_defaut'] = $nom['nom_sci'];
|
144 |
$widget['donnees']['nom_sci_espece_defaut'] = $nom['nom_sci'];
|
141 |
$widget['donnees']['infos_espece'] = $this->array2js($nom, true);
|
145 |
$widget['donnees']['infos_espece'] = $this->array2js($nom, true);
|
142 |
}
|
146 |
}
|
143 |
|
147 |
|
144 |
$projetsAListeDeNoms = $this->transformerEnTableau($this->config['projets']['liste_noms']);
|
148 |
$projetsAListeDeNoms = $this->transformerEnTableau($this->config['projets']['liste_noms']);
|
145 |
if (in_array($this->projet, $projetsAListeDeNoms)) {
|
149 |
if (in_array($this->projet, $projetsAListeDeNoms)) {
|
146 |
$projetsAListeDeNomsSciEtVerna = $this->transformerEnTableau($this->config['projets']['liste_noms_sci_et_verna']);
|
150 |
$projetsAListeDeNomsSciEtVerna = $this->transformerEnTableau($this->config['projets']['liste_noms_sci_et_verna']);
|
147 |
if (in_array($this->projet, $projetsAListeDeNomsSciEtVerna)) {
|
151 |
if (in_array($this->projet, $projetsAListeDeNomsSciEtVerna)) {
|
148 |
$widget['donnees']['taxons'] = $this->recupererListeNoms();
|
152 |
$widget['donnees']['taxons'] = $this->recupererListeNoms();
|
149 |
} else {
|
153 |
} else {
|
150 |
$widget['donnees']['taxons'] = $this->recupererListeNomsSci();
|
154 |
$widget['donnees']['taxons'] = $this->recupererListeNomsSci();
|
151 |
}
|
155 |
}
|
152 |
}
|
156 |
}
|
153 |
|
157 |
|
154 |
// Chargement de la liste des milieux issues du fichier .ini du projet
|
158 |
// Chargement de la liste des milieux issues du fichier .ini du projet
|
155 |
$projetsAListeDeMilieux = $this->transformerEnTableau($this->config['projets']['liste_milieux']);
|
159 |
$projetsAListeDeMilieux = $this->transformerEnTableau($this->config['projets']['liste_milieux']);
|
156 |
if (in_array($this->projet, $projetsAListeDeMilieux)) {
|
160 |
if (in_array($this->projet, $projetsAListeDeMilieux)) {
|
157 |
$widget['donnees']['milieux'] = $this->parserMilieux();
|
161 |
$widget['donnees']['milieux'] = $this->parserMilieux();
|
158 |
}
|
162 |
}
|
159 |
|
163 |
|
160 |
return $widget;
|
164 |
return $widget;
|
161 |
}
|
165 |
}
|
162 |
|
166 |
|
163 |
private function getTitrePage() {
|
167 |
private function getTitrePage() {
|
164 |
$titre = 'defaut';
|
168 |
$titre = 'defaut';
|
165 |
if (isset($this->configProjet['titre_page'])) {
|
169 |
if (isset($this->configProjet['titre_page'])) {
|
166 |
$titre = $this->configProjet['titre_page'];
|
170 |
$titre = $this->configProjet['titre_page'];
|
167 |
}
|
171 |
}
|
168 |
if (isset($this->configMission['titre_page'])) {
|
172 |
if (isset($this->configMission['titre_page'])) {
|
169 |
$titre = $this->configMission['titre_page'];
|
173 |
$titre = $this->configMission['titre_page'];
|
170 |
}
|
174 |
}
|
171 |
if (isset($_GET['titre'])) {
|
175 |
if (isset($_GET['titre'])) {
|
172 |
$titre = $_GET['titre'];
|
176 |
$titre = $_GET['titre'];
|
173 |
}
|
177 |
}
|
174 |
if ($titre === 0) {
|
178 |
if ($titre === 0) {
|
175 |
$titre = '';
|
179 |
$titre = '';
|
176 |
}
|
180 |
}
|
177 |
return $titre;
|
181 |
return $titre;
|
178 |
}
|
182 |
}
|
179 |
|
183 |
|
180 |
public function executerTaxons() {
|
184 |
public function executerTaxons() {
|
181 |
$widget['squelette'] = $this->projet.'_taxons';
|
185 |
$widget['squelette'] = $this->projet.'_taxons';
|
182 |
$widget['squelette_ext'] = '.tpl.js';
|
186 |
$widget['squelette_ext'] = '.tpl.js';
|
183 |
$widget['donnees'] = array();
|
187 |
$widget['donnees'] = array();
|
184 |
$nomsAAfficher = $this->recupererListeNomsSci();
|
188 |
$nomsAAfficher = $this->recupererListeNomsSci();
|
185 |
$taxons_tries = array();
|
189 |
$taxons_tries = array();
|
186 |
foreach ($nomsAAfficher as $taxon) {
|
190 |
foreach ($nomsAAfficher as $taxon) {
|
187 |
$taxons_tries[$taxon['num_nom_sel']] = $taxon;
|
191 |
$taxons_tries[$taxon['num_nom_sel']] = $taxon;
|
188 |
}
|
192 |
}
|
189 |
$widget['donnees']['taxons'] = json_encode($taxons_tries);
|
193 |
$widget['donnees']['taxons'] = json_encode($taxons_tries);
|
190 |
return $widget;
|
194 |
return $widget;
|
191 |
}
|
195 |
}
|
192 |
|
196 |
|
193 |
private function recupererListeNomsSci() {
|
197 |
private function recupererListeNomsSci() {
|
194 |
$taxons = $this->recupererListeTaxon();
|
198 |
$taxons = $this->recupererListeTaxon();
|
195 |
if (is_array($taxons)) {
|
199 |
if (is_array($taxons)) {
|
196 |
$taxons = self::trierTableauMd($taxons, array('nom_fr' => SORT_ASC));
|
200 |
$taxons = self::trierTableauMd($taxons, array('nom_fr' => SORT_ASC));
|
197 |
}
|
201 |
}
|
198 |
return $taxons;
|
202 |
return $taxons;
|
199 |
}
|
203 |
}
|
200 |
|
204 |
|
201 |
private function recupererListeNoms() {
|
205 |
private function recupererListeNoms() {
|
202 |
$taxons = $this->recupererListeTaxon();
|
206 |
$taxons = $this->recupererListeTaxon();
|
203 |
$nomsAAfficher = array();
|
207 |
$nomsAAfficher = array();
|
204 |
$nomsSpeciaux = array();
|
208 |
$nomsSpeciaux = array();
|
205 |
if (is_array($taxons)) {
|
209 |
if (is_array($taxons)) {
|
206 |
foreach ($taxons as $taxon) {
|
210 |
foreach ($taxons as $taxon) {
|
207 |
$nomSciTitle = $taxon['nom_ret'].
|
211 |
$nomSciTitle = $taxon['nom_ret'].
|
208 |
($taxon['nom_fr'] != '' ? ' - '.$taxon['nom_fr'] : '' ).
|
212 |
($taxon['nom_fr'] != '' ? ' - '.$taxon['nom_fr'] : '' ).
|
209 |
($taxon['nom_fr_autre'] != '' ? ' - '.$taxon['nom_fr_autre'] : '' );
|
213 |
($taxon['nom_fr_autre'] != '' ? ' - '.$taxon['nom_fr_autre'] : '' );
|
210 |
$nomFrTitle = $taxon['nom_sel'].
|
214 |
$nomFrTitle = $taxon['nom_sel'].
|
211 |
($taxon['nom_ret'] != $taxon['nom_sel']? ' - '.$taxon['nom_ret'] : '' ).
|
215 |
($taxon['nom_ret'] != $taxon['nom_sel']? ' - '.$taxon['nom_ret'] : '' ).
|
212 |
($taxon['nom_fr_autre'] != '' ? ' - '.$taxon['nom_fr_autre'] : '' );
|
216 |
($taxon['nom_fr_autre'] != '' ? ' - '.$taxon['nom_fr_autre'] : '' );
|
213 |
|
217 |
|
214 |
if ($taxon['groupe'] == 'special') {
|
218 |
if ($taxon['groupe'] == 'special') {
|
215 |
$nomsSpeciaux[] = array(
|
219 |
$nomsSpeciaux[] = array(
|
216 |
'num_nom' => $taxon['num_nom_sel'],
|
220 |
'num_nom' => $taxon['num_nom_sel'],
|
217 |
'nom_a_afficher' => $taxon['nom_fr'],
|
221 |
'nom_a_afficher' => $taxon['nom_fr'],
|
218 |
'nom_a_sauver' => $taxon['nom_sel'],
|
222 |
'nom_a_sauver' => $taxon['nom_sel'],
|
219 |
'nom_title' => $nomSciTitle,
|
223 |
'nom_title' => $nomSciTitle,
|
220 |
'nom_type' => 'nom-special');
|
224 |
'nom_type' => 'nom-special');
|
221 |
} else {
|
225 |
} else {
|
222 |
$nomsAAfficher[] = array(
|
226 |
$nomsAAfficher[] = array(
|
223 |
'num_nom' => $taxon['num_nom_sel'],
|
227 |
'num_nom' => $taxon['num_nom_sel'],
|
224 |
'nom_a_afficher' => $taxon['nom_sel'],
|
228 |
'nom_a_afficher' => $taxon['nom_sel'],
|
225 |
'nom_a_sauver' => $taxon['nom_sel'],
|
229 |
'nom_a_sauver' => $taxon['nom_sel'],
|
226 |
'nom_title' => $nomSciTitle,
|
230 |
'nom_title' => $nomSciTitle,
|
227 |
'nom_type' => 'nom-sci');
|
231 |
'nom_type' => 'nom-sci');
|
228 |
$nomsAAfficher[] = array(
|
232 |
$nomsAAfficher[] = array(
|
229 |
'num_nom' => $taxon['num_nom_sel'],
|
233 |
'num_nom' => $taxon['num_nom_sel'],
|
230 |
'nom_a_afficher' => $taxon['nom_fr'],
|
234 |
'nom_a_afficher' => $taxon['nom_fr'],
|
231 |
'nom_a_sauver' => $taxon['nom_fr'],
|
235 |
'nom_a_sauver' => $taxon['nom_fr'],
|
232 |
'nom_title' => $nomFrTitle,
|
236 |
'nom_title' => $nomFrTitle,
|
233 |
'nom_type' => 'nom-fr');
|
237 |
'nom_type' => 'nom-fr');
|
234 |
}
|
238 |
}
|
235 |
}
|
239 |
}
|
236 |
$nomsAAfficher = self::trierTableauMd($nomsAAfficher, array('nom_a_afficher' => SORT_ASC));
|
240 |
$nomsAAfficher = self::trierTableauMd($nomsAAfficher, array('nom_a_afficher' => SORT_ASC));
|
237 |
$nomsSpeciaux = self::trierTableauMd($nomsSpeciaux, array('nom_a_afficher' => SORT_ASC));
|
241 |
$nomsSpeciaux = self::trierTableauMd($nomsSpeciaux, array('nom_a_afficher' => SORT_ASC));
|
238 |
}
|
242 |
}
|
239 |
return array('speciaux' => $nomsSpeciaux, 'sci-et-fr' => $nomsAAfficher);
|
243 |
return array('speciaux' => $nomsSpeciaux, 'sci-et-fr' => $nomsAAfficher);
|
240 |
}
|
244 |
}
|
241 |
|
245 |
|
242 |
private function recupererListeTaxon() {
|
246 |
private function recupererListeTaxon() {
|
243 |
$taxons = null;
|
247 |
$taxons = null;
|
244 |
$fichier_tsv = dirname(__FILE__).self::DS.'configurations'.self::DS.$this->projet.'_taxons.tsv';
|
248 |
$fichier_tsv = dirname(__FILE__).self::DS.'configurations'.self::DS.$this->projet.'_taxons.tsv';
|
245 |
if (file_exists($fichier_tsv) && is_readable($fichier_tsv)) {
|
249 |
if (file_exists($fichier_tsv) && is_readable($fichier_tsv)) {
|
246 |
$taxons = $this->decomposerFichierTsv($fichier_tsv);
|
250 |
$taxons = $this->decomposerFichierTsv($fichier_tsv);
|
247 |
} else {
|
251 |
} else {
|
248 |
$this->debug[] = "Impossible d'ouvrir le fichier '$fichier_tsv'.";
|
252 |
$this->debug[] = "Impossible d'ouvrir le fichier '$fichier_tsv'.";
|
249 |
}
|
253 |
}
|
250 |
return $taxons;
|
254 |
return $taxons;
|
251 |
}
|
255 |
}
|
252 |
|
256 |
|
253 |
private function decomposerFichierTsv($fichier, $delimiter = "\t"){
|
257 |
private function decomposerFichierTsv($fichier, $delimiter = "\t"){
|
254 |
$header = null;
|
258 |
$header = null;
|
255 |
$data = array();
|
259 |
$data = array();
|
256 |
if (($handle = fopen($fichier, 'r')) !== FALSE) {
|
260 |
if (($handle = fopen($fichier, 'r')) !== FALSE) {
|
257 |
while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) {
|
261 |
while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) {
|
258 |
if (!$header) {
|
262 |
if (!$header) {
|
259 |
$header = $row;
|
263 |
$header = $row;
|
260 |
} else {
|
264 |
} else {
|
261 |
$data[] = array_combine($header, $row);
|
265 |
$data[] = array_combine($header, $row);
|
262 |
}
|
266 |
}
|
263 |
}
|
267 |
}
|
264 |
fclose($handle);
|
268 |
fclose($handle);
|
265 |
}
|
269 |
}
|
266 |
return $data;
|
270 |
return $data;
|
267 |
}
|
271 |
}
|
268 |
|
272 |
|
269 |
private function parserMilieux() {
|
273 |
private function parserMilieux() {
|
270 |
$infosMilieux = array();
|
274 |
$infosMilieux = array();
|
271 |
if (isset($this->configProjet['milieux'])) {
|
275 |
if (isset($this->configProjet['milieux'])) {
|
272 |
$milieux = explode('|', $this->configProjet['milieux']);
|
276 |
$milieux = explode('|', $this->configProjet['milieux']);
|
273 |
foreach ($milieux as $milieu) {
|
277 |
foreach ($milieux as $milieu) {
|
274 |
$milieu = trim($milieu);
|
278 |
$milieu = trim($milieu);
|
275 |
$details = explode(';', $milieu);
|
279 |
$details = explode(';', $milieu);
|
276 |
if (isset($details[1])) {
|
280 |
if (isset($details[1])) {
|
277 |
$infosMilieux[$details[0]] = $details[1];
|
281 |
$infosMilieux[$details[0]] = $details[1];
|
278 |
} else {
|
282 |
} else {
|
279 |
$infosMilieux[$details[0]] = '';
|
283 |
$infosMilieux[$details[0]] = '';
|
280 |
}
|
284 |
}
|
281 |
}
|
285 |
}
|
282 |
ksort($infosMilieux);
|
286 |
ksort($infosMilieux);
|
283 |
}
|
287 |
}
|
284 |
return $infosMilieux;
|
288 |
return $infosMilieux;
|
285 |
}
|
289 |
}
|
286 |
|
290 |
|
287 |
private function especeEstImposee() {
|
291 |
private function especeEstImposee() {
|
288 |
return (isset($_GET['num_nom']) && $_GET['num_nom'] != ''
|
292 |
return (isset($_GET['num_nom']) && $_GET['num_nom'] != ''
|
289 |
|| isset($this->configProjet['sp_imposee']) || isset($this->configMission['sp_imposee']));
|
293 |
|| isset($this->configProjet['sp_imposee']) || isset($this->configMission['sp_imposee']));
|
290 |
}
|
294 |
}
|
291 |
|
295 |
|
292 |
private function getNnEspeceImposee() {
|
296 |
private function getNnEspeceImposee() {
|
293 |
$nn = null;
|
297 |
$nn = null;
|
294 |
if (isset($_GET['num_nom']) && is_numeric($_GET['num_nom'])) {
|
298 |
if (isset($_GET['num_nom']) && is_numeric($_GET['num_nom'])) {
|
295 |
$nn = $_GET['num_nom'];
|
299 |
$nn = $_GET['num_nom'];
|
296 |
} else if (isset($this->configProjet['sp_imposee'])) {
|
300 |
} else if (isset($this->configProjet['sp_imposee'])) {
|
297 |
$nn = $this->configProjet['sp_imposee'];
|
301 |
$nn = $this->configProjet['sp_imposee'];
|
298 |
} else if (isset($this->configMission['sp_imposee'])) {
|
302 |
} else if (isset($this->configMission['sp_imposee'])) {
|
299 |
$nn = $this->configMission['sp_imposee'];
|
303 |
$nn = $this->configMission['sp_imposee'];
|
300 |
}
|
304 |
}
|
301 |
return $nn;
|
305 |
return $nn;
|
302 |
}
|
306 |
}
|
303 |
|
307 |
|
304 |
private function executerChargementInfosTaxon($num_nom) {
|
308 |
private function executerChargementInfosTaxon($num_nom) {
|
305 |
$url_service_infos = sprintf($this->config['chemins']['infosTaxonUrl'], $this->ns_referentiel, $num_nom);
|
309 |
$url_service_infos = sprintf($this->config['chemins']['infosTaxonUrl'], $this->ns_referentiel, $num_nom);
|
306 |
$infos = json_decode(file_get_contents($url_service_infos));
|
310 |
$infos = json_decode(file_get_contents($url_service_infos));
|
307 |
// trop de champs injectés dans les infos espèces peut
|
311 |
// trop de champs injectés dans les infos espèces peut
|
308 |
// faire planter javascript
|
312 |
// faire planter javascript
|
309 |
$champs_a_garder = array('id', 'nom_sci','nom_sci_complet',
|
313 |
$champs_a_garder = array('id', 'nom_sci','nom_sci_complet',
|
310 |
'famille','nom_retenu.id', 'nom_retenu.libelle', 'num_taxonomique');
|
314 |
'famille','nom_retenu.id', 'nom_retenu.libelle', 'num_taxonomique');
|
311 |
$resultat = array();
|
315 |
$resultat = array();
|
312 |
if (isset($infos) && !empty($infos)) {
|
316 |
if (isset($infos) && !empty($infos)) {
|
313 |
$infos = (array)$infos;
|
317 |
$infos = (array)$infos;
|
314 |
if (isset($infos['nom_sci']) && $infos['nom_sci'] != '') {
|
318 |
if (isset($infos['nom_sci']) && $infos['nom_sci'] != '') {
|
315 |
$resultat = array_intersect_key($infos, array_flip($champs_a_garder));
|
319 |
$resultat = array_intersect_key($infos, array_flip($champs_a_garder));
|
316 |
$resultat['retenu'] = ($infos['id'] == $infos['nom_retenu.id']) ? "true" : "false";
|
320 |
$resultat['retenu'] = ($infos['id'] == $infos['nom_retenu.id']) ? "true" : "false";
|
317 |
}
|
321 |
}
|
318 |
}
|
322 |
}
|
319 |
return $resultat;
|
323 |
return $resultat;
|
320 |
}
|
324 |
}
|
321 |
|
325 |
|
322 |
private function array2js($array,$show_keys) {
|
326 |
private function array2js($array,$show_keys) {
|
323 |
$tableauJs = '{}';
|
327 |
$tableauJs = '{}';
|
324 |
if (!empty($array)) {
|
328 |
if (!empty($array)) {
|
325 |
$total = count($array) - 1;
|
329 |
$total = count($array) - 1;
|
326 |
$i = 0;
|
330 |
$i = 0;
|
327 |
$dimensions = array();
|
331 |
$dimensions = array();
|
328 |
foreach ($array as $key => $value) {
|
332 |
foreach ($array as $key => $value) {
|
329 |
if (is_array($value)) {
|
333 |
if (is_array($value)) {
|
330 |
$dimensions[$i] = array2js($value,$show_keys);
|
334 |
$dimensions[$i] = array2js($value,$show_keys);
|
331 |
if ($show_keys) {
|
335 |
if ($show_keys) {
|
332 |
$dimensions[$i] = '"'.$key.'":'.$dimensions[$i];
|
336 |
$dimensions[$i] = '"'.$key.'":'.$dimensions[$i];
|
333 |
}
|
337 |
}
|
334 |
} else {
|
338 |
} else {
|
335 |
$dimensions[$i] = '"'.addslashes($value).'"';
|
339 |
$dimensions[$i] = '"'.addslashes($value).'"';
|
336 |
if ($show_keys) {
|
340 |
if ($show_keys) {
|
337 |
$dimensions[$i] = '"'.$key.'":'.$dimensions[$i];
|
341 |
$dimensions[$i] = '"'.$key.'":'.$dimensions[$i];
|
338 |
}
|
342 |
}
|
339 |
}
|
343 |
}
|
340 |
if ($i == 0) {
|
344 |
if ($i == 0) {
|
341 |
$dimensions[$i] = '{'.$dimensions[$i];
|
345 |
$dimensions[$i] = '{'.$dimensions[$i];
|
342 |
}
|
346 |
}
|
343 |
if ($i == $total) {
|
347 |
if ($i == $total) {
|
344 |
$dimensions[$i].= '}';
|
348 |
$dimensions[$i].= '}';
|
345 |
}
|
349 |
}
|
346 |
$i++;
|
350 |
$i++;
|
347 |
}
|
351 |
}
|
348 |
$tableauJs = implode(',', $dimensions);
|
352 |
$tableauJs = implode(',', $dimensions);
|
349 |
}
|
353 |
}
|
350 |
return $tableauJs;
|
354 |
return $tableauJs;
|
351 |
}
|
355 |
}
|
352 |
}
|
356 |
}
|