| Line 34... |
Line 34... |
| 34 |
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(dirname(realpath(__FILE__))) . '/lib');
|
34 |
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(dirname(realpath(__FILE__))) . '/lib');
|
| 35 |
// TERM
|
35 |
// TERM
|
| 36 |
ini_set('html_errors', 0);
|
36 |
ini_set('html_errors', 0);
|
| 37 |
ini_set('xdebug.cli_color', 2);
|
37 |
ini_set('xdebug.cli_color', 2);
|
| 38 |
require_once('lib/PHPExcel/Classes/PHPExcel.php');
|
38 |
require_once('lib/PHPExcel/Classes/PHPExcel.php');
|
| 39 |
|
- |
|
| 40 |
define('SEPARATEUR_IMAGES', ",");
|
- |
|
| 41 |
|
- |
|
| 42 |
// si getNomCommun_v2 ou getNomCommun_v3 sont utilisés
|
- |
|
| 43 |
/*require_once('/home/raphael/eflore/framework/framework/Framework.php');
|
39 |
require_once('lib/FormateurGroupeColonne.php');
|
| 44 |
Framework::setCheminAppli("/home/raphael/eflore/projets/services/index.php");
|
- |
|
| 45 |
Framework::setInfoAppli(Config::get('info'));
|
- |
|
| 46 |
require_once('/home/raphael/eflore/projets/services/modules/0.1/Projets.php');*/
|
- |
|
| Line 47... |
Line 40... |
| 47 |
|
40 |
|
| Line 48... |
Line -... |
| 48 |
class ExportXLS extends Cel {
|
- |
|
| 49 |
|
41 |
class ExportXLS extends Cel {
|
| 50 |
private $cache = Array();
|
42 |
|
| 51 |
private $id_utilisateur = NULL;
|
43 |
private $id_utilisateur = NULL;
|
| Line 52... |
Line 44... |
| 52 |
private $parametres_defaut = array("range" => "*",
|
44 |
private $parametres_defaut = array("range" => "*",
|
| 53 |
"format" => "CSV");
|
45 |
"format" => "CSV");
|
| 54 |
|
46 |
|
| 55 |
private $filtres_autorises = array(
|
47 |
private $filtres_autorises = array(
|
| Line 148... |
Line 140... |
| 148 |
// XXX: malheureusement l'instance de JRest n'est pas accessible ici
|
140 |
// XXX: malheureusement l'instance de JRest n'est pas accessible ici
|
| 149 |
if(!$observations) {
|
141 |
if(!$observations) {
|
| 150 |
header('HTTP/1.0 204 No Content');
|
142 |
header('HTTP/1.0 204 No Content');
|
| 151 |
exit;
|
143 |
exit;
|
| 152 |
}
|
144 |
}
|
| 153 |
|
145 |
|
| 154 |
$colonnes = self::nomEnsembleVersListeColonnes($parametres_format['groupe_champs']);
|
146 |
$colonnes = FormateurGroupeColonne::nomEnsembleVersListeColonnes($parametres_format['groupe_champs']);
|
| 155 |
// $colonne_abbrev = array_keys($colonnes);
|
147 |
// $colonne_abbrev = array_keys($colonnes);
|
| 156 |
$objPHPExcel = $this->gerenerFeuilleImportFormatee($parametres_format);
|
148 |
$objPHPExcel = $this->gerenerFeuilleImportFormatee($parametres_format);
|
| 157 |
$feuille = $objPHPExcel->setActiveSheetIndex(0);
|
149 |
$feuille = $objPHPExcel->setActiveSheetIndex(0);
|
| 158 |
// attention formaterColonnesFeuille prend ses 2 premiers paramètres par référence
|
150 |
// attention formaterColonnesFeuille prend ses 2 premiers paramètres par référence
|
| 159 |
$this->formaterColonnesFeuille($feuille, $colonnes, $parametres_format);
|
151 |
$this->formaterColonnesFeuille($feuille, $colonnes, $parametres_format);
|
| Line 191... |
Line 183... |
| 191 |
if(isset($obs[$abbrev])) $valeur = $obs[$abbrev];
|
183 |
if(isset($obs[$abbrev])) $valeur = $obs[$abbrev];
|
| Line 192... |
Line 184... |
| 192 |
|
184 |
|
| 193 |
// pré-processeur de la champs
|
185 |
// pré-processeur de la champs
|
| 194 |
if(function_exists($colonne['fonction'])) {
|
186 |
if(function_exists($colonne['fonction'])) {
|
| - |
|
187 |
$valeur = $colonne['fonction']($valeur);
|
| - |
|
188 |
} elseif(method_exists('FormateurGroupeColonne', $colonne['fonction'])) {
|
| 195 |
$valeur = $colonne['fonction']($valeur);
|
189 |
$valeur = call_user_func(array('FormateurGroupeColonne', $colonne['fonction']), $valeur);
|
| 196 |
} elseif(method_exists(__CLASS__, $colonne['fonction'])) {
|
190 |
} elseif(method_exists(__CLASS__, $colonne['fonction'])) {
|
| 197 |
$valeur = call_user_func(array(__CLASS__, $colonne['fonction']), $valeur);
|
191 |
$valeur = call_user_func(array(__CLASS__, $colonne['fonction']), $valeur);
|
| 198 |
} elseif($colonne['fonction']) {
|
192 |
} elseif($colonne['fonction']) {
|
| 199 |
die("méthode {$colonne['fonction']} introuvable");
|
193 |
die("méthode {$colonne['fonction']} introuvable");
|
| Line 209... |
Line 203... |
| 209 |
// // cette section devrait être vide:
|
203 |
// // cette section devrait être vide:
|
| 210 |
// // cas particuliers ingérable avec l'architecture actuelle:
|
204 |
// // cas particuliers ingérable avec l'architecture actuelle:
|
| 211 |
if(false && $abbrev == 'date_observation' && $valeur == "0000-00-00") {
|
205 |
if(false && $abbrev == 'date_observation' && $valeur == "0000-00-00") {
|
| 212 |
/* blah */
|
206 |
/* blah */
|
| 213 |
}
|
207 |
}
|
| - |
|
208 |
if($abbrev == 'images') {
|
| - |
|
209 |
$valeur = FormateurGroupeColonne::getImages($obs, $this->id_utilisateur, $this);
|
| - |
|
210 |
}
|
| - |
|
211 |
|
| 214 |
// // fin de section "cas particuliers"
|
212 |
// // fin de section "cas particuliers"
|
| 215 |
$feuille->setCellValueByColumnAndRow($no_colonne, $no_ligne, $valeur);
|
213 |
$feuille->setCellValueByColumnAndRow($no_colonne, $no_ligne, $valeur);
|
| 216 |
$no_colonne++;
|
214 |
$no_colonne++;
|
| 217 |
}
|
215 |
}
|
| 218 |
}
|
216 |
}
|
| Line 279... |
Line 277... |
| 279 |
$outSets = array_unique($outSets);
|
277 |
$outSets = array_unique($outSets);
|
| 280 |
$outSets = array_filter($outSets, 'is_numeric');
|
278 |
$outSets = array_filter($outSets, 'is_numeric');
|
| 281 |
sort($outSets);
|
279 |
sort($outSets);
|
| 282 |
return $outSets;
|
280 |
return $outSets;
|
| 283 |
}
|
281 |
}
|
| 284 |
|
- |
|
| 285 |
/*
|
- |
|
| 286 |
* @param $fieldSets: un liste de noms de colonnes ou de sets de colonnes
|
- |
|
| 287 |
* séparés par des virgules
|
- |
|
| 288 |
* eg: "espece" ou "champs-etendus", ...
|
- |
|
| 289 |
*
|
- |
|
| 290 |
* @return: un tableau associatif déjà ordonné
|
- |
|
| 291 |
* clé: abbrev [machine-name] de la colonne (eg: "espece" ou "mot-clef")
|
- |
|
| 292 |
* valeur: des données relative à cette colonne, cf GenColInfo
|
- |
|
| 293 |
*
|
- |
|
| 294 |
* @TODO: fonction commune à la génération en CSV
|
- |
|
| 295 |
*
|
- |
|
| 296 |
*/
|
- |
|
| 297 |
static function nomEnsembleVersListeColonnes($groupe_de_champs = 'standard') {
|
- |
|
| 298 |
if(! $groupe_de_champs) $groupe_de_champs = 'standard';
|
- |
|
| 299 |
$groupe_de_champs = array_flip(explode(',', $groupe_de_champs));
|
- |
|
| 300 |
$colonnes = Array();
|
- |
|
| 301 |
|
- |
|
| 302 |
if(isset($groupe_de_champs['standard'])) {
|
- |
|
| 303 |
$colonnes += Array(
|
- |
|
| 304 |
'nom_sel' => self::GenColInfo('nom_sel', 'Espèce'),
|
- |
|
| 305 |
'nom_sel_nn' => self::GenColInfo('nom_sel_nn', 'Numéro nomenclatural', 0, NULL, NULL, FALSE),
|
- |
|
| 306 |
'nom_ret' => self::GenColInfo('nom_ret', 'Nom retenu', 0, NULL, NULL, FALSE),
|
- |
|
| 307 |
'nom_ret_nn' => self::GenColInfo('nom_ret_nn', 'Numéro nomenclatural nom retenu', 0, NULL, NULL, FALSE),
|
- |
|
| 308 |
'nt' => self::GenColInfo('nt', 'Numéro taxonomique', 0, NULL, NULL, FALSE),
|
- |
|
| 309 |
'famille' => self::GenColInfo('famille', 'Famille', 0, NULL, NULL, FALSE),
|
- |
|
| 310 |
'nom_referentiel' => self::GenColInfo('nom_referentiel', 'Referentiel taxonomique'),
|
- |
|
| 311 |
'zone_geo' => self::GenColInfo('zone_geo', 'Commune'),
|
- |
|
| 312 |
'ce_zone_geo' => self::GenColInfo('ce_zone_geo', 'Identifiant Commune', 0, 'convertirCodeZoneGeoVersDepartement'),
|
- |
|
| 313 |
'date_observation' => self::GenColInfo('date_observation', 'Date', 0, 'formaterDate'),
|
- |
|
| 314 |
'lieudit' => self::GenColInfo('lieudit', 'Lieu-dit'),
|
- |
|
| 315 |
'station' => self::GenColInfo('station', 'Station'),
|
- |
|
| 316 |
'milieu' => self::GenColInfo('milieu', 'Milieu'),
|
- |
|
| 317 |
'commentaire' => self::GenColInfo('commentaire', 'Notes'),
|
- |
|
| 318 |
'latitude' => self::GenColInfo('latitude', 'Latitude', 1),
|
- |
|
| 319 |
'longitude' => self::GenColInfo('longitude', 'Longitude', 1),
|
- |
|
| 320 |
'geodatum' => self::GenColInfo('geodatum', 'Référentiel Géographique', 1, NULL, NULL, FALSE),
|
- |
|
| 321 |
|
- |
|
| 322 |
// TODO: importable = FALSE car pas de merge de données importées
|
- |
|
| 323 |
'ordre' => self::GenColInfo('ordre', 'Ordre', 1, NULL, NULL, FALSE),
|
- |
|
| 324 |
'id_observation' => self::GenColInfo('id_observation', 'Identifiant', 1, NULL, NULL, FALSE),
|
- |
|
| 325 |
|
- |
|
| 326 |
'mots_cles_texte' => self::GenColInfo('mots_cles_texte', 'Mots Clés', 1),
|
- |
|
| 327 |
'commentaire' => self::GenColInfo('commentaire', 'Commentaires', 1),
|
- |
|
| 328 |
'date_creation' => self::GenColInfo('date_creation', 'Date Création', 1, NULL, NULL, FALSE),
|
- |
|
| 329 |
'date_modification' => self::GenColInfo('date_modification', 'Date Modification', 1, NULL, NULL, FALSE),
|
- |
|
| 330 |
|
- |
|
| 331 |
// rappel transmission = 1, signifie simplement "public"
|
- |
|
| 332 |
// des données importées peuvent être d'emblée "publiques"
|
- |
|
| 333 |
// "importable" = TRUE
|
- |
|
| 334 |
'transmission' => self::GenColInfo('transmission', 'Transmis', 1),
|
- |
|
| 335 |
'date_transmission' => self::GenColInfo('date_transmission', 'Date Transmission', 1, NULL, NULL, FALSE),
|
- |
|
| 336 |
'abondance' => self::GenColInfo('abondance', 'Abondance', 1),
|
- |
|
| 337 |
'certitude' => self::GenColInfo('certitude', 'Certitude', 1),
|
- |
|
| 338 |
'phenologie' => self::GenColInfo('phenologie', 'Phénologie', 1),
|
- |
|
| 339 |
|
- |
|
| 340 |
'nom_commun' => self::GenColInfo('nom_commun', 'Nom Commun', 1, NULL, 'getNomCommun', FALSE),
|
- |
|
| 341 |
//'nom-commun' => self::GenColInfo('nom-commun', 'Nom Commun', 1, NULL, 'getNomCommun_v2'),
|
- |
|
| 342 |
//'nom-commun' => self::GenColInfo('nom-commun', 'Nom Commun', 1, NULL, 'getNomCommun_v3'),
|
- |
|
| 343 |
|
- |
|
| 344 |
'images' => self::GenColInfo('images', 'Image(s)', 1, NULL, 'getImages', TRUE),
|
- |
|
| 345 |
);
|
- |
|
| 346 |
}
|
- |
|
| 347 |
|
- |
|
| 348 |
return $colonnes;
|
- |
|
| 349 |
}
|
- |
|
| 350 |
|
- |
|
| 351 |
/*
|
- |
|
| 352 |
* Wrapper générant un tableau associatif:
|
- |
|
| 353 |
|
- |
|
| 354 |
* @param $abbrev (obligatoire): nom court de colonne, largement utilisé lors de l'import.
|
- |
|
| 355 |
* En effet chaque ligne importée est accessible à l'aide du `define` de $abbrev en majuscule, préfixé de "C_"
|
- |
|
| 356 |
* Exemple: $ligne[C_LONGITUDE] pour "longitude".
|
- |
|
| 357 |
* cf: ImportXLS::detectionEntete()
|
- |
|
| 358 |
|
- |
|
| 359 |
* @param $nom (obligatoire): nom complet de colonne (utilisé pour la ligne d'en-tête)
|
- |
|
| 360 |
|
- |
|
| 361 |
* @param $is_extra:
|
- |
|
| 362 |
* Si 0, la colonne est une colonne standard
|
- |
|
| 363 |
* Si 1, la colonne est extra [le plus souvent générée automatiquement]
|
- |
|
| 364 |
* (auquel cas une bordure bleue entoure son nom dans la ligne d'entête)
|
- |
|
| 365 |
* Si 2, la colonne n'est pas traité à l'export, mais une définition peut lui être donnée
|
- |
|
| 366 |
* qui pourra être utilisée à l'import, exemple: "image"
|
- |
|
| 367 |
|
- |
|
| 368 |
* @param $fonction (optionnel): un nom d'un fonction de préprocessing
|
- |
|
| 369 |
* $fonction doit prendre comme seul argument la valeur d'origine et retourner la valeur transformée
|
- |
|
| 370 |
|
- |
|
| 371 |
* @param $fonction_data (optionnel): une *méthode* d'obtention de donnée
|
- |
|
| 372 |
* $fonction_data doit prendre comme premier argument le tableau des champs de l'enregistrement existant
|
- |
|
| 373 |
* $fonction_data doit retourner une valeur
|
- |
|
| 374 |
|
- |
|
| 375 |
* @param $importable (optionnel): défini si la colonne est traitée (ou absolument ignorée par PHPExcel) lors de
|
- |
|
| 376 |
* l'import.
|
- |
|
| 377 |
|
- |
|
| 378 |
*/
|
- |
|
| 379 |
static function GenColInfo($abbrev, $nom, $is_extra = 0, $fonction = NULL, $fonction_data = NULL, $importable = TRUE) {
|
- |
|
| 380 |
return Array('abbrev' => $abbrev,
|
- |
|
| 381 |
'nom' => $nom,
|
- |
|
| 382 |
'extra' => $is_extra ? 1 : 0,
|
- |
|
| 383 |
'fonction' => $fonction,
|
- |
|
| 384 |
'fonction_data' => $fonction_data,
|
- |
|
| 385 |
'importable' => $importable
|
- |
|
| 386 |
);
|
- |
|
| 387 |
}
|
- |
|
| 388 |
|
- |
|
| 389 |
protected function formaterDate($date_heure_mysql, $format = NULL) {
|
- |
|
| 390 |
if (!$date_heure_mysql || $date_heure_mysql == "0000-00-00 00:00:00") return "00/00/0000";
|
- |
|
| 391 |
$date_format = DateTime::createFromFormat("Y-m-d H:i:s", $date_heure_mysql);
|
- |
|
| 392 |
$timestamp = @$date_format->getTimestamp();
|
- |
|
| 393 |
if(!$timestamp) return "00/00/0000";
|
- |
|
| 394 |
// TODO: les widgets ne font malheureusement pas usage de l'heure dans le CEL
|
- |
|
| 395 |
// TODO: si modification, ne pas oublier de modifier le format d'import correspondant
|
- |
|
| 396 |
// dans ImportXLS (actuellement: "d/m/Y")
|
- |
|
| 397 |
$date_formatee = strftime('%d/%m/%Y', $timestamp);
|
- |
|
| 398 |
if(!$date_formatee) return "00/00/0000";
|
- |
|
| 399 |
return $date_formatee;
|
- |
|
| 400 |
}
|
- |
|
| 401 |
|
- |
|
| 402 |
|
- |
|
| 403 |
// TODO: mettre en static + param "id_utilisateur"
|
- |
|
| 404 |
function getImages($obs) {
|
- |
|
| 405 |
if(! $this->id_utilisateur) return NULL;
|
- |
|
| 406 |
|
- |
|
| 407 |
$rec = $this->requeter(
|
- |
|
| 408 |
sprintf("SELECT GROUP_CONCAT(nom_original SEPARATOR '%s') FROM cel_images i"
|
- |
|
| 409 |
. " LEFT JOIN cel_obs_images oi ON (i.id_image = oi.id_image)"
|
- |
|
| 410 |
. " LEFT JOIN cel_obs o ON (oi.id_observation = o.id_observation)"
|
- |
|
| 411 |
. " WHERE ce_utilisateur = %d",
|
- |
|
| 412 |
|
- |
|
| 413 |
SEPARATEUR_IMAGES,
|
- |
|
| 414 |
$this->id_utilisateur));
|
- |
|
| 415 |
return $rec ? array_pop($rec) : NULL;
|
- |
|
| 416 |
|
- |
|
| 417 |
}
|
- |
|
| 418 |
|
- |
|
| 419 |
|
- |
|
| 420 |
// TODO: référentiel ne devrait pas être généré au moment d'un Config::get,
|
- |
|
| 421 |
// comme dans Config::get('nomsVernaRechercheLimiteeTpl')
|
- |
|
| 422 |
// Par exemple, la variable pour "nva" ?
|
- |
|
| 423 |
function getNomCommun($obs) {
|
- |
|
| 424 |
$langue = 'fra';
|
- |
|
| 425 |
list($referentiel) = explode(':', strtolower($obs['nom_referentiel']));
|
- |
|
| 426 |
if($referentiel == 'bdtfx') $referentiel = 'nvjfl';
|
- |
|
| 427 |
else return '';
|
- |
|
| 428 |
|
- |
|
| 429 |
$cache_id = $referentiel . '-' . $obs['nt'] . '-' . $langue;
|
- |
|
| 430 |
if(isset($this->cache['getNomCommun'][$cache_id])) {
|
- |
|
| 431 |
//debug: error_log("require url_service_nom_attribution: OK ! (pour \"{$obs['nom_ret']}\")");
|
- |
|
| 432 |
return $this->cache['getNomCommun'][$cache_id];
|
- |
|
| 433 |
}
|
- |
|
| 434 |
// pas de cache:
|
- |
|
| 435 |
//debug: error_log("require url_service_nom_attribution pour \"{$obs['nom_ret']}\"");
|
- |
|
| 436 |
|
- |
|
| 437 |
// pour bdtfx:
|
- |
|
| 438 |
// /service:eflore:0.1/nvjfl/noms-vernaculaires/attributions?masque.nt=X&masque.lg=fra&retour.champs=num_statut
|
- |
|
| 439 |
// /projet/services/modules/0.1/nvjfl/NomsVernaculaires.php
|
- |
|
| 440 |
$url = str_replace(Array('{referentiel}', '{valeur}', '{langue}'),
|
- |
|
| 441 |
Array($referentiel, $obs['nt'], $langue),
|
- |
|
| 442 |
$this->config['eflore']['url_service_nom_attribution']) .
|
- |
|
| 443 |
"&retour.champs=num_statut";
|
- |
|
| 444 |
$noms = @json_decode(file_get_contents($url));
|
- |
|
| 445 |
if(! $noms) return '';
|
- |
|
| 446 |
$noms = array_filter((array)($noms->resultat), function($item) { return ($item->num_statut == 1); });
|
- |
|
| 447 |
$nom = array_pop($noms)->nom_vernaculaire;
|
- |
|
| 448 |
|
- |
|
| 449 |
// cache
|
- |
|
| 450 |
$this->cache['getNomCommun'][$cache_id] = $nom;
|
- |
|
| 451 |
return $nom;
|
- |
|
| 452 |
}
|
- |
|
| 453 |
|
- |
|
| 454 |
|
- |
|
| 455 |
/* Tente de bootstraper le framework au plus court et d'initialiser une instance de
|
- |
|
| 456 |
NomsVernaculaires pour obtenir le nom commun */
|
- |
|
| 457 |
function getNomCommun_v2($obs) {
|
- |
|
| 458 |
static $service;
|
- |
|
| 459 |
$service = new Projets();
|
- |
|
| 460 |
|
- |
|
| 461 |
$langue = 'fra';
|
- |
|
| 462 |
list($referentiel) = explode(':', strtolower($obs['nom_referentiel']));
|
- |
|
| 463 |
if($referentiel == 'bdtfx') $referentiel = 'nvjfl';
|
- |
|
| 464 |
else return '';
|
- |
|
| 465 |
|
- |
|
| 466 |
$cache_id = $referentiel . '-' . $obs['nt'] . '-' . $langue;
|
- |
|
| 467 |
if(isset($this->cache['getNomCommun'][$cache_id])) {
|
- |
|
| 468 |
error_log("require NomsVernaculaires.php: OK ! (pour \"{$obs['nom_ret']}\")");
|
- |
|
| 469 |
return $this->cache['getNomCommun'][$cache_id];
|
- |
|
| 470 |
}
|
- |
|
| 471 |
// pas de cache:
|
- |
|
| 472 |
error_log("require NomsVernaculaires.php pour \"{$obs['nom_ret']}\"");
|
- |
|
| 473 |
|
- |
|
| 474 |
$donnees = Array('masque.nt' => $obs['nt'],
|
- |
|
| 475 |
'masque.lg' => $langue,
|
- |
|
| 476 |
'retour.champs' => 'num_statut');
|
- |
|
| 477 |
$noms = $service->consulter(Array('nvjfl', 'noms-vernaculaires'), $donnees);
|
- |
|
| 478 |
|
- |
|
| 479 |
if(! $noms) return '';
|
- |
|
| 480 |
$noms = array_filter((array)($noms->resultat), function($item) { return ($item->num_statut == 1); });
|
- |
|
| 481 |
$nom = array_pop($noms)->nom_vernaculaire;
|
- |
|
| 482 |
|
- |
|
| 483 |
// cache
|
- |
|
| 484 |
$this->cache['getNomCommun'][$cache_id] = $nom;
|
- |
|
| 485 |
return $nom;
|
- |
|
| 486 |
}
|
- |
|
| 487 |
|
- |
|
| 488 |
|
- |
|
| 489 |
/* Effectue un bootstraping plus sage que ci-dessus, mais le gain d'efficacité
|
- |
|
| 490 |
n'est pas aussi retentissant qu'espéré */
|
- |
|
| 491 |
static $service;
|
- |
|
| 492 |
function getNomCommun_v3($obs) {
|
- |
|
| 493 |
if(! $this->service) $this->service = new Projets();
|
- |
|
| 494 |
|
- |
|
| 495 |
$langue = 'fra';
|
- |
|
| 496 |
list($referentiel) = explode(':', strtolower($obs['nom_referentiel']));
|
- |
|
| 497 |
if($referentiel == 'bdtfx') $referentiel = 'nvjfl';
|
- |
|
| 498 |
else return '';
|
- |
|
| 499 |
|
- |
|
| 500 |
$cache_id = $referentiel . '-' . $obs['nt'] . '-' . $langue;
|
- |
|
| 501 |
if(isset($this->cache['getNomCommun'][$cache_id])) {
|
- |
|
| 502 |
error_log("require NomsVernaculaires.php: OK ! (pour \"{$obs['nom_ret']}\")");
|
- |
|
| 503 |
return $this->cache['getNomCommun'][$cache_id];
|
- |
|
| 504 |
}
|
- |
|
| 505 |
// pas de cache:
|
- |
|
| 506 |
error_log("require NomsVernaculaires.php pour \"{$obs['nom_ret']}\"");
|
- |
|
| 507 |
|
- |
|
| 508 |
$donnees = Array('masque.nt' => $obs['nt'],
|
- |
|
| 509 |
'masque.lg' => $langue,
|
- |
|
| 510 |
'retour.champs' => 'conseil_emploi');
|
- |
|
| 511 |
$this->service->initialiserRessourcesEtParametres(Array('nvjfl', 'noms-vernaculaires', 'attributions'), $donnees);
|
- |
|
| 512 |
try {
|
- |
|
| 513 |
$noms = $this->service->traiterRessources();
|
- |
|
| 514 |
} catch(Exception $e) { return ''; }
|
- |
|
| 515 |
if(! $noms) return '';
|
- |
|
| 516 |
$noms = array_filter($noms['resultat'], function($item) { return ($item['num_statut'] == 1); });
|
- |
|
| 517 |
$premier_nom = array_pop($noms);
|
- |
|
| 518 |
$nom = $premier_nom['nom_vernaculaire'];
|
- |
|
| 519 |
|
- |
|
| 520 |
// cache
|
- |
|
| 521 |
$this->cache['getNomCommun'][$cache_id] = $nom;
|
- |
|
| 522 |
return $nom;
|
- |
|
| 523 |
}
|
- |
|
| 524 |
|
- |
|
| 525 |
}
|
282 |
}
|
| 526 |
|
283 |
|