1 |
<?php
|
1 |
<?php
|
2 |
// declare(encoding='UTF-8');
|
2 |
// declare(encoding='UTF-8');
|
3 |
/**
|
3 |
/**
|
4 |
* Classe métier de mise en forme des groupes de colonnes pour les exports.
|
4 |
* Classe métier de mise en forme des groupes de colonnes pour les exports.
|
5 |
*
|
5 |
*
|
6 |
* @internal Mininum PHP version : 5.2
|
6 |
* @internal Mininum PHP version : 5.2
|
7 |
* @category CEL
|
7 |
* @category CEL
|
8 |
* @package Services
|
8 |
* @package Services
|
9 |
* @subpackage Bibliothèques
|
9 |
* @subpackage Bibliothèques
|
10 |
* @version 0.1
|
10 |
* @version 0.1
|
11 |
* @author Mathias CHOUET <mathias@tela-botanica.org>
|
11 |
* @author Mathias CHOUET <mathias@tela-botanica.org>
|
12 |
* @author Raphaël Droz <raphael@tela-botania.org>
|
12 |
* @author Raphaël Droz <raphael@tela-botania.org>
|
13 |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
13 |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
14 |
* @author Aurelien PERONNET <aurelien@tela-botanica.org>
|
14 |
* @author Aurelien PERONNET <aurelien@tela-botanica.org>
|
15 |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
|
15 |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
|
16 |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
|
16 |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
|
17 |
* @copyright 1999-2014 Tela Botanica <accueil@tela-botanica.org>
|
17 |
* @copyright 1999-2014 Tela Botanica <accueil@tela-botanica.org>
|
18 |
*/
|
18 |
*/
|
19 |
define('SEPARATEUR_IMAGES', ' / ');
|
19 |
define('SEPARATEUR_IMAGES', ' / ');
|
20 |
define('PREFIX_CHAMPS_ETENDUS', 'ext:');
|
20 |
define('PREFIX_CHAMPS_ETENDUS', 'ext:');
|
21 |
// utilisé par formaterUrlUser() [ nécessaire pour le widget d'export)
|
21 |
// utilisé par formaterUrlUser() [ nécessaire pour le widget d'export)
|
22 |
define('USER_BASEURL', 'http://www.tela-botanica.org/profil:%d');
|
22 |
define('USER_BASEURL', 'http://www.tela-botanica.org/profil:%d');
|
23 |
|
23 |
|
24 |
class FormateurGroupeColonne {
|
24 |
class FormateurGroupeColonne {
|
25 |
|
25 |
|
26 |
// cache pour les données des fonctions
|
26 |
// cache pour les données des fonctions
|
27 |
static $cache = Array();
|
27 |
static $cache = Array();
|
28 |
|
28 |
|
29 |
// test sur la table cel_references, mis à TRUE si la table existe
|
29 |
// test sur la table cel_references, mis à TRUE si la table existe
|
30 |
static $is_table = false;
|
30 |
static $is_table = false;
|
31 |
|
31 |
|
32 |
// les groupes de champs utilisables
|
32 |
// les groupes de champs utilisables
|
33 |
static $fieldGroups = array(
|
33 |
static $fieldGroups = array(
|
34 |
'standard',
|
34 |
'standard',
|
35 |
'standardexport',
|
35 |
'standardexport',
|
36 |
'avance',
|
36 |
'avance',
|
37 |
'etendu',
|
37 |
'etendu',
|
38 |
'baseflor',
|
38 |
'baseflor',
|
39 |
'auteur'
|
39 |
'auteur'
|
40 |
);
|
40 |
);
|
41 |
|
41 |
|
42 |
// les données baseflor à récupérer: colonnes présentes dans cel_references
|
42 |
// les données baseflor à récupérer: colonnes présentes dans cel_references
|
43 |
// et intitulés associés
|
43 |
// et intitulés associés
|
44 |
static $baseflor_col = array(
|
44 |
static $baseflor_col = array(
|
45 |
've_lumiere' => 'Lumière',
|
45 |
've_lumiere' => 'Lumière',
|
46 |
've_temperature' => 'Température',
|
46 |
've_temperature' => 'Température',
|
47 |
've_continentalite' => 'Continentalité',
|
47 |
've_continentalite' => 'Continentalité',
|
48 |
've_humidite_atmos' => 'Humidité Atmosphérique',
|
48 |
've_humidite_atmos' => 'Humidité Atmosphérique',
|
49 |
've_humidite_edaph' => 'Humidité',
|
49 |
've_humidite_edaph' => 'Humidité',
|
50 |
've_reaction_sol' => 'Réaction (pH)',
|
50 |
've_reaction_sol' => 'Réaction (pH)',
|
51 |
've_nutriments_sol' => 'Nutriments',
|
51 |
've_nutriments_sol' => 'Nutriments',
|
52 |
've_salinite' => 'Salinité',
|
52 |
've_salinite' => 'Salinité',
|
53 |
've_texture_sol' => 'Texture' ,
|
53 |
've_texture_sol' => 'Texture' ,
|
54 |
've_mat_org_sol' => 'Matière Organique',
|
54 |
've_mat_org_sol' => 'Matière Organique',
|
55 |
'catminat_code' => 'Code Catminat',
|
55 |
'catminat_code' => 'Code Catminat',
|
56 |
'syntaxon' => 'Syntaxon',
|
56 |
'syntaxon' => 'Syntaxon',
|
57 |
);
|
57 |
);
|
58 |
|
58 |
|
59 |
// TODO: dirty, ordre des champs étendus... souhaité pour florilèges:
|
59 |
// TODO: dirty, ordre des champs étendus... souhaité pour florilèges:
|
60 |
static $ordre_champ_etendus_Florileges = array(
|
60 |
static $ordre_champ_etendus_Florileges = array(
|
61 |
'personneStructure',
|
61 |
'personneStructure',
|
62 |
'personneService',
|
62 |
'personneService',
|
63 |
'personneFonction',
|
63 |
'personneFonction',
|
64 |
'adresse',
|
64 |
'adresse',
|
65 |
'latitudeDebutRue',
|
65 |
'latitudeDebutRue',
|
66 |
'longitudeDebutRue',
|
66 |
'longitudeDebutRue',
|
67 |
'latitudeFinRue',
|
67 |
'latitudeFinRue',
|
68 |
'longitudeFinRue',
|
68 |
'longitudeFinRue',
|
69 |
'typoUrbaine',
|
69 |
'typoUrbaine',
|
70 |
'revetementSol',
|
70 |
'revetementSol',
|
71 |
'presenceZoneVegetalise',
|
71 |
'presenceZoneVegetalise',
|
72 |
'hauteurBatimentAvoisinant',
|
72 |
'hauteurBatimentAvoisinant',
|
73 |
'intensiteGestion',
|
73 |
'intensiteGestion',
|
74 |
'periodiciteTraitementPhyto',
|
74 |
'periodiciteTraitementPhyto',
|
75 |
'dateArretTraitementPhyto',
|
75 |
'dateArretTraitementPhyto',
|
76 |
'itineraireGestion',
|
76 |
'itineraireGestion',
|
77 |
'dateDerniereIntervention',
|
77 |
'dateDerniereIntervention',
|
78 |
'hauteurPlante',
|
78 |
'hauteurPlante',
|
79 |
'resistanceTraitementPhyto',
|
79 |
'resistanceTraitementPhyto',
|
80 |
'vitesseCroissance',
|
80 |
'vitesseCroissance',
|
81 |
'perceptionTechnicien',
|
81 |
'perceptionTechnicien',
|
82 |
'perceptionRiverainMauvaise',
|
82 |
'perceptionRiverainMauvaise',
|
83 |
);
|
83 |
);
|
84 |
|
84 |
|
85 |
static function colGroupsValidation($groupe_de_champs = 'standard,avance', $programme = "") {
|
85 |
static function colGroupsValidation($groupe_de_champs = 'standard,avance', $programme = "") {
|
86 |
if (! $groupe_de_champs) return FALSE;
|
86 |
if (! $groupe_de_champs) return FALSE;
|
87 |
if (is_string($groupe_de_champs)) {
|
87 |
if (is_string($groupe_de_champs)) {
|
88 |
$groupe_de_champs = array_flip(explode(',', $groupe_de_champs));
|
88 |
$groupe_de_champs = array_flip(explode(',', $groupe_de_champs));
|
89 |
} elseif(is_array($groupe_de_champs)) {
|
89 |
} elseif(is_array($groupe_de_champs)) {
|
90 |
$groupe_de_champs = array_flip($groupe_de_champs);
|
90 |
$groupe_de_champs = array_flip($groupe_de_champs);
|
91 |
} else {
|
91 |
} else {
|
92 |
return null;
|
92 |
return null;
|
93 |
}
|
93 |
}
|
94 |
$groupe_de_champs = array_intersect_key(array_flip(self::$fieldGroups), $groupe_de_champs);
|
94 |
$groupe_de_champs = array_intersect_key(array_flip(self::$fieldGroups), $groupe_de_champs);
|
95 |
if (!$groupe_de_champs) {
|
95 |
if (!$groupe_de_champs) {
|
96 |
return false;
|
96 |
return false;
|
97 |
}
|
97 |
}
|
98 |
if ($programme != "") {
|
98 |
if ($programme != "") {
|
99 |
$groupe_de_champs['avance'] = true;
|
99 |
$groupe_de_champs['avance'] = true;
|
100 |
$groupe_de_champs['etendu'] = true;
|
100 |
$groupe_de_champs['etendu'] = true;
|
101 |
}
|
101 |
}
|
102 |
// toujours ajouter standard
|
102 |
// toujours ajouter standard
|
103 |
$groupe_de_champs['standard'] = true;
|
103 |
$groupe_de_champs['standard'] = true;
|
104 |
return implode(',', array_keys($groupe_de_champs));
|
104 |
return implode(',', array_keys($groupe_de_champs));
|
105 |
}
|
105 |
}
|
106 |
|
106 |
|
107 |
/*
|
107 |
/*
|
108 |
* @param $fieldSets: un liste de noms de colonnes ou de sets de colonnes
|
108 |
* @param $fieldSets: un liste de noms de colonnes ou de sets de colonnes
|
109 |
* séparés par des virgules
|
109 |
* séparés par des virgules
|
110 |
* eg: "espece" ou "champs-etendus", ...
|
110 |
* eg: "espece" ou "champs-etendus", ...
|
111 |
*
|
111 |
*
|
112 |
* @return: un tableau associatif déjà ordonné
|
112 |
* @return: un tableau associatif déjà ordonné
|
113 |
* clé: abbrev [machine-name] de la colonne (eg: "espece" ou "mot-clef")
|
113 |
* clé: abbrev [machine-name] de la colonne (eg: "espece" ou "mot-clef")
|
114 |
* valeur: des données relative à cette colonne, cf GenColInfo
|
114 |
* valeur: des données relative à cette colonne, cf GenColInfo
|
115 |
*
|
115 |
*
|
116 |
* Si la colonne n'utilise pas de fonction de récupération particulière
|
116 |
* Si la colonne n'utilise pas de fonction de récupération particulière
|
117 |
* (ie: si le champ exportés [ou importé] correspond exactement au champ dans la base de donnée)
|
117 |
* (ie: si le champ exportés [ou importé] correspond exactement au champ dans la base de donnée)
|
118 |
* Alors 'abbrev' doit avoir la même valeur que le nom de la colonne dans la table mysql `cel_obs`.
|
118 |
* Alors 'abbrev' doit avoir la même valeur que le nom de la colonne dans la table mysql `cel_obs`.
|
119 |
*/
|
119 |
*/
|
120 |
static function nomEnsembleVersListeColonnes($groupe_de_champs = 'standard') {
|
120 |
static function nomEnsembleVersListeColonnes($groupe_de_champs = 'standard') {
|
121 |
if (! $groupe_de_champs) {
|
121 |
if (! $groupe_de_champs) {
|
122 |
$groupe_de_champs = 'standard';
|
122 |
$groupe_de_champs = 'standard';
|
123 |
}
|
123 |
}
|
124 |
if (is_string($groupe_de_champs)) {
|
124 |
if (is_string($groupe_de_champs)) {
|
125 |
$groupe_de_champs = array_flip(explode(',', $groupe_de_champs));
|
125 |
$groupe_de_champs = array_flip(explode(',', $groupe_de_champs));
|
126 |
} elseif(is_array($groupe_de_champs)) {
|
126 |
} elseif(is_array($groupe_de_champs)) {
|
127 |
$groupe_de_champs = array_flip($groupe_de_champs);
|
127 |
$groupe_de_champs = array_flip($groupe_de_champs);
|
128 |
} else {
|
128 |
} else {
|
129 |
return null;
|
129 |
return null;
|
130 |
}
|
130 |
}
|
131 |
$groupe_de_champs = array_intersect_key(array_flip(self::$fieldGroups), $groupe_de_champs);
|
131 |
$groupe_de_champs = array_intersect_key(array_flip(self::$fieldGroups), $groupe_de_champs);
|
132 |
if (!$groupe_de_champs) {
|
132 |
if (!$groupe_de_champs) {
|
133 |
return null;
|
133 |
return null;
|
134 |
}
|
134 |
}
|
135 |
|
135 |
|
136 |
$colonnes = array();
|
136 |
$colonnes = array();
|
137 |
if (isset($groupe_de_champs['standardexport'])) {
|
137 |
if (isset($groupe_de_champs['standardexport'])) {
|
138 |
$colonnes += Array(
|
138 |
$colonnes += Array(
|
139 |
'guid' => self::GenColInfo(Array('abbrev' => 'guid',
|
139 |
'guid' => self::GenColInfo(Array('abbrev' => 'guid',
|
140 |
'nom' => 'Identifiant unique')),
|
140 |
'nom' => 'Identifiant unique')),
|
141 |
'id_observation' => self::GenColInfo(Array('abbrev' => 'id_observation',
|
141 |
'id_observation' => self::GenColInfo(Array('abbrev' => 'id_observation',
|
142 |
'nom' => 'Identifiant',
|
142 |
'nom' => 'Identifiant',
|
143 |
'extra' => 1,
|
143 |
'extra' => 1,
|
144 |
'importable' => FALSE)),
|
144 |
'importable' => FALSE)),
|
145 |
'nom_sel' => self::GenColInfo(Array('abbrev' => 'nom_sel',
|
145 |
'nom_sel' => self::GenColInfo(Array('abbrev' => 'nom_sel',
|
146 |
'nom' => 'Espèce')),
|
146 |
'nom' => 'Espèce')),
|
147 |
'nom_sel_nn' => self::GenColInfo(Array('abbrev' => 'nom_sel_nn',
|
147 |
'nom_sel_nn' => self::GenColInfo(Array('abbrev' => 'nom_sel_nn',
|
148 |
'nom' => 'Numéro nomenclatural',
|
148 |
'nom' => 'Numéro nomenclatural',
|
149 |
'importable' => FALSE)),
|
149 |
'importable' => FALSE)),
|
150 |
'nom_ret' => self::GenColInfo(Array('abbrev' => 'nom_ret',
|
150 |
'nom_ret' => self::GenColInfo(Array('abbrev' => 'nom_ret',
|
151 |
'nom' => 'Nom retenu',
|
151 |
'nom' => 'Nom retenu',
|
152 |
'importable' => FALSE)),
|
152 |
'importable' => FALSE)),
|
153 |
'nom_ret_nn' => self::GenColInfo(Array('abbrev' => 'nom_ret_nn',
|
153 |
'nom_ret_nn' => self::GenColInfo(Array('abbrev' => 'nom_ret_nn',
|
154 |
'nom' => 'Numéro nomenclatural nom retenu',
|
154 |
'nom' => 'Numéro nomenclatural nom retenu',
|
155 |
'importable' => FALSE)),
|
155 |
'importable' => FALSE)),
|
156 |
'nt' => self::GenColInfo(Array('abbrev' => 'nt',
|
- |
|
157 |
'nom' => 'Numéro taxonomique',
|
- |
|
158 |
'importable' => FALSE)),
|
- |
|
159 |
'famille' => self::GenColInfo(Array('abbrev' => 'famille',
|
156 |
'famille' => self::GenColInfo(Array('abbrev' => 'famille',
|
160 |
'nom' => 'Famille',
|
157 |
'nom' => 'Famille',
|
161 |
'importable' => FALSE)),
|
158 |
'importable' => FALSE)),
|
162 |
'nom_referentiel' => self::GenColInfo(Array('abbrev' => 'nom_referentiel',
|
159 |
'nom_referentiel' => self::GenColInfo(Array('abbrev' => 'nom_referentiel',
|
163 |
'nom' => 'Référentiel taxonomique')),
|
160 |
'nom' => 'Référentiel taxonomique')),
|
164 |
'certitude' => self::GenColInfo(Array('abbrev' => 'certitude',
|
161 |
'certitude' => self::GenColInfo(Array('abbrev' => 'certitude',
|
165 |
'nom' => 'Certitude')),
|
162 |
'nom' => 'Certitude')),
|
166 |
'type_donnees' => self::GenColInfo(Array('abbrev' => 'type_donnees',
|
163 |
'type_donnees' => self::GenColInfo(Array('abbrev' => 'type_donnees',
|
167 |
'nom' => 'Type d\'observation')),
|
164 |
'nom' => 'Type d\'observation')),
|
168 |
'source' => self::GenColInfo(Array('abbrev' => 'source',
|
165 |
'source' => self::GenColInfo(Array('abbrev' => 'source',
|
169 |
'nom' => 'Source de la saisie')),
|
166 |
'nom' => 'Source de la saisie')),
|
170 |
'spontaneite' => self::GenColInfo(Array('abbrev' => 'spontaneite',
|
167 |
'spontaneite' => self::GenColInfo(Array('abbrev' => 'spontaneite',
|
171 |
'nom' => 'Spontanéité')),
|
168 |
'nom' => 'Spontanéité')),
|
172 |
'latitude' => self::GenColInfo(Array('abbrev' => 'latitude',
|
169 |
'latitude' => self::GenColInfo(Array('abbrev' => 'latitude',
|
173 |
'nom' => 'Latitude',
|
170 |
'nom' => 'Latitude',
|
174 |
'extra' => 1)),
|
171 |
'extra' => 1)),
|
175 |
'longitude' => self::GenColInfo(Array('abbrev' => 'longitude',
|
172 |
'longitude' => self::GenColInfo(Array('abbrev' => 'longitude',
|
176 |
'nom' => 'Longitude',
|
173 |
'nom' => 'Longitude',
|
177 |
'extra' => 1)),
|
174 |
'extra' => 1)),
|
178 |
|
175 |
|
179 |
'geodatum' => self::GenColInfo(Array('abbrev' => 'geodatum',
|
176 |
'geodatum' => self::GenColInfo(Array('abbrev' => 'geodatum',
|
180 |
'nom' => 'Référentiel Géographique',
|
177 |
'nom' => 'Référentiel Géographique',
|
181 |
'extra' => 1,
|
178 |
'extra' => 1,
|
182 |
'importable' => FALSE)),
|
179 |
'importable' => FALSE)),
|
183 |
|
180 |
|
184 |
'pays' => self::GenColInfo(Array('abbrev' => 'pays',
|
181 |
'pays' => self::GenColInfo(Array('abbrev' => 'pays',
|
185 |
'nom' => 'Pays')),
|
182 |
'nom' => 'Pays')),
|
186 |
'zone_geo' => self::GenColInfo(Array('abbrev' => 'zone_geo',
|
183 |
'zone_geo' => self::GenColInfo(Array('abbrev' => 'zone_geo',
|
187 |
'nom' => 'Commune')),
|
184 |
'nom' => 'Commune')),
|
188 |
'ce_zone_geo' => self::GenColInfo(Array('abbrev' => 'ce_zone_geo',
|
185 |
'ce_zone_geo' => self::GenColInfo(Array('abbrev' => 'ce_zone_geo',
|
189 |
'nom' => 'Identifiant Commune')),
|
186 |
'nom' => 'Identifiant Commune')),
|
190 |
'localisation_floutage' => self::GenColInfo(Array('abbrev' => 'localisation_floutage',
|
187 |
'localisation_floutage' => self::GenColInfo(Array('abbrev' => 'localisation_floutage',
|
191 |
'nom' => 'Floutage (niveau de localisation diffusé)')),
|
188 |
'nom' => 'Floutage (niveau de localisation diffusé)')),
|
192 |
'altitude' => self::GenColInfo(Array('abbrev' => 'altitude',
|
189 |
'altitude' => self::GenColInfo(Array('abbrev' => 'altitude',
|
193 |
'nom' => 'Altitude',
|
190 |
'nom' => 'Altitude',
|
194 |
'extra' => 1)), // pas de trim0 car INT(5) en DB
|
191 |
'extra' => 1)), // pas de trim0 car INT(5) en DB
|
195 |
'lieudit' => self::GenColInfo(Array('abbrev' => 'lieudit',
|
192 |
'lieudit' => self::GenColInfo(Array('abbrev' => 'lieudit',
|
196 |
'nom' => 'Lieu-dit')),
|
193 |
'nom' => 'Lieu-dit')),
|
197 |
'milieu' => self::GenColInfo(Array('abbrev' => 'milieu',
|
194 |
'milieu' => self::GenColInfo(Array('abbrev' => 'milieu',
|
198 |
'nom' => 'Milieu')),
|
195 |
'nom' => 'Milieu')),
|
199 |
'date_observation' => self::GenColInfo(Array('abbrev' => 'date_observation',
|
196 |
'date_observation' => self::GenColInfo(Array('abbrev' => 'date_observation',
|
200 |
'nom' => 'Date',
|
197 |
'nom' => 'Date',
|
201 |
'fonction' => 'formaterDate')),
|
198 |
'fonction' => 'formaterDate')),
|
202 |
'commentaire' => self::GenColInfo(Array('abbrev' => 'commentaire',
|
199 |
'commentaire' => self::GenColInfo(Array('abbrev' => 'commentaire',
|
203 |
'nom' => 'Notes')),
|
200 |
'nom' => 'Notes')),
|
204 |
'programme' => self::GenColInfo(Array('abbrev' => 'programme',
|
201 |
'programme' => self::GenColInfo(Array('abbrev' => 'programme',
|
205 |
'nom' => 'Programme de sciences participatives ou observatoire citoyen',
|
202 |
'nom' => 'Programme de sciences participatives ou observatoire citoyen',
|
206 |
'importable' => FALSE)),
|
203 |
'importable' => FALSE)),
|
207 |
'mots_cles_texte' => self::GenColInfo(Array('abbrev' => 'mots_cles_texte',
|
204 |
'mots_cles_texte' => self::GenColInfo(Array('abbrev' => 'mots_cles_texte',
|
208 |
'nom' => 'Mots Clés',
|
205 |
'nom' => 'Mots Clés',
|
209 |
'importable' => FALSE)),
|
206 |
'importable' => FALSE)),
|
210 |
'url_identiplante' => self::GenColInfo(Array('abbrev' => 'url_identiplante',
|
207 |
'url_identiplante' => self::GenColInfo(Array('abbrev' => 'url_identiplante',
|
211 |
'nom' => "Lien vers l'observation sur IdentiPlante",
|
208 |
'nom' => "Lien vers l'observation sur IdentiPlante",
|
212 |
'importable' => FALSE)),
|
209 |
'importable' => FALSE)),
|
213 |
'image' => self::GenColInfo(Array('abbrev' => 'image',
|
210 |
'images' => self::GenColInfo(Array('abbrev' => 'images',
|
214 |
'nom' => 'Image(s)',
|
211 |
'nom' => 'Image(s)',
|
215 |
'extra' => 1)),
|
212 |
'extra' => 1)),
|
216 |
|
213 |
|
217 |
);
|
214 |
);
|
218 |
} elseif (isset($groupe_de_champs['standard'])) {
|
215 |
} elseif (isset($groupe_de_champs['standard'])) {
|
219 |
$colonnes += Array(
|
216 |
$colonnes += Array(
|
220 |
'guid' => self::GenColInfo(Array('abbrev' => 'guid',
|
217 |
'guid' => self::GenColInfo(Array('abbrev' => 'guid',
|
221 |
'nom' => 'Identifiant unique')),
|
218 |
'nom' => 'Identifiant unique')),
|
222 |
'id_observation' => self::GenColInfo(Array('abbrev' => 'id_observation',
|
219 |
'id_observation' => self::GenColInfo(Array('abbrev' => 'id_observation',
|
223 |
'nom' => 'Identifiant',
|
220 |
'nom' => 'Identifiant',
|
224 |
'extra' => 1,
|
221 |
'extra' => 1,
|
225 |
'importable' => FALSE)),
|
222 |
'importable' => FALSE)),
|
226 |
'nom_sel' => self::GenColInfo(Array('abbrev' => 'nom_sel',
|
223 |
'nom_sel' => self::GenColInfo(Array('abbrev' => 'nom_sel',
|
227 |
'nom' => 'Espèce')),
|
224 |
'nom' => 'Espèce')),
|
228 |
'nom_sel_nn' => self::GenColInfo(Array('abbrev' => 'nom_sel_nn',
|
225 |
'nom_sel_nn' => self::GenColInfo(Array('abbrev' => 'nom_sel_nn',
|
229 |
'nom' => 'Numéro nomenclatural',
|
226 |
'nom' => 'Numéro nomenclatural',
|
230 |
'importable' => FALSE)),
|
227 |
'importable' => FALSE)),
|
231 |
'nom_ret' => self::GenColInfo(Array('abbrev' => 'nom_ret',
|
228 |
'nom_ret' => self::GenColInfo(Array('abbrev' => 'nom_ret',
|
232 |
'nom' => 'Nom retenu',
|
229 |
'nom' => 'Nom retenu',
|
233 |
'importable' => FALSE)),
|
230 |
'importable' => FALSE)),
|
234 |
'nom_ret_nn' => self::GenColInfo(Array('abbrev' => 'nom_ret_nn',
|
231 |
'nom_ret_nn' => self::GenColInfo(Array('abbrev' => 'nom_ret_nn',
|
235 |
'nom' => 'Numéro nomenclatural nom retenu',
|
232 |
'nom' => 'Numéro nomenclatural nom retenu',
|
236 |
'importable' => FALSE)),
|
233 |
'importable' => FALSE)),
|
237 |
'nt' => self::GenColInfo(Array('abbrev' => 'nt',
|
- |
|
238 |
'nom' => 'Numéro taxonomique',
|
- |
|
239 |
'importable' => FALSE)),
|
- |
|
240 |
'famille' => self::GenColInfo(Array('abbrev' => 'famille',
|
234 |
'famille' => self::GenColInfo(Array('abbrev' => 'famille',
|
241 |
'nom' => 'Famille',
|
235 |
'nom' => 'Famille',
|
242 |
'importable' => FALSE)),
|
236 |
'importable' => FALSE)),
|
243 |
'nom_referentiel' => self::GenColInfo(Array('abbrev' => 'nom_referentiel',
|
237 |
'nom_referentiel' => self::GenColInfo(Array('abbrev' => 'nom_referentiel',
|
244 |
'nom' => 'Référentiel taxonomique')),
|
238 |
'nom' => 'Référentiel taxonomique')),
|
245 |
'certitude' => self::GenColInfo(Array('abbrev' => 'certitude',
|
239 |
'certitude' => self::GenColInfo(Array('abbrev' => 'certitude',
|
246 |
'nom' => 'Certitude')),
|
240 |
'nom' => 'Certitude')),
|
247 |
'type_donnees' => self::GenColInfo(Array('abbrev' => 'type_donnees',
|
241 |
'type_donnees' => self::GenColInfo(Array('abbrev' => 'type_donnees',
|
248 |
'nom' => 'Type d\'observation')),
|
242 |
'nom' => 'Type d\'observation')),
|
249 |
'source' => self::GenColInfo(Array('abbrev' => 'source',
|
243 |
'source' => self::GenColInfo(Array('abbrev' => 'source',
|
250 |
'nom' => 'Source de la saisie')),
|
244 |
'nom' => 'Source de la saisie')),
|
251 |
'spontaneite' => self::GenColInfo(Array('abbrev' => 'spontaneite',
|
245 |
'spontaneite' => self::GenColInfo(Array('abbrev' => 'spontaneite',
|
252 |
'nom' => 'Spontanéité')),
|
246 |
'nom' => 'Spontanéité')),
|
253 |
'latitude' => self::GenColInfo(Array('abbrev' => 'latitude',
|
247 |
'latitude' => self::GenColInfo(Array('abbrev' => 'latitude',
|
254 |
'nom' => 'Latitude',
|
248 |
'nom' => 'Latitude',
|
255 |
'extra' => 1)),
|
249 |
'extra' => 1)),
|
256 |
'longitude' => self::GenColInfo(Array('abbrev' => 'longitude',
|
250 |
'longitude' => self::GenColInfo(Array('abbrev' => 'longitude',
|
257 |
'nom' => 'Longitude',
|
251 |
'nom' => 'Longitude',
|
258 |
'extra' => 1)),
|
252 |
'extra' => 1)),
|
259 |
|
253 |
|
260 |
'geodatum' => self::GenColInfo(Array('abbrev' => 'geodatum',
|
254 |
'geodatum' => self::GenColInfo(Array('abbrev' => 'geodatum',
|
261 |
'nom' => 'Référentiel Géographique',
|
255 |
'nom' => 'Référentiel Géographique',
|
262 |
'extra' => 1,
|
256 |
'extra' => 1,
|
263 |
'importable' => FALSE)),
|
257 |
'importable' => FALSE)),
|
264 |
|
258 |
|
265 |
'pays' => self::GenColInfo(Array('abbrev' => 'pays',
|
259 |
'pays' => self::GenColInfo(Array('abbrev' => 'pays',
|
266 |
'nom' => 'Pays')),
|
260 |
'nom' => 'Pays')),
|
267 |
'zone_geo' => self::GenColInfo(Array('abbrev' => 'zone_geo',
|
261 |
'zone_geo' => self::GenColInfo(Array('abbrev' => 'zone_geo',
|
268 |
'nom' => 'Commune')),
|
262 |
'nom' => 'Commune')),
|
269 |
'ce_zone_geo' => self::GenColInfo(Array('abbrev' => 'ce_zone_geo',
|
263 |
'ce_zone_geo' => self::GenColInfo(Array('abbrev' => 'ce_zone_geo',
|
270 |
'nom' => 'Identifiant Commune')),
|
264 |
'nom' => 'Identifiant Commune')),
|
271 |
'localisation_floutage' => self::GenColInfo(Array('abbrev' => 'localisation_floutage',
|
265 |
'localisation_floutage' => self::GenColInfo(Array('abbrev' => 'localisation_floutage',
|
272 |
'nom' => 'Floutage (niveau de localisation diffusé)')),
|
266 |
'nom' => 'Floutage (niveau de localisation diffusé)')),
|
273 |
'altitude' => self::GenColInfo(Array('abbrev' => 'altitude',
|
267 |
'altitude' => self::GenColInfo(Array('abbrev' => 'altitude',
|
274 |
'nom' => 'Altitude',
|
268 |
'nom' => 'Altitude',
|
275 |
'extra' => 1)), // pas de trim0 car INT(5) en DB
|
269 |
'extra' => 1)), // pas de trim0 car INT(5) en DB
|
276 |
'lieudit' => self::GenColInfo(Array('abbrev' => 'lieudit',
|
270 |
'lieudit' => self::GenColInfo(Array('abbrev' => 'lieudit',
|
277 |
'nom' => 'Lieu-dit')),
|
271 |
'nom' => 'Lieu-dit')),
|
278 |
'milieu' => self::GenColInfo(Array('abbrev' => 'milieu',
|
272 |
'milieu' => self::GenColInfo(Array('abbrev' => 'milieu',
|
279 |
'nom' => 'Milieu')),
|
273 |
'nom' => 'Milieu')),
|
280 |
'date_observation' => self::GenColInfo(Array('abbrev' => 'date_observation',
|
274 |
'date_observation' => self::GenColInfo(Array('abbrev' => 'date_observation',
|
281 |
'nom' => 'Date',
|
275 |
'nom' => 'Date',
|
282 |
'fonction' => 'formaterDate')),
|
276 |
'fonction' => 'formaterDate')),
|
283 |
'commentaire' => self::GenColInfo(Array('abbrev' => 'commentaire',
|
277 |
'commentaire' => self::GenColInfo(Array('abbrev' => 'commentaire',
|
284 |
'nom' => 'Notes')),
|
278 |
'nom' => 'Notes')),
|
285 |
'programme' => self::GenColInfo(Array('abbrev' => 'programme',
|
279 |
'programme' => self::GenColInfo(Array('abbrev' => 'programme',
|
286 |
'nom' => 'Programme de sciences participatives ou observatoire citoyen',
|
280 |
'nom' => 'Programme de sciences participatives ou observatoire citoyen',
|
287 |
'importable' => FALSE)),
|
281 |
'importable' => FALSE)),
|
288 |
'mots_cles_texte' => self::GenColInfo(Array('abbrev' => 'mots_cles_texte',
|
282 |
'mots_cles_texte' => self::GenColInfo(Array('abbrev' => 'mots_cles_texte',
|
289 |
'nom' => 'Mots Clés',
|
283 |
'nom' => 'Mots Clés',
|
290 |
'importable' => FALSE)),
|
284 |
'importable' => FALSE)),
|
291 |
|
285 |
|
292 |
'image' => self::GenColInfo(Array('abbrev' => 'image',
|
286 |
'images' => self::GenColInfo(Array('abbrev' => 'images',
|
293 |
'nom' => 'Image(s)',
|
287 |
'nom' => 'Image(s)',
|
294 |
'extra' => 1)),
|
288 |
'extra' => 1)),
|
295 |
'url_identiplante' => self::GenColInfo(Array('abbrev' => 'url_identiplante',
|
289 |
'url_identiplante' => self::GenColInfo(Array('abbrev' => 'url_identiplante',
|
296 |
'nom' => "Lien vers l'observation sur IdentiPlante",
|
290 |
'nom' => "Lien vers l'observation sur IdentiPlante",
|
297 |
'importable' => FALSE)),
|
291 |
'importable' => FALSE)),
|
298 |
|
292 |
|
299 |
);
|
293 |
);
|
300 |
}
|
294 |
}
|
301 |
|
295 |
|
302 |
if(isset($groupe_de_champs['avance'])) {
|
296 |
if(isset($groupe_de_champs['avance'])) {
|
303 |
$colonnes += array(
|
297 |
$colonnes += array(
|
304 |
'localisation_coherence' => self::GenColInfo(Array('abbrev' => 'localisation_coherence',
|
298 |
'localisation_coherence' => self::GenColInfo(Array('abbrev' => 'localisation_coherence',
|
305 |
'nom' => 'Cohérence entre la localité et les coordonnées GPS')),
|
299 |
'nom' => 'Cohérence entre la localité et les coordonnées GPS')),
|
306 |
'localisation_precision' => self::GenColInfo(Array('abbrev' => 'localisation_precision',
|
300 |
'localisation_precision' => self::GenColInfo(Array('abbrev' => 'localisation_precision',
|
307 |
'nom' => 'Précision de la localisation')),
|
301 |
'nom' => 'Précision de la localisation')),
|
308 |
'station' => self::GenColInfo(Array('abbrev' => 'station',
|
302 |
'station' => self::GenColInfo(Array('abbrev' => 'station',
|
309 |
'nom' => 'Station')),
|
303 |
'nom' => 'Station')),
|
310 |
'validation_identiplante' => self::GenColInfo(Array('abbrev' => 'validation_identiplante',
|
304 |
'validation_identiplante' => self::GenColInfo(Array('abbrev' => 'validation_identiplante',
|
311 |
'nom' => 'Détermination validée sur IdentiPlante',
|
305 |
'nom' => 'Détermination validée sur IdentiPlante',
|
312 |
'importable' => FALSE)),
|
306 |
'importable' => FALSE)),
|
313 |
'score_identiplante' => self::GenColInfo(Array('abbrev' => 'score_identiplante',
|
307 |
'score_identiplante' => self::GenColInfo(Array('abbrev' => 'score_identiplante',
|
314 |
'nom' => 'Détermination validée sur IdentiPlante',
|
308 |
'nom' => 'Détermination validée sur IdentiPlante',
|
315 |
'importable' => FALSE)),
|
309 |
'importable' => FALSE)),
|
316 |
'abondance' => self::GenColInfo(Array('abbrev' => 'abondance',
|
310 |
'abondance' => self::GenColInfo(Array('abbrev' => 'abondance',
|
317 |
'nom' => 'Abondance',
|
311 |
'nom' => 'Abondance',
|
318 |
'extra' => 1)),
|
312 |
'extra' => 1)),
|
319 |
'phenologie' => self::GenColInfo(Array('abbrev' => 'phenologie',
|
313 |
'phenologie' => self::GenColInfo(Array('abbrev' => 'phenologie',
|
320 |
'nom' => 'Phénologie',
|
314 |
'nom' => 'Phénologie',
|
321 |
'extra' => 1)),
|
315 |
'extra' => 1)),
|
322 |
'herbier' => self::GenColInfo(Array('abbrev' => 'herbier',
|
316 |
'herbier' => self::GenColInfo(Array('abbrev' => 'herbier',
|
323 |
'nom' => 'Présence d\'un échantillon d\'herbier',
|
317 |
'nom' => 'Présence d\'un échantillon d\'herbier',
|
324 |
'extra' => 1)),
|
318 |
'extra' => 1)),
|
325 |
|
319 |
|
326 |
// TODO: importable = FALSE car pas de merge de données importées
|
320 |
// TODO: importable = FALSE car pas de merge de données importées
|
327 |
'date_creation' => self::GenColInfo(Array('abbrev' => 'date_creation',
|
321 |
'date_creation' => self::GenColInfo(Array('abbrev' => 'date_creation',
|
328 |
'nom' => 'Date Création',
|
322 |
'nom' => 'Date Création',
|
329 |
'extra' => 1,
|
323 |
'extra' => 1,
|
330 |
'importable' => FALSE)),
|
324 |
'importable' => FALSE)),
|
331 |
'date_modification' => self::GenColInfo(Array('abbrev' => 'date_modification',
|
325 |
'date_modification' => self::GenColInfo(Array('abbrev' => 'date_modification',
|
332 |
'nom' => 'Date Modification',
|
326 |
'nom' => 'Date Modification',
|
333 |
'extra' => 1,
|
327 |
'extra' => 1,
|
334 |
'importable' => FALSE)),
|
328 |
'importable' => FALSE)),
|
335 |
|
329 |
|
336 |
// rappel transmission = 1, signifie simplement "public"
|
330 |
// rappel transmission = 1, signifie simplement "public"
|
337 |
// des données importées peuvent être d'emblée "publiques"
|
331 |
// des données importées peuvent être d'emblée "publiques"
|
338 |
// "importable" = TRUE
|
332 |
// "importable" = TRUE
|
339 |
'transmission' => self::GenColInfo(Array('abbrev' => 'transmission',
|
333 |
'transmission' => self::GenColInfo(Array('abbrev' => 'transmission',
|
340 |
'nom' => 'Transmis',
|
334 |
'nom' => 'Transmis',
|
341 |
'extra' => 1,
|
335 |
'extra' => 1,
|
342 |
'fonction' => 'boolOuiNon')),
|
336 |
'fonction' => 'boolOuiNon')),
|
343 |
'date_transmission' => self::GenColInfo(Array('abbrev' => 'date_transmission',
|
337 |
'date_transmission' => self::GenColInfo(Array('abbrev' => 'date_transmission',
|
344 |
'nom' => 'Date Transmission',
|
338 |
'nom' => 'Date Transmission',
|
345 |
'extra' => 1,
|
339 |
'extra' => 1,
|
346 |
'importable' => FALSE)),
|
340 |
'importable' => FALSE)),
|
347 |
|
341 |
|
348 |
|
342 |
|
349 |
/* 'nom_commun' => self::GenColInfo(Array('abbrev' => 'nom_commun',
|
343 |
/* 'nom_commun' => self::GenColInfo(Array('abbrev' => 'nom_commun',
|
350 |
'nom' => 'Nom Commun',
|
344 |
'nom' => 'Nom Commun',
|
351 |
'extra' => 1,
|
345 |
'extra' => 1,
|
352 |
'fonction_data' => 'getNomCommun',
|
346 |
'fonction_data' => 'getNomCommun',
|
353 |
'importable' => FALSE),
|
347 |
'importable' => FALSE),
|
354 |
|
348 |
|
355 |
'nom-commun' => self::GenColInfo(Array('abbrev' => 'nom-commun',
|
349 |
'nom-commun' => self::GenColInfo(Array('abbrev' => 'nom-commun',
|
356 |
'nom' => 'Nom Commun',
|
350 |
'nom' => 'Nom Commun',
|
357 |
'extra' => 1,
|
351 |
'extra' => 1,
|
358 |
'fonction_data' => 'getNomCommun_v2'),
|
352 |
'fonction_data' => 'getNomCommun_v2'),
|
359 |
|
353 |
|
360 |
'nom-commun' => self::GenColInfo(Array('abbrev' => 'nom-commun',
|
354 |
'nom-commun' => self::GenColInfo(Array('abbrev' => 'nom-commun',
|
361 |
'nom' => 'Nom Commun',
|
355 |
'nom' => 'Nom Commun',
|
362 |
'extra' => 1,
|
356 |
'extra' => 1,
|
363 |
'fonction_data' => 'getNomCommun_v3'),
|
357 |
'fonction_data' => 'getNomCommun_v3'),
|
364 |
'importable' => FALSE), */ /* cas particu 'getNomCommun_v4' */
|
358 |
'importable' => FALSE), */ /* cas particu 'getNomCommun_v4' */
|
365 |
/*'nom-commun' => self::GenColInfo(array(
|
359 |
/*'nom-commun' => self::GenColInfo(array(
|
366 |
'abbrev' => 'nom-commun',
|
360 |
'abbrev' => 'nom-commun',
|
367 |
'nom' => 'Nom Commun',
|
361 |
'nom' => 'Nom Commun',
|
368 |
'extra' => 1,
|
362 |
'extra' => 1,
|
369 |
'fonction_data' => null ,
|
363 |
'fonction_data' => null ,
|
370 |
'preload' => array(__CLASS__, 'getNomCommun_preload')))*/
|
364 |
'preload' => array(__CLASS__, 'getNomCommun_preload')))*/
|
371 |
);
|
365 |
);
|
372 |
}
|
366 |
}
|
373 |
|
367 |
|
374 |
if(isset($groupe_de_champs['baseflor'])) {
|
368 |
if(isset($groupe_de_champs['baseflor'])) {
|
375 |
$colonnes += array(
|
369 |
$colonnes += array(
|
376 |
// champ dynamique
|
370 |
// champ dynamique
|
377 |
'baseflor' => self::GenColInfo(array(
|
371 |
'baseflor' => self::GenColInfo(array(
|
378 |
'abbrev' => 'baseflor',
|
372 |
'abbrev' => 'baseflor',
|
379 |
'nom' => '',
|
373 |
'nom' => '',
|
380 |
'extra' => 1,
|
374 |
'extra' => 1,
|
381 |
'importable' => false,
|
375 |
'importable' => false,
|
382 |
'preload' => array(__CLASS__, 'baseflor_preload'),
|
376 |
'preload' => array(__CLASS__, 'baseflor_preload'),
|
383 |
'dyna' => array(__CLASS__, 'baseflor_ligne'))),
|
377 |
'dyna' => array(__CLASS__, 'baseflor_ligne'))),
|
384 |
);
|
378 |
);
|
385 |
}
|
379 |
}
|
386 |
|
380 |
|
387 |
if (isset($groupe_de_champs['etendu'])) {
|
381 |
if (isset($groupe_de_champs['etendu'])) {
|
388 |
$colonnes += array(
|
382 |
$colonnes += array(
|
389 |
// champ dynamique
|
383 |
// champ dynamique
|
390 |
'etendu' => self::GenColInfo(array(
|
384 |
'etendu' => self::GenColInfo(array(
|
391 |
'abbrev' => 'etendu',
|
385 |
'abbrev' => 'etendu',
|
392 |
'nom' => '',
|
386 |
'nom' => '',
|
393 |
'extra' => 1,
|
387 |
'extra' => 1,
|
394 |
'importable' => false,
|
388 |
'importable' => false,
|
395 |
'preload' => array(__CLASS__, 'champsEtendus_preload'),
|
389 |
'preload' => array(__CLASS__, 'champsEtendus_preload'),
|
396 |
'dyna' => array(__CLASS__, 'champsEtendus_ligne'))),
|
390 |
'dyna' => array(__CLASS__, 'champsEtendus_ligne'))),
|
397 |
);
|
391 |
);
|
398 |
}
|
392 |
}
|
399 |
|
393 |
|
400 |
if (isset($groupe_de_champs['auteur'])) {
|
394 |
if (isset($groupe_de_champs['auteur'])) {
|
401 |
$colonnes += array(
|
395 |
$colonnes += array(
|
402 |
'observateur' => self::GenColInfo(array(
|
396 |
'observateur' => self::GenColInfo(array(
|
403 |
'abbrev' => 'pseudo_utilisateur',
|
397 |
'abbrev' => 'pseudo_utilisateur',
|
404 |
'nom' => 'Auteur',
|
398 |
'nom' => 'Auteur',
|
405 |
'extra' => 1,
|
399 |
'extra' => 1,
|
406 |
'importable' => false)),
|
400 |
'importable' => false)),
|
407 |
);
|
401 |
);
|
408 |
}
|
402 |
}
|
409 |
return $colonnes;
|
403 |
return $colonnes;
|
410 |
}
|
404 |
}
|
411 |
|
405 |
|
412 |
static function preload($colonnes, $cel, $ids) {
|
406 |
static function preload($colonnes, $cel, $ids) {
|
413 |
$result = array();
|
407 |
$result = array();
|
414 |
foreach ($colonnes as $abbrev => $colonne) {
|
408 |
foreach ($colonnes as $abbrev => $colonne) {
|
415 |
if (!$colonne['preload']) {
|
409 |
if (!$colonne['preload']) {
|
416 |
continue;
|
410 |
continue;
|
417 |
}
|
411 |
}
|
418 |
$result[$abbrev] = call_user_func($colonne['preload'], $cel, $ids);
|
412 |
$result[$abbrev] = call_user_func($colonne['preload'], $cel, $ids);
|
419 |
}
|
413 |
}
|
420 |
return $result;
|
414 |
return $result;
|
421 |
}
|
415 |
}
|
422 |
|
416 |
|
423 |
public static function getIntitulesColonnes($colonnes) {
|
417 |
public static function getIntitulesColonnes($colonnes) {
|
424 |
// array_filter pour supprimer les colonnes "dynamique" n'ayant pas défini $nom (cf GenColInfo())
|
418 |
// array_filter pour supprimer les colonnes "dynamique" n'ayant pas défini $nom (cf GenColInfo())
|
425 |
return array_filter(array_map(array('FormateurGroupeColonne', 'retournerNomItem'), $colonnes));
|
419 |
return array_filter(array_map(array('FormateurGroupeColonne', 'retournerNomItem'), $colonnes));
|
426 |
}
|
420 |
}
|
427 |
|
421 |
|
428 |
public static function retournerNomItem(&$item) {
|
422 |
public static function retournerNomItem(&$item) {
|
429 |
return $item['nom'];
|
423 |
return $item['nom'];
|
430 |
}
|
424 |
}
|
431 |
|
425 |
|
432 |
public static function getLigneObservation(&$obs, &$colonnes, $cel = false) {
|
426 |
public static function getLigneObservation(&$obs, &$colonnes, $cel = false) {
|
433 |
$ligne_formatee = array();
|
427 |
$ligne_formatee = array();
|
434 |
foreach($colonnes as $abbrev => $colonne) {
|
428 |
foreach($colonnes as $abbrev => $colonne) {
|
435 |
$valeur = null;
|
429 |
$valeur = null;
|
436 |
if ($colonne['extra'] == 2 || ! is_null($colonne['dyna'])) {
|
430 |
if ($colonne['extra'] == 2 || ! is_null($colonne['dyna'])) {
|
437 |
continue;
|
431 |
continue;
|
438 |
}
|
432 |
}
|
439 |
|
433 |
|
440 |
// valeur directe depuis cel_obs ?
|
434 |
// valeur directe depuis cel_obs ?
|
441 |
if (isset($obs[$abbrev])) {
|
435 |
if (isset($obs[$abbrev])) {
|
442 |
$valeur = $obs[$abbrev];
|
436 |
$valeur = $obs[$abbrev];
|
443 |
}
|
437 |
}
|
444 |
|
438 |
|
445 |
// pré-processeur des champs
|
439 |
// pré-processeur des champs
|
446 |
if (function_exists($colonne['fonction'])) {
|
440 |
if (function_exists($colonne['fonction'])) {
|
447 |
$valeur = $colonne['fonction']($valeur);
|
441 |
$valeur = $colonne['fonction']($valeur);
|
448 |
} else if(method_exists(__CLASS__, $colonne['fonction'])) {
|
442 |
} else if(method_exists(__CLASS__, $colonne['fonction'])) {
|
449 |
$valeur = call_user_func(array(__CLASS__, $colonne['fonction']), $valeur);
|
443 |
$valeur = call_user_func(array(__CLASS__, $colonne['fonction']), $valeur);
|
450 |
} else if($colonne['fonction']) {
|
444 |
} else if($colonne['fonction']) {
|
451 |
die("méthode {$colonne['fonction']} introuvable");
|
445 |
die("méthode {$colonne['fonction']} introuvable");
|
452 |
} else if(function_exists($colonne['fonction_data'])) {// fonction pour obtenir des champs (étendus)
|
446 |
} else if(function_exists($colonne['fonction_data'])) {// fonction pour obtenir des champs (étendus)
|
453 |
$valeur = $colonne['fonction_data']($obs);
|
447 |
$valeur = $colonne['fonction_data']($obs);
|
454 |
} else if(method_exists(__CLASS__, $colonne['fonction_data'])) {
|
448 |
} else if(method_exists(__CLASS__, $colonne['fonction_data'])) {
|
455 |
$valeur = call_user_func(array(__CLASS__, $colonne['fonction_data']), $obs);
|
449 |
$valeur = call_user_func(array(__CLASS__, $colonne['fonction_data']), $obs);
|
456 |
}
|
450 |
}
|
457 |
|
451 |
|
458 |
|
452 |
|
459 |
// ici à cause du passage de $cel ($this->utilisateur)
|
453 |
// ici à cause du passage de $cel ($this->utilisateur)
|
460 |
|
454 |
|
461 |
if ($abbrev == 'nom-commun') {
|
455 |
if ($abbrev == 'nom-commun') {
|
462 |
$valeur = FormateurGroupeColonne::getNomCommun_v4($obs);
|
456 |
$valeur = FormateurGroupeColonne::getNomCommun_v4($obs);
|
463 |
}
|
457 |
}
|
464 |
|
458 |
|
465 |
if ($valeur == null) {
|
459 |
if ($valeur == null) {
|
466 |
$valeur = '';
|
460 |
$valeur = '';
|
467 |
}
|
461 |
}
|
468 |
|
462 |
|
469 |
// fin de section "cas particuliers"
|
463 |
// fin de section "cas particuliers"
|
470 |
$ligne_formatee[] = $valeur;
|
464 |
$ligne_formatee[] = $valeur;
|
471 |
}
|
465 |
}
|
472 |
|
466 |
|
473 |
// uniquement les champs dynamiques
|
467 |
// uniquement les champs dynamiques
|
474 |
foreach($colonnes as $abbrev => $colonne) {
|
468 |
foreach($colonnes as $abbrev => $colonne) {
|
475 |
$valeur = null;
|
469 |
$valeur = null;
|
476 |
if (is_null($colonne['dyna'])) {
|
470 |
if (is_null($colonne['dyna'])) {
|
477 |
continue;
|
471 |
continue;
|
478 |
}
|
472 |
}
|
479 |
call_user_func_array($colonne['dyna'], array($obs, &$ligne_formatee));
|
473 |
call_user_func_array($colonne['dyna'], array($obs, &$ligne_formatee));
|
480 |
}
|
474 |
}
|
481 |
return $ligne_formatee;
|
475 |
return $ligne_formatee;
|
482 |
}
|
476 |
}
|
483 |
|
477 |
|
484 |
/*
|
478 |
/*
|
485 |
* Wrapper générant un tableau associatif:
|
479 |
* Wrapper générant un tableau associatif:
|
486 |
* Ne pas changer les valeurs par défaut du prototype sans réflexion sur l'implication pour nomEnsembleVersListeColonnes()
|
480 |
* Ne pas changer les valeurs par défaut du prototype sans réflexion sur l'implication pour nomEnsembleVersListeColonnes()
|
487 |
|
481 |
|
488 |
* @param $abbrev (obligatoire): nom court de colonne, largement utilisé lors de l'import.
|
482 |
* @param $abbrev (obligatoire): nom court de colonne, largement utilisé lors de l'import.
|
489 |
* En effet chaque ligne importée est accessible à l'aide du `define` de $abbrev en majuscule, préfixé de "C_"
|
483 |
* En effet chaque ligne importée est accessible à l'aide du `define` de $abbrev en majuscule, préfixé de "C_"
|
490 |
* Exemple: $ligne[C_LONGITUDE] pour "longitude".
|
484 |
* Exemple: $ligne[C_LONGITUDE] pour "longitude".
|
491 |
* cf: ImportXLS::detectionEntete()
|
485 |
* cf: ImportXLS::detectionEntete()
|
492 |
|
486 |
|
493 |
* @param $nom (obligatoire): nom complet de colonne (utilisé pour la ligne d'en-tête)
|
487 |
* @param $nom (obligatoire): nom complet de colonne (utilisé pour la ligne d'en-tête)
|
494 |
* Les définition de champs dynamique (correspondant à de multiples colonnes) doivent laisser cette valeur
|
488 |
* Les définition de champs dynamique (correspondant à de multiples colonnes) doivent laisser cette valeur
|
495 |
* vide afin de ne pas créer une colonne supplémentaire erronée.
|
489 |
* vide afin de ne pas créer une colonne supplémentaire erronée.
|
496 |
|
490 |
|
497 |
* @param $is_extra:
|
491 |
* @param $is_extra:
|
498 |
* Si 0, la colonne est une colonne standard
|
492 |
* Si 0, la colonne est une colonne standard
|
499 |
* Si 1, la colonne est extra [le plus souvent générée automatiquement]
|
493 |
* Si 1, la colonne est extra [le plus souvent générée automatiquement]
|
500 |
* (auquel cas une bordure bleue entoure son nom dans la ligne d'entête)
|
494 |
* (auquel cas une bordure bleue entoure son nom dans la ligne d'entête)
|
501 |
* Si 2, la colonne n'est pas traité à l'export, mais une définition peut lui être donnée
|
495 |
* Si 2, la colonne n'est pas traité à l'export, mais une définition peut lui être donnée
|
502 |
* qui pourra être utilisée à l'import, exemple: "image"
|
496 |
* qui pourra être utilisée à l'import, exemple: "image"
|
503 |
|
497 |
|
504 |
* @param $fonction (optionnel): un nom d'un fonction de préprocessing
|
498 |
* @param $fonction (optionnel): un nom d'un fonction de préprocessing
|
505 |
* $fonction doit prendre comme seul argument la valeur d'origine et retourner la valeur transformée
|
499 |
* $fonction doit prendre comme seul argument la valeur d'origine et retourner la valeur transformée
|
506 |
|
500 |
|
507 |
* @param $fonction_data (optionnel): une *méthode* d'obtention de donnée
|
501 |
* @param $fonction_data (optionnel): une *méthode* d'obtention de donnée
|
508 |
* $fonction_data doit prendre comme premier argument le tableau des champs de l'enregistrement existant
|
502 |
* $fonction_data doit prendre comme premier argument le tableau des champs de l'enregistrement existant
|
509 |
* $fonction_data doit retourner une valeur
|
503 |
* $fonction_data doit retourner une valeur
|
510 |
|
504 |
|
511 |
* @param $importable (optionnel): défini si la colonne est traitée (ou absolument ignorée par PHPExcel) lors de
|
505 |
* @param $importable (optionnel): défini si la colonne est traitée (ou absolument ignorée par PHPExcel) lors de
|
512 |
* l'import.
|
506 |
* l'import.
|
513 |
|
507 |
|
514 |
* @param $preload (optionnel): défini une fonction de préchargement massif de donnée potentiellement utilisable par $fonction_data.
|
508 |
* @param $preload (optionnel): défini une fonction de préchargement massif de donnée potentiellement utilisable par $fonction_data.
|
515 |
* Utile, notamment, dans le cadre de l'export
|
509 |
* Utile, notamment, dans le cadre de l'export
|
516 |
|
510 |
|
517 |
* @param $fonction_dynamique (optionnel): défini une fonction ajoutant un nombre arbitraire de colonnes à une ligne donnée
|
511 |
* @param $fonction_dynamique (optionnel): défini une fonction ajoutant un nombre arbitraire de colonnes à une ligne donnée
|
518 |
* Utile, notamment, dans le cadre de l'export des champs étendus ou des données baseflor
|
512 |
* Utile, notamment, dans le cadre de l'export des champs étendus ou des données baseflor
|
519 |
* La fonction doit TOUJOURS alterer la ligne en lui ajoutant une nombre CONSTANT d'éléments (NULL ou non)
|
513 |
* La fonction doit TOUJOURS alterer la ligne en lui ajoutant une nombre CONSTANT d'éléments (NULL ou non)
|
520 |
* La fonction doit prendre comme arguments ($obs, &$ligne_formatee)
|
514 |
* La fonction doit prendre comme arguments ($obs, &$ligne_formatee)
|
521 |
*/
|
515 |
*/
|
522 |
static function GenColInfo($args) {
|
516 |
static function GenColInfo($args) {
|
523 |
$default = array(
|
517 |
$default = array(
|
524 |
'abbrev' => null,
|
518 |
'abbrev' => null,
|
525 |
'nom' => null,
|
519 |
'nom' => null,
|
526 |
'extra' => 0,
|
520 |
'extra' => 0,
|
527 |
'fonction' => null,
|
521 |
'fonction' => null,
|
528 |
'fonction_data' => null,
|
522 |
'fonction_data' => null,
|
529 |
'importable' => true,
|
523 |
'importable' => true,
|
530 |
'preload' => null,
|
524 |
'preload' => null,
|
531 |
'dyna' => null);
|
525 |
'dyna' => null);
|
532 |
$ret = array_intersect_key($args, $default);
|
526 |
$ret = array_intersect_key($args, $default);
|
533 |
return array_merge($default, $ret);
|
527 |
return array_merge($default, $ret);
|
534 |
}
|
528 |
}
|
535 |
|
529 |
|
536 |
static function formaterDate($date_heure_mysql) {
|
530 |
static function formaterDate($date_heure_mysql) {
|
537 |
//return "";
|
531 |
//return "";
|
538 |
if (!$date_heure_mysql || $date_heure_mysql == "0000-00-00 00:00:00") {
|
532 |
if (!$date_heure_mysql || $date_heure_mysql == "0000-00-00 00:00:00") {
|
539 |
return null;
|
533 |
return null;
|
540 |
}
|
534 |
}
|
541 |
// malheureusement pas disponible en php < 5.3
|
535 |
// malheureusement pas disponible en php < 5.3
|
542 |
//$date_format = DateTime::createFromFormat("Y-m-d H:i:s", $date_heure_mysql);
|
536 |
//$date_format = DateTime::createFromFormat("Y-m-d H:i:s", $date_heure_mysql);
|
543 |
$val = explode(' ', $date_heure_mysql);
|
537 |
$val = explode(' ', $date_heure_mysql);
|
544 |
$date = explode('-', $val[0]);
|
538 |
$date = explode('-', $val[0]);
|
545 |
$heure = explode(':', $val[1]);
|
539 |
$heure = explode(':', $val[1]);
|
546 |
$timestamp = mktime((int) $heure[0], (int) $heure[1], (int) $heure[2], (int) $date[1], (int) $date[2], (int) $date[0]);
|
540 |
$timestamp = mktime((int) $heure[0], (int) $heure[1], (int) $heure[2], (int) $date[1], (int) $date[2], (int) $date[0]);
|
547 |
if (!$timestamp) {
|
541 |
if (!$timestamp) {
|
548 |
return null;
|
542 |
return null;
|
549 |
}
|
543 |
}
|
550 |
// TODO: les widgets ne font malheureusement pas usage de l'heure dans le CEL
|
544 |
// TODO: les widgets ne font malheureusement pas usage de l'heure dans le CEL
|
551 |
// TODO: si modification, ne pas oublier de modifier le format d'import correspondant
|
545 |
// TODO: si modification, ne pas oublier de modifier le format d'import correspondant
|
552 |
// dans ImportXLS, traiterDateObs() (actuellement: "Y/m/d" car utilisation de strtotime() qui ne lit pas tout)
|
546 |
// dans ImportXLS, traiterDateObs() (actuellement: "Y/m/d" car utilisation de strtotime() qui ne lit pas tout)
|
553 |
// $date_formatee = strftime('%d/%m/%Y', $timestamp);
|
547 |
// $date_formatee = strftime('%d/%m/%Y', $timestamp);
|
554 |
$date_formatee = strftime('%Y/%m/%d', $timestamp);
|
548 |
$date_formatee = strftime('%Y/%m/%d', $timestamp);
|
555 |
if (!$date_formatee) {
|
549 |
if (!$date_formatee) {
|
556 |
return '00/00/0000';
|
550 |
return '00/00/0000';
|
557 |
}
|
551 |
}
|
558 |
return $date_formatee;
|
552 |
return $date_formatee;
|
559 |
}
|
553 |
}
|
560 |
|
554 |
|
561 |
|
555 |
|
562 |
|
556 |
|
563 |
|
557 |
|
564 |
|
558 |
|
565 |
/**
|
559 |
/**
|
566 |
* Enlève les zéros excédentaires (devenus nomades) au début et à la fin d'une
|
560 |
* Enlève les zéros excédentaires (devenus nomades) au début et à la fin d'une
|
567 |
* latitude ou longitude, en prenant garde à ne pas foirer les nombres 0.xyz
|
561 |
* latitude ou longitude, en prenant garde à ne pas foirer les nombres 0.xyz
|
568 |
*/
|
562 |
*/
|
569 |
public static function trim0($lonlat) {
|
563 |
public static function trim0($lonlat) {
|
570 |
$retour = trim($lonlat, "0");
|
564 |
$retour = trim($lonlat, "0");
|
571 |
// si on a trop enlevé de zéros à gauche, on en remet un (mode synthobois)
|
565 |
// si on a trop enlevé de zéros à gauche, on en remet un (mode synthobois)
|
572 |
if (substr($retour, 0, 1) == ".") {
|
566 |
if (substr($retour, 0, 1) == ".") {
|
573 |
$retour = "0" . $retour;
|
567 |
$retour = "0" . $retour;
|
574 |
}
|
568 |
}
|
575 |
return $retour;
|
569 |
return $retour;
|
576 |
}
|
570 |
}
|
577 |
|
571 |
|
578 |
public static function boolOuiNon($transmission) {
|
572 |
public static function boolOuiNon($transmission) {
|
579 |
return $transmission ? 'oui' : '';
|
573 |
return $transmission ? 'oui' : '';
|
580 |
}
|
574 |
}
|
581 |
|
575 |
|
582 |
|
576 |
|
583 |
|
577 |
|
584 |
// TODO: référentiel ne devrait pas être généré au moment d'un Config::get,
|
578 |
// TODO: référentiel ne devrait pas être généré au moment d'un Config::get,
|
585 |
// comme dans Config::get('nomsVernaRechercheLimiteeTpl')
|
579 |
// comme dans Config::get('nomsVernaRechercheLimiteeTpl')
|
586 |
// Par exemple, la variable pour "nva" ?
|
580 |
// Par exemple, la variable pour "nva" ?
|
587 |
function getNomCommun($obs) {
|
581 |
function getNomCommun($obs) {
|
588 |
$langue = 'fra';
|
582 |
$langue = 'fra';
|
589 |
list($referentiel) = explode(':', strtolower($obs['nom_referentiel']));
|
583 |
list($referentiel) = explode(':', strtolower($obs['nom_referentiel']));
|
590 |
if($referentiel == 'bdtfx') $referentiel = 'nvjfl';
|
584 |
if($referentiel == 'bdtfx') $referentiel = 'nvjfl';
|
591 |
else return '';
|
585 |
else return '';
|
592 |
|
586 |
|
593 |
$cache_id = $referentiel . '-' . $obs['nt'] . '-' . $langue;
|
587 |
$cache_id = $referentiel . '-' . $obs['nt'] . '-' . $langue;
|
594 |
if(isset(self::$cache['getNomCommun'][$cache_id])) {
|
588 |
if(isset(self::$cache['getNomCommun'][$cache_id])) {
|
595 |
//debug: error_log("require url_service_nom_attribution: OK ! (pour \"{$obs['nom_ret']}\")");
|
589 |
//debug: error_log("require url_service_nom_attribution: OK ! (pour \"{$obs['nom_ret']}\")");
|
596 |
return self::$cache['getNomCommun'][$cache_id];
|
590 |
return self::$cache['getNomCommun'][$cache_id];
|
597 |
}
|
591 |
}
|
598 |
// pas de cache:
|
592 |
// pas de cache:
|
599 |
//debug: error_log("require url_service_nom_attribution pour \"{$obs['nom_ret']}\"");
|
593 |
//debug: error_log("require url_service_nom_attribution pour \"{$obs['nom_ret']}\"");
|
600 |
|
594 |
|
601 |
// pour bdtfx:
|
595 |
// pour bdtfx:
|
602 |
// /service:eflore:0.1/nvjfl/noms-vernaculaires/attributions?masque.nt=X&masque.lg=fra&retour.champs=num_statut
|
596 |
// /service:eflore:0.1/nvjfl/noms-vernaculaires/attributions?masque.nt=X&masque.lg=fra&retour.champs=num_statut
|
603 |
// /projet/services/modules/0.1/nvjfl/NomsVernaculaires.php
|
597 |
// /projet/services/modules/0.1/nvjfl/NomsVernaculaires.php
|
604 |
$url = str_replace(Array('{referentiel}', '{valeur}', '{langue}'),
|
598 |
$url = str_replace(Array('{referentiel}', '{valeur}', '{langue}'),
|
605 |
Array($referentiel, $obs['nt'], $langue),
|
599 |
Array($referentiel, $obs['nt'], $langue),
|
606 |
self::$config['eflore']['url_service_nom_attribution']) . // TODO !
|
600 |
self::$config['eflore']['url_service_nom_attribution']) . // TODO !
|
607 |
"&retour.champs=num_statut";
|
601 |
"&retour.champs=num_statut";
|
608 |
$noms = @json_decode(file_get_contents($url));
|
602 |
$noms = @json_decode(file_get_contents($url));
|
609 |
if(! $noms) return '';
|
603 |
if(! $noms) return '';
|
610 |
$noms = array_filter((array)($noms->resultat), array($this, retournerNumStatutUn)); // XXX: php 5.3
|
604 |
$noms = array_filter((array)($noms->resultat), array($this, retournerNumStatutUn)); // XXX: php 5.3
|
611 |
$nom = array_pop($noms)->nom_vernaculaire;
|
605 |
$nom = array_pop($noms)->nom_vernaculaire;
|
612 |
|
606 |
|
613 |
// cache
|
607 |
// cache
|
614 |
self::$cache['getNomCommun'][$cache_id] = $nom;
|
608 |
self::$cache['getNomCommun'][$cache_id] = $nom;
|
615 |
return $nom;
|
609 |
return $nom;
|
616 |
}
|
610 |
}
|
617 |
|
611 |
|
618 |
private function retournerNumStatutUn(&$item) {
|
612 |
private function retournerNumStatutUn(&$item) {
|
619 |
return ($item->num_statut == 1);
|
613 |
return ($item->num_statut == 1);
|
620 |
}
|
614 |
}
|
621 |
|
615 |
|
622 |
private function retournerNumStatutUnArr(&$item) {
|
616 |
private function retournerNumStatutUnArr(&$item) {
|
623 |
return ($item['num_statut'] == 1);
|
617 |
return ($item['num_statut'] == 1);
|
624 |
}
|
618 |
}
|
625 |
|
619 |
|
626 |
// si getNomCommun_v2 ou getNomCommun_v3 sont utilisés
|
620 |
// si getNomCommun_v2 ou getNomCommun_v3 sont utilisés
|
627 |
/* require_once('/home/raphael/eflore/framework/framework/Framework.php');
|
621 |
/* require_once('/home/raphael/eflore/framework/framework/Framework.php');
|
628 |
Framework::setCheminAppli("/home/raphael/eflore/projets/services/index.php");
|
622 |
Framework::setCheminAppli("/home/raphael/eflore/projets/services/index.php");
|
629 |
Framework::setInfoAppli(Config::get('info'));
|
623 |
Framework::setInfoAppli(Config::get('info'));
|
630 |
require_once('/home/raphael/eflore/projets/services/modules/0.1/Projets.php');*/
|
624 |
require_once('/home/raphael/eflore/projets/services/modules/0.1/Projets.php');*/
|
631 |
|
625 |
|
632 |
/* Tente de bootstraper le framework au plus court et d'initialiser une instance de
|
626 |
/* Tente de bootstraper le framework au plus court et d'initialiser une instance de
|
633 |
NomsVernaculaires pour obtenir le nom commun */
|
627 |
NomsVernaculaires pour obtenir le nom commun */
|
634 |
function getNomCommun_v2($obs) {
|
628 |
function getNomCommun_v2($obs) {
|
635 |
static $service;
|
629 |
static $service;
|
636 |
$service = new Projets();
|
630 |
$service = new Projets();
|
637 |
|
631 |
|
638 |
$langue = 'fra';
|
632 |
$langue = 'fra';
|
639 |
list($referentiel) = explode(':', strtolower($obs['nom_referentiel']));
|
633 |
list($referentiel) = explode(':', strtolower($obs['nom_referentiel']));
|
640 |
if($referentiel == 'bdtfx') $referentiel = 'nvjfl';
|
634 |
if($referentiel == 'bdtfx') $referentiel = 'nvjfl';
|
641 |
else return '';
|
635 |
else return '';
|
642 |
|
636 |
|
643 |
$cache_id = $referentiel . '-' . $obs['nt'] . '-' . $langue;
|
637 |
$cache_id = $referentiel . '-' . $obs['nt'] . '-' . $langue;
|
644 |
if(isset(self::$cache['getNomCommun'][$cache_id])) {
|
638 |
if(isset(self::$cache['getNomCommun'][$cache_id])) {
|
645 |
error_log("require NomsVernaculaires.php: OK ! (pour \"{$obs['nom_ret']}\")");
|
639 |
error_log("require NomsVernaculaires.php: OK ! (pour \"{$obs['nom_ret']}\")");
|
646 |
return self::$cache['getNomCommun'][$cache_id];
|
640 |
return self::$cache['getNomCommun'][$cache_id];
|
647 |
}
|
641 |
}
|
648 |
// pas de cache:
|
642 |
// pas de cache:
|
649 |
error_log("require NomsVernaculaires.php pour \"{$obs['nom_ret']}\"");
|
643 |
error_log("require NomsVernaculaires.php pour \"{$obs['nom_ret']}\"");
|
650 |
|
644 |
|
651 |
$donnees = Array('masque.nt' => $obs['nt'],
|
645 |
$donnees = Array('masque.nt' => $obs['nt'],
|
652 |
'masque.lg' => $langue,
|
646 |
'masque.lg' => $langue,
|
653 |
'retour.champs' => 'num_statut');
|
647 |
'retour.champs' => 'num_statut');
|
654 |
$noms = $service->consulter(Array('nvjfl', 'noms-vernaculaires'), $donnees);
|
648 |
$noms = $service->consulter(Array('nvjfl', 'noms-vernaculaires'), $donnees);
|
655 |
|
649 |
|
656 |
if(! $noms) return '';
|
650 |
if(! $noms) return '';
|
657 |
$noms = array_filter((array)($noms->resultat), array($this, retournerNumStatutUn)); // XXX: php 5.3
|
651 |
$noms = array_filter((array)($noms->resultat), array($this, retournerNumStatutUn)); // XXX: php 5.3
|
658 |
$nom = array_pop($noms)->nom_vernaculaire;
|
652 |
$nom = array_pop($noms)->nom_vernaculaire;
|
659 |
|
653 |
|
660 |
// cache
|
654 |
// cache
|
661 |
self::$cache['getNomCommun'][$cache_id] = $nom;
|
655 |
self::$cache['getNomCommun'][$cache_id] = $nom;
|
662 |
return $nom;
|
656 |
return $nom;
|
663 |
}
|
657 |
}
|
664 |
|
658 |
|
665 |
|
659 |
|
666 |
/* Effectue un bootstraping plus sage que ci-dessus, mais le gain d'efficacité
|
660 |
/* Effectue un bootstraping plus sage que ci-dessus, mais le gain d'efficacité
|
667 |
n'est pas aussi retentissant qu'espéré */
|
661 |
n'est pas aussi retentissant qu'espéré */
|
668 |
static $service;
|
662 |
static $service;
|
669 |
function getNomCommun_v3($obs) {
|
663 |
function getNomCommun_v3($obs) {
|
670 |
if(! $this->service) $this->service = new Projets();
|
664 |
if(! $this->service) $this->service = new Projets();
|
671 |
|
665 |
|
672 |
$langue = 'fra';
|
666 |
$langue = 'fra';
|
673 |
list($referentiel) = explode(':', strtolower($obs['nom_referentiel']));
|
667 |
list($referentiel) = explode(':', strtolower($obs['nom_referentiel']));
|
674 |
if($referentiel == 'bdtfx') $referentiel = 'nvjfl';
|
668 |
if($referentiel == 'bdtfx') $referentiel = 'nvjfl';
|
675 |
else return '';
|
669 |
else return '';
|
676 |
|
670 |
|
677 |
$cache_id = $referentiel . '-' . $obs['nt'] . '-' . $langue;
|
671 |
$cache_id = $referentiel . '-' . $obs['nt'] . '-' . $langue;
|
678 |
if(isset(self::$cache['getNomCommun'][$cache_id])) {
|
672 |
if(isset(self::$cache['getNomCommun'][$cache_id])) {
|
679 |
error_log("require NomsVernaculaires.php: OK ! (pour \"{$obs['nom_ret']}\")");
|
673 |
error_log("require NomsVernaculaires.php: OK ! (pour \"{$obs['nom_ret']}\")");
|
680 |
return self::$cache['getNomCommun'][$cache_id];
|
674 |
return self::$cache['getNomCommun'][$cache_id];
|
681 |
}
|
675 |
}
|
682 |
// pas de cache:
|
676 |
// pas de cache:
|
683 |
error_log("require NomsVernaculaires.php pour \"{$obs['nom_ret']}\"");
|
677 |
error_log("require NomsVernaculaires.php pour \"{$obs['nom_ret']}\"");
|
684 |
|
678 |
|
685 |
$donnees = Array('masque.nt' => $obs['nt'],
|
679 |
$donnees = Array('masque.nt' => $obs['nt'],
|
686 |
'masque.lg' => $langue,
|
680 |
'masque.lg' => $langue,
|
687 |
'retour.champs' => 'conseil_emploi');
|
681 |
'retour.champs' => 'conseil_emploi');
|
688 |
$this->service->initialiserRessourcesEtParametres(Array('nvjfl', 'noms-vernaculaires', 'attributions'), $donnees);
|
682 |
$this->service->initialiserRessourcesEtParametres(Array('nvjfl', 'noms-vernaculaires', 'attributions'), $donnees);
|
689 |
try {
|
683 |
try {
|
690 |
$noms = $this->service->traiterRessources();
|
684 |
$noms = $this->service->traiterRessources();
|
691 |
} catch(Exception $e) {
|
685 |
} catch(Exception $e) {
|
692 |
return '';
|
686 |
return '';
|
693 |
}
|
687 |
}
|
694 |
if(! $noms) return '';
|
688 |
if(! $noms) return '';
|
695 |
$noms = array_filter($noms['resultat'], array($this, retournerNumStatutUnArr)); // XXX: php 5.3
|
689 |
$noms = array_filter($noms['resultat'], array($this, retournerNumStatutUnArr)); // XXX: php 5.3
|
696 |
$premier_nom = array_pop($noms);
|
690 |
$premier_nom = array_pop($noms);
|
697 |
$nom = $premier_nom['nom_vernaculaire'];
|
691 |
$nom = $premier_nom['nom_vernaculaire'];
|
698 |
|
692 |
|
699 |
// cache
|
693 |
// cache
|
700 |
self::$cache['getNomCommun'][$cache_id] = $nom;
|
694 |
self::$cache['getNomCommun'][$cache_id] = $nom;
|
701 |
return $nom;
|
695 |
return $nom;
|
702 |
}
|
696 |
}
|
703 |
|
697 |
|
704 |
|
698 |
|
705 |
|
699 |
|
706 |
|
700 |
|
707 |
|
701 |
|
708 |
static function getNomCommun_v4($obs) {
|
702 |
static function getNomCommun_v4($obs) {
|
709 |
// Attention la fonction suppose que l'on ait fait appel à getNomCommun_preload avant
|
703 |
// Attention la fonction suppose que l'on ait fait appel à getNomCommun_preload avant
|
710 |
// d'être appelée
|
704 |
// d'être appelée
|
711 |
if(! $obs['nt']) return NULL;
|
705 |
if(! $obs['nt']) return NULL;
|
712 |
if(! self::referenceTableExiste()) return NULL;
|
706 |
if(! self::referenceTableExiste()) return NULL;
|
713 |
|
707 |
|
714 |
$langue = 'fra';
|
708 |
$langue = 'fra';
|
715 |
list($referentiel) = explode(':', strtolower($obs['nom_referentiel']));
|
709 |
list($referentiel) = explode(':', strtolower($obs['nom_referentiel']));
|
716 |
$cache_id = $referentiel . '-' . $obs['nt'] . '-' . $langue;
|
710 |
$cache_id = $referentiel . '-' . $obs['nt'] . '-' . $langue;
|
717 |
|
711 |
|
718 |
$nom = null;
|
712 |
$nom = null;
|
719 |
// cache:
|
713 |
// cache:
|
720 |
if(isset(self::$cache['getNomCommun'])) {
|
714 |
if(isset(self::$cache['getNomCommun'])) {
|
721 |
if(isset(self::$cache['getNomCommun'][$cache_id])) return self::$cache['getNomCommun'][$cache_id];
|
715 |
if(isset(self::$cache['getNomCommun'][$cache_id])) return self::$cache['getNomCommun'][$cache_id];
|
722 |
// XXX: problème de valeurs NULL ?
|
716 |
// XXX: problème de valeurs NULL ?
|
723 |
if(array_key_exists($cache_id, self::$cache['getNomCommun'])) {
|
717 |
if(array_key_exists($cache_id, self::$cache['getNomCommun'])) {
|
724 |
$nom = self::$cache['getNomCommun'][$cache_id];
|
718 |
$nom = self::$cache['getNomCommun'][$cache_id];
|
725 |
}
|
719 |
}
|
726 |
}
|
720 |
}
|
727 |
|
721 |
|
728 |
return $nom;
|
722 |
return $nom;
|
729 |
}
|
723 |
}
|
730 |
|
724 |
|
731 |
|
725 |
|
732 |
/* Cette fonction initialise le cache des données baseflor en 1 fois, sur la liste des observations à exporter.
|
726 |
/* Cette fonction initialise le cache des données baseflor en 1 fois, sur la liste des observations à exporter.
|
733 |
Ainsi, les appels successifs à baseflor_ligne() ne sont pas couteux (pas de requête SQL) */
|
727 |
Ainsi, les appels successifs à baseflor_ligne() ne sont pas couteux (pas de requête SQL) */
|
734 |
static function baseflor_preload($cel, $obsids) {
|
728 |
static function baseflor_preload($cel, $obsids) {
|
735 |
if(!$obsids) return;
|
729 |
if(!$obsids) return;
|
736 |
if(!self::referenceTableExiste()) return NULL;
|
730 |
if(!self::referenceTableExiste()) return NULL;
|
737 |
|
731 |
|
738 |
// Attention (en attendant de faire une meilleure table et une meilleure requete) le distinct est très important
|
732 |
// Attention (en attendant de faire une meilleure table et une meilleure requete) le distinct est très important
|
739 |
$req = sprintf("SELECT DISTINCT referentiel, num_nom_retenu, %s FROM cel_references r" .
|
733 |
$req = sprintf("SELECT DISTINCT referentiel, num_nom_retenu, %s FROM cel_references r" .
|
740 |
" INNER JOIN cel_obs c ON (r.num_nom_retenu = c.nom_ret_nn)" .
|
734 |
" INNER JOIN cel_obs c ON (r.num_nom_retenu = c.nom_ret_nn)" .
|
741 |
" AND r.referentiel = IF(LOCATE(':', c.nom_referentiel) = 0, c.nom_referentiel, SUBSTR(c.nom_referentiel FROM 1 FOR LOCATE(':', c.nom_referentiel) - 1))" .
|
735 |
" AND r.referentiel = IF(LOCATE(':', c.nom_referentiel) = 0, c.nom_referentiel, SUBSTR(c.nom_referentiel FROM 1 FOR LOCATE(':', c.nom_referentiel) - 1))" .
|
742 |
" WHERE c.id_observation IN (%s)",
|
736 |
" WHERE c.id_observation IN (%s)",
|
743 |
//" AND catminat_code IS NOT NULL", // TODO: suppression des NULL ici signifie que le cache sera partiel...
|
737 |
//" AND catminat_code IS NOT NULL", // TODO: suppression des NULL ici signifie que le cache sera partiel...
|
744 |
implode(',', array_keys(self::$baseflor_col)),
|
738 |
implode(',', array_keys(self::$baseflor_col)),
|
745 |
implode(',', $obsids));
|
739 |
implode(',', $obsids));
|
746 |
$res = Cel::db()->requeter($req);
|
740 |
$res = Cel::db()->requeter($req);
|
747 |
if(!$res) return NULL;
|
741 |
if(!$res) return NULL;
|
748 |
|
742 |
|
749 |
foreach($res as $v) {
|
743 |
foreach($res as $v) {
|
750 |
$data = $v;
|
744 |
$data = $v;
|
751 |
unset($data['referentiel']); // non nécessaire
|
745 |
unset($data['referentiel']); // non nécessaire
|
752 |
unset($data['num_nom_retenu']); // non nécessaire
|
746 |
unset($data['num_nom_retenu']); // non nécessaire
|
753 |
|
747 |
|
754 |
// Des fois les synonymes ont des valeurs pour baseflor et pas le nom retenu et vice versa
|
748 |
// Des fois les synonymes ont des valeurs pour baseflor et pas le nom retenu et vice versa
|
755 |
// on les fusionne pour avoir le maximum d'infos, en attendant de repenser la table référence
|
749 |
// on les fusionne pour avoir le maximum d'infos, en attendant de repenser la table référence
|
756 |
if(isset(self::$cache['getBaseflor'][$v['referentiel'] . '-' . $v['num_nom_retenu']])) {
|
750 |
if(isset(self::$cache['getBaseflor'][$v['referentiel'] . '-' . $v['num_nom_retenu']])) {
|
757 |
$orig = array_filter(self::$cache['getBaseflor'][$v['referentiel'] . '-' . $v['num_nom_retenu']], 'strlen');
|
751 |
$orig = array_filter(self::$cache['getBaseflor'][$v['referentiel'] . '-' . $v['num_nom_retenu']], 'strlen');
|
758 |
$data = array_filter($data , 'strlen');
|
752 |
$data = array_filter($data , 'strlen');
|
759 |
$data = array_merge($orig, $data);
|
753 |
$data = array_merge($orig, $data);
|
760 |
}
|
754 |
}
|
761 |
|
755 |
|
762 |
self::$cache['getBaseflor'][$v['referentiel'] . '-' . $v['num_nom_retenu']] = $data;
|
756 |
self::$cache['getBaseflor'][$v['referentiel'] . '-' . $v['num_nom_retenu']] = $data;
|
763 |
}
|
757 |
}
|
764 |
|
758 |
|
765 |
return NULL;
|
759 |
return NULL;
|
766 |
}
|
760 |
}
|
767 |
|
761 |
|
768 |
/**
|
762 |
/**
|
769 |
* Attention la fonction suppose que l'on ait fait appel à baseflor_preload avant
|
763 |
* Attention la fonction suppose que l'on ait fait appel à baseflor_preload avant
|
770 |
* d'être appelée
|
764 |
* d'être appelée
|
771 |
* @CASSECOUILLES elle pourrait le détecter et le faire elle-même
|
765 |
* @CASSECOUILLES elle pourrait le détecter et le faire elle-même
|
772 |
*/
|
766 |
*/
|
773 |
static function baseflor_ligne($obs, &$ligne) {
|
767 |
static function baseflor_ligne($obs, &$ligne) {
|
774 |
$clefsBF = array_keys(self::$baseflor_col);
|
768 |
$clefsBF = array_keys(self::$baseflor_col);
|
775 |
// par défaut des colonnes vides pour ne pas décaler le bousin
|
769 |
// par défaut des colonnes vides pour ne pas décaler le bousin
|
776 |
$donneesBF = array_fill_keys($clefsBF, "");
|
770 |
$donneesBF = array_fill_keys($clefsBF, "");
|
777 |
|
771 |
|
778 |
// s'il y a des données baseflor
|
772 |
// s'il y a des données baseflor
|
779 |
if ($obs['nom_ret_nn'] && self::referenceTableExiste() && count(self::$cache['getBaseflor']) > 0) {
|
773 |
if ($obs['nom_ret_nn'] && self::referenceTableExiste() && count(self::$cache['getBaseflor']) > 0) {
|
780 |
// l'astuce à un franc vingt
|
774 |
// l'astuce à un franc vingt
|
781 |
list($referentiel) = explode(':', strtolower($obs['nom_referentiel']));
|
775 |
list($referentiel) = explode(':', strtolower($obs['nom_referentiel']));
|
782 |
$cache_id = $referentiel . '-' . $obs['nom_ret_nn'];
|
776 |
$cache_id = $referentiel . '-' . $obs['nom_ret_nn'];
|
783 |
|
777 |
|
784 |
// si les données baseflor existent dans le cache pour ce nom_ret_nn
|
778 |
// si les données baseflor existent dans le cache pour ce nom_ret_nn
|
785 |
if (array_key_exists($cache_id, self::$cache['getBaseflor'])) {
|
779 |
if (array_key_exists($cache_id, self::$cache['getBaseflor'])) {
|
786 |
$donneesBFATrous = self::$cache['getBaseflor'][$cache_id];
|
780 |
$donneesBFATrous = self::$cache['getBaseflor'][$cache_id];
|
787 |
foreach($clefsBF as $colbf) { // remplit les trous tout en préservant l'ordre
|
781 |
foreach($clefsBF as $colbf) { // remplit les trous tout en préservant l'ordre
|
788 |
if(array_key_exists($colbf, $donneesBFATrous)) {
|
782 |
if(array_key_exists($colbf, $donneesBFATrous)) {
|
789 |
$donneesBF[$colbf] = $donneesBFATrous[$colbf];
|
783 |
$donneesBF[$colbf] = $donneesBFATrous[$colbf];
|
790 |
} else {
|
784 |
} else {
|
791 |
$donneesBF[$colbf] = "";
|
785 |
$donneesBF[$colbf] = "";
|
792 |
}
|
786 |
}
|
793 |
}
|
787 |
}
|
794 |
}
|
788 |
}
|
795 |
}
|
789 |
}
|
796 |
|
790 |
|
797 |
// Quand les données sont prêtes, on les fusionne
|
791 |
// Quand les données sont prêtes, on les fusionne
|
798 |
$ligne = array_merge($ligne, $donneesBF);
|
792 |
$ligne = array_merge($ligne, $donneesBF);
|
799 |
}
|
793 |
}
|
800 |
|
794 |
|
801 |
static function champsEtendus_preload($cel, $obsids) {
|
795 |
static function champsEtendus_preload($cel, $obsids) {
|
802 |
// obs étendues
|
796 |
// obs étendues
|
803 |
$gestion_obs_etendus = new GestionChampsEtendus($cel->config);
|
797 |
$gestion_obs_etendus = new GestionChampsEtendus($cel->config);
|
804 |
// champs étendus
|
798 |
// champs étendus
|
805 |
$gestion_champs_etendus = new GestionChampsEtendus2($cel->config);
|
799 |
$gestion_champs_etendus = new GestionChampsEtendus2($cel->config);
|
806 |
$colonnes_champs_supp_par_obs = $gestion_obs_etendus->consulterClesParLots($obsids);
|
800 |
$colonnes_champs_supp_par_obs = $gestion_obs_etendus->consulterClesParLots($obsids);
|
807 |
|
801 |
|
808 |
// Supprime les champs étendus considérés comme privés dans le cas de l'export public en chargeant
|
802 |
// Supprime les champs étendus considérés comme privés dans le cas de l'export public en chargeant
|
809 |
// le catalogue et en excluant ceux qui sont explicitement privés
|
803 |
// le catalogue et en excluant ceux qui sont explicitement privés
|
810 |
if(!$cel->export_prive) {
|
804 |
if(!$cel->export_prive) {
|
811 |
$indices_a_supprimer = array();
|
805 |
$indices_a_supprimer = array();
|
812 |
$catalogue_champs_etendus = $gestion_champs_etendus->consulterCatalogueChampsEtendusPredefinis();
|
806 |
$catalogue_champs_etendus = $gestion_champs_etendus->consulterCatalogueChampsEtendusPredefinis();
|
813 |
foreach($catalogue_champs_etendus as $champ_catalogue) {
|
807 |
foreach($catalogue_champs_etendus as $champ_catalogue) {
|
814 |
if($champ_catalogue['options']['prive'] == 1) {
|
808 |
if($champ_catalogue['options']['prive'] == 1) {
|
815 |
// Les champs étendus peuvent avoir des variantes lorsqu'ils apparaissent de multiples fois.
|
809 |
// Les champs étendus peuvent avoir des variantes lorsqu'ils apparaissent de multiples fois.
|
816 |
// Vont donc matcher monChamp mais aussi monChamp:1, monChamp:2 ou bien monChamp1, monChamp: etc...
|
810 |
// Vont donc matcher monChamp mais aussi monChamp:1, monChamp:2 ou bien monChamp1, monChamp: etc...
|
817 |
// pour plus de sécurité (ce filtra n'est affectué qu'une fois au début de l'export donc on ne s'en prive pas)
|
811 |
// pour plus de sécurité (ce filtra n'est affectué qu'une fois au début de l'export donc on ne s'en prive pas)
|
818 |
$entrees = preg_grep("/".$champ_catalogue['cle']."(?::?\d*)?$/", $colonnes_champs_supp_par_obs);
|
812 |
$entrees = preg_grep("/".$champ_catalogue['cle']."(?::?\d*)?$/", $colonnes_champs_supp_par_obs);
|
819 |
$indices_a_supprimer = array_merge($indices_a_supprimer, array_keys($entrees));
|
813 |
$indices_a_supprimer = array_merge($indices_a_supprimer, array_keys($entrees));
|
820 |
}
|
814 |
}
|
821 |
}
|
815 |
}
|
822 |
// les champs étendus sont renvoyés dans l'export suivant les colonnes présentes dans ce tableau
|
816 |
// les champs étendus sont renvoyés dans l'export suivant les colonnes présentes dans ce tableau
|
823 |
// les éliminer de la liste des colonnes suffit à les faire ignorer par l'export
|
817 |
// les éliminer de la liste des colonnes suffit à les faire ignorer par l'export
|
824 |
foreach($indices_a_supprimer as $indice_supp) {
|
818 |
foreach($indices_a_supprimer as $indice_supp) {
|
825 |
unset($colonnes_champs_supp_par_obs[$indice_supp]);
|
819 |
unset($colonnes_champs_supp_par_obs[$indice_supp]);
|
826 |
}
|
820 |
}
|
827 |
}
|
821 |
}
|
828 |
|
822 |
|
829 |
// ces deux lignes réordonnent l'ordre des colonnes des champs étendus en fonction de l'ordre (très spécifique)
|
823 |
// ces deux lignes réordonnent l'ordre des colonnes des champs étendus en fonction de l'ordre (très spécifique)
|
830 |
// de self::$ordre_champ_etendus_Florileges, les champs non-mentionnés sont ajoutés à la fin.
|
824 |
// de self::$ordre_champ_etendus_Florileges, les champs non-mentionnés sont ajoutés à la fin.
|
831 |
$colonnes_champs_supp_par_obs = self::sortArrayByArray(array_flip($colonnes_champs_supp_par_obs),
|
825 |
$colonnes_champs_supp_par_obs = self::sortArrayByArray(array_flip($colonnes_champs_supp_par_obs),
|
832 |
self::$ordre_champ_etendus_Florileges);
|
826 |
self::$ordre_champ_etendus_Florileges);
|
833 |
$colonnes_champs_supp_par_obs = array_keys($colonnes_champs_supp_par_obs);
|
827 |
$colonnes_champs_supp_par_obs = array_keys($colonnes_champs_supp_par_obs);
|
834 |
|
828 |
|
835 |
// si le SELECT des clefs ne retourne rien, une autre requêtes est inutile
|
829 |
// si le SELECT des clefs ne retourne rien, une autre requêtes est inutile
|
836 |
// TODO: optimize, 1 seule requête
|
830 |
// TODO: optimize, 1 seule requête
|
837 |
if(!$colonnes_champs_supp_par_obs) return Array('header' => array(), 'data' => array());
|
831 |
if(!$colonnes_champs_supp_par_obs) return Array('header' => array(), 'data' => array());
|
838 |
|
832 |
|
839 |
$champs_supp_par_obs = $gestion_obs_etendus->consulterParLots($obsids);
|
833 |
$champs_supp_par_obs = $gestion_obs_etendus->consulterParLots($obsids);
|
840 |
|
834 |
|
841 |
self::$cache['champsEtendus']['header'] = self::champsEtendus_prefixHeader($colonnes_champs_supp_par_obs);
|
835 |
self::$cache['champsEtendus']['header'] = self::champsEtendus_prefixHeader($colonnes_champs_supp_par_obs);
|
842 |
|
836 |
|
843 |
foreach($champs_supp_par_obs as &$v) {
|
837 |
foreach($champs_supp_par_obs as &$v) {
|
844 |
$v = self::champsEtendus_aplatir($v);
|
838 |
$v = self::champsEtendus_aplatir($v);
|
845 |
}
|
839 |
}
|
846 |
self::$cache['champsEtendus']['data'] = $champs_supp_par_obs;
|
840 |
self::$cache['champsEtendus']['data'] = $champs_supp_par_obs;
|
847 |
// ce return est temporaire,
|
841 |
// ce return est temporaire,
|
848 |
// le temps que toutes les fonctions bougent ici et utilise plutôt le cache statique
|
842 |
// le temps que toutes les fonctions bougent ici et utilise plutôt le cache statique
|
849 |
// encore utilisé pour les entêtes (self::$cache['champsEtendus']['header'])
|
843 |
// encore utilisé pour les entêtes (self::$cache['champsEtendus']['header'])
|
850 |
return self::$cache['champsEtendus'];
|
844 |
return self::$cache['champsEtendus'];
|
851 |
}
|
845 |
}
|
852 |
|
846 |
|
853 |
// XXX: PHP-5.3, fonction anonyme + array_map
|
847 |
// XXX: PHP-5.3, fonction anonyme + array_map
|
854 |
static function champsEtendus_prefixHeader($array) {
|
848 |
static function champsEtendus_prefixHeader($array) {
|
855 |
return array_map(create_function('$v', 'return "' . PREFIX_CHAMPS_ETENDUS . '".$v;'), $array);
|
849 |
return array_map(create_function('$v', 'return "' . PREFIX_CHAMPS_ETENDUS . '".$v;'), $array);
|
856 |
}
|
850 |
}
|
857 |
|
851 |
|
858 |
// XXX: PHP-5.3, fonction anonyme + array_map
|
852 |
// XXX: PHP-5.3, fonction anonyme + array_map
|
859 |
static function champsEtendus_aplatir($ligne_champs_etendus) {
|
853 |
static function champsEtendus_aplatir($ligne_champs_etendus) {
|
860 |
$champs_etendus_fmt = array();
|
854 |
$champs_etendus_fmt = array();
|
861 |
if(!$ligne_champs_etendus) return $champs_etendus_fmt;
|
855 |
if(!$ligne_champs_etendus) return $champs_etendus_fmt;
|
862 |
foreach($ligne_champs_etendus as $champ) {
|
856 |
foreach($ligne_champs_etendus as $champ) {
|
863 |
$champs_etendus_fmt[PREFIX_CHAMPS_ETENDUS . $champ->cle] = $champ->valeur;
|
857 |
$champs_etendus_fmt[PREFIX_CHAMPS_ETENDUS . $champ->cle] = $champ->valeur;
|
864 |
}
|
858 |
}
|
865 |
return $champs_etendus_fmt;
|
859 |
return $champs_etendus_fmt;
|
866 |
}
|
860 |
}
|
867 |
|
861 |
|
868 |
static function champsEtendus_ligne($obs, &$ligne) {
|
862 |
static function champsEtendus_ligne($obs, &$ligne) {
|
869 |
// si header n'est pas défini, aucune observation ne possède de champ étendu
|
863 |
// si header n'est pas défini, aucune observation ne possède de champ étendu
|
870 |
// et nous n'ajoutons ni colonnes, ni valeurs.
|
864 |
// et nous n'ajoutons ni colonnes, ni valeurs.
|
871 |
if(! isset(self::$cache['champsEtendus']['header'])) return;
|
865 |
if(! isset(self::$cache['champsEtendus']['header'])) return;
|
872 |
$ligne_etendue_aplatie = @self::$cache['champsEtendus']['data'][$obs['id_observation']];
|
866 |
$ligne_etendue_aplatie = @self::$cache['champsEtendus']['data'][$obs['id_observation']];
|
873 |
|
867 |
|
874 |
$ligne_supp = array_fill(0, count(self::$cache['champsEtendus']['header']), '');
|
868 |
$ligne_supp = array_fill(0, count(self::$cache['champsEtendus']['header']), '');
|
875 |
$ligne_etendue_fmt = array();
|
869 |
$ligne_etendue_fmt = array();
|
876 |
|
870 |
|
877 |
// si, cependant cette seule observation n'a pas de champs étendus,
|
871 |
// si, cependant cette seule observation n'a pas de champs étendus,
|
878 |
// nous devons rajouter des blancs (notamment dans le cas ou d'autres
|
872 |
// nous devons rajouter des blancs (notamment dans le cas ou d'autres
|
879 |
// champs viennent à être ajoutés en aval à l'avenir
|
873 |
// champs viennent à être ajoutés en aval à l'avenir
|
880 |
// cf: $fonction_dynamique dans FormateurGroupeColonne::GenColInfo()
|
874 |
// cf: $fonction_dynamique dans FormateurGroupeColonne::GenColInfo()
|
881 |
if(! $ligne_etendue_aplatie) {
|
875 |
if(! $ligne_etendue_aplatie) {
|
882 |
$ligne = array_merge($ligne, $ligne_supp);
|
876 |
$ligne = array_merge($ligne, $ligne_supp);
|
883 |
return;
|
877 |
return;
|
884 |
}
|
878 |
}
|
885 |
|
879 |
|
886 |
foreach(self::$cache['champsEtendus']['header'] as $colonne) {
|
880 |
foreach(self::$cache['champsEtendus']['header'] as $colonne) {
|
887 |
if(!isset($ligne_etendue_aplatie[$colonne])) {
|
881 |
if(!isset($ligne_etendue_aplatie[$colonne])) {
|
888 |
$ligne_etendue_fmt[$colonne] = '';
|
882 |
$ligne_etendue_fmt[$colonne] = '';
|
889 |
} else {
|
883 |
} else {
|
890 |
$ligne_etendue_fmt[$colonne] = $ligne_etendue_aplatie[$colonne];
|
884 |
$ligne_etendue_fmt[$colonne] = $ligne_etendue_aplatie[$colonne];
|
891 |
}
|
885 |
}
|
892 |
}
|
886 |
}
|
893 |
|
887 |
|
894 |
// XXX/ array_merge() ?
|
888 |
// XXX/ array_merge() ?
|
895 |
$ligne += $ligne_etendue_fmt;
|
889 |
$ligne += $ligne_etendue_fmt;
|
896 |
}
|
890 |
}
|
897 |
|
891 |
|
898 |
/* HELPERS */
|
892 |
/* HELPERS */
|
899 |
|
893 |
|
900 |
// http://stackoverflow.com/questions/348410/sort-an-array-based-on-another-array
|
894 |
// http://stackoverflow.com/questions/348410/sort-an-array-based-on-another-array
|
901 |
// XXX; redéfinition, utilisé aussi par ExportXLS
|
895 |
// XXX; redéfinition, utilisé aussi par ExportXLS
|
902 |
static function sortArrayByArray($array, $orderArray) {
|
896 |
static function sortArrayByArray($array, $orderArray) {
|
903 |
$ordered = array();
|
897 |
$ordered = array();
|
904 |
foreach($orderArray as $key) {
|
898 |
foreach($orderArray as $key) {
|
905 |
if(array_key_exists($key, $array)) {
|
899 |
if(array_key_exists($key, $array)) {
|
906 |
$ordered[$key] = $array[$key];
|
900 |
$ordered[$key] = $array[$key];
|
907 |
unset($array[$key]);
|
901 |
unset($array[$key]);
|
908 |
}
|
902 |
}
|
909 |
}
|
903 |
}
|
910 |
return $ordered + $array;
|
904 |
return $ordered + $array;
|
911 |
}
|
905 |
}
|
912 |
}
|
906 |
}
|