Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

Rev 960 Rev 1126
1
<?php
1
<?php
2
// declare(encoding='UTF-8');
2
// declare(encoding='UTF-8');
3
/**
3
/**
4
 * Classe mère du module fiche metadonnées.
4
 * Classe mère du module fiche metadonnées.
5
 *
5
 *
6
 * @category	PHP 5.2
6
 * @category	PHP 5.2
7
 * @package		eflore-consultation
7
 * @package		eflore-consultation
8
 * @author		Aurélien Peronnet <aurelien@tela-botanica.org>
8
 * @author		Aurélien Peronnet <aurelien@tela-botanica.org>
9
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
9
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
10
 * @author		Delphine CAUQUIL <delphine@tela-botanica.org>
10
 * @author		Delphine CAUQUIL <delphine@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 FicheMetadonnees extends aControleur {
16
class FicheMetadonnees extends aControleur {
17
 
17
 
18
	private $projet = '';
18
	private $projet = '';
19
	private $serviceMetaDonnees;
19
	private $serviceMetaDonnees;
20
 
20
 
21
	public function __construct($metadonnees = null) {
21
	public function __construct($metadonnees = null) {
22
		$this->capturerParametres();
22
		$this->capturerParametres();
23
		$this->serviceMetaDonnees = (is_null($this->serviceMetaDonnees)) ? new MetaDonnees($this->projet) : $metadonnees;
23
		$this->serviceMetaDonnees = (is_null($this->serviceMetaDonnees)) ? new MetaDonnees($this->projet) : $metadonnees;
24
	}
24
	}
25
 
25
 
26
	public function executerActionParDefaut() {
26
	public function executerActionParDefaut() {
27
		$this->executerAffichageMetaDonnees();
27
		$this->executerAffichageMetaDonnees();
28
	}
28
	}
29
 
29
 
30
	public function chargerMetadonneesHtml() {
30
	public function chargerMetadonneesHtml() {
31
		$donnees['metadonnees'] = $this->serviceMetaDonnees->getMetaDonnees();
31
		$meta = $this->serviceMetaDonnees->getMetaDonnees();
-
 
32
		foreach ($meta as $index => $metadonnees) {
-
 
33
			$meta[$index] = $this->formaterClesMetadonnees($metadonnees);
-
 
34
		}
-
 
35
		$donnees['metadonnees'] = $meta;
-
 
36
		$donnees['i18n'] = I18n::get('Metadonnees');
32
		$html = $this->getVue(dirname(__FILE__).'/squelettes/metadonnees', $donnees);
37
		$html = $this->getVue(dirname(__FILE__).'/squelettes/metadonnees', $donnees);
33
		return $html;
38
		return $html;
34
	}
39
	}
35
 
40
 
36
	public function executerAffichageMetaDonnees($donnees) {
41
	public function executerAffichageMetaDonnees($donnees) {
37
		header('Content-type: text/html; charset=UTF-8');
42
		header('Content-type: text/html; charset=UTF-8');
38
		$html = $this->chargerMetadonneesHtml();
43
		$html = $this->chargerMetadonneesHtml();
39
		echo $html;
44
		echo $html;
40
		exit;
45
		exit;
41
	}
46
	}
42
 
47
 
43
	private function capturerParametres() {
48
	private function capturerParametres() {
44
		if (isset($_GET['projet'])) {
49
		if (isset($_GET['projet'])) {
45
			$this->projet = $_GET['projet'];
50
			$this->projet = $_GET['projet'];
46
		}
51
		}
47
	}
52
	}
-
 
53
	
-
 
54
	private function formaterClesMetadonnees($metadonnees) {
-
 
55
		$meta_fmt = array();
-
 
56
		foreach ($metadonnees as $cle => $metadonnee) {
-
 
57
			$cle_fmt = str_replace('.', '_', $cle);
-
 
58
			if(is_array($metadonnee)) {
-
 
59
				$metadonnee = $this->formaterClesMetadonnees($metadonnee);
-
 
60
			} elseif($this->estUnLien($metadonnee)) {
-
 
61
				$metadonnee = $this->formaterLienMetadonnee($metadonnee);
-
 
62
			}
-
 
63
			$meta_fmt[$cle_fmt] = $metadonnee;		
-
 
64
		}
-
 
65
		return $meta_fmt;
-
 
66
	}
-
 
67
	
-
 
68
	private function estUnLien($valeur) {
-
 
69
		// le test du pauvre, mais ça suffit ici
-
 
70
		// car nous controlons le format des métadonnées
-
 
71
		return strpos($valeur, "http://") !== false;
-
 
72
	}
-
 
73
	
-
 
74
	private function formaterLienMetadonnee($lien) {
-
 
75
		return '<a href="'.$lien.'" target="_blank">'.$lien.'</a>';
-
 
76
	}
48
}
77
}
49
?>
78
?>