Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 188 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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