Subversion Repositories eFlore/Projets.eflore-projets

Rev

Go to most recent revision | 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
					}
32
				}
33
			}
34
		}
35
	}
36
 
163 jpm 37
	public function ajouterId() {
38
		$this->nomFormate['id'] = (int) $this->nom->getTag('num_nom');
39
	}
207 jpm 40
 
163 jpm 41
	public function ajouterIntitule() {
42
		$this->nomFormate['nom_sci'] = $this->nom->getTag('nom_sci');
43
	}
207 jpm 44
 
45
	public function ajouterHref() {
46
		if ($this->nom->verifierTag('num_nom')) {
47
			$href = sprintf($this->detailsHrefTpl, $this->nom->getTag('num_nom'));
48
			$this->nomFormate['href'] = $href;
49
		}
50
	}
51
 
163 jpm 52
	public function ajouterAuteur() {
53
		if ($this->nom->verifierTag('auteur')) {
54
			$this->nomFormate['auteur'] = $this->nom->getTag('auteur');
55
		}
56
	}
207 jpm 57
 
163 jpm 58
	public function ajouterAnnee() {
59
		if ($this->nom->verifierTag('annee')) {
60
			$this->nomFormate['annee'] = $this->nom->getTag('annee');
61
		}
62
	}
207 jpm 63
 
163 jpm 64
	public function ajouterBiblio() {
65
		if ($this->nom->verifierTag('biblio_origine')) {
66
			$this->nomFormate['biblio_origine'] = $this->nom->getTag('biblio_origine');
67
		}
68
	}
207 jpm 69
 
163 jpm 70
	public function ajouterAddendum() {
71
		if ($this->nom->verifierTag('nom_addendum')) {
72
			$this->nomFormate['nom_addendum'] = $this->nom->getTag('nom_addendum');
73
		}
74
	}
207 jpm 75
 
163 jpm 76
	public function ajouterNotes() {
77
		if ($this->nom->verifierTag('notes')) {
78
			$this->nomFormate['notes'] = $this->nom->getTag('notes');
79
		}
80
	}
207 jpm 81
 
163 jpm 82
	public function ajouterHomonyme() {
83
		if ($this->nom->verifierTag('homonyme') && $this->nom->getTag('homonyme') == 1) {
84
			$this->nomFormate['homonyme'] = true;
85
		}
86
	}
207 jpm 87
 
163 jpm 88
	public function initialiserNomFormate() {
89
		$this->nomFormate = array();
90
	}
207 jpm 91
 
163 jpm 92
	public function getNomFormate() {
93
		return $this->nomFormate;
94
	}
95
}
96
?>