Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 1107 | Rev 1423 | Go to most recent revision | 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
1410 aurelien 8
 * @author		Isabelle NEMBROT
9
 * @author		Aurélien PERONNET <aurelien@tela-botanica.org>
10
 * @copyright	2015 Tela-Botanica
990 isa 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 $parametres = array();
18
	private $conteneur = null;
19
	private $num_nom = 0;
20
	private $nom_courant = null;
21
	private $nom_retenu = '';
22
	private $url;
23
 
24
	public function initialiser() {
25
		$this->capturerParametres();
26
		$this->conteneur = new Conteneur($this->parametres);
27
		$this->url = $this->conteneur->getAppUrls();
28
		$this->nomCourant = $this->conteneur->getNomCourant();
29
		$this->nom_retenu = $this->conteneur->getNomCourant()->getNomRetenu();
30
		spl_autoload_register(array($this, 'chargerClassesSources'));
31
	}
1105 jpm 32
 
990 isa 33
	private function chargerClassesSources($classe) {
34
		$base = dirname(__FILE__).DS;
35
		$cheminSources = $base.'sources'.DS;
36
		$dossiers = array($base, $cheminSources);
37
		foreach ($dossiers as $chemin) {
38
			$fichierATester = $chemin.$classe.'.php';
39
			if (file_exists($fichierATester)) {
40
				include_once $fichierATester;
41
				return null;
42
			}
43
		}
44
	}
45
 
46
	private function capturerParametres() {
1105 jpm 47
		$this->parametres['num_nom'] = isset($_GET['num_nom']) ? $_GET['num_nom'] : '';
48
		$this->parametres['nom'] = isset($_GET['nom']) ? $_GET['nom'] : '';
49
		$this->parametres['type_nom'] = isset($_GET['type_nom']) ? $_GET['type_nom'] : 'nom_scientifique';
50
 
51
		$referentiel = isset($_GET['referentiel']) ? $_GET['referentiel'] : '';
52
		Registre::set('parametres.referentiel', $referentiel);
1107 jpm 53
		$this->parametres['referentiel'] = $referentiel;
1105 jpm 54
 
55
		$niveau = isset($_GET['niveau']) ? $_GET['niveau'] : '1';
56
		Registre::set('parametres.niveau', $niveau);
990 isa 57
	}
1105 jpm 58
 
990 isa 59
	public function executerActionParDefaut() {
60
		$this->executerFiche();
61
	}
62
 
63
	public function executerFiche(){
64
		$donnees = $this->parametres;
65
		$donnees['nom_retenu'] = $this->nom_retenu->get('nom_sci_html').' '.$this->nom_retenu->get('auteur');
66
		$donnees['famille'] = $this->nom_retenu->getTaxonSupRang('180');
67
		$donnees = array_merge($this->obtenirDonnees(), $donnees);
1064 aurelien 68
		$donnees['url_absolue'] = "http://".$_SERVER['SERVER_NAME'].'/'.$_SERVER['REQUEST_URI'];
1410 aurelien 69
		$donnees['lien'] = $this->url->obtenirUrlMobile($this->parametres['num_nom']);
70
		$donnees['lien_fiche'] = $this->url->obtenirUrlFiche($this->parametres['num_nom']);
71
 
72
		$this->setSortie(self::RENDU_CORPS, $this->getVue('smartflore', $donnees), true);
990 isa 73
	}
1105 jpm 74
 
990 isa 75
	public function obtenirDonnees() {
76
		$donnees = array();
77
		$num_nom = $this->nomCourant->getNns();
78
		$referentiel = $this->conteneur->getParametre('referentiel');
1105 jpm 79
 
992 isa 80
		$taxons = new Taxons($this->conteneur);
81
		$donnees['permalien_num_nom'] = $taxons->getUrlPermalienNumNom($referentiel, 1, $num_nom);
1105 jpm 82
 
1410 aurelien 83
		$sources = array('illustrations', 'texte', 'nomsCommuns');
990 isa 84
		foreach ($sources as $source) {
85
			$nom_classe = ucfirst($source);
86
			$classe = new $nom_classe($this->conteneur);
87
			$donnees[$source] = $classe->getDonnees();
88
		}
89
 
90
		return $donnees;
91
	}
92
}
93
?>