Subversion Repositories eFlore/Projets.eflore-projets

Compare Revisions

Ignore whitespace Rev 843 → Rev 912

/tags/v5.0-agropyraie-20130829/services/bibliotheque/ontologie/decorateurs/OntologieChampsProjetDecorateur.php
New file
0,0 → 1,38
<?php
class OntologieChampsProjetDecorateur extends OntologieDecorateur {
 
private $ontologieDecorateur = null;
private $champs = array();
protected $correspondances = array();
 
public function __construct(OntologieDecorateur $ontologieDecorateur, Array $champs) {
$this->ontologieDecorateur = $ontologieDecorateur;
$this->champs = $champs;
$this->correspondances = array_flip($this->champs);
}
 
public function traiterChampsRetour(Array $champsRetour) {
//die(print_r($this->correspondances,true));
foreach ($champsRetour as $champ) {
if (array_key_exists($champ, $this->correspondances)) {
$champBdd = $this->correspondances[$champ];
$champSortie = $champ;
//die(print_r($this->ontologieDecorateur->terme,true));
if ($this->ontologieDecorateur->terme->verifierTag($champBdd)) {
$valeur = $this->ontologieDecorateur->terme->getTag($champBdd);
$this->ontologieDecorateur->termeFormate[$champSortie] = $valeur;
}
}
}
}
 
public function ajouterChampsSupplementaires() {
foreach ($this->champs as $champBdd => $champSortie) {
if ($this->ontologieDecorateur->terme->verifierTag($champBdd)) {
$valeur = $this->ontologieDecorateur->terme->getTag($champBdd);
$this->ontologieDecorateur->termeFormate[$champSortie] = $valeur;
}
}
}
}
?>
/tags/v5.0-agropyraie-20130829/services/bibliotheque/ontologie/decorateurs/OntologieDecorateur.php
New file
0,0 → 1,92
<?php
class OntologieDecorateur implements OntologieResponsabilite {
protected $terme = null;
protected $termeFormate = array();
private $detailsHrefTpl = null;
private $langueDemandee = null;
protected $correspondances = array(
'id' => 'Id',
'nom' => 'Intitule',
'description' => 'Description',
'href' => 'Href',
'classe' => 'Classe',
'classe.id' => 'ClasseId',
'classe.href' => 'ClasseHref',
'classe.*' => 'ClasseId,Classe,ClasseHref');
 
public function __construct(OntologieDO $termeADecorer, $detailsHrefTpl, $langueDemandee) {
$this->terme = $termeADecorer;
$this->detailsHrefTpl = $detailsHrefTpl;
$this->langueDemandee = $langueDemandee;
$this->initialiserTermeFormate();
}
 
public function traiterChampsRetour(Array $champsRetour) {
foreach ($champsRetour as $champ) {
if (array_key_exists($champ, $this->correspondances)) {
$methodesAExecuter = explode(',', $this->correspondances[$champ]);
foreach ($methodesAExecuter as $methodeNom) {
$methodeAjouter = 'ajouter'.$methodeNom;
if (method_exists($this, $methodeAjouter)) {
$this->$methodeAjouter();
}
}
}
}
}
 
public function ajouterId() {
$this->termeFormate['id'] = (int) $this->terme->getTag('id_terme');
}
 
public function ajouterIntitule() {
if ($this->langueDemandee == 'en') {
$this->termeFormate['nom'] = $this->terme->getTag('nom_en');
} else {
$this->termeFormate['nom'] = $this->terme->getTag('nom');
}
}
 
public function ajouterDescription() {
if ($this->langueDemandee == 'en') {
if ($this->terme->verifierTag('description_en')) {
$this->termeFormate['description'] = $this->terme->getTag('description_en');
}
} else {
if ($this->terme->verifierTag('description')) {
$this->termeFormate['description'] = $this->terme->getTag('description');
}
}
}
 
public function ajouterHref() {
if ($this->terme->verifierTag('id_terme')) {
$href = sprintf($this->detailsHrefTpl, $this->terme->getTag('id_terme'));
$this->termeFormate['href'] = $href;
}
}
 
public function ajouterClasseId() {
$this->termeFormate['classe.id'] = (int) $this->terme->getTag('ce_type');
}
 
public function ajouterClasse() {
$this->termeFormate['classe'] = (string) $this->terme->getTag('type');
}
 
public function ajouterClasseHref() {
if ($this->terme->verifierTag('ce_type')) {
$href = sprintf($this->detailsHrefTpl, $this->terme->getTag('ce_type'));
$this->termeFormate['classe.href'] = $href;
}
}
 
public function initialiserTermeFormate() {
$this->termeFormate = array();
}
 
public function getTermeFormate() {
return $this->termeFormate;
}
}
?>
/tags/v5.0-agropyraie-20130829/services/bibliotheque/ontologie/decorateurs/OntologieResponsabilite.php
New file
0,0 → 1,5
<?php
interface OntologieResponsabilite {
public function traiterChampsRetour(Array $champsRetour);
}
?>