Subversion Repositories eFlore/Projets.eflore-projets

Compare Revisions

Ignore whitespace Rev 206 → Rev 207

/trunk/services/bibliotheque/nom/NomFormateur.php
2,46 → 2,123
class NomFormateur {
 
private $nomAFormater = null;
private $decorateurs = array();
private $bdd = null;
private $champsProjet = array();
private $champsRetour = null;
private $detailsHrefTpl = null;
private $ontologieHrefTpl = null;
 
public function __construct(NomDO $nomDO) {
$this->nomAFormater = $nomDO;
}
 
public function formater() {
$nomDeco = new NomDecorateur($this->nomAFormater);
$nomDeco->ajouterId();
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 setBdd($bdd) {
$this->bdd = $bdd;
}
 
public function setOntologieHrefTpl($tpl) {
$this->ontologieHrefTpl = $tpl;
}
 
public function formaterDetails() {
$nomDeco = new NomDecorateur($this->nomAFormater, $this->detailsHrefTpl);
$retenuDeco = new NomRetenuDecorateur($nomDeco, $this->detailsHrefTpl);
$rangDeco = new NomRangDecorateur($nomDeco, $this->bdd, $this->ontologieHrefTpl);
$compoDeco = new NomCompoDecorateur($nomDeco);
$basioDeco = new NomBasionymeDecorateur($nomDeco, $this->detailsHrefTpl);
$projetDeco = new NomChampsProjetDecorateur($nomDeco, $this->champsProjet);
 
if ($this->avoirDemandeChampsRetour()) {
$this->decorateurs[] = $nomDeco;
$this->decorateurs[] = $retenuDeco;
$this->decorateurs[] = $rangDeco;
$this->decorateurs[] = $compoDeco;
$this->decorateurs[] = $basioDeco;
$this->decorateurs[] = $projetDeco;
 
$this->traiterChampsRetour();
} else {
$nomDeco->ajouterId();
$nomDeco->ajouterIntitule();
 
$retenuDeco->ajouterRetenu();
$retenuDeco->ajouterId();
$retenuDeco->ajouterIntitule();
$retenuDeco->ajouterHref();
 
$rangDeco->ajouterCode();
$rangDeco->ajouterIntitule();
$rangDeco->ajouterHref();
 
$compoDeco->ajouterCompo();
 
$nomDeco->ajouterAuteur();
$nomDeco->ajouterAnnee();
$nomDeco->ajouterBiblio();
$nomDeco->ajouterAddendum();
$nomDeco->ajouterNotes();
 
$basioDeco->ajouterId();
$basioDeco->ajouterIntitule();
$basioDeco->ajouterHref();
 
$projetDeco->ajouterChampsSupplementaires();
}
return $nomDeco->getNomFormate();
}
 
public function formaterListe() {
$nomDeco = new NomDecorateur($this->nomAFormater, $this->detailsHrefTpl);
$nomDeco->ajouterIntitule();
 
$retenuDeco = new NomRetenuDecorateur($nomDeco, $this->detailsHrefTpl);
$retenuDeco->ajouterRetenu();
$retenuDeco->ajouterId();
$retenuDeco->ajouterIntitule();
$retenuDeco->ajouterHref();
 
$rangDeco = new NomRangDecorateur($nomDeco, $this->bdd, $this->ontologieHrefTpl);
$rangDeco->ajouterCode();
$rangDeco->ajouterIntitule();
$rangDeco->ajouterHref();
$nomDeco->ajouterHref();
 
$compoDeco = new NomCompoDecorateur($nomDeco);
$compoDeco->ajouterCompo();
if ($this->avoirDemandeChampsRetour()) {
$this->decorateurs[] = $nomDeco;
$this->decorateurs[] = $retenuDeco;
 
$nomDeco->ajouterAuteur();
$nomDeco->ajouterAnnee();
$nomDeco->ajouterBiblio();
$nomDeco->ajouterAddendum();
$nomDeco->ajouterNotes();
$this->decorateurs[] = new NomRangDecorateur($nomDeco, $this->bdd, $this->ontologieHrefTpl);
$this->decorateurs[] = new NomCompoDecorateur($nomDeco);
$this->decorateurs[] = new NomBasionymeDecorateur($nomDeco, $this->detailsHrefTpl);
$this->decorateurs[] = new NomChampsProjetDecorateur($nomDeco, $this->champsProjet);
 
$basioDeco = new NomBasionymeDecorateur($nomDeco, $this->detailsHrefTpl);
$basioDeco->ajouterId();
$basioDeco->ajouterIntitule();
$basioDeco->ajouterHref();
$this->traiterChampsRetour();
}
 
$projetDeco = new NomChampsProjetDecorateur($nomDeco, $this->champsProjet);
$projetDeco->ajouterChampsSupplementaires();
 
return $nomDeco->getNomFormate();
}
 
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) {
$this->champsRetour = $deco->traiterChampsRetour($this->champsRetour);
if (count($this->champsRetour) == 0) {
break;
}
}
}
}
?>
/trunk/services/bibliotheque/nom/decorateurs/NomBasionymeDecorateur.php
5,6 → 5,11
private $basionyme = null;
private $basionymeId = null;
private $detailsHrefTpl = null;
protected $correspondances = array(
'basionyme' => 'Intitule',
'basionyme.id' => 'Id',
'basionyme.href' => 'Href',
'basionyme.*' => 'Intitule,Id,Href');
 
public function __construct(NomDecorateur $nomDecorateur, $detailsHrefTpl) {
$this->nomDecorateur = $nomDecorateur;
/trunk/services/bibliotheque/nom/decorateurs/NomRangDecorateur.php
5,6 → 5,11
private $rang = null;
private $bdd = null;
private $ontologieHrefTpl = null;
protected $correspondances = array(
'rang' => 'Intitule',
'rang.code' => 'Code',
'rang.href' => 'Href',
'rang.*' => 'Intitule,Code,Href');
 
public function __construct(NomDecorateur $nomDecorateur, Bdd $bdd = null, $ontologieHrefTpl) {
$this->nomDecorateur = $nomDecorateur;
/trunk/services/bibliotheque/nom/decorateurs/NomCompoDecorateur.php
1,12 → 1,23
<?php
class NomCompoDecorateur extends NomDecorateur {
 
private $nomDecorateur;
protected $correspondances = array(
'nom_sci.*' => 'Compo',
'nom_sci.supra_generique', 'SupraGenre',
'nom_sci.genre' => 'Genre',
'nom_sci.infra_generique' => 'InfraGenre',
'nom_sci.sp' => 'Sp',
'nom_sci.type_epithete' => 'TypeInfraSp',
'nom_sci.infra_sp' => 'InfraSp',
'nom_sci.cultivar_groupe' => 'CultivarGroupe',
'nom_sci.cultivar' => 'Cultivar',
'nom_sci.nom_commercial' => 'NomCommercial');
 
public function __construct(NomDecorateur $nomDecorateur) {
$this->nomDecorateur = $nomDecorateur;
}
 
public function ajouterCompo() {
$this->ajouterSupraGenre();
$this->ajouterGenre();
18,50 → 29,50
$this->ajouterCultivar();
$this->ajouterNomCommercial();
}
 
public function ajouterSupraGenre() {
$this->ajouterPourChampSonFormatage('nom_supra_generique', 'supra_generique');
}
 
public function ajouterGenre() {
$this->ajouterPourChampSonFormatage('genre', 'genre');
}
 
public function ajouterInfraGenre() {
$this->ajouterPourChampSonFormatage('epithete_infra_generique', 'infra_generique');
}
 
public function ajouterSp() {
$this->ajouterPourChampSonFormatage('epithete_sp', 'sp');
}
 
public function ajouterTypeInfraSp() {
$this->ajouterPourChampSonFormatage('type_epithete', 'type_epithete');
}
 
public function ajouterInfraSp() {
$this->ajouterPourChampSonFormatage('epithete_infra_sp', 'infra_sp');
}
 
public function ajouterCultivarGroupe() {
$this->ajouterPourChampSonFormatage('cultivar_groupe', 'cultivar_groupe');
}
 
public function ajouterCultivar() {
$this->ajouterPourChampSonFormatage('cultivar', 'cultivar');
}
 
public function ajouterNomCommercial() {
$this->ajouterPourChampSonFormatage('nom_commercial', 'nom_commercial');
}
 
private function ajouterPourChampSonFormatage($champ, $format) {
$valeur = $this->nomDecorateur->nom->getTag($champ);
if ($this->exister($valeur)) {
if ($this->exister($valeur)) {
$this->nomDecorateur->nomFormate["nom_sci.$format"] = $valeur;
}
}
 
private function exister($valeur) {
$existe = true;
if (is_null($valeur) || $valeur == '') {
/trunk/services/bibliotheque/nom/decorateurs/NomChampsProjetDecorateur.php
1,14 → 1,29
<?php
class NomChampsProjetDecorateur extends NomDecorateur {
 
private $nomDecorateur = null;
private $champs = array();
protected $correspondances = array();
 
public function __construct(NomDecorateur $nomDecorateur, Array $champs) {
$this->nomDecorateur = $nomDecorateur;
$this->champs = $champs;
$this->correspondances = array_flip($this->champs);
}
 
public function traiterChampsRetour(Array $champsRetour) {
foreach ($champsRetour as $champ) {
if (array_key_exists($champ, $this->correspondances)) {
$champBdd = $this->correspondances[$champ];
$champSortie = $champ;
if ($this->nomDecorateur->nom->verifierTag($champBdd)) {
$valeur = $this->nomDecorateur->nom->getTag($champBdd);
$this->nomDecorateur->nomFormate[$champSortie] = $valeur;
}
}
}
}
 
public function ajouterChampsSupplementaires() {
foreach ($this->champs as $champBdd => $champSortie) {
if ($this->nomDecorateur->nom->verifierTag($champBdd)) {
/trunk/services/bibliotheque/nom/decorateurs/NomDecorateur.php
1,61 → 1,96
<?php
class NomDecorateur {
class NomDecorateur implements NomResponsabilite {
protected $nom = null;
protected $nomFormate = array();
public function __construct(NomDO $nomADecorer) {
private $detailsHrefTpl = null;
protected $correspondances = array(
'id' => 'Id',
'nom_sci' => 'Intitule',
'href' => 'Href',
'auteur' => 'Auteur',
'annee' => 'Annee',
'biblio_origine' => 'Biblio',
'nom_addendum' => 'Addendum',
'notes' => 'Notes',
'homonyme' => 'Homonyme');
 
public function __construct(NomDO $nomADecorer, $detailsHrefTpl) {
$this->nom = $nomADecorer;
$this->detailsHrefTpl = $detailsHrefTpl;
$this->initialiserNomFormate();
}
 
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();
unset($champsRetour[$champ]);
}
}
}
}
return $champsRetour;
}
 
public function ajouterId() {
$this->nomFormate['id'] = (int) $this->nom->getTag('num_nom');
}
 
public function ajouterIntitule() {
$this->nomFormate['nom_sci'] = $this->nom->getTag('nom_sci');
}
 
public function ajouterHref() {
if ($this->nom->verifierTag('num_nom')) {
$href = sprintf($this->detailsHrefTpl, $this->nom->getTag('num_nom'));
$this->nomFormate['href'] = $href;
}
}
 
public function ajouterAuteur() {
if ($this->nom->verifierTag('auteur')) {
$this->nomFormate['auteur'] = $this->nom->getTag('auteur');
}
}
 
public function ajouterAnnee() {
if ($this->nom->verifierTag('annee')) {
$this->nomFormate['annee'] = $this->nom->getTag('annee');
}
}
 
public function ajouterBiblio() {
if ($this->nom->verifierTag('biblio_origine')) {
$this->nomFormate['biblio_origine'] = $this->nom->getTag('biblio_origine');
}
}
 
public function ajouterAddendum() {
if ($this->nom->verifierTag('nom_addendum')) {
$this->nomFormate['nom_addendum'] = $this->nom->getTag('nom_addendum');
}
}
 
public function ajouterNotes() {
if ($this->nom->verifierTag('notes')) {
$this->nomFormate['notes'] = $this->nom->getTag('notes');
}
}
 
public function ajouterHomonyme() {
if ($this->nom->verifierTag('homonyme') && $this->nom->getTag('homonyme') == 1) {
$this->nomFormate['homonyme'] = true;
}
}
 
public function initialiserNomFormate() {
$this->nomFormate = array();
}
 
public function getNomFormate() {
return $this->nomFormate;
}
/trunk/services/bibliotheque/nom/decorateurs/NomRetenuDecorateur.php
6,6 → 6,12
private $numNomRetenu = null;
private $nomSciRetenu = null;
private $detailsHrefTpl = null;
protected $correspondances = array(
'retenu' => 'Retenu',
'nom_retenu' => 'Intitule',
'nom_retenu.id' => 'Id',
'nom_retenu.href' => 'Href',
'nom_retenu.*' => 'Intitule,Id,Href');
 
public function __construct(NomDecorateur $nomDecorateur, $detailsHrefTpl) {
$this->nomDecorateur = $nomDecorateur;
/trunk/services/bibliotheque/nom/decorateurs/NomResponsabilite.php
New file
0,0 → 1,5
<?php
interface NomResponsabilite {
public function traiterChampsRetour(Array $champsRetour);
}
?>