Subversion Repositories eFlore/Projets.eflore-projets

Compare Revisions

Ignore whitespace Rev 207 → Rev 208

/trunk/services/modules/0.2/commun/NomsListeGenerique.php
3,43 → 3,20
 
private $parametres = null;
private $ressources = null;
private $bdd = null;
private $projet = null;
private $versions = null;
private $nomDao = null;
private $nomFormateur = null;
 
private $listeUrl = null;
private $detailsHrefTpl = null;
private $ontologieHrefTpl = null;
private $champsProjet = array();
 
private $nbreTotalNoms = 0;
private $noms = array();
 
public function __construct(Ressources $ressources, Parametres $parametres, Bdd $bdd) {
public function __construct(Ressources $ressources, Parametres $parametres, NomDAO $nomDao, NomFormateur $nomFormateur) {
$this->ressources = $ressources;
$this->parametres = $parametres;
$this->bdd = $bdd;
$this->nomDao = $nomDao;
$this->nomFormateur = $nomFormateur;
}
 
public function setProjet($projet) {
$this->projet = $projet;
}
 
public function setVersions($versions) {
$this->versions = $versions;
}
 
public function setChampsProjet($champsProjet) {
$this->champsProjet = $champsProjet;
}
 
public function setDetailsHrefTpl($tpl) {
$this->detailsHrefTpl = $tpl;
}
 
public function setOntologieHrefTpl($tpl) {
$this->ontologieHrefTpl = $tpl;
}
 
public function setListeUrl($url) {
$this->listeUrl = $url;
}
46,16 → 23,12
 
public function consulter() {
$this->noms = $this->rechercher();
$this->nbreNomsTotal = $this->recupererNombreNomsTotal();
$this->nbreNomsTotal = $this->nomDao->recupererNombreNomsTotal();
$this->trierNoms();
$retour = $this->construireTableauRetour();
return $retour;
}
 
private function getTable() {
$versions = $this->versions->getVersions();
return $this->projet.'_v'.end($versions);
}
 
private function rechercher() {
$resultats = array();
62,98 → 35,16
$recherche = $this->parametres->get('recherche');
 
if ($recherche == 'stricte') {
$resultats = $this->rechercherStricte();
$resultats = $this->nomDao->rechercherStricte();
} else if ($recherche == 'etendue') {
$resultats = $this->rechercherEtendue();
$resultats = $this->nomDao->rechercherEtendue();
} else if ($recherche == 'floue') {
$resultats = $this->rechercherFloue();
$resultats = $this->nomDao->rechercherFloue();
}
 
return $resultats;
}
 
private function rechercherStricte() {
$table = $this->getTable();
$conditions = array();
if ($masque = $this->parametres->getMasquePourBdd()) {
$conditions[] = "ns.nom_sci = $masque";
}
if ($masqueSg = $this->parametres->getMasquePourBdd('sg')) {
$conditions[] = "ns.nom_supra_generique = $masqueSg";
}
if ($masqueGen = $this->parametres->getMasquePourBdd('gen')) {
$conditions[] = "ns.genre = $masqueGen";
}
if ($masqueSp = $this->parametres->getMasquePourBdd('sp')) {
$conditions[] = "ns.epithete_sp = $masqueSp";
}
 
$requete = 'SELECT SQL_CALC_FOUND_ROWS ns.*, '.
' nr.nom_sci AS nr_nom_sci, nb.nom_sci AS nb_nom_sci '.
"FROM $table AS ns ".
" LEFT JOIN $table AS nr ON (ns.num_nom_retenu = nr.num_nom) ".
" LEFT JOIN $table AS nb ON (ns.basionyme = nb.num_nom) ".
(count($conditions) > 0 ? 'WHERE ' : '').
implode(' AND ', $conditions).
'ORDER BY ns.nom_sci ASC '.
'LIMIT 0,100';
$resultats = $this->bdd->recupererTous($requete);
 
return $resultats;
}
 
private function rechercherEtendue() {
$table = $this->getTable();
$conditions = array();
if ($masque = $this->parametres->getMasquePourBdd()) {
$conditions[] = "ns.nom_sci LIKE $masque";
}
if ($masqueSg = $this->parametres->getMasquePourBdd('sg')) {
$conditions[] = "ns.nom_supra_generique LIKE $masqueSg";
}
if ($masqueGen = $this->parametres->getMasquePourBdd('gen')) {
$conditions[] = "ns.genre LIKE $masqueGen";
}
if ($masqueSp = $this->parametres->getMasquePourBdd('sp')) {
$conditions[] = "ns.epithete_sp LIKE $masqueSp";
}
$requete = 'SELECT SQL_CALC_FOUND_ROWS ns.*, '.
' nr.nom_sci AS nr_nom_sci, nb.nom_sci AS nb_nom_sci '.
"FROM $table AS ns ".
" LEFT JOIN $table AS nr ON (ns.num_nom_retenu = nr.num_nom) ".
" LEFT JOIN $table AS nb ON (ns.basionyme = nb.num_nom) ".
(count($conditions) > 0 ? 'WHERE ' : '').
implode(' AND ', $conditions).
'ORDER BY ns.nom_sci ASC '.
'LIMIT 0,100';
 
$resultats = $this->bdd->recupererTous($requete);
return $resultats;
}
 
private function rechercherFloue() {
$table = $this->getTable();
$masque = $this->parametres->getMasquePourBdd();
$requete = 'SELECT SQL_CALC_FOUND_ROWS ns.*, '.
' nr.nom_sci AS nr_nom_sci, nb.nom_sci AS nb_nom_sci '.
"FROM $table AS ns ".
" LEFT JOIN $table AS nr ON (ns.num_nom_retenu = nr.num_nom) ".
" LEFT JOIN $table AS nb ON (ns.basionyme = nb.num_nom) ".
($masque ? 'WHERE '.
" (SOUNDEX(ns.nom_sci) = SOUNDEX($masque)) ".
" OR (SOUNDEX(REVERSE(ns.nom_sci)) = SOUNDEX(REVERSE($masque))) " : '').
'ORDER BY ns.nom_sci ASC '.
'LIMIT 0,100';
$resultats = $this->bdd->recupererTous($requete);
return $resultats;
}
 
private function recupererNombreNomsTotal() {
$requete = 'SELECT FOUND_ROWS() AS nbre';
$nombre = $this->bdd->recuperer($requete);
return (int) $nombre['nbre'];
}
 
private function trierNoms() {
$recherche = $this->parametres->get('recherche');
if ($recherche == 'floue') {
196,11 → 87,9
 
private function formaterNom($infos) {
$nomAFormater = new NomDO($infos);
$formateur = new NomFormateur($nomAFormater);
$formateur->setBdd($this->bdd);
$formateur->setDetailsHrefTpl($this->detailsHrefTpl);
$formateur->setChampsRetour($this->parametres->getListe('retour.champs'));
$nom = $formateur->formaterListe();
$this->nomFormateur->setNomAFormater($nomAFormater);
$this->nomFormateur->setChampsRetour($this->parametres->getListe('retour.champs'));
$nom = $this->nomFormateur->formaterListe();
return $nom;
}
 
/trunk/services/modules/0.2/commun/NomDetailsGenerique.php
3,76 → 3,27
 
private $parametres = null;
private $ressources = null;
private $bdd = null;
private $projet = null;
private $versions = null;
private $detailsHrefTpl = null;
private $ontologieHrefTpl = null;
 
private $nomDao = null;
private $nomFormateur = null;
private $nom = array();
private $champsProjet = array();
 
public function __construct(Ressources $ressources, Parametres $parametres, Bdd $bdd) {
public function __construct(Ressources $ressources, Parametres $parametres, NomDAO $nomDao, NomFormateur $nomFormateur) {
$this->ressources = $ressources;
$this->parametres = $parametres;
$this->bdd = $bdd;
$this->nomDao = $nomDao;
$this->nomFormateur = $nomFormateur;
}
 
public function setProjet($projet) {
$this->projet = $projet;
}
 
public function setVersions($versions) {
$this->versions = $versions;
}
 
public function setChampsProjet($champsProjet) {
$this->champsProjet = $champsProjet;
}
 
public function setDetailsHrefTpl($tpl) {
$this->detailsHrefTpl = $tpl;
}
 
public function setOntologieHrefTpl($tpl) {
$this->ontologieHrefTpl = $tpl;
}
 
public function consulter() {
$infos = $this->rechercherInfosNom();
$retour = $this->formaterDetails($infos);
$this->nom = $this->nomDao->rechercherInfosNom();
$retour = $this->formaterDetails();
return $retour;
}
 
private function getTable() {
$versions = $this->versions->getVersions();
return $this->projet.'_v'.end($versions);
}
 
private function rechercherInfosNom() {
$table = $this->getTable();
$detailsId = $this->ressources->getDetailsId();
$detailsId = $this->bdd->proteger($detailsId);
$requete =
'SELECT ns.*, '.
' nr.nom_sci AS nr_nom_sci, nb.nom_sci AS nb_nom_sci '.
"FROM $table AS ns ".
" LEFT JOIN $table AS nr ON (ns.num_nom_retenu = nr.num_nom) ".
" LEFT JOIN $table AS nb ON (ns.basionyme = nb.num_nom) ".
"WHERE ns.num_nom = $detailsId ";
$resultats = $this->bdd->recuperer($requete);
return $resultats;
}
 
private function formaterDetails($infos) {
$nomAFormater = new NomDO($infos);
$formateur = new NomFormateur($nomAFormater);
$formateur->setBdd($this->bdd);
$formateur->setChampsProjet($this->champsProjet);
$formateur->setDetailsHrefTpl($this->detailsHrefTpl);
$formateur->setOntologieHrefTpl($this->ontologieHrefTpl);
$formateur->setChampsRetour($this->parametres->getListe('retour.champs'));
$details = $formateur->formaterDetails();
private function formaterDetails() {
$this->nomFormateur->setNomAFormater($this->nom);
$this->nomFormateur->setChampsRetour($this->parametres->getListe('retour.champs'));
$details = $this->nomFormateur->formaterDetails();
return $details;
}
}
/trunk/services/bibliotheque/interfaces/NomsListe.php
1,7 → 1,6
<?php
interface NomsListe {
public function setDetailsHrefTpl($tpl);
public function setListeUrl($url);
public function __construct(Ressources $ressources, Parametres $parametres, NomDAO $nomDao, NomFormateur $nomFormateur);
public function consulter();
}
?>
/trunk/services/bibliotheque/interfaces/NomDetails.php
1,8 → 1,6
<?php
interface NomDetails {
public function setChampsProjet($champsProjet);
public function setDetailsHrefTpl($tpl);
public function setOntologieHrefTpl($tpl);
public function __construct(Ressources $ressources, Parametres $parametres, NomDAO $nomDao, NomFormateur $nomFormateur);
public function consulter();
}
?>
/trunk/services/bibliotheque/Conteneur.php
100,13 → 100,27
return $this->partages['Bdd'];
}
 
public function getNomDao() {
$ressources = $this->getRessourcesUrl();
$parametres = $this->getParametresUrl();
$bdd = $this->getBdd();
$projet = $this->getProjet();
$versions = $this->getVersions();
$nomDao = new NomDAO($ressources, $parametres, $bdd, $projet, $versions);
return $nomDao;
}
 
public function getNomFormateur() {
$formateur = new NomFormateur();
$formateur->setBdd($this->getBdd());
$formateur->setChampsProjet($this->getParametreTableau('champsProjet'));
$formateur->setDetailsHrefTpl($this->getParametre('detailsHrefTpl'));
$formateur->setOntologieHrefTpl($this->getParametre('ontologieHrefTpl'));
return $formateur;
}
 
public function getService($classe) {
$service = new $classe($this->getRessourcesUrl(), $this->getParametresUrl(), $this->getBdd());
$service->setProjet($this->getProjet()->getNom());
$service->setVersions($this->getVersions());
$service->setDetailsHrefTpl($this->getParametre('detailsHrefTpl'));
$service->setChampsProjet($this->getParametreTableau('champsProjet'));
$service->setOntologieHrefTpl($this->getParametre('ontologieHrefTpl'));
$service = new $classe($this->getRessourcesUrl(), $this->getParametresUrl(), $this->getNomDao(), $this->getNomFormateur());
if ($service instanceof NomsListe) {
$service->setListeUrl($this->getParametre('listeUrl'));
}
/trunk/services/bibliotheque/nom/NomDAO.php
New file
0,0 → 1,120
<?php
class NomDAO {
private $bdd = null;
private $projet = null;
private $versions = null;
 
public function __construct(Ressources $ressources, Parametres $parametres, Bdd $bdd, Projet $projet, Versions $versions) {
$this->ressources = $ressources;
$this->parametres = $parametres;
$this->bdd = $bdd;
$this->projet = $projet;
$this->versions = $versions;
}
 
private function getTable() {
$versions = $this->versions->getVersions();
$derniereVersion = end($versions);
$projetNom = $this->projet->getNom();
return $projetNom.'_v'.$derniereVersion;
}
 
public function rechercherInfosNom() {
$table = $this->getTable();
$detailsId = $this->ressources->getDetailsId();
$detailsId = $this->bdd->proteger($detailsId);
$requete =
'SELECT ns.*, '.
' nr.nom_sci AS nr_nom_sci, nb.nom_sci AS nb_nom_sci '.
"FROM $table AS ns ".
" LEFT JOIN $table AS nr ON (ns.num_nom_retenu = nr.num_nom) ".
" LEFT JOIN $table AS nb ON (ns.basionyme = nb.num_nom) ".
"WHERE ns.num_nom = $detailsId ";
$resultats = $this->bdd->recuperer($requete);
$nom = new NomDO($resultats);
return $nom;
}
 
public function rechercherStricte() {
$table = $this->getTable();
$conditions = array();
if ($masque = $this->parametres->getMasquePourBdd()) {
$conditions[] = "ns.nom_sci = $masque";
}
if ($masqueSg = $this->parametres->getMasquePourBdd('sg')) {
$conditions[] = "ns.nom_supra_generique = $masqueSg";
}
if ($masqueGen = $this->parametres->getMasquePourBdd('gen')) {
$conditions[] = "ns.genre = $masqueGen";
}
if ($masqueSp = $this->parametres->getMasquePourBdd('sp')) {
$conditions[] = "ns.epithete_sp = $masqueSp";
}
 
$requete = 'SELECT SQL_CALC_FOUND_ROWS ns.*, '.
' nr.nom_sci AS nr_nom_sci, nb.nom_sci AS nb_nom_sci '.
"FROM $table AS ns ".
" LEFT JOIN $table AS nr ON (ns.num_nom_retenu = nr.num_nom) ".
" LEFT JOIN $table AS nb ON (ns.basionyme = nb.num_nom) ".
(count($conditions) > 0 ? 'WHERE ' : '').
implode(' AND ', $conditions).
'ORDER BY ns.nom_sci ASC '.
'LIMIT 0,100';
$resultats = $this->bdd->recupererTous($requete);
 
return $resultats;
}
 
public function rechercherEtendue() {
$table = $this->getTable();
$conditions = array();
if ($masque = $this->parametres->getMasquePourBdd()) {
$conditions[] = "ns.nom_sci LIKE $masque";
}
if ($masqueSg = $this->parametres->getMasquePourBdd('sg')) {
$conditions[] = "ns.nom_supra_generique LIKE $masqueSg";
}
if ($masqueGen = $this->parametres->getMasquePourBdd('gen')) {
$conditions[] = "ns.genre LIKE $masqueGen";
}
if ($masqueSp = $this->parametres->getMasquePourBdd('sp')) {
$conditions[] = "ns.epithete_sp LIKE $masqueSp";
}
$requete = 'SELECT SQL_CALC_FOUND_ROWS ns.*, '.
' nr.nom_sci AS nr_nom_sci, nb.nom_sci AS nb_nom_sci '.
"FROM $table AS ns ".
" LEFT JOIN $table AS nr ON (ns.num_nom_retenu = nr.num_nom) ".
" LEFT JOIN $table AS nb ON (ns.basionyme = nb.num_nom) ".
(count($conditions) > 0 ? 'WHERE ' : '').
implode(' AND ', $conditions).
'ORDER BY ns.nom_sci ASC '.
'LIMIT 0,100';
 
$resultats = $this->bdd->recupererTous($requete);
return $resultats;
}
 
public function rechercherFloue() {
$table = $this->getTable();
$masque = $this->parametres->getMasquePourBdd();
$requete = 'SELECT SQL_CALC_FOUND_ROWS ns.*, '.
' nr.nom_sci AS nr_nom_sci, nb.nom_sci AS nb_nom_sci '.
"FROM $table AS ns ".
" LEFT JOIN $table AS nr ON (ns.num_nom_retenu = nr.num_nom) ".
" LEFT JOIN $table AS nb ON (ns.basionyme = nb.num_nom) ".
($masque ? 'WHERE '.
" (SOUNDEX(ns.nom_sci) = SOUNDEX($masque)) ".
" OR (SOUNDEX(REVERSE(ns.nom_sci)) = SOUNDEX(REVERSE($masque))) " : '').
'ORDER BY ns.nom_sci ASC '.
'LIMIT 0,100';
$resultats = $this->bdd->recupererTous($requete);
return $resultats;
}
 
public function recupererNombreNomsTotal() {
$requete = 'SELECT FOUND_ROWS() AS nbre';
$nombre = $this->bdd->recuperer($requete);
return (int) $nombre['nbre'];
}
}
?>
/trunk/services/bibliotheque/nom/NomFormateur.php
9,7 → 9,7
private $detailsHrefTpl = null;
private $ontologieHrefTpl = null;
 
public function __construct(NomDO $nomDO) {
public function setNomAFormater(NomDO $nomDO) {
$this->nomAFormater = $nomDO;
}