Subversion Repositories eFlore/Applications.eflore-consultation

Compare Revisions

Ignore whitespace Rev 58 → Rev 59

/trunk/modules/liste/Liste.php
14,21 → 14,41
*/
class Liste extends aControleur {
private $alphabet = null;
protected $rang = null;
protected $lettre = null;
public function initialiser() {
$this->capturerParametres();
}
public function executerActionParDefaut() {
$this->executerFamille();
$this->executerListe();
}
public function executerFamille() {
public function executerListe() {
$this->chargerAlphabet();
$this->lettre = key($this->alphabet);
$this->executerFiltre();
}
public function executerFiltre() {
$this->chargerAlphabet();
$couleurs = $this->creerColoration($this->alphabet);
$taxons = $this->getListeTaxons();
$donnees = array();
$donnees['i18n'] = I18n::get('Liste');
$donnees['referentiel_titre'] = I18n::get('Referentiels-titres.'.Registre::get('parametres.referentiel'));
$noms = new Noms(Registre::get('parametres.referentiel'));
$donnees['initialesFamille'] = $noms->getStatsInitialesFamille();
$donnees['lettre'] = $this->lettre;
$donnees['rang'] = $this->rang;
$donnees['initiales'] = $this->alphabet;
$donnees['couleurs'] = $couleurs;
$donnees['taxons'] = $taxons;
$donnees['nbreTaxons'] = $this->getEfloreTaxons()->getEnteteTotal();
$donnees['urlFiltre'] = $this->obtenirUrlBase();
$donnees['referentiel'] = Registre::get('parametres.referentiel');
$donnees['module'] = strtolower(get_class($this));
$donnees['action'] = 'filtre';
$this->setSortie(self::RENDU_CORPS, $this->getVue('liste', $donnees));
}
35,8 → 55,75
private function capturerParametres() {
if (isset($_GET['rang'])) {
Registre::set('parametres.rang', $_GET['rang']);
$this->rang = $_GET['rang'];
}
if (isset($_GET['lettre'])) {
$this->lettre = $_GET['lettre'];
}
}
private function chargerAlphabet() {
if (!isset($this->alphabet)) {
$this->alphabet = $this->getStatsInitiales();
}
ksort($this->alphabet);
}
private function getStatsInitiales() {
$nomRang = $this->getNomCodeRang();
$stats = array();
if ($nomRang) {
$methode = 'getStatsInitiales'.$nomRang;
$stats = $this->getEfloreTaxons()->$methode();
}
return $stats;
}
private function getListeTaxons() {
$taxons = array();
if (isset($this->lettre)) {
$nomRang = $this->getNomCodeRang();
if ($nomRang) {
$methode = "getListe{$nomRang}ParInitiale";
$taxons = $this->getEfloreTaxons()->$methode($this->lettre);
}
}
return $taxons;
}
private function getNomCodeRang() {
$nom = false;
switch ($this->rang) {
case 'F' :
$nom = 'Famille';
break;
case 'G' :
$nom = 'Genre';
break;
default :
$m = "Ce code de rang '{$this->rang}' est inconnu. Codes disponibles : F (Famille), G (Genre).";
trigger_error($m, E_USER_WARNING);
}
return $nom;
}
/**
* Gestion de la coloration de l'alphabet en fonction du nombre de résultat
*/
private function creerColoration($alphabet) {
$debut = explode(',', Config::get('couleur_alphabet_debut')); // Tableau RGB de départ
$fin = explode(',', Config::get('couleur_alphabet_fin')); // Tableau RGB d'arrivée
$rvbAbreviations = array('R','V','B');
$nbreLettres = count($alphabet);
$valeurMax = max($alphabet);
$couleurs = array();
foreach ($alphabet as $lettre => $nbre) {
foreach ($rvbAbreviations as $index => $rvb) { //Pour faire le Rouge, Vert, Bleu
$couleurs[$nbre][$rvb] = round($debut[$index] - (($debut[$index]-$fin[$index]) / $valeurMax * $nbre) , 0);
}
}
return $couleurs;
}
}
?>