Subversion Repositories eFlore/Projets.eflore-projets

Compare Revisions

Ignore whitespace Rev 206 → Rev 207

/trunk/services/bibliotheque/Conteneur.php
82,6 → 82,17
return $this->partages['Projet'];
}
 
public function getVersions() {
if (!isset($this->partages['Versions'])){
$parametres = $this->getParametresUrl();
$bdd = $this->getBdd();
$projetNom = $this->getProjet()->getNom();
$versions = new Versions($parametres, $bdd, $projetNom);
$this->partages['Versions'] = $versions;
}
return $this->partages['Versions'];
}
 
public function getBdd() {
if (!isset($this->partages['Bdd'])){
$this->partages['Bdd'] = new Bdd();
91,12 → 102,12
 
public function getService($classe) {
$service = new $classe($this->getRessourcesUrl(), $this->getParametresUrl(), $this->getBdd());
if ($service instanceof NomDetails) {
$service->setDetailsHrefTpl($this->getParametre('detailsHrefTpl'));
$service->setChampsProjet($this->getParametreTableau('champsProjet'));
$service->setOntologieHrefTpl($this->getParametre('ontologieHrefTpl'));
} else if ($service instanceof NomsListe) {
$service->setDetailsHrefTpl($this->getParametre('detailsHrefTpl'));
$service->setProjet($this->getProjet()->getNom());
$service->setVersions($this->getVersions());
$service->setDetailsHrefTpl($this->getParametre('detailsHrefTpl'));
$service->setChampsProjet($this->getParametreTableau('champsProjet'));
$service->setOntologieHrefTpl($this->getParametre('ontologieHrefTpl'));
if ($service instanceof NomsListe) {
$service->setListeUrl($this->getParametre('listeUrl'));
}
return $service;
/trunk/services/bibliotheque/Parametres.php
41,6 → 41,15
return $valeur;
}
 
public function getListe($parametreCode) {
$valeurs = array();
if ($this->exister($parametreCode)) {
$valeurs = explode(',', $this->parametres[$parametreCode]);
$valeurs = array_map('trim', $valeurs);
}
return $valeurs;
}
 
public function exister($parametreCode) {
$existe = false;
if (array_key_exists($parametreCode, $this->parametres) && $this->parametres[$parametreCode] != '') {
/trunk/services/bibliotheque/Projet.php
115,7 → 115,7
}
}
}
$classeNomProjet = $classeNom.ucfirst($this->getNom());
$classeNomProjet = $classeNom.'Generique';//.ucfirst($this->getNom());
return $classeNomProjet;
}
 
/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);
}
?>
/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/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/Versions.php
1,47 → 1,61
<?php
class Versions {
private $parametres = null;
private $projet = null;
private $versions = array();
public function __construct(AnalyseurParametres $parametres, $projetNom) {
private $bdd = null;
private $projetNom = null;
private $versionsDispo = array();
private $versionCourrante = array();
 
public function __construct(Parametres $parametres, Bdd $bdd,$projetNom) {
$this->parametres = $parametres;
$this->projet = $projet;
$this->bdd = $bdd;
$this->projetNom = $projetNom;
$this->versionsDispo = $this->chargerVersionsDisponibles();
}
private function getVersion() {
$version = $this->parametres->getVersionProjet();
$versionBdd = '';
if ($version == '+') {
$versionBdd = Config::get('Versions.derniere');
} else if (is_numeric($version)) {
$versionBdd = str_replace('.', '_', $version);
} else if ($version == '*') {
$message = "La version du projet ne peut valoir * pour cette ressource.";
$code = RestServeur::HTTP_CODE_MAUVAISE_REQUETE;
 
private function chargerVersionsDisponibles() {
$tableMeta = $this->projetNom.'_meta';
$requete = "SELECT version FROM $tableMeta";
$resultat = $this->bdd->recupererTous($requete);
if ($resultat == '') {
//cas ou la requete comporte des erreurs
$message = "La requête SQL de versionnage formée comporte une erreur : $requete";
$code = RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE;
throw new Exception($message, $code);
} elseif ($resultat === false) {
$message = "Versions introuvables dans la table des méta-données";
$code = RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE;
throw new Exception($message, $code);
} else {
foreach ($resultat as $version) {
$versionsDispo[] = $version['version'];
}
}
return $versionBdd;
 
return $versionsDispo;
}
public function chargerVersionsDisponibles() {
$tableMeta = $this->projetNom.'_meta';
$req_version = "SELECT version FROM $tableMeta";
$res_version = $this->getBdd()->recupererTous($req_version);
if ($res_version == '') {
//cas ou la requete comporte des erreurs
$e = "La requête SQL de versionnage formée comporte une erreur : $req_version";
$this->renvoyerErreur(RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE, $e);
} elseif ($res_version) {
foreach ($res_version as $version) {
$versions_dispo[] = $version['version'];
 
public function getVersions() {
$versions = array();
$versionDemandee = $this->parametres->get('version.projet');
if ($versionDemandee == '+') {
$versions[] = end($this->versionsDispo);
} else if (is_numeric($versionDemandee)) {
if (in_array($versionDemandee, $this->versionsDispo)) {
$versions[] = $versionDemandee;
}
} else {
$m = 'Versions introuvables dans la table des méta-données';
$this->renvoyerErreur(RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE, $m);
} else if ($versionDemandee == '*') {
$versions = $this->versionsDispo;
}
return $versions_dispo;
$versions = $this->remplacerPointParUnderscore($versions);
return $versions;
}
 
private function remplacerPointParUnderscore($versions) {
foreach ($versions as $cle => $valeur) {
$versions[$cle] = str_replace('.', '_', $valeur);
}
return $versions;
}
}
?>