Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 163 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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