163 |
jpm |
1 |
<?php
|
|
|
2 |
class NomRangDecorateur extends NomDecorateur {
|
|
|
3 |
|
|
|
4 |
private $nomDecorateur = null;
|
|
|
5 |
private $rang = null;
|
|
|
6 |
private $bdd = null;
|
|
|
7 |
private $ontologieHrefTpl = null;
|
207 |
jpm |
8 |
protected $correspondances = array(
|
|
|
9 |
'rang' => 'Intitule',
|
|
|
10 |
'rang.code' => 'Code',
|
|
|
11 |
'rang.href' => 'Href',
|
|
|
12 |
'rang.*' => 'Intitule,Code,Href');
|
163 |
jpm |
13 |
|
|
|
14 |
public function __construct(NomDecorateur $nomDecorateur, Bdd $bdd = null, $ontologieHrefTpl) {
|
|
|
15 |
$this->nomDecorateur = $nomDecorateur;
|
|
|
16 |
$this->rang = $this->nomDecorateur->nom->getTag('rang');
|
|
|
17 |
$this->bdd = is_null($bdd) ? new Bdd() : $bdd;
|
|
|
18 |
$this->ontologieHrefTpl = $ontologieHrefTpl;
|
|
|
19 |
}
|
|
|
20 |
|
|
|
21 |
public function ajouterCode() {
|
|
|
22 |
$squelette = 'bdnt.rangTaxo:%s';
|
|
|
23 |
$rangCode = sprintf($squelette, $this->rang);
|
|
|
24 |
$this->nomDecorateur->nomFormate['rang.code'] = $rangCode;
|
|
|
25 |
}
|
|
|
26 |
|
|
|
27 |
public function ajouterHref() {
|
|
|
28 |
$href = sprintf($this->ontologieHrefTpl, $this->rang);
|
|
|
29 |
$this->nomDecorateur->nomFormate['rang.href'] = $href;
|
|
|
30 |
}
|
|
|
31 |
|
|
|
32 |
public function ajouterIntitule() {
|
|
|
33 |
$resultat = $this->rechercherOntologieNomParCode($this->rang);
|
|
|
34 |
$this->nomDecorateur->nomFormate['rang'] = $resultat['nom'];
|
|
|
35 |
}
|
|
|
36 |
|
188 |
jpm |
37 |
// TODO : supprimer cette recherche dans la bdd de cette classe
|
163 |
jpm |
38 |
private function rechercherOntologieNomParCode($code) {
|
|
|
39 |
$code = $this->bdd->proteger($code);
|
|
|
40 |
$requete = 'SELECT nom '.
|
|
|
41 |
'FROM bdnt_ontologies_v4_30 '.
|
|
|
42 |
"WHERE code = $code ";
|
|
|
43 |
$resultats = $this->bdd->recuperer($requete);
|
|
|
44 |
return $resultats;
|
|
|
45 |
}
|
|
|
46 |
}
|
|
|
47 |
?>
|