Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 833 | Rev 961 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 833 Rev 876
1
<?php
1
<?php
2
// declare(encoding='UTF-8');
2
// declare(encoding='UTF-8');
3
/**
3
/**
4
 * Classe Onglet Synthese.
4
 * Classe Onglet Synthese.
5
 *
5
 *
6
 * @category	PHP 5.2
6
 * @category	PHP 5.2
7
 * @package		eflore-consultation
7
 * @package		eflore-consultation
8
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
8
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
9
 * @author		Delphine CAUQUIL <delphine@tela-botanica.org>
9
 * @author		Delphine CAUQUIL <delphine@tela-botanica.org>
10
 * @author		Grégoire DUCHÉ <gregoire@tela-botanica.org>
10
 * @author		Grégoire DUCHÉ <gregoire@tela-botanica.org>
11
 * @copyright	2011 Tela-Botanica
11
 * @copyright	2011 Tela-Botanica
12
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL-v3
12
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL-v3
13
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL-v2
13
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL-v2
14
 * @version		$Id$
14
 * @version		$Id$
15
 */
15
 */
16
class Synthese extends aControleur {
16
class Synthese extends aControleur {
17
 
17
 
18
	private $conteneur = null;
18
	private $conteneur = null;
19
	private $nomCourant = null;
19
	private $nomCourant = null;
20
 
20
 
21
	public function __construct(Conteneur $conteneur) {
21
	public function __construct(Conteneur $conteneur) {
22
		$this->conteneur = $conteneur;
22
		$this->conteneur = $conteneur;
23
		$this->nomCourant = $this->conteneur->getNomCourant();
23
		$this->nomCourant = $this->conteneur->getNomCourant();
24
		
24
		
25
		parent::__construct();
25
		parent::__construct();
26
	}
26
	}
27
 
27
 
28
	public function obtenirDonnees() {
28
	public function obtenirDonnees() {
29
		$donnees = array();
29
		$donnees = array();
30
		$num_nom = $this->nomCourant->getNns();
30
		$num_nom = $this->nomCourant->getNns();
31
		if(Config::get('cache')) {
-
 
32
			$cache = array(
-
 
33
				'illustration' => $this->obtenirCache('infos_bloc_'.$num_nom),
-
 
34
				'repartition' => $this->obtenirCache('repartition_bloc_'.$num_nom),
-
 
-
 
31
		
35
				'nomenclature' => $this->obtenirCache('nomenclature_bloc_'.$num_nom),
32
		$blocs = array('illustrations','repartition','nomenclature','description',
36
				'description' => $this->obtenirCache('description_bloc_'.$num_nom),
-
 
37
				'ethnobotanique' => $this->obtenirCache('ethnobotanique_bloc_'.$num_nom),
33
				'ethnobotanique','bibliographie','statut','ecologie');
38
				'classification' => $this->obtenirCache('classification_bloc_'.$num_nom),
-
 
39
				'bibliographie' => $this->obtenirCache('bibliographie_bloc_'.$num_nom),
-
 
40
				'statut' => $this->obtenirCache('statut_bloc_'.$num_nom),
-
 
41
				'ecologie' => $this->obtenirCache('ecologie_bloc_'.$num_nom)
-
 
42
			);
34
		$cache = array();
43
		}
-
 
44
		
35
		
45
		$nt = $this->conteneur->getNomCourant()->getNomRetenu()->get('num_taxonomique');
36
		$nt = $this->conteneur->getNomCourant()->getNomRetenu()->get('num_taxonomique');
46
		$donnees['infos'] = array('referentiel' => $this->conteneur->getParametre('referentiel'), 'num_tax' => $nt);
37
		$donnees['infos'] = array('referentiel' => $this->conteneur->getParametre('referentiel'), 'num_tax' => $nt);
47
		
-
 
48
		// TODO: factoriser cette portion de code avec un tableau de classes 
-
 
49
		// et des boucles
-
 
50
		if($cache['illustration'] != null) {
38
		foreach ($blocs as $bloc) {
51
			$donnees['illustration'] = $cache['illustration'];
-
 
52
		} else {
-
 
53
			$illustrations = new Illustrations($this->conteneur);
-
 
54
			$donnees['illustration'] = $illustrations->getBloc();
-
 
55
			if(!empty($donnees['illustration'])) {
-
 
56
				$this->mettreEnCache('infos_bloc_'.$num_nom, $donnees['illustration']);
39
			$cache_bloc = Config::get('cache') ? $this->obtenirCache($bloc.'_bloc_'.$num_nom) : null;
57
			}
-
 
58
		}
-
 
59
		
-
 
60
		if($cache['repartition'] != null) {
40
			if($cache_bloc != null) {
61
			$donnees['repartition'] = $cache['repartition'];
41
				$donnees[$bloc] = $cache_bloc;
62
		} else {
42
			} else {
63
			$repartition = new Repartition($this->conteneur);
-
 
64
			$donnees['repartition'] = $repartition->getBloc();
-
 
65
			$this->mettreEnCache('repartition_bloc_'.$num_nom, $donnees['repartition']);
-
 
66
		}
-
 
67
		
-
 
68
		if($cache['nomenclature'] != null) {
-
 
69
			$donnees['nomenclature'] = $cache['nomenclature'];
43
				$nom_classe = ucfirst($bloc);
70
		} else {
-
 
71
			$nomenclature = new Nomenclature($this->conteneur);
44
				$classe = new $nom_classe($this->conteneur);
72
			$donnees['nomenclature'] = $nomenclature->getBloc();
45
				$donnees[$bloc] = $classe->getBloc();
-
 
46
				if(!empty($donnees[$bloc])) {
73
			$this->mettreEnCache('nomenclature_bloc_'.$num_nom, $donnees['nomenclature']);
47
					$this->mettreEnCache($bloc.'_bloc_'.$num_nom, $donnees[$bloc]);
74
		}
48
				}
75
		
-
 
76
		if($cache['description'] != null) {
-
 
77
			$donnees['description'] = $cache['description'];
-
 
78
		} else {
-
 
79
			$description = new Description($this->conteneur);
-
 
80
			$donnees['description'] = $description->getBloc();
-
 
81
			// Le contenu des wiki ne doit pas être mis en cache dans la fiche synthèse car il est éditable en live
-
 
82
			if($donnees['description']['titre'] != 'Description collaborative') {
-
 
83
				$this->mettreEnCache('description_bloc_'.$num_nom, $donnees['description']);
-
 
84
			}
49
			}
85
		}
50
		}
86
		
-
 
87
		if($cache['ethnobotanique'] != null) {
-
 
88
			$donnees['ethnobotanique'] = $cache['ethnobotanique'];
-
 
89
		} else {
-
 
90
			$ethnobotanique = new Ethnobotanique($this->conteneur);
-
 
91
			$donnees['ethnobotanique'] = $ethnobotanique->getBloc();
-
 
92
			$this->mettreEnCache('ethnobotanique_bloc_'.$num_nom, $donnees['ethnobotanique']);
-
 
93
		}
-
 
94
		
-
 
95
	
-
 
96
		if($cache['bibliographie'] != null) {
-
 
97
			$donnees['bibliographie'] = $cache['bibliographie'];
-
 
98
		} else {
-
 
99
			$bibliographie = new Bibliographie($this->conteneur);
-
 
100
			$donnees['bibliographie'] = $bibliographie->getBloc();
-
 
101
			$this->mettreEnCache('bibliographie_bloc_'.$num_nom, $donnees['bibliographie']);
-
 
102
		}
-
 
103
		
-
 
104
		if($cache['statut'] != null) {
-
 
105
			$donnees['statut'] = $cache['statut'];
-
 
106
		} else {
-
 
107
			$statut = new Statut($this->conteneur);
-
 
108
		$donnees['statut'] = $statut->getBloc();
-
 
109
			$this->mettreEnCache('statut_bloc_'.$num_nom, $donnees['statut']);
-
 
110
		}
-
 
111
		
-
 
112
		if($cache['ecologie'] != null) {
-
 
113
			$donnees['ecologie'] = $cache['ecologie'];
-
 
114
		} else {
-
 
115
			$ecologie = new Ecologie($this->conteneur);
-
 
116
			$donnees['ecologie'] = $ecologie->getBloc();
-
 
117
			$this->mettreEnCache('ecologie_bloc_'.$num_nom, $donnees['ecologie']);
-
 
118
		}
-
 
119
		return $donnees;
51
		return $donnees;
120
	}
52
	}
121
 
-
 
122
}
53
}
123
?>
54
?>