Subversion Repositories eFlore/Projets.eflore-projets

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
163 jpm 1
<?php
207 jpm 2
class NomDecorateur implements NomResponsabilite {
163 jpm 3
	protected $nom = null;
4
	protected $nomFormate = array();
207 jpm 5
	private $detailsHrefTpl = null;
6
	protected $correspondances = array(
7
		'id' => 'Id',
8
		'nom_sci' => 'Intitule',
9
		'href' => 'Href',
10
		'auteur' => 'Auteur',
11
		'annee' => 'Annee',
12
		'biblio_origine' => 'Biblio',
13
		'nom_addendum' => 'Addendum',
14
		'notes' => 'Notes',
15
		'homonyme' => 'Homonyme');
16
 
17
	public function __construct(NomDO $nomADecorer, $detailsHrefTpl) {
163 jpm 18
		$this->nom = $nomADecorer;
207 jpm 19
		$this->detailsHrefTpl = $detailsHrefTpl;
163 jpm 20
		$this->initialiserNomFormate();
21
	}
207 jpm 22
 
23
	public function traiterChampsRetour(Array $champsRetour) {
24
		foreach ($champsRetour as $champ) {
25
			if (array_key_exists($champ, $this->correspondances)) {
26
				$methodesAExecuter = explode(',', $this->correspondances[$champ]);
27
				foreach ($methodesAExecuter as $methodeNom) {
28
					$methodeAjouter = 'ajouter'.$methodeNom;
29
					if (method_exists($this, $methodeAjouter)) {
30
						$this->$methodeAjouter();
31
						unset($champsRetour[$champ]);
32
					}
33
				}
34
			}
35
		}
36
		return $champsRetour;
37
	}
38
 
163 jpm 39
	public function ajouterId() {
40
		$this->nomFormate['id'] = (int) $this->nom->getTag('num_nom');
41
	}
207 jpm 42
 
163 jpm 43
	public function ajouterIntitule() {
44
		$this->nomFormate['nom_sci'] = $this->nom->getTag('nom_sci');
45
	}
207 jpm 46
 
47
	public function ajouterHref() {
48
		if ($this->nom->verifierTag('num_nom')) {
49
			$href = sprintf($this->detailsHrefTpl, $this->nom->getTag('num_nom'));
50
			$this->nomFormate['href'] = $href;
51
		}
52
	}
53
 
163 jpm 54
	public function ajouterAuteur() {
55
		if ($this->nom->verifierTag('auteur')) {
56
			$this->nomFormate['auteur'] = $this->nom->getTag('auteur');
57
		}
58
	}
207 jpm 59
 
163 jpm 60
	public function ajouterAnnee() {
61
		if ($this->nom->verifierTag('annee')) {
62
			$this->nomFormate['annee'] = $this->nom->getTag('annee');
63
		}
64
	}
207 jpm 65
 
163 jpm 66
	public function ajouterBiblio() {
67
		if ($this->nom->verifierTag('biblio_origine')) {
68
			$this->nomFormate['biblio_origine'] = $this->nom->getTag('biblio_origine');
69
		}
70
	}
207 jpm 71
 
163 jpm 72
	public function ajouterAddendum() {
73
		if ($this->nom->verifierTag('nom_addendum')) {
74
			$this->nomFormate['nom_addendum'] = $this->nom->getTag('nom_addendum');
75
		}
76
	}
207 jpm 77
 
163 jpm 78
	public function ajouterNotes() {
79
		if ($this->nom->verifierTag('notes')) {
80
			$this->nomFormate['notes'] = $this->nom->getTag('notes');
81
		}
82
	}
207 jpm 83
 
163 jpm 84
	public function ajouterHomonyme() {
85
		if ($this->nom->verifierTag('homonyme') && $this->nom->getTag('homonyme') == 1) {
86
			$this->nomFormate['homonyme'] = true;
87
		}
88
	}
207 jpm 89
 
163 jpm 90
	public function initialiserNomFormate() {
91
		$this->nomFormate = array();
92
	}
207 jpm 93
 
163 jpm 94
	public function getNomFormate() {
95
		return $this->nomFormate;
96
	}
97
}
98
?>