/tags/v0.1-20130829/services/bibliotheque/nom/decorateurs/NomCompoDecorateur.php |
---|
New file |
0,0 → 1,84 |
<?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(); |
$this->ajouterInfraGenre(); |
$this->ajouterSp(); |
$this->ajouterTypeInfraSp(); |
$this->ajouterInfraSp(); |
$this->ajouterCultivarGroupe(); |
$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)) { |
$this->nomDecorateur->nomFormate["nom_sci.$format"] = $valeur; |
} |
} |
private function exister($valeur) { |
$existe = true; |
if (is_null($valeur) || $valeur == '') { |
$existe = false; |
} |
return $existe; |
} |
} |
?> |
/tags/v0.1-20130829/services/bibliotheque/nom/decorateurs/NomChampsProjetDecorateur.php |
---|
New file |
0,0 → 1,36 |
<?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)) { |
$valeur = $this->nomDecorateur->nom->getTag($champBdd); |
$this->nomDecorateur->nomFormate[$champSortie] = $valeur; |
} |
} |
} |
} |
?> |
/tags/v0.1-20130829/services/bibliotheque/nom/decorateurs/NomDecorateur.php |
---|
New file |
0,0 → 1,96 |
<?php |
class NomDecorateur implements NomResponsabilite { |
protected $nom = null; |
protected $nomFormate = array(); |
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(); |
} |
} |
} |
} |
} |
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; |
} |
} |
?> |
/tags/v0.1-20130829/services/bibliotheque/nom/decorateurs/NomRetenuDecorateur.php |
---|
New file |
0,0 → 1,47 |
<?php |
class NomRetenuDecorateur extends NomDecorateur { |
private $nomDecorateur = null; |
private $numNom = null; |
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; |
$this->numNom = $this->nomDecorateur->nom->getTag('num_nom'); |
$this->numNomRetenu = $this->nomDecorateur->nom->getTag('num_nom_retenu'); |
$this->nomSciRetenu = $this->nomDecorateur->nom->getTag('nr_nom_sci'); |
$this->detailsHrefTpl = $detailsHrefTpl; |
} |
public function ajouterRetenu() { |
$nn = (int) $this->numNom; |
$nnr = (int) $this->numNomRetenu; |
$this->nomDecorateur->nomFormate['retenu'] = ($nn == $nnr) ? true : false; |
} |
public function ajouterId() { |
if (empty($this->numNomRetenu) === false) { |
$this->nomDecorateur->nomFormate['nom_retenu.id'] = (int) $this->numNomRetenu; |
} |
} |
public function ajouterHref() { |
if (empty($this->numNomRetenu) === false) { |
$href = sprintf($this->detailsHrefTpl, $this->numNomRetenu); |
$this->nomDecorateur->nomFormate['nom_retenu.href'] = $href; |
} |
} |
public function ajouterIntitule() { |
$this->nomDecorateur->nomFormate['nom_retenu'] = $this->nomSciRetenu; |
} |
} |
?> |
/tags/v0.1-20130829/services/bibliotheque/nom/decorateurs/NomResponsabilite.php |
---|
New file |
0,0 → 1,5 |
<?php |
interface NomResponsabilite { |
public function traiterChampsRetour(Array $champsRetour); |
} |
?> |
/tags/v0.1-20130829/services/bibliotheque/nom/decorateurs/NomBasionymeDecorateur.php |
---|
New file |
0,0 → 1,44 |
<?php |
class NomBasionymeDecorateur extends NomDecorateur { |
private $nomDecorateur = null; |
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; |
$this->detailsHrefTpl = $detailsHrefTpl; |
if ($this->nomDecorateur->nom->verifierTag('basionyme')) { |
$this->basionymeId = $this->nomDecorateur->nom->getTag('basionyme'); |
} |
if ($this->nomDecorateur->nom->verifierTag('nb_nom_sci')) { |
$this->basionyme = $this->nomDecorateur->nom->getTag('nb_nom_sci'); |
} |
} |
public function ajouterId() { |
if (is_null($this->basionymeId) === false) { |
$this->nomDecorateur->nomFormate['basionyme.id'] = $this->basionymeId; |
} |
} |
public function ajouterHref() { |
if (is_null($this->basionymeId) === false) { |
$href = sprintf($this->detailsHrefTpl, $this->basionymeId); |
$this->nomDecorateur->nomFormate['basionyme.href'] = $href; |
} |
} |
public function ajouterIntitule() { |
if (is_null($this->basionyme) === false) { |
$this->nomDecorateur->nomFormate['basionyme'] = $this->basionyme; |
} |
} |
} |
?> |
/tags/v0.1-20130829/services/bibliotheque/nom/decorateurs/NomRangDecorateur.php |
---|
New file |
0,0 → 1,47 |
<?php |
class NomRangDecorateur extends NomDecorateur { |
private $nomDecorateur = null; |
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; |
$this->rang = $this->nomDecorateur->nom->getTag('rang'); |
$this->bdd = is_null($bdd) ? new Bdd() : $bdd; |
$this->ontologieHrefTpl = $ontologieHrefTpl; |
} |
public function ajouterCode() { |
$squelette = 'bdnt.rangTaxo:%s'; |
$rangCode = sprintf($squelette, $this->rang); |
$this->nomDecorateur->nomFormate['rang.code'] = $rangCode; |
} |
public function ajouterHref() { |
$href = sprintf($this->ontologieHrefTpl, $this->rang); |
$this->nomDecorateur->nomFormate['rang.href'] = $href; |
} |
public function ajouterIntitule() { |
$resultat = $this->rechercherOntologieNomParCode($this->rang); |
$this->nomDecorateur->nomFormate['rang'] = $resultat['nom']; |
} |
// TODO : supprimer cette recherche dans la bdd de cette classe |
private function rechercherOntologieNomParCode($code) { |
$code = $this->bdd->proteger($code); |
$requete = 'SELECT nom '. |
'FROM bdnt_ontologies_v4_30 '. |
"WHERE code = $code "; |
$resultats = $this->bdd->recuperer($requete); |
return $resultats; |
} |
} |
?> |