Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Go to most recent revision | Details | 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
	}
33
 
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() {
48
		if (isset($_GET['num_nom'])) {
49
			$this->parametres['num_nom'] = $_GET['num_nom'];
50
		}
51
		if (isset($_GET['nom'])) {
52
			$this->parametres['nom'] = $_GET['nom'];
53
		}
54
		if (isset($_GET['type_nom'])) {
55
			$this->parametres['type_nom'] = $_GET['type_nom'];
56
		}
57
		if (isset($_GET['referentiel'])) {
58
			$this->parametres['referentiel'] = $_GET['referentiel'];
59
			Registre::set('parametres.referentiel', $_GET['referentiel']);
60
		}
61
		if (isset($_GET['niveau'])) {
62
			Registre::set('parametres.niveau', $_GET['niveau']);
63
		}
64
		if (isset($_GET['theme'])) {
65
			$this->theme = $_GET['theme'];
66
		}
67
	}
68
 
69
	public function executerActionParDefaut() {
70
		$this->executerFiche();
71
	}
72
 
73
	public function executerFiche(){
74
		$niveau = isset($_GET['niveau']) ? $_GET['niveau'] : '1';
75
 
76
		$squelette = 'theme_'.$this->theme.'_niveau'.$niveau;
77
 
78
		$donnees = $this->parametres;
79
		$donnees['nom_retenu'] = $this->nom_retenu->get('nom_sci_html').' '.$this->nom_retenu->get('auteur');
80
		$donnees['famille'] = $this->nom_retenu->getTaxonSupRang('180');
81
		$donnees = array_merge($this->obtenirDonnees(), $donnees);
82
		$donnees['css'] = $this->obtenirLienCss();
1064 aurelien 83
		$donnees['url_absolue'] = "http://".$_SERVER['SERVER_NAME'].'/'.$_SERVER['REQUEST_URI'];
990 isa 84
		$donnees['contenu_onglet'] = $this->getVue($squelette, $donnees);
85
		$donnees['lien'] = $this->url->obtenirUrlMobile($this->parametres['num_nom'], $this->parametres['type_nom'], $this->parametres['nom']);
86
		$this->setSortie(self::RENDU_CORPS, $this->getVue('fiche', $donnees), true);
87
		//print_r($donnees);
88
	}
89
 
90
	public function obtenirDonnees() {
91
		$donnees = array();
92
		$num_nom = $this->nomCourant->getNns();
93
		$referentiel = $this->conteneur->getParametre('referentiel');
94
 
992 isa 95
		$taxons = new Taxons($this->conteneur);
96
		$donnees['permalien_num_nom'] = $taxons->getUrlPermalienNumNom($referentiel, 1, $num_nom);
97
 
990 isa 98
		$sources = array('illustrations', 'repartition', 'texte', 'floraison', 'nomsCommuns');
99
		foreach ($sources as $source) {
100
			$nom_classe = ucfirst($source);
101
			$classe = new $nom_classe($this->conteneur);
102
			$donnees[$source] = $classe->getDonnees();
103
		}
104
 
105
		return $donnees;
106
	}
107
 
108
	private function obtenirLienCss() {
109
		$lien = 'modules/mobile/presentations/css/';
110
		if (strcmp($this->theme, 'pyracantha') >= 0) {
111
			$lien .= 'pyracantha_blanc.css';
112
		} else {
113
			$lien .= 'gentiana.css';
114
		}
115
		return $lien;
116
	}
117
}
118
?>