Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 1106 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
990 isa 1
<?php
2
// declare(encoding='UTF-8');
3
/**
4
 * Classe mère du module Mobile.
5
 *
6
 * @category	PHP 5.2
7
 * @package		eflore-consultation
8
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
9
 * @author		Delphine CAUQUIL <delphine@tela-botanica.org>
10
 * @copyright	2011 Tela-Botanica
11
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL-v3
12
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL-v2
13
 * @version		$Id$
14
 */
15
class Mobile extends aControleur {
16
 
17
	private $theme = 'pyracantha';
18
	private $parametres = array();
19
	private $conteneur = null;
20
	private $num_nom = 0;
21
	private $nom_courant = null;
22
	private $nom_retenu = '';
23
	private $url;
24
 
25
	public function initialiser() {
26
		$this->capturerParametres();
27
		$this->conteneur = new Conteneur($this->parametres);
28
		$this->url = $this->conteneur->getAppUrls();
29
		$this->nomCourant = $this->conteneur->getNomCourant();
30
		$this->nom_retenu = $this->conteneur->getNomCourant()->getNomRetenu();
31
		spl_autoload_register(array($this, 'chargerClassesSources'));
32
	}
1106 jpm 33
 
990 isa 34
	private function chargerClassesSources($classe) {
35
		$base = dirname(__FILE__).DS;
36
		$cheminSources = $base.'sources'.DS;
37
		$dossiers = array($base, $cheminSources);
38
		foreach ($dossiers as $chemin) {
39
			$fichierATester = $chemin.$classe.'.php';
40
			if (file_exists($fichierATester)) {
41
				include_once $fichierATester;
42
				return null;
43
			}
44
		}
45
	}
46
 
47
	private function capturerParametres() {
1106 jpm 48
		$this->parametres['num_nom'] = isset($_GET['num_nom']) ? $_GET['num_nom'] : '';
49
		$this->parametres['nom'] = isset($_GET['nom']) ? $_GET['nom'] : '';
50
		$this->parametres['type_nom'] = isset($_GET['type_nom']) ? $_GET['type_nom'] : 'nom_scientifique';
51
		$this->theme = isset($_GET['theme']) ? $_GET['theme'] : $this->theme;
52
 
53
		$referentiel = isset($_GET['referentiel']) ? $_GET['referentiel'] : '';
54
		Registre::set('parametres.referentiel', $referentiel);
1110 mathias 55
		$this->parametres['referentiel'] = $referentiel;
1106 jpm 56
 
57
		$niveau = isset($_GET['niveau']) ? $_GET['niveau'] : '1';
58
		Registre::set('parametres.niveau', $niveau);
990 isa 59
	}
1106 jpm 60
 
990 isa 61
	public function executerActionParDefaut() {
62
		$this->executerFiche();
63
	}
64
 
65
	public function executerFiche(){
1106 jpm 66
		$niveau = Registre::get('parametres.niveau');
67
		$squelette = "theme_{$this->theme}_niveau{$niveau}";
68
 
990 isa 69
		$donnees = $this->parametres;
70
		$donnees['nom_retenu'] = $this->nom_retenu->get('nom_sci_html').' '.$this->nom_retenu->get('auteur');
71
		$donnees['famille'] = $this->nom_retenu->getTaxonSupRang('180');
72
		$donnees = array_merge($this->obtenirDonnees(), $donnees);
73
		$donnees['css'] = $this->obtenirLienCss();
1064 aurelien 74
		$donnees['url_absolue'] = "http://".$_SERVER['SERVER_NAME'].'/'.$_SERVER['REQUEST_URI'];
990 isa 75
		$donnees['contenu_onglet'] = $this->getVue($squelette, $donnees);
1106 jpm 76
		$donnees['lien'] = $this->url->obtenirUrlMobile($this->parametres['num_nom']);
990 isa 77
		$this->setSortie(self::RENDU_CORPS, $this->getVue('fiche', $donnees), true);
78
		//print_r($donnees);
79
	}
1106 jpm 80
 
990 isa 81
	public function obtenirDonnees() {
82
		$donnees = array();
83
		$num_nom = $this->nomCourant->getNns();
84
		$referentiel = $this->conteneur->getParametre('referentiel');
1106 jpm 85
 
992 isa 86
		$taxons = new Taxons($this->conteneur);
87
		$donnees['permalien_num_nom'] = $taxons->getUrlPermalienNumNom($referentiel, 1, $num_nom);
1106 jpm 88
 
990 isa 89
		$sources = array('illustrations', 'repartition', 'texte', 'floraison', 'nomsCommuns');
90
		foreach ($sources as $source) {
91
			$nom_classe = ucfirst($source);
92
			$classe = new $nom_classe($this->conteneur);
93
			$donnees[$source] = $classe->getDonnees();
94
		}
95
 
96
		return $donnees;
97
	}
1106 jpm 98
 
990 isa 99
	private function obtenirLienCss() {
1106 jpm 100
		$theme = $this->theme;
990 isa 101
		if (strcmp($this->theme, 'pyracantha') >= 0) {
1106 jpm 102
			$theme = 'pyracantha_blanc';
990 isa 103
		}
1106 jpm 104
		$lien = "modules/mobile/presentations/css/$theme.css";
990 isa 105
		return $lien;
106
	}
107
}
108
?>