| Line 120... |
Line 120... |
| 120 |
$groupe_de_champs = array_intersect_key(array_flip(self::$fieldGroups),
|
120 |
$groupe_de_champs = array_intersect_key(array_flip(self::$fieldGroups),
|
| 121 |
$groupe_de_champs);
|
121 |
$groupe_de_champs);
|
| 122 |
if(!$groupe_de_champs) return NULL;
|
122 |
if(!$groupe_de_champs) return NULL;
|
| Line 123... |
Line 123... |
| 123 |
|
123 |
|
| 124 |
$colonnes = Array();
|
124 |
$colonnes = Array();
|
| 125 |
|
125 |
|
| 126 |
if(isset($groupe_de_champs['standard'])) {
|
126 |
if(isset($groupe_de_champs['standard'])) {
|
| 127 |
$colonnes += Array(
|
127 |
$colonnes += Array(
|
| 128 |
'nom_sel' => self::GenColInfo(Array('abbrev' => 'nom_sel',
|
128 |
'nom_sel' => self::GenColInfo(Array('abbrev' => 'nom_sel',
|
| 129 |
'nom' => 'Espèce')),
|
129 |
'nom' => 'Espèce')),
|
| Line 175... |
Line 175... |
| 175 |
'nom' => 'Référentiel Géographique',
|
175 |
'nom' => 'Référentiel Géographique',
|
| 176 |
'extra' => 1,
|
176 |
'extra' => 1,
|
| 177 |
'importable' => FALSE)),
|
177 |
'importable' => FALSE)),
|
| 178 |
);
|
178 |
);
|
| 179 |
}
|
179 |
}
|
| 180 |
|
180 |
|
| 181 |
if(isset($groupe_de_champs['avance'])) {
|
181 |
if(isset($groupe_de_champs['avance'])) {
|
| 182 |
$colonnes += array(
|
182 |
$colonnes += array(
|
| 183 |
// TODO: importable = FALSE car pas de merge de données importées
|
183 |
// TODO: importable = FALSE car pas de merge de données importées
|
| 184 |
'ordre' => self::GenColInfo(Array('abbrev' => 'ordre',
|
184 |
'ordre' => self::GenColInfo(Array('abbrev' => 'ordre',
|
| 185 |
'nom' => 'Ordre',
|
185 |
'nom' => 'Ordre',
|
| Line 220... |
Line 220... |
| 220 |
'nom' => 'Certitude',
|
220 |
'nom' => 'Certitude',
|
| 221 |
'extra' => 1)),
|
221 |
'extra' => 1)),
|
| 222 |
'phenologie' => self::GenColInfo(Array('abbrev' => 'phenologie',
|
222 |
'phenologie' => self::GenColInfo(Array('abbrev' => 'phenologie',
|
| 223 |
'nom' => 'Phénologie',
|
223 |
'nom' => 'Phénologie',
|
| 224 |
'extra' => 1)),
|
224 |
'extra' => 1)),
|
| 225 |
|
225 |
|
| 226 |
// XXX: getImages() dépend du contexte de Cel, et doit être appelée comme cas particulier
|
226 |
// XXX: getImages() dépend du contexte de Cel, et doit être appelée comme cas particulier
|
| 227 |
// cf ExportXLS::traiterLigneObservation()
|
227 |
// cf ExportXLS::traiterLigneObservation()
|
| 228 |
'images' => self::GenColInfo(Array('abbrev' => 'images',
|
228 |
'images' => self::GenColInfo(Array('abbrev' => 'images',
|
| 229 |
'nom' => 'Image(s)',
|
229 |
'nom' => 'Image(s)',
|
| 230 |
'extra' => 1,
|
230 |
'extra' => 1,
|
| Line 300... |
Line 300... |
| 300 |
if(!$colonne['preload']) continue;
|
300 |
if(!$colonne['preload']) continue;
|
| 301 |
$result[$abbrev] = call_user_func($colonne['preload'], $cel, $ids);
|
301 |
$result[$abbrev] = call_user_func($colonne['preload'], $cel, $ids);
|
| 302 |
}
|
302 |
}
|
| 303 |
return $result;
|
303 |
return $result;
|
| 304 |
}
|
304 |
}
|
| 305 |
|
305 |
|
| 306 |
public static function getIntitulesColonnes($colonnes) {
|
306 |
public static function getIntitulesColonnes($colonnes) {
|
| 307 |
// array_filter pour supprimer les colonnes "dynamique" n'ayant pas défini $nom (cf GenColInfo())
|
307 |
// array_filter pour supprimer les colonnes "dynamique" n'ayant pas défini $nom (cf GenColInfo())
|
| 308 |
return array_filter(array_map(array('FormateurGroupeColonne', 'retournerNomItem'), $colonnes));
|
308 |
return array_filter(array_map(array('FormateurGroupeColonne', 'retournerNomItem'), $colonnes));
|
| 309 |
}
|
309 |
}
|
| 310 |
|
310 |
|
| 311 |
public static function retournerNomItem(&$item) {
|
311 |
public static function retournerNomItem(&$item) {
|
| 312 |
return $item['nom'];
|
312 |
return $item['nom'];
|
| 313 |
}
|
313 |
}
|
| Line 314... |
Line 314... |
| 314 |
|
314 |
|
| 315 |
public static function getLigneObservation(&$obs, &$colonnes, $cel = false) {
|
315 |
public static function getLigneObservation(&$obs, &$colonnes, $cel = false) {
|
| 316 |
$ligne_formatee = array();
|
316 |
$ligne_formatee = array();
|
| 317 |
foreach($colonnes as $abbrev => $colonne) {
|
317 |
foreach($colonnes as $abbrev => $colonne) {
|
| 318 |
$valeur = null;
|
318 |
$valeur = null;
|
| 319 |
if($colonne['extra'] == 2 || ! is_null($colonne['dyna'])) continue;
|
319 |
if($colonne['extra'] == 2 || ! is_null($colonne['dyna'])) continue;
|
| 320 |
|
320 |
|
| 321 |
// valeur directe depuis cel_obs ?
|
321 |
// valeur directe depuis cel_obs ?
|
| 322 |
if(isset($obs[$abbrev])) $valeur = $obs[$abbrev];
|
322 |
if(isset($obs[$abbrev])) $valeur = $obs[$abbrev];
|
| 323 |
|
323 |
|
| 324 |
// pré-processeur des champs
|
324 |
// pré-processeur des champs
|
| 325 |
if(function_exists($colonne['fonction'])) {
|
325 |
if(function_exists($colonne['fonction'])) {
|
| 326 |
$valeur = $colonne['fonction']($valeur);
|
326 |
$valeur = $colonne['fonction']($valeur);
|
| 327 |
} elseif(method_exists(__CLASS__, $colonne['fonction'])) {
|
327 |
} elseif(method_exists(__CLASS__, $colonne['fonction'])) {
|
| Line 334... |
Line 334... |
| 334 |
$valeur = $colonne['fonction_data']($obs);
|
334 |
$valeur = $colonne['fonction_data']($obs);
|
| 335 |
}
|
335 |
}
|
| 336 |
elseif(method_exists(__CLASS__, $colonne['fonction_data'])) {
|
336 |
elseif(method_exists(__CLASS__, $colonne['fonction_data'])) {
|
| 337 |
$valeur = call_user_func(array(__CLASS__, $colonne['fonction_data']), $obs);
|
337 |
$valeur = call_user_func(array(__CLASS__, $colonne['fonction_data']), $obs);
|
| 338 |
}
|
338 |
}
|
| 339 |
|
339 |
|
| 340 |
// // cette section devrait être vide:
|
340 |
// // cette section devrait être vide:
|
| 341 |
// // cas particuliers ingérable avec l'architecture actuelle:
|
341 |
// // cas particuliers ingérable avec l'architecture actuelle:
|
| 342 |
if(false && $abbrev == 'date_observation' && $valeur == "0000-00-00") {
|
342 |
if(false && $abbrev == 'date_observation' && $valeur == "0000-00-00") {
|
| 343 |
/* blah */
|
343 |
/* blah */
|
| 344 |
}
|
344 |
}
|
| Line 347... |
Line 347... |
| 347 |
$valeur = FormateurGroupeColonne::getImages($obs, $cel->id_utilisateur);
|
347 |
$valeur = FormateurGroupeColonne::getImages($obs, $cel->id_utilisateur);
|
| 348 |
}
|
348 |
}
|
| 349 |
if($abbrev == 'nom-commun') {
|
349 |
if($abbrev == 'nom-commun') {
|
| 350 |
$valeur = FormateurGroupeColonne::getNomCommun_v4($obs);
|
350 |
$valeur = FormateurGroupeColonne::getNomCommun_v4($obs);
|
| 351 |
}
|
351 |
}
|
| 352 |
|
352 |
|
| 353 |
if($valeur == null) {
|
353 |
if($valeur == null) {
|
| 354 |
$valeur = "";
|
354 |
$valeur = "";
|
| 355 |
}
|
355 |
}
|
| 356 |
|
356 |
|
| 357 |
// // fin de section "cas particuliers"
|
357 |
// // fin de section "cas particuliers"
|
| 358 |
$ligne_formatee[] = $valeur;
|
358 |
$ligne_formatee[] = $valeur;
|
| 359 |
}
|
359 |
}
|
| Line 360... |
Line 360... |
| 360 |
|
360 |
|
| Line 367... |
Line 367... |
| 367 |
array($obs, &$ligne_formatee));
|
367 |
array($obs, &$ligne_formatee));
|
| 368 |
}
|
368 |
}
|
| Line 369... |
Line 369... |
| 369 |
|
369 |
|
| 370 |
return $ligne_formatee;
|
370 |
return $ligne_formatee;
|
| 371 |
}
|
371 |
}
|
| 372 |
|
372 |
|
| 373 |
/*
|
373 |
/*
|
| 374 |
* Wrapper générant un tableau associatif:
|
374 |
* Wrapper générant un tableau associatif:
|
| 375 |
* Ne pas changer les valeurs par défaut du prototype sans réflexion sur l'implication pour nomEnsembleVersListeColonnes()
|
375 |
* Ne pas changer les valeurs par défaut du prototype sans réflexion sur l'implication pour nomEnsembleVersListeColonnes()
|
| 376 |
|
376 |
|
| 377 |
* @param $abbrev (obligatoire): nom court de colonne, largement utilisé lors de l'import.
|
377 |
* @param $abbrev (obligatoire): nom court de colonne, largement utilisé lors de l'import.
|
| 378 |
* En effet chaque ligne importée est accessible à l'aide du `define` de $abbrev en majuscule, préfixé de "C_"
|
378 |
* En effet chaque ligne importée est accessible à l'aide du `define` de $abbrev en majuscule, préfixé de "C_"
|
| 379 |
* Exemple: $ligne[C_LONGITUDE] pour "longitude".
|
379 |
* Exemple: $ligne[C_LONGITUDE] pour "longitude".
|
| 380 |
* cf: ImportXLS::detectionEntete()
|
380 |
* cf: ImportXLS::detectionEntete()
|
| 381 |
|
381 |
|
| 382 |
* @param $nom (obligatoire): nom complet de colonne (utilisé pour la ligne d'en-tête)
|
382 |
* @param $nom (obligatoire): nom complet de colonne (utilisé pour la ligne d'en-tête)
|
| 383 |
* Les définition de champs dynamique (correspondant à de multiples colonnes) doivent laisser cette valeur
|
383 |
* Les définition de champs dynamique (correspondant à de multiples colonnes) doivent laisser cette valeur
|
| 384 |
* vide afin de ne pas créer une colonne supplémentaire erronée.
|
384 |
* vide afin de ne pas créer une colonne supplémentaire erronée.
|
| 385 |
|
385 |
|
| 386 |
* @param $is_extra:
|
386 |
* @param $is_extra:
|
| 387 |
* Si 0, la colonne est une colonne standard
|
387 |
* Si 0, la colonne est une colonne standard
|
| 388 |
* Si 1, la colonne est extra [le plus souvent générée automatiquement]
|
388 |
* Si 1, la colonne est extra [le plus souvent générée automatiquement]
|
| 389 |
* (auquel cas une bordure bleue entoure son nom dans la ligne d'entête)
|
389 |
* (auquel cas une bordure bleue entoure son nom dans la ligne d'entête)
|
| 390 |
* Si 2, la colonne n'est pas traité à l'export, mais une définition peut lui être donnée
|
390 |
* Si 2, la colonne n'est pas traité à l'export, mais une définition peut lui être donnée
|
| 391 |
* qui pourra être utilisée à l'import, exemple: "image"
|
391 |
* qui pourra être utilisée à l'import, exemple: "image"
|
| 392 |
|
392 |
|
| 393 |
* @param $fonction (optionnel): un nom d'un fonction de préprocessing
|
393 |
* @param $fonction (optionnel): un nom d'un fonction de préprocessing
|
| 394 |
* $fonction doit prendre comme seul argument la valeur d'origine et retourner la valeur transformée
|
394 |
* $fonction doit prendre comme seul argument la valeur d'origine et retourner la valeur transformée
|
| 395 |
|
395 |
|
| 396 |
* @param $fonction_data (optionnel): une *méthode* d'obtention de donnée
|
396 |
* @param $fonction_data (optionnel): une *méthode* d'obtention de donnée
|
| 397 |
* $fonction_data doit prendre comme premier argument le tableau des champs de l'enregistrement existant
|
397 |
* $fonction_data doit prendre comme premier argument le tableau des champs de l'enregistrement existant
|
| 398 |
* $fonction_data doit retourner une valeur
|
398 |
* $fonction_data doit retourner une valeur
|
| 399 |
|
399 |
|
| 400 |
* @param $importable (optionnel): défini si la colonne est traitée (ou absolument ignorée par PHPExcel) lors de
|
400 |
* @param $importable (optionnel): défini si la colonne est traitée (ou absolument ignorée par PHPExcel) lors de
|
| Line 401... |
Line 401... |
| 401 |
* l'import.
|
401 |
* l'import.
|
| 402 |
|
402 |
|
| Line 418... |
Line 418... |
| 418 |
'preload' => NULL,
|
418 |
'preload' => NULL,
|
| 419 |
'dyna' => NULL);
|
419 |
'dyna' => NULL);
|
| 420 |
$ret = array_intersect_key($args, $default);
|
420 |
$ret = array_intersect_key($args, $default);
|
| 421 |
return array_merge($default, $ret);
|
421 |
return array_merge($default, $ret);
|
| 422 |
}
|
422 |
}
|
| 423 |
|
423 |
|
| 424 |
static function formaterDate($date_heure_mysql) {
|
424 |
static function formaterDate($date_heure_mysql) {
|
| 425 |
//return "";
|
425 |
//return "";
|
| 426 |
if (!$date_heure_mysql || $date_heure_mysql == "0000-00-00 00:00:00") return NULL;
|
426 |
if (!$date_heure_mysql || $date_heure_mysql == "0000-00-00 00:00:00") return NULL;
|
| 427 |
// malheureusement pas disponible en php < 5.3
|
427 |
// malheureusement pas disponible en php < 5.3
|
| 428 |
//$date_format = DateTime::createFromFormat("Y-m-d H:i:s", $date_heure_mysql);
|
428 |
//$date_format = DateTime::createFromFormat("Y-m-d H:i:s", $date_heure_mysql);
|
| Line 478... |
Line 478... |
| 478 |
SEPARATEUR_IMAGES,
|
478 |
SEPARATEUR_IMAGES,
|
| 479 |
$id_utilisateur,
|
479 |
$id_utilisateur,
|
| 480 |
$obs['id_observation']));
|
480 |
$obs['id_observation']));
|
| 481 |
return $rec ? $rec[0]['i'] : NULL;
|
481 |
return $rec ? $rec[0]['i'] : NULL;
|
| 482 |
}
|
482 |
}
|
| 483 |
|
483 |
|
| 484 |
public static function convertirCodeZoneGeoVersDepartement($code_zone_geo) {
|
484 |
public static function convertirCodeZoneGeoVersDepartement($code_zone_geo) {
|
| 485 |
$code_departement = '';
|
485 |
$code_departement = '';
|
| 486 |
if(self::estUnCodeInseeDepartement($code_zone_geo)) {
|
486 |
if(self::estUnCodeInseeDepartement($code_zone_geo)) {
|
| 487 |
$code_departement = substr(ltrim($code_zone_geo,'INSEE-C:'),0,2);
|
487 |
$code_departement = substr(ltrim($code_zone_geo,'INSEE-C:'),0,2);
|
| 488 |
}
|
488 |
}
|
| 489 |
|
489 |
|
| 490 |
return $code_departement;
|
490 |
return $code_departement;
|
| 491 |
}
|
491 |
}
|
| Line 492... |
Line 492... |
| 492 |
|
492 |
|
| 493 |
public static function trim0($lonlat) {
|
493 |
public static function trim0($lonlat) {
|
| 494 |
return trim(trim($lonlat, "0"), ".");
|
494 |
return trim(trim($lonlat, "0"), ".");
|
| Line 495... |
Line 495... |
| 495 |
}
|
495 |
}
|
| 496 |
|
496 |
|
| 497 |
public static function boolOuiNon($transmission) {
|
497 |
public static function boolOuiNon($transmission) {
|
| 498 |
return $transmission ? 'oui' : '';
|
498 |
return $transmission ? 'oui' : '';
|
| 499 |
}
|
499 |
}
|
| 500 |
|
500 |
|
| 501 |
public static function estUnCodeInseeDepartement($code_a_tester) {
|
501 |
public static function estUnCodeInseeDepartement($code_a_tester) {
|
| 502 |
return preg_match('/^INSEE-C:[0-9]{5}/',$code_a_tester);
|
502 |
return preg_match('/^INSEE-C:[0-9]{5}/',$code_a_tester);
|
| 503 |
}
|
503 |
}
|
| 504 |
|
504 |
|
| 505 |
|
505 |
|
| 506 |
// TODO: référentiel ne devrait pas être généré au moment d'un Config::get,
|
506 |
// TODO: référentiel ne devrait pas être généré au moment d'un Config::get,
|
| 507 |
// comme dans Config::get('nomsVernaRechercheLimiteeTpl')
|
507 |
// comme dans Config::get('nomsVernaRechercheLimiteeTpl')
|
| 508 |
// Par exemple, la variable pour "nva" ?
|
508 |
// Par exemple, la variable pour "nva" ?
|
| 509 |
function getNomCommun($obs) {
|
509 |
function getNomCommun($obs) {
|
| 510 |
$langue = 'fra';
|
510 |
$langue = 'fra';
|
| 511 |
list($referentiel) = explode(':', strtolower($obs['nom_referentiel']));
|
511 |
list($referentiel) = explode(':', strtolower($obs['nom_referentiel']));
|
| 512 |
if($referentiel == 'bdtfx') $referentiel = 'nvjfl';
|
512 |
if($referentiel == 'bdtfx') $referentiel = 'nvjfl';
|
| 513 |
else return '';
|
513 |
else return '';
|
| 514 |
|
514 |
|
| 515 |
$cache_id = $referentiel . '-' . $obs['nt'] . '-' . $langue;
|
515 |
$cache_id = $referentiel . '-' . $obs['nt'] . '-' . $langue;
|
| 516 |
if(isset(self::$cache['getNomCommun'][$cache_id])) {
|
516 |
if(isset(self::$cache['getNomCommun'][$cache_id])) {
|
| 517 |
//debug: error_log("require url_service_nom_attribution: OK ! (pour \"{$obs['nom_ret']}\")");
|
517 |
//debug: error_log("require url_service_nom_attribution: OK ! (pour \"{$obs['nom_ret']}\")");
|
| 518 |
return self::$cache['getNomCommun'][$cache_id];
|
518 |
return self::$cache['getNomCommun'][$cache_id];
|
| 519 |
}
|
519 |
}
|
| 520 |
// pas de cache:
|
520 |
// pas de cache:
|
| 521 |
//debug: error_log("require url_service_nom_attribution pour \"{$obs['nom_ret']}\"");
|
521 |
//debug: error_log("require url_service_nom_attribution pour \"{$obs['nom_ret']}\"");
|
| 522 |
|
522 |
|
| 523 |
// pour bdtfx:
|
523 |
// pour bdtfx:
|
| 524 |
// /service:eflore:0.1/nvjfl/noms-vernaculaires/attributions?masque.nt=X&masque.lg=fra&retour.champs=num_statut
|
524 |
// /service:eflore:0.1/nvjfl/noms-vernaculaires/attributions?masque.nt=X&masque.lg=fra&retour.champs=num_statut
|
| 525 |
// /projet/services/modules/0.1/nvjfl/NomsVernaculaires.php
|
525 |
// /projet/services/modules/0.1/nvjfl/NomsVernaculaires.php
|
| Line 529... |
Line 529... |
| 529 |
"&retour.champs=num_statut";
|
529 |
"&retour.champs=num_statut";
|
| 530 |
$noms = @json_decode(file_get_contents($url));
|
530 |
$noms = @json_decode(file_get_contents($url));
|
| 531 |
if(! $noms) return '';
|
531 |
if(! $noms) return '';
|
| 532 |
$noms = array_filter((array)($noms->resultat), array($this, retournerNumStatutUn)); // XXX: php 5.3
|
532 |
$noms = array_filter((array)($noms->resultat), array($this, retournerNumStatutUn)); // XXX: php 5.3
|
| 533 |
$nom = array_pop($noms)->nom_vernaculaire;
|
533 |
$nom = array_pop($noms)->nom_vernaculaire;
|
| 534 |
|
534 |
|
| 535 |
// cache
|
535 |
// cache
|
| 536 |
self::$cache['getNomCommun'][$cache_id] = $nom;
|
536 |
self::$cache['getNomCommun'][$cache_id] = $nom;
|
| 537 |
return $nom;
|
537 |
return $nom;
|
| 538 |
}
|
538 |
}
|
| 539 |
|
539 |
|
| 540 |
private function retournerNumStatutUn(&$item) {
|
540 |
private function retournerNumStatutUn(&$item) {
|
| 541 |
return ($item->num_statut == 1);
|
541 |
return ($item->num_statut == 1);
|
| 542 |
}
|
542 |
}
|
| Line 543... |
Line 543... |
| 543 |
|
543 |
|
| 544 |
private function retournerNumStatutUnArr(&$item) {
|
544 |
private function retournerNumStatutUnArr(&$item) {
|
| 545 |
return ($item['num_statut'] == 1);
|
545 |
return ($item['num_statut'] == 1);
|
| 546 |
}
|
546 |
}
|
| 547 |
|
547 |
|
| 548 |
// si getNomCommun_v2 ou getNomCommun_v3 sont utilisés
|
548 |
// si getNomCommun_v2 ou getNomCommun_v3 sont utilisés
|
| 549 |
/* require_once('/home/raphael/eflore/framework/framework/Framework.php');
|
549 |
/* require_once('/home/raphael/eflore/framework/framework/Framework.php');
|
| 550 |
Framework::setCheminAppli("/home/raphael/eflore/projets/services/index.php");
|
550 |
Framework::setCheminAppli("/home/raphael/eflore/projets/services/index.php");
|
| 551 |
Framework::setInfoAppli(Config::get('info'));
|
551 |
Framework::setInfoAppli(Config::get('info'));
|
| 552 |
require_once('/home/raphael/eflore/projets/services/modules/0.1/Projets.php');*/
|
552 |
require_once('/home/raphael/eflore/projets/services/modules/0.1/Projets.php');*/
|
| 553 |
|
553 |
|
| 554 |
/* Tente de bootstraper le framework au plus court et d'initialiser une instance de
|
554 |
/* Tente de bootstraper le framework au plus court et d'initialiser une instance de
|
| 555 |
NomsVernaculaires pour obtenir le nom commun */
|
555 |
NomsVernaculaires pour obtenir le nom commun */
|
| 556 |
function getNomCommun_v2($obs) {
|
556 |
function getNomCommun_v2($obs) {
|
| 557 |
static $service;
|
557 |
static $service;
|
| 558 |
$service = new Projets();
|
558 |
$service = new Projets();
|
| 559 |
|
559 |
|
| 560 |
$langue = 'fra';
|
560 |
$langue = 'fra';
|
| 561 |
list($referentiel) = explode(':', strtolower($obs['nom_referentiel']));
|
561 |
list($referentiel) = explode(':', strtolower($obs['nom_referentiel']));
|
| 562 |
if($referentiel == 'bdtfx') $referentiel = 'nvjfl';
|
562 |
if($referentiel == 'bdtfx') $referentiel = 'nvjfl';
|
| 563 |
else return '';
|
563 |
else return '';
|
| 564 |
|
564 |
|
| 565 |
$cache_id = $referentiel . '-' . $obs['nt'] . '-' . $langue;
|
565 |
$cache_id = $referentiel . '-' . $obs['nt'] . '-' . $langue;
|
| 566 |
if(isset(self::$cache['getNomCommun'][$cache_id])) {
|
566 |
if(isset(self::$cache['getNomCommun'][$cache_id])) {
|
| 567 |
error_log("require NomsVernaculaires.php: OK ! (pour \"{$obs['nom_ret']}\")");
|
567 |
error_log("require NomsVernaculaires.php: OK ! (pour \"{$obs['nom_ret']}\")");
|
| 568 |
return self::$cache['getNomCommun'][$cache_id];
|
568 |
return self::$cache['getNomCommun'][$cache_id];
|
| 569 |
}
|
569 |
}
|
| 570 |
// pas de cache:
|
570 |
// pas de cache:
|
| 571 |
error_log("require NomsVernaculaires.php pour \"{$obs['nom_ret']}\"");
|
571 |
error_log("require NomsVernaculaires.php pour \"{$obs['nom_ret']}\"");
|
| 572 |
|
572 |
|
| 573 |
$donnees = Array('masque.nt' => $obs['nt'],
|
573 |
$donnees = Array('masque.nt' => $obs['nt'],
|
| 574 |
'masque.lg' => $langue,
|
574 |
'masque.lg' => $langue,
|
| 575 |
'retour.champs' => 'num_statut');
|
575 |
'retour.champs' => 'num_statut');
|
| 576 |
$noms = $service->consulter(Array('nvjfl', 'noms-vernaculaires'), $donnees);
|
576 |
$noms = $service->consulter(Array('nvjfl', 'noms-vernaculaires'), $donnees);
|
| 577 |
|
577 |
|
| 578 |
if(! $noms) return '';
|
578 |
if(! $noms) return '';
|
| 579 |
$noms = array_filter((array)($noms->resultat), array($this, retournerNumStatutUn)); // XXX: php 5.3
|
579 |
$noms = array_filter((array)($noms->resultat), array($this, retournerNumStatutUn)); // XXX: php 5.3
|
| 580 |
$nom = array_pop($noms)->nom_vernaculaire;
|
580 |
$nom = array_pop($noms)->nom_vernaculaire;
|
| 581 |
|
581 |
|
| 582 |
// cache
|
582 |
// cache
|
| 583 |
self::$cache['getNomCommun'][$cache_id] = $nom;
|
583 |
self::$cache['getNomCommun'][$cache_id] = $nom;
|
| 584 |
return $nom;
|
584 |
return $nom;
|
| 585 |
}
|
585 |
}
|
| 586 |
|
586 |
|
| 587 |
|
587 |
|
| 588 |
/* Effectue un bootstraping plus sage que ci-dessus, mais le gain d'efficacité
|
588 |
/* Effectue un bootstraping plus sage que ci-dessus, mais le gain d'efficacité
|
| 589 |
n'est pas aussi retentissant qu'espéré */
|
589 |
n'est pas aussi retentissant qu'espéré */
|
| 590 |
static $service;
|
590 |
static $service;
|
| 591 |
function getNomCommun_v3($obs) {
|
591 |
function getNomCommun_v3($obs) {
|
| 592 |
if(! $this->service) $this->service = new Projets();
|
592 |
if(! $this->service) $this->service = new Projets();
|
| 593 |
|
593 |
|
| 594 |
$langue = 'fra';
|
594 |
$langue = 'fra';
|
| 595 |
list($referentiel) = explode(':', strtolower($obs['nom_referentiel']));
|
595 |
list($referentiel) = explode(':', strtolower($obs['nom_referentiel']));
|
| 596 |
if($referentiel == 'bdtfx') $referentiel = 'nvjfl';
|
596 |
if($referentiel == 'bdtfx') $referentiel = 'nvjfl';
|
| 597 |
else return '';
|
597 |
else return '';
|
| 598 |
|
598 |
|
| 599 |
$cache_id = $referentiel . '-' . $obs['nt'] . '-' . $langue;
|
599 |
$cache_id = $referentiel . '-' . $obs['nt'] . '-' . $langue;
|
| 600 |
if(isset(self::$cache['getNomCommun'][$cache_id])) {
|
600 |
if(isset(self::$cache['getNomCommun'][$cache_id])) {
|
| 601 |
error_log("require NomsVernaculaires.php: OK ! (pour \"{$obs['nom_ret']}\")");
|
601 |
error_log("require NomsVernaculaires.php: OK ! (pour \"{$obs['nom_ret']}\")");
|
| 602 |
return self::$cache['getNomCommun'][$cache_id];
|
602 |
return self::$cache['getNomCommun'][$cache_id];
|
| 603 |
}
|
603 |
}
|
| 604 |
// pas de cache:
|
604 |
// pas de cache:
|
| 605 |
error_log("require NomsVernaculaires.php pour \"{$obs['nom_ret']}\"");
|
605 |
error_log("require NomsVernaculaires.php pour \"{$obs['nom_ret']}\"");
|
| 606 |
|
606 |
|
| 607 |
$donnees = Array('masque.nt' => $obs['nt'],
|
607 |
$donnees = Array('masque.nt' => $obs['nt'],
|
| 608 |
'masque.lg' => $langue,
|
608 |
'masque.lg' => $langue,
|
| 609 |
'retour.champs' => 'conseil_emploi');
|
609 |
'retour.champs' => 'conseil_emploi');
|
| 610 |
$this->service->initialiserRessourcesEtParametres(Array('nvjfl', 'noms-vernaculaires', 'attributions'), $donnees);
|
610 |
$this->service->initialiserRessourcesEtParametres(Array('nvjfl', 'noms-vernaculaires', 'attributions'), $donnees);
|
| 611 |
try {
|
611 |
try {
|
| 612 |
$noms = $this->service->traiterRessources();
|
612 |
$noms = $this->service->traiterRessources();
|
| 613 |
} catch(Exception $e) {
|
613 |
} catch(Exception $e) {
|
| 614 |
return '';
|
614 |
return '';
|
| 615 |
}
|
615 |
}
|
| 616 |
if(! $noms) return '';
|
616 |
if(! $noms) return '';
|
| 617 |
$noms = array_filter($noms['resultat'], array($this, retournerNumStatutUnArr)); // XXX: php 5.3
|
617 |
$noms = array_filter($noms['resultat'], array($this, retournerNumStatutUnArr)); // XXX: php 5.3
|
| 618 |
$premier_nom = array_pop($noms);
|
618 |
$premier_nom = array_pop($noms);
|
| 619 |
$nom = $premier_nom['nom_vernaculaire'];
|
619 |
$nom = $premier_nom['nom_vernaculaire'];
|
| 620 |
|
620 |
|
| 621 |
// cache
|
621 |
// cache
|
| 622 |
self::$cache['getNomCommun'][$cache_id] = $nom;
|
622 |
self::$cache['getNomCommun'][$cache_id] = $nom;
|
| 623 |
return $nom;
|
623 |
return $nom;
|
| Line 640... |
Line 640... |
| 640 |
}
|
640 |
}
|
| 641 |
return NULL;
|
641 |
return NULL;
|
| 642 |
}
|
642 |
}
|
| Line 643... |
Line 643... |
| 643 |
|
643 |
|
| 644 |
static function referenceTableExiste() {
|
644 |
static function referenceTableExiste() {
|
| 645 |
if(!self::$is_table) {
|
645 |
if (!self::$is_table) {
|
| 646 |
// une seule fois
|
646 |
// une seule fois
|
| 647 |
if(! Cel::db()->executerRequete("SHOW TABLES LIKE 'cel_references'", Cel::SQL_RETOUR_LIGNE)) return FALSE;
|
647 |
if (! Cel::db()->requeterLigne("SHOW TABLES LIKE 'cel_references'")) return FALSE;
|
| 648 |
self::$is_table = TRUE;
|
648 |
self::$is_table = TRUE;
|
| 649 |
}
|
649 |
}
|
| 650 |
return TRUE;
|
650 |
return TRUE;
|
| 651 |
}
|
651 |
}
|
| 652 |
|
652 |
|
| 653 |
static function getNomCommun_v4($obs) {
|
653 |
static function getNomCommun_v4($obs) {
|
| 654 |
if(! $obs['nt']) return NULL;
|
654 |
if(! $obs['nt']) return NULL;
|
| Line 655... |
Line 655... |
| 655 |
if(! self::referenceTableExiste()) return NULL;
|
655 |
if(! self::referenceTableExiste()) return NULL;
|
| Line 664... |
Line 664... |
| 664 |
// XXX: problème de valeurs NULL ?
|
664 |
// XXX: problème de valeurs NULL ?
|
| 665 |
if(array_key_exists($cache_id, self::$cache['getNomCommun'])) return self::$cache['getNomCommun'][$cache_id];
|
665 |
if(array_key_exists($cache_id, self::$cache['getNomCommun'])) return self::$cache['getNomCommun'][$cache_id];
|
| 666 |
}
|
666 |
}
|
| Line 667... |
Line 667... |
| 667 |
|
667 |
|
| 668 |
// pas de cache:
|
668 |
// pas de cache:
|
| 669 |
$nom = Cel::db()->executerRequete(sprintf("SELECT nom_commun FROM cel_references " .
|
669 |
$nom = Cel::db()->requeterLigne(sprintf("SELECT nom_commun FROM cel_references " .
|
| 670 |
"WHERE referentiel = '%s' AND num_taxon = %d LIMIT 1",
|
670 |
"WHERE referentiel = '%s' AND num_taxon = %d LIMIT 1",
|
| 671 |
$referentiel,
|
671 |
$referentiel,
|
| 672 |
$obs['nt']),
|
- |
|
| Line 673... |
Line 672... |
| 673 |
Cel::SQL_RETOUR_LIGNE);
|
672 |
$obs['nt']));
|
| 674 |
|
673 |
|
| Line 675... |
Line 674... |
| 675 |
if(! $nom) return NULL;
|
674 |
if(! $nom) return NULL;
|
| Line 703... |
Line 702... |
| 703 |
self::$cache['getBaseflor'][$v['referentiel'] . '-' . $v['num_nom_retenu']] = $data;
|
702 |
self::$cache['getBaseflor'][$v['referentiel'] . '-' . $v['num_nom_retenu']] = $data;
|
| 704 |
}
|
703 |
}
|
| Line 705... |
Line 704... |
| 705 |
|
704 |
|
| 706 |
return NULL;
|
705 |
return NULL;
|
| 707 |
}
|
706 |
}
|
| Line 708... |
Line 707... |
| 708 |
|
707 |
|
| 709 |
|
708 |
|
| 710 |
static function baseflor_ligne($obs, &$ligne) {
|
709 |
static function baseflor_ligne($obs, &$ligne) {
|
| 711 |
if(! $obs['nom_ret_nn']) {
|
710 |
if(! $obs['nom_ret_nn']) {
|
| Line 727... |
Line 726... |
| 727 |
$ligne = array_merge($ligne, self::$cache['getBaseflor'][$cache_id]);
|
726 |
$ligne = array_merge($ligne, self::$cache['getBaseflor'][$cache_id]);
|
| 728 |
return;
|
727 |
return;
|
| 729 |
}
|
728 |
}
|
| Line 730... |
Line 729... |
| 730 |
|
729 |
|
| 731 |
// pas de cache:
|
730 |
// pas de cache:
|
| 732 |
$data = Cel::db()->executerRequete(sprintf("SELECT %s FROM cel_references " .
|
731 |
$data = Cel::db()->requeterLigne(sprintf("SELECT %s FROM cel_references " .
|
| 733 |
"WHERE referentiel = '%s' AND num_nom_retenu = %d LIMIT 1",
|
732 |
"WHERE referentiel = '%s' AND num_nom_retenu = %d LIMIT 1",
|
| 734 |
implode(', ', array_keys(self::$baseflor_col)),
|
733 |
implode(', ', array_keys(self::$baseflor_col)),
|
| 735 |
$referentiel,
|
734 |
$referentiel,
|
| 736 |
$obs['nom_ret_nn']),
|
- |
|
| Line 737... |
Line 735... |
| 737 |
Cel::SQL_RETOUR_LIGNE);
|
735 |
$obs['nom_ret_nn']));
|
| 738 |
|
736 |
|
| 739 |
if(! $data) {
|
737 |
if(! $data) {
|
| 740 |
$ligne = array_merge($ligne, array_fill(0, count(self::$baseflor_col), NULL));
|
738 |
$ligne = array_merge($ligne, array_fill(0, count(self::$baseflor_col), NULL));
|
| Line 806... |
Line 804... |
| 806 |
return;
|
804 |
return;
|
| 807 |
}
|
805 |
}
|
| Line 808... |
Line 806... |
| 808 |
|
806 |
|
| 809 |
foreach(self::$cache['champsEtendus']['header'] as $colonne) {
|
807 |
foreach(self::$cache['champsEtendus']['header'] as $colonne) {
|
| 810 |
if(!isset($ligne_etendue_aplatie[$colonne])) {
|
808 |
if(!isset($ligne_etendue_aplatie[$colonne])) {
|
| 811 |
$ligne_etendue_fmt[$colonne] = '';
|
809 |
$ligne_etendue_fmt[$colonne] = '';
|
| 812 |
} else {
|
810 |
} else {
|
| 813 |
$ligne_etendue_fmt[$colonne] = $ligne_etendue_aplatie[$colonne];
|
811 |
$ligne_etendue_fmt[$colonne] = $ligne_etendue_aplatie[$colonne];
|
| 814 |
}
|
812 |
}
|