Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 1684 → Rev 1685

/trunk/jrest/lib/FormateurGroupeColonne.php
77,13 → 77,15
// XXX: getImages() dépend du contexte de Cel, et doit être appelée comme cas particulier
// cf ExportXLS::traiterLigneObservation()
'images' => self::GenColInfo('images', 'Image(s)', 1, NULL, 'getImages', TRUE),
 
/* 'nom_commun' => self::GenColInfo('nom_commun', 'Nom Commun', 1, NULL, 'getNomCommun', FALSE),
'nom-commun' => self::GenColInfo('nom-commun', 'Nom Commun', 1, NULL, 'getNomCommun_v2'),
'nom-commun' => self::GenColInfo('nom-commun', 'Nom Commun', 1, NULL, 'getNomCommun_v3'), */
'nom-commun' => self::GenColInfo('nom-commun', 'Nom Commun', 1, NULL, 'getNomCommun_v4'),
 
);
}
 
/* 'nom_commun' => self::GenColInfo('nom_commun', 'Nom Commun', 1, NULL, 'getNomCommun', FALSE),
'nom-commun' => self::GenColInfo('nom-commun', 'Nom Commun', 1, NULL, 'getNomCommun_v2'),
'nom-commun' => self::GenColInfo('nom-commun', 'Nom Commun', 1, NULL, 'getNomCommun_v3'), */
 
return $colonnes;
}
126,9 → 128,13
if(false && $abbrev == 'date_observation' && $valeur == "0000-00-00") {
/* blah */
}
// ici à cause du passage de $cel ($this), TODO: DB en Singleton !
if($abbrev == 'images') {
$valeur = FormateurGroupeColonne::getImages($obs, $cel->id_utilisateur, $cel);
}
if($abbrev == 'nom-commun') {
$valeur = FormateurGroupeColonne::getNomCommun_v4($obs, $cel);
}
if($valeur == null) {
$valeur = "";
341,5 → 347,35
self::$cache['getNomCommun'][$cache_id] = $nom;
return $nom;
}
 
static function getNomCommun_v4($obs, $cel) {
if(! $obs['nt']) return NULL;
if(! $cel->executerRequete("SHOW TABLES LIKE 'cel_references'", Cel::SQL_RETOUR_LIGNE)) return NULL;
$langue = 'fra';
list($referentiel) = explode(':', strtolower($obs['nom_referentiel']));
$cache_id = $referentiel . '-' . $obs['nt'] . '-' . $langue;
 
if(isset(self::$cache['getNomCommun'][$cache_id])) return self::$cache['getNomCommun'][$cache_id];
 
// pas de cache:
$donnees = Array('masque.nt' => $obs['nt'],
'masque.lg' => $langue,
'retour.champs' => 'conseil_emploi');
 
$nom = $cel->executerRequete(sprintf("SELECT nom_commun FROM cel_references " .
"WHERE referentiel = '%s' AND num_taxon = %d LIMIT 1",
$referentiel,
$obs['nt']),
Cel::SQL_RETOUR_LIGNE);
 
if(! $nom) return NULL;
$nom = $nom["nom_commun"];
 
// cache
self::$cache['getNomCommun'][$cache_id] = $nom;
return $nom;
}
 
}