/trunk/services/modules/0.2/prometheus/OntologiesListePrometheus.php |
---|
New file |
0,0 → 1,14 |
<?php |
class OntologiesListePrometheus implements OntologiesListe { |
private $ontologiesListe = null; |
public function __construct(OntologiesListeGenerique $ontologiesListe) { |
$this->ontologiesListe = $ontologiesListe; |
} |
public function consulter() { |
return $this->ontologiesListe->consulter(); |
} |
} |
?> |
/trunk/services/configurations/config_prometheus.ini |
---|
New file |
0,0 → 1,56 |
; Encodage : UTF-8 |
; Nom du projet |
nomProjet = "prometheus" |
; Nom de la table principalement utilisée. |
bddTable= "prometheus" |
; Nom de la table métadonnées utilisée. |
bddTableMeta = "prometheus_meta" |
; +------------------------------------------------------------------------------------------------------+ |
; Paramètres pour la V2 |
baseServiceUrl = "{ref:url_base}service:eflore:0.2/" |
baseProjetUrl = "{ref:baseServiceUrl}prometheus/" |
listeUrlOntologies = "{ref:baseProjetUrl}ontologies" |
detailsHrefOntologiesTpl = "{ref:baseProjetUrl}ontologies/%s" |
; Config spécifique au projet |
; Noms des ressources disponible pour ce projet |
servicesDispo = "meta-donnees,aide,ontologies" |
; Paramètres de l'api |
parametresAPI = " |
recherche, |
navigation.depart, |
navigation.limite, |
masque, |
masque.code, |
masque.nom, |
masque.description, |
retour, |
retour.format, |
retour.champs, |
retour.langue, |
version.projet, |
contexte" |
; Champs supplémentaires spécifique au projet : champsBdd = champsSortie (dans Json) |
champsProjet = " |
notes = notes, |
preference = preference, |
auteur.id = a.id_auteur, |
publication.id = ce_publication, |
image.id = i.id_image, |
prenom = auteur.prenom, |
a.nom = auteur.nom, |
a.naissance_date = auteur.naissance.date, |
a.deces_date = auteur.deces.date, |
p.ce_auteur_principal = publication.auteur.id, |
p.titre = publication.titre, |
p.date = publication.date, |
p.uri = publication.uri, |
i.uri = image.uri |
i.ce_publication = image.publicaiton.id |
" |
/trunk/services/bibliotheque/Ressources.php |
---|
65,6 → 65,8 |
$classeNom = 'NomsListe'; |
} else if ($this->getServiceNom() == 'taxons') { |
$classeNom = 'TaxonsListe'; |
} else if ($this->getServiceNom() == 'ontologies') { |
$classeNom = 'OntologiesListe'; |
} |
} else if ($this->getNombre() == 3) { |
/trunk/services/bibliotheque/interfaces/OntologiesListe.php |
---|
New file |
0,0 → 1,6 |
<?php |
interface OntologiesListe { |
public function __construct(OntologiesListeGenerique $ontologiesListe); |
public function consulter(); |
} |
?> |
/trunk/services/bibliotheque/generique/OntologiesListeGenerique.php |
---|
New file |
0,0 → 1,157 |
<?php |
class OntologiesListeGenerique { |
private $parametres = null; |
private $ressources = null; |
private $ontologieDao = null; |
private $ontologieFormateur = null; |
private $listeUrl = null; |
private $nbreTotalTermes = 0; |
private $termes = array(); |
public function __construct(Ressources $ressources, Parametres $parametres, OntologieDAO $ontologieDao, OntologieFormateur $ontologieFormateur) { |
$this->ressources = $ressources; |
$this->parametres = $parametres; |
$this->ontologieDao = $ontologieDao; |
$this->ontologieFormateur = $ontologieFormateur; |
} |
public function setListeUrl($url) { |
$this->listeUrl = $url; |
} |
public function consulter() { |
$this->rechercher(); |
if ($this->avoirResultats()) { |
$this->trierResultats(); |
$retour = $this->construireTableauRetour(); |
} else { |
$message = "Aucun résultat ne correspond a votre requête !"; |
$code = RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE; |
throw new Exception($message, $code); |
} |
return $retour; |
} |
private function rechercher() { |
$resultats = array(); |
$resultats = $this->ontologieDao->rechercher(); |
$this->termes = $resultats; |
$this->nbreTotalTermes = $this->ontologieDao->recupererNombreTermesTotal(); |
} |
private function avoirResultats() { |
$resultat = ($this->nbreTotalTermes == 0) ? false : true; |
return $resultat; |
} |
private function trierResultats() { |
$recherche = $this->parametres->get('recherche'); |
if ($recherche == 'floue') { |
$this->termes = $this->ontologieDao->trierResultatsFloue($this->termes); |
} |
} |
private function construireTableauRetour() { |
$retour = array('entete' => array(), 'resultats' => array()); |
$retour['resultats'] = $this->construireResultats(); |
$retour['entete'] = $this->construireEntete(); |
return $retour; |
} |
private function construireResultats() { |
$nomsFormates = array(); |
foreach ($this->termes as $terme) { |
$id = $terme['id_terme']; |
$termesFormates[$id] = $this->formaterTerme($terme); |
} |
return $termesFormates; |
} |
private function formaterTerme($infos) { |
$termeAFormater = new OntologieDO($infos); |
$this->ontologieFormateur->setTermeAFormater($termeAFormater); |
$this->ontologieFormateur->setChampsRetour($this->parametres->getListe('retour.champs')); |
$terme = $this->ontologieFormateur->formaterListe(); |
return $terme; |
} |
private function construireEntete() { |
$entete = array('masque' => '', 'depart' => 0, 'limite' => 100, 'total' => 0); |
$entete['masque'] = $this->formaterEnteteMasque(); |
$entete['depart'] = (int) $this->parametres->get('navigation.depart'); |
$entete['limite'] = (int) $this->parametres->get('navigation.limite'); |
$entete['total'] = $this->nbreTotalTermes; |
if ($hrefPrecedent = $this->formaterEnteteHrefPrecedent()) { |
$entete['href.precedent'] = $hrefPrecedent; |
} |
if ($hrefSuivant = $this->formaterEnteteHrefSuivant()) { |
$entete['href.suivant'] = $hrefSuivant; |
} |
return $entete; |
} |
private function formaterEnteteMasque() { |
$masquesStrictes = array('code'); |
$paramsMasque = array( |
'' => 'terme', |
'code' => 'id_terme', |
'nom' => 'terme', |
'description' => 'definition'); |
$etendre = ($this->parametres->get('recherche') == 'etendue') ? true : false; |
$masqueComplet = array(); |
foreach ($paramsMasque as $masqueType => $champ) { |
$masqueParam = 'masque'.($masqueType != '' ? '.'.$masqueType : $masqueType); |
if ($this->parametres->exister($masqueParam)) { |
$masqueValeur = $this->parametres->get($masqueParam); |
$masque = "$champ=$masqueValeur"; |
$masque .= ($etendre && in_array($masqueType, $masquesStrictes) === false) ? '%' : ''; |
$masqueComplet[] = $masque; |
} |
} |
return implode('&', $masqueComplet); |
} |
private function formaterEnteteHrefPrecedent() { |
$limite = $this->parametres->get('navigation.limite'); |
$departActuel = $this->parametres->get('navigation.depart'); |
$departPrecedent = $departActuel - $limite; |
$href = null; |
if ($departPrecedent >= 0) { |
$squelette = $this->construireTplHrefNavigation(); |
$href = sprintf($squelette, $departPrecedent, $limite); |
} |
return $href; |
} |
private function formaterEnteteHrefSuivant() { |
$limite = $this->parametres->get('navigation.limite'); |
$departActuel = $this->parametres->get('navigation.depart'); |
$departSuivant = $departActuel + $limite; |
$href = null; |
if ($departSuivant < $this->nbreTotalTermes) { |
$squelette = $this->construireTplHrefNavigation(); |
$href = sprintf($squelette, $departSuivant, $limite); |
} |
return $href; |
} |
private function construireTplHrefNavigation() { |
$requetes = array(); |
$this->parametres->rewind(); |
while (is_null($parametre = $this->parametres->key()) === false) { |
if (strpos($parametre, 'navigation') === false) { |
$valeur = $this->parametres->current(); |
$requetes[] = "$parametre=$valeur"; |
} |
$this->parametres->next(); |
} |
$requetes[] = "navigation.depart=%s"; |
$requetes[] = "navigation.limite=%s"; |
$tpl = $this->listeUrl.'?'.implode('&', $requetes); |
return $tpl; |
} |
} |
/trunk/services/bibliotheque/Conteneur.php |
---|
121,6 → 121,15 |
return $nomDao; |
} |
public function getOntologiesDao() { |
$ressources = $this->getRessourcesUrl(); |
$parametres = $this->getParametresUrl(); |
$bdd = $this->getBdd(); |
$versions = $this->getVersions(); |
$ontologieDao = new OntologieDAO($ressources, $parametres, $bdd, $versions); |
return $ontologieDao; |
} |
public function getNomFormateur() { |
$formateur = new NomFormateur(); |
$formateur->setBdd($this->getBdd()); |
130,13 → 139,31 |
return $formateur; |
} |
public function getOntologiesFormateur() { |
$formateur = new OntologieFormateur(); |
$formateur->setBdd($this->getBdd()); |
$formateur->setChampsProjet($this->getParametreTableau('champsProjet')); |
$formateur->setDetailsHrefTpl($this->getParametre('detailsHrefOntologiesTpl')); |
$formateur->setLangueDemandee($this->getParametresUrl()->get('retour.langue')); |
return $formateur; |
} |
public function getServiceGenerique() { |
$classe = $this->getRessourcesUrl()->getServiceClasse(); |
$ressources = $this->getRessourcesUrl(); |
$classe = $ressources->getServiceClasse(); |
$classeGenerique = $classe.'Generique'; |
$service = new $classeGenerique($this->getRessourcesUrl(), $this->getParametresUrl(), $this->getNomDao(), $this->getNomFormateur()); |
if ($classe == 'NomsListe') { |
$service->setListeUrl($this->getParametre('listeUrl')); |
if ($ressources->getServiceNom() == 'noms' || $ressources->getServiceNom() == 'taxons') { |
$service = new $classeGenerique($this->getRessourcesUrl(), $this->getParametresUrl(), $this->getNomDao(), $this->getNomFormateur()); |
if ($classe == 'NomsListe') { |
$service->setListeUrl($this->getParametre('listeUrl')); |
} |
} else if ($ressources->getServiceNom() == 'ontologies') { |
$service = new $classeGenerique($this->getRessourcesUrl(), $this->getParametresUrl(), $this->getOntologiesDao(), $this->getOntologiesFormateur()); |
if ($classe == 'OntologiesListe') { |
$service->setListeUrl($this->getParametre('listeUrlOntologies')); |
} |
} |
return $service; |
} |
} |
/trunk/services/bibliotheque/Projet.php |
---|
78,6 → 78,8 |
$chemins[] = $this->cheminBiblio.'interfaces'.DS; |
$chemins[] = $this->cheminBiblio.'nom'.DS; |
$chemins[] = $this->cheminBiblio.'nom'.DS.'decorateurs'.DS; |
$chemins[] = $this->cheminBiblio.'ontologie'.DS; |
$chemins[] = $this->cheminBiblio.'ontologie'.DS.'decorateurs'.DS; |
foreach ($chemins as $chemin) { |
$chemin = $chemin.$classe.'.php'; |
/trunk/services/bibliotheque/ontologie/OntologieDO.php |
---|
New file |
0,0 → 1,21 |
<?php |
class OntologieDO { |
private $infos; |
public function __construct(Array $infos) { |
$this->infos = $infos; |
} |
public function getTag($tag) { |
return isset($this->infos[$tag]) ? $this->infos[$tag] : null; |
} |
public function verifierTag($tag) { |
$existe = true; |
if ($this->getTag($tag) == null || $this->getTag($tag) == '') { |
$existe = false; |
} |
return $existe; |
} |
} |
?> |
/trunk/services/bibliotheque/ontologie/OntologieDAO.php |
---|
New file |
0,0 → 1,202 |
<?php |
class OntologieDAO { |
private $bdd = null; |
private $versions = null; |
private $requeteNbreTermesTotal = null; |
private $masquesStrictes = array(); |
private $paramsMasque = array(); |
public function __construct(Ressources $ressources, Parametres $parametres, Bdd $bdd, Versions $versions) { |
$this->ressources = $ressources; |
$this->parametres = $parametres; |
$this->bdd = $bdd; |
$this->versions = $versions; |
$this->masquesStrictes = array('code'); |
$this->paramsMasque = array( |
'' => 'nom', |
'code' => 'id_terme', |
'nom' => $this->getChampPourLangue('nom'), |
'description' => $this->getChampPourLangue('description')); |
} |
public function getDetails() { |
$table = $this->getTableTerme(); |
$tableType = $this->getTableType(); |
$detailsId = $this->ressources->getDetailsId(); |
$detailsId = $this->bdd->proteger($detailsId); |
$requete = |
'SELECT o.*, type '. |
"FROM $table AS o ". |
" LEFT JOIN $tableType ON (ce_type = id_type) ". |
"WHERE id_terme = $detailsId "; |
$resultats = $this->bdd->recuperer($requete); |
$terme = new OntologieDO($resultats); |
return $terme; |
} |
public function rechercher() { |
$clause = $this->getClauseSelectSpeciale(); |
$table = $this->getTableTerme(); |
$tableType = $this->getTableType(); |
$tablePublication = $this->getTablePublication(); |
$tableAuteur = $this->getTableAuteur(); |
$tableImage = $this->getTableImage(); |
$conditions = $this->getConditions(); |
$where = $this->getWhere($conditions); |
$ordre = $this->getOrdre(); |
$navigation = $this->getNavigation(); |
$requete = "SELECT $clause o.*, t.type, p.*, a.*, i.* ". |
"FROM $table AS o ". |
" LEFT JOIN $tableType AS t ON (ce_type = id_type) ". |
" LEFT JOIN $tablePublication AS p ON (ce_publication = id_publication) ". |
" LEFT JOIN $tableAuteur AS a ON (ce_auteur = id_auteur) ". |
" LEFT JOIN $tableImage AS i ON (ce_image = id_image) ". |
$where.' '.$conditions.' '.$ordre.' '. |
"LIMIT $navigation "; |
//die($requete); |
$this->requeteNbreNomsTotal = $this->transformerRequetePourNbreTermesTotal($requete); |
$resultats = $this->bdd->recupererTous($requete); |
return $resultats; |
} |
private function getClauseSelectSpeciale() { |
$clause = (Config::get('bdd_protocole') == 'mysql') ? 'SQL_CALC_FOUND_ROWS' : ''; |
return $clause; |
} |
private function getTableTerme() { |
return sprintf($this->getNomTableTpl(), 'terme'); |
} |
private function getTableType() { |
return sprintf($this->getNomTableTpl(), 'type'); |
} |
private function getTablePublication() { |
return sprintf($this->getNomTableTpl(), 'publication'); |
} |
private function getTableAuteur() { |
return sprintf($this->getNomTableTpl(), 'auteur'); |
} |
private function getTableImage() { |
return sprintf($this->getNomTableTpl(), 'image'); |
} |
private function getTableHierarchie() { |
return sprintf($this->getNomTableTpl(), 'hierarchie'); |
} |
private function getNomTableTpl() { |
$versions = $this->versions->getVersions(); |
$derniereVersion = end($versions); |
$projetNom = strtolower($this->ressources->getProjetNom()); |
return $projetNom.'_ontologies_%s_v'.$derniereVersion; |
} |
private function getConditions() { |
$operateurParDefaut = $this->getOperateurCondition(); |
$conditionsSql = array(); |
foreach ($this->paramsMasque as $typeMasque => $champ) { |
$operateur = in_array($typeMasque, $this->masquesStrictes) ? '=' : $operateurParDefaut; |
if ($valeurMasque = $this->parametres->getMasquePourBdd($typeMasque)) { |
if ($operateur == 'SOUNDEX') { |
$tpl = '(SOUNDEX(%s) = SOUNDEX(%s)) OR (SOUNDEX(REVERSE(%s)) = SOUNDEX(REVERSE(%s))) '; |
$conditionsSql[] = sprintf($tpl, $champ, $valeurMasque, $champ, $valeurMasque); |
} else { |
$conditionsSql[] = "$champ $operateur $valeurMasque"; |
} |
} |
} |
return implode(' AND ', $conditionsSql); |
} |
private function getOperateurCondition() { |
$operateur = ''; |
$recherche = $this->parametres->get('recherche'); |
if ($recherche == 'stricte') { |
$operateur = '='; |
} else if ($recherche == 'etendue') { |
$operateur = 'LIKE'; |
} else if ($recherche == 'floue') { |
$operateur = 'SOUNDEX'; |
} |
return $operateur; |
} |
private function getWhere($conditions = '') { |
$where = ''; |
if ($conditions != '') { |
$where = 'WHERE '; |
} |
return $where; |
} |
private function getOrdre() { |
$champNom = $this->getChampPourLangue('nom'); |
$ordre = "ORDER BY $champNom ASC "; |
return $ordre; |
} |
private function getChampPourLangue($champ) { |
$lg = $this->parametres->get('retour.langue'); |
if ($lg == 'en') { |
$champ .= '_en'; |
} |
return $champ; |
} |
private function getNavigation() { |
$debut = (int) $this->parametres->get('navigation.depart'); |
$nbre = $this->parametres->get('navigation.limite'); |
$navigation = "$debut,$nbre"; |
return $navigation; |
} |
private function transformerRequetePourNbreTermesTotal($requete) { |
$requete = preg_replace('/SELECT .* FROM/', 'SELECT COUNT(*) AS nbre FROM', $requete); |
$requete = preg_replace('/LIMIT [0-9]+,[0-9]+/', '', $requete); |
return $requete; |
} |
public function trierResultatsFloue($termes) { |
foreach ($this->paramsMasque as $typeMasque => $champ) { |
if ($termeDemande = $this->parametres->getMasquePourBdd($typeMasque)) { |
$termeDemandeSimple = strtolower(Chaine::supprimerAccents($termeDemande)); |
foreach ($termes as $id => $terme) { |
$termeFlouSimple = strtolower(Chaine::supprimerAccents($terme[$this->getChampPourLangue('nom')])); |
// Prime pour la ressemblance globale : |
$leven = levenshtein($termeFlouSimple, $termeDemandeSimple); |
// On affine |
$similar = similar_text($termeDemandeSimple, $termeFlouSimple) * 3; |
// Prime Soundex |
$soundex = (soundex($termeDemandeSimple) == soundex($termeFlouSimple)) ? 1000 : 0; |
// Calcul du score |
$score = 500 - $leven + $similar + $soundex; |
$termes[$id]['score'] = $score; |
$termes[$id]['score_calcul'] = "$termeDemandeSimple / $termeFlouSimple : 500 - $leven + $similar + $soundex = $score"; |
} |
$termes = Tableau::trierMD($termes, array('score' => SORT_DESC)); |
} |
} |
//echo 'ici<pre>'.print_r($termes, true).'</pre>';die(); |
return $termes; |
} |
public function recupererNombreTermesTotal() { |
if (Config::get('bdd_protocole') == 'mysql') { |
$requete = 'SELECT FOUND_ROWS() AS nbre'; |
} else { |
$requete = $this->requeteNbreNomsTotal; |
} |
$nombre = $this->bdd->recuperer($requete); |
return (int) $nombre['nbre']; |
} |
} |
?> |
/trunk/services/bibliotheque/ontologie/OntologieFormateur.php |
---|
New file |
0,0 → 1,89 |
<?php |
class OntologieFormateur { |
private $termeAFormater = null; |
private $decorateurs = array(); |
private $bdd = null; |
private $champsProjet = array(); |
private $champsRetour = null; |
private $detailsHrefTpl = null; |
private $langueDemandee = null; |
public function setTermeAFormater(OntologieDO $ontologieDO) { |
$this->termeAFormater = $ontologieDO; |
} |
public function setChampsRetour(Array $champsRetour) { |
$this->champsRetour = $champsRetour; |
} |
public function setChampsProjet(Array $champsProjet) { |
$this->champsProjet = $champsProjet; |
} |
public function setDetailsHrefTpl($tpl) { |
$this->detailsHrefTpl = $tpl; |
} |
public function setLangueDemandee($langue) { |
$this->langueDemandee = $langue; |
} |
public function setBdd($bdd) { |
$this->bdd = $bdd; |
} |
public function formaterDetails() { |
$termeDeco = new OntologieDecorateur($this->termeAFormater, $this->detailsHrefTpl, $this->langueDemandee); |
$projetDeco = new OntologieChampsProjetDecorateur($termeDeco, $this->champsProjet); |
if ($this->avoirDemandeChampsRetour()) { |
$this->decorateurs[] = $termeDeco; |
$this->decorateurs[] = $projetDeco; |
$this->traiterChampsRetour(); |
} else { |
$termeDeco->ajouterId(); |
$termeDeco->ajouterIntitule(); |
$termeDeco->ajouterDescription(); |
$termeDeco->ajouterClasseId(); |
$termeDeco->ajouterClasse(); |
$termeDeco->ajouterClasseHref(); |
$projetDeco->ajouterChampsSupplementaires(); |
} |
return $termeDeco->getTermeFormate(); |
} |
public function formaterListe() { |
$termeDeco = new OntologieDecorateur($this->termeAFormater, $this->detailsHrefTpl, $this->langueDemandee); |
$termeDeco->ajouterId(); |
$termeDeco->ajouterIntitule(); |
$termeDeco->ajouterHref(); |
if ($this->avoirDemandeChampsRetour()) { |
$this->decorateurs[] = $termeDeco; |
$this->decorateurs[] = new OntologieChampsProjetDecorateur($termeDeco, $this->champsProjet); |
$this->traiterChampsRetour(); |
} |
return $termeDeco->getTermeFormate(); |
} |
private function avoirDemandeChampsRetour() { |
$demande = true; |
if ($this->champsRetour === null || count($this->champsRetour) == 0) { |
$demande = false; |
} |
return $demande; |
} |
private function traiterChampsRetour() { |
foreach ($this->decorateurs as $deco) { |
$deco->traiterChampsRetour($this->champsRetour); |
} |
} |
} |
?> |
/trunk/services/bibliotheque/ontologie/decorateurs/OntologieResponsabilite.php |
---|
New file |
0,0 → 1,5 |
<?php |
interface OntologieResponsabilite { |
public function traiterChampsRetour(Array $champsRetour); |
} |
?> |
/trunk/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; |
} |
} |
} |
} |
?> |
/trunk/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; |
} |
} |
?> |