231 |
jpm |
1 |
<?php
|
|
|
2 |
class OntologieFormateur {
|
|
|
3 |
|
|
|
4 |
private $termeAFormater = null;
|
|
|
5 |
private $decorateurs = array();
|
|
|
6 |
private $bdd = null;
|
|
|
7 |
private $champsProjet = array();
|
|
|
8 |
private $champsRetour = null;
|
|
|
9 |
private $detailsHrefTpl = null;
|
|
|
10 |
private $langueDemandee = null;
|
|
|
11 |
|
|
|
12 |
public function setTermeAFormater(OntologieDO $ontologieDO) {
|
|
|
13 |
$this->termeAFormater = $ontologieDO;
|
|
|
14 |
}
|
|
|
15 |
|
|
|
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 setLangueDemandee($langue) {
|
|
|
29 |
$this->langueDemandee = $langue;
|
|
|
30 |
}
|
|
|
31 |
|
|
|
32 |
public function setBdd($bdd) {
|
|
|
33 |
$this->bdd = $bdd;
|
|
|
34 |
}
|
|
|
35 |
|
|
|
36 |
public function formaterDetails() {
|
|
|
37 |
$termeDeco = new OntologieDecorateur($this->termeAFormater, $this->detailsHrefTpl, $this->langueDemandee);
|
|
|
38 |
$projetDeco = new OntologieChampsProjetDecorateur($termeDeco, $this->champsProjet);
|
|
|
39 |
|
|
|
40 |
if ($this->avoirDemandeChampsRetour()) {
|
|
|
41 |
$this->decorateurs[] = $termeDeco;
|
|
|
42 |
$this->decorateurs[] = $projetDeco;
|
|
|
43 |
|
|
|
44 |
$this->traiterChampsRetour();
|
|
|
45 |
} else {
|
|
|
46 |
$termeDeco->ajouterId();
|
|
|
47 |
$termeDeco->ajouterIntitule();
|
|
|
48 |
$termeDeco->ajouterDescription();
|
|
|
49 |
$termeDeco->ajouterClasseId();
|
|
|
50 |
$termeDeco->ajouterClasse();
|
|
|
51 |
$termeDeco->ajouterClasseHref();
|
|
|
52 |
|
|
|
53 |
$projetDeco->ajouterChampsSupplementaires();
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
return $termeDeco->getTermeFormate();
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
public function formaterListe() {
|
|
|
60 |
$termeDeco = new OntologieDecorateur($this->termeAFormater, $this->detailsHrefTpl, $this->langueDemandee);
|
|
|
61 |
$termeDeco->ajouterId();
|
|
|
62 |
$termeDeco->ajouterIntitule();
|
|
|
63 |
$termeDeco->ajouterHref();
|
|
|
64 |
|
|
|
65 |
if ($this->avoirDemandeChampsRetour()) {
|
|
|
66 |
$this->decorateurs[] = $termeDeco;
|
|
|
67 |
$this->decorateurs[] = new OntologieChampsProjetDecorateur($termeDeco, $this->champsProjet);
|
|
|
68 |
|
|
|
69 |
$this->traiterChampsRetour();
|
|
|
70 |
}
|
|
|
71 |
|
|
|
72 |
return $termeDeco->getTermeFormate();
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
private function avoirDemandeChampsRetour() {
|
|
|
76 |
$demande = true;
|
|
|
77 |
if ($this->champsRetour === null || count($this->champsRetour) == 0) {
|
|
|
78 |
$demande = false;
|
|
|
79 |
}
|
|
|
80 |
return $demande;
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
private function traiterChampsRetour() {
|
|
|
84 |
foreach ($this->decorateurs as $deco) {
|
|
|
85 |
$deco->traiterChampsRetour($this->champsRetour);
|
|
|
86 |
}
|
|
|
87 |
}
|
|
|
88 |
}
|
|
|
89 |
?>
|