204 |
jpm |
1 |
<?php
|
|
|
2 |
class NomFormateur {
|
|
|
3 |
|
|
|
4 |
private $nomAFormater = null;
|
207 |
jpm |
5 |
private $decorateurs = array();
|
|
|
6 |
private $bdd = null;
|
|
|
7 |
private $champsProjet = array();
|
|
|
8 |
private $champsRetour = null;
|
|
|
9 |
private $detailsHrefTpl = null;
|
|
|
10 |
private $ontologieHrefTpl = null;
|
204 |
jpm |
11 |
|
|
|
12 |
public function __construct(NomDO $nomDO) {
|
|
|
13 |
$this->nomAFormater = $nomDO;
|
|
|
14 |
}
|
|
|
15 |
|
207 |
jpm |
16 |
public function setChampsRetour(Array $champsRetour) {
|
|
|
17 |
$this->champsRetour = $champsRetour;
|
|
|
18 |
}
|
|
|
19 |
|
|
|
20 |
public function setChampsProjet(Array $champsProjet) {
|
|
|
21 |
$this->champsProjet = $champsProjet;
|
|
|
22 |
}
|
|
|
23 |
|
|
|
24 |
public function setDetailsHrefTpl($tpl) {
|
|
|
25 |
$this->detailsHrefTpl = $tpl;
|
|
|
26 |
}
|
|
|
27 |
|
|
|
28 |
public function setBdd($bdd) {
|
|
|
29 |
$this->bdd = $bdd;
|
|
|
30 |
}
|
|
|
31 |
|
|
|
32 |
public function setOntologieHrefTpl($tpl) {
|
|
|
33 |
$this->ontologieHrefTpl = $tpl;
|
|
|
34 |
}
|
|
|
35 |
|
|
|
36 |
public function formaterDetails() {
|
|
|
37 |
$nomDeco = new NomDecorateur($this->nomAFormater, $this->detailsHrefTpl);
|
|
|
38 |
$retenuDeco = new NomRetenuDecorateur($nomDeco, $this->detailsHrefTpl);
|
|
|
39 |
$rangDeco = new NomRangDecorateur($nomDeco, $this->bdd, $this->ontologieHrefTpl);
|
|
|
40 |
$compoDeco = new NomCompoDecorateur($nomDeco);
|
|
|
41 |
$basioDeco = new NomBasionymeDecorateur($nomDeco, $this->detailsHrefTpl);
|
|
|
42 |
$projetDeco = new NomChampsProjetDecorateur($nomDeco, $this->champsProjet);
|
|
|
43 |
|
|
|
44 |
if ($this->avoirDemandeChampsRetour()) {
|
|
|
45 |
$this->decorateurs[] = $nomDeco;
|
|
|
46 |
$this->decorateurs[] = $retenuDeco;
|
|
|
47 |
$this->decorateurs[] = $rangDeco;
|
|
|
48 |
$this->decorateurs[] = $compoDeco;
|
|
|
49 |
$this->decorateurs[] = $basioDeco;
|
|
|
50 |
$this->decorateurs[] = $projetDeco;
|
|
|
51 |
|
|
|
52 |
$this->traiterChampsRetour();
|
|
|
53 |
} else {
|
|
|
54 |
$nomDeco->ajouterId();
|
|
|
55 |
$nomDeco->ajouterIntitule();
|
|
|
56 |
|
|
|
57 |
$retenuDeco->ajouterRetenu();
|
|
|
58 |
$retenuDeco->ajouterId();
|
|
|
59 |
$retenuDeco->ajouterIntitule();
|
|
|
60 |
$retenuDeco->ajouterHref();
|
|
|
61 |
|
|
|
62 |
$rangDeco->ajouterCode();
|
|
|
63 |
$rangDeco->ajouterIntitule();
|
|
|
64 |
$rangDeco->ajouterHref();
|
|
|
65 |
|
|
|
66 |
$compoDeco->ajouterCompo();
|
|
|
67 |
|
|
|
68 |
$nomDeco->ajouterAuteur();
|
|
|
69 |
$nomDeco->ajouterAnnee();
|
|
|
70 |
$nomDeco->ajouterBiblio();
|
|
|
71 |
$nomDeco->ajouterAddendum();
|
|
|
72 |
$nomDeco->ajouterNotes();
|
|
|
73 |
|
|
|
74 |
$basioDeco->ajouterId();
|
|
|
75 |
$basioDeco->ajouterIntitule();
|
|
|
76 |
$basioDeco->ajouterHref();
|
|
|
77 |
|
|
|
78 |
$projetDeco->ajouterChampsSupplementaires();
|
|
|
79 |
}
|
|
|
80 |
return $nomDeco->getNomFormate();
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
public function formaterListe() {
|
|
|
84 |
$nomDeco = new NomDecorateur($this->nomAFormater, $this->detailsHrefTpl);
|
204 |
jpm |
85 |
$nomDeco->ajouterIntitule();
|
|
|
86 |
|
|
|
87 |
$retenuDeco = new NomRetenuDecorateur($nomDeco, $this->detailsHrefTpl);
|
|
|
88 |
$retenuDeco->ajouterRetenu();
|
|
|
89 |
|
207 |
jpm |
90 |
$nomDeco->ajouterHref();
|
204 |
jpm |
91 |
|
207 |
jpm |
92 |
if ($this->avoirDemandeChampsRetour()) {
|
|
|
93 |
$this->decorateurs[] = $nomDeco;
|
|
|
94 |
$this->decorateurs[] = $retenuDeco;
|
204 |
jpm |
95 |
|
207 |
jpm |
96 |
$this->decorateurs[] = new NomRangDecorateur($nomDeco, $this->bdd, $this->ontologieHrefTpl);
|
|
|
97 |
$this->decorateurs[] = new NomCompoDecorateur($nomDeco);
|
|
|
98 |
$this->decorateurs[] = new NomBasionymeDecorateur($nomDeco, $this->detailsHrefTpl);
|
|
|
99 |
$this->decorateurs[] = new NomChampsProjetDecorateur($nomDeco, $this->champsProjet);
|
204 |
jpm |
100 |
|
207 |
jpm |
101 |
$this->traiterChampsRetour();
|
|
|
102 |
}
|
204 |
jpm |
103 |
|
|
|
104 |
return $nomDeco->getNomFormate();
|
|
|
105 |
}
|
|
|
106 |
|
207 |
jpm |
107 |
private function avoirDemandeChampsRetour() {
|
|
|
108 |
$demande = true;
|
|
|
109 |
if ($this->champsRetour === null || count($this->champsRetour) == 0) {
|
|
|
110 |
$demande = false;
|
|
|
111 |
}
|
|
|
112 |
return $demande;
|
|
|
113 |
}
|
|
|
114 |
|
|
|
115 |
private function traiterChampsRetour() {
|
|
|
116 |
foreach ($this->decorateurs as $deco) {
|
|
|
117 |
$this->champsRetour = $deco->traiterChampsRetour($this->champsRetour);
|
|
|
118 |
if (count($this->champsRetour) == 0) {
|
|
|
119 |
break;
|
|
|
120 |
}
|
|
|
121 |
}
|
|
|
122 |
}
|
204 |
jpm |
123 |
}
|
|
|
124 |
?>
|