Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 1423 | Rev 1435 | 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;
1425 aurelien 65
		$donnees['nom_retenu'] = $this->nom_retenu->get('nom_sci').' '.$this->nom_retenu->get('auteur');
990 isa 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'];
1423 aurelien 69
 
70
		$donnees['url_logos'] = "modules/mobile/presentations/logos/";
71
 
1410 aurelien 72
		$donnees['lien'] = $this->url->obtenirUrlMobile($this->parametres['num_nom']);
73
		$donnees['lien_fiche'] = $this->url->obtenirUrlFiche($this->parametres['num_nom']);
1425 aurelien 74
 
75
		$tpl_edition = Config::get('smartFloreEditionFormulaireUrlTpl');
76
		$url_edition = sprintf($tpl_edition, strtoupper($this->parametres['referentiel']), $this->nom_retenu->get('num_taxonomique'));
77
		$donnees['lien_edition'] = $url_edition;
1410 aurelien 78
 
79
		$this->setSortie(self::RENDU_CORPS, $this->getVue('smartflore', $donnees), true);
990 isa 80
	}
1105 jpm 81
 
990 isa 82
	public function obtenirDonnees() {
83
		$donnees = array();
84
		$num_nom = $this->nomCourant->getNns();
85
		$referentiel = $this->conteneur->getParametre('referentiel');
1105 jpm 86
 
992 isa 87
		$taxons = new Taxons($this->conteneur);
88
		$donnees['permalien_num_nom'] = $taxons->getUrlPermalienNumNom($referentiel, 1, $num_nom);
1105 jpm 89
 
1410 aurelien 90
		$sources = array('illustrations', 'texte', 'nomsCommuns');
990 isa 91
		foreach ($sources as $source) {
92
			$nom_classe = ucfirst($source);
93
			$classe = new $nom_classe($this->conteneur);
94
			$donnees[$source] = $classe->getDonnees();
95
		}
96
 
97
		return $donnees;
98
	}
99
}
100
?>