Subversion Repositories eFlore/Projets.eflore-projets

Compare Revisions

Ignore whitespace Rev 477 → Rev 478

/trunk/scripts/modules/coste/CreationCol.php
File deleted
\ No newline at end of file
/trunk/scripts/modules/coste/Cles.php
File deleted
\ No newline at end of file
/trunk/scripts/modules/coste/CreationProjetCoste.php
File deleted
/trunk/scripts/modules/coste/DescriptionSp.php
File deleted
/trunk/scripts/modules/coste/Wiki.php
2,6 → 2,7
class Wiki {
 
const URL_WIKI = 'http://www.tela-botanica.org/wikini/florecoste/api/rest/0.5/pages';
const URL_WIKI_EFLORE = 'http://www.tela-botanica.org/wikini/Coste/api/rest/0.5/pages';
const DOSSIER_V2 = '../../../donnees/coste/2.00/';
const DOSSIER_DSC_TXT = '../../../donnees/coste/descriptions/txt/';
 
38,8 → 39,9
$this->messages->traiterErreur("Le fichier $fichier est introuvable.");
}
}
$this->messages->afficherAvancement("Upload des fichiers dans le wikini");
$this->messages->afficherAvancement("Upload des fichiers d'espèce dans le wikini");
}
echo "\n";
}
 
public function dowloaderPagesWiki() {
66,8 → 68,43
}
$this->messages->afficherAvancement("Download des fichiers en cours");
}
echo "\n";
}
 
public function uploaderDansWikiEflore() {
$this->chargerIndex();
$envoyes = array();
foreach ($this->index as $nom) {
$tagDsc = $nom['page_wiki_dsc'];
if (isset($envoyes[$tagDsc]) == false) {
$fichier = $this->dossierBase.self::DOSSIER_V2.'/dsc/'.$tagDsc.'.txt';
if (file_exists($fichier) === true) {
$txt = file_get_contents($fichier);
$donnees = array('pageTag' => $tagDsc, 'pageContenu' => $txt);
$this->restClient->ajouter(self::URL_WIKI_EFLORE, $donnees);
$envoyes[$tagDsc] = 'OK';
} else {
$this->messages->traiterErreur("Le fichier $fichier est introuvable.");
}
}
 
$tagCle = $nom['page_wiki_cle'];
if (isset($envoyes[$tagCle]) == false) {
$fichier = $this->dossierBase.self::DOSSIER_V2.'/cle/'.$tagCle.'.txt';
if (file_exists($fichier) === true) {
$txt = file_get_contents($fichier);
$donnees = array('pageTag' => $tagCle, 'pageContenu' => $txt);
$this->restClient->ajouter(self::URL_WIKI_EFLORE, $donnees);
$envoyes[$tagCle] = 'OK';
} else {
$this->messages->traiterErreur("Le fichier $fichier est introuvable.");
}
}
$this->messages->afficherAvancement("Upload des textes dans le wikini eFlore");
}
echo "\n";
}
 
private function telechargerTxt($url) {
$json = $this->restClient->consulter($url);
$donnees = json_decode($json, true);
/trunk/scripts/modules/coste/coste.ini
1,7 → 1,7
; Ajouter les nouvelles version à la suite dans versions et versionsDonnees.
versions="1_00"
versionsDonnees="1.00"
dossierTsv = "{ref:dossierDonneesEflore}chorodep/{ref:versionDonnees}/"
versions="2_00"
versionsDonnees="2.00"
dossierTsv = "{ref:dossierDonneesEflore}coste/{ref:versionDonnees}/"
dossierTsvTpl = "{ref:dossierDonneesEflore}coste/%s/"
dossierSql = "{ref:dossierDonneesEflore}coste/"
 
/trunk/scripts/modules/coste/Version1.php
New file
0,0 → 1,109
<?php
class Version1 {
 
private $conteneur = null;
private $eflore = null;
private $bdd = null;
 
public function __construct(Conteneur $conteneur) {
$this->conteneur = $conteneur;
$this->eflore = $conteneur->getEfloreCommun();
$this->bdd = $conteneur->getBdd();
}
 
public function chargerTous() {
$this->chargerStructureSql();
$this->chargerVersions();
}
 
public function chargerStructureSql() {
$this->eflore->chargerStructureSql();
}
 
public function chargerVersions() {
$versions = explode(',', Config::get('versions'));
$versionsDonnees = explode(',', Config::get('versionsDonnees'));
foreach ($versions as $id => $version) {
$versionDonnees = $versionsDonnees[$id];
$this->chargerStructureSqlVersion($versionDonnees, $version);
$this->chargerIndexVersion($versionDonnees, $version);
$this->chargerDumpWikiniVersion($versionDonnees, $version);
}
}
 
private function chargerStructureSqlVersion($versionDonnees, $version) {
$fichierSqlTpl = Config::get('chemins.structureSqlVersionTpl');
$fichierSql = sprintf($fichierSqlTpl, $versionDonnees, $version);
$contenuSql = $this->eflore->recupererContenu($fichierSql);
$this->eflore->executerScripSql($contenuSql);
}
 
private function chargerIndexVersion($versionDonnees, $version) {
$fichierTsvTpl = Config::get('chemins.costeTpl');
$fichierTsv = sprintf($fichierTsvTpl, $versionDonnees, $version);
$tableTpl = Config::get('tables.costeTpl');
$table = sprintf($tableTpl, $version);
$requete = "LOAD DATA INFILE '$fichierTsv' ".
"REPLACE INTO TABLE $table ".
'CHARACTER SET utf8 '.
'FIELDS '.
" TERMINATED BY '\t' ".
" ENCLOSED BY '' ".
" ESCAPED BY '\\\' ".
'IGNORE 1 LINES ';
$this->bdd->requeter($requete);
}
 
private function chargerDumpWikiniVersion($versionDonnees, $version) {
$fichierWikiTpl = Config::get('chemins.costeWikiniTpl');
$fichierDump = sprintf($fichierWikiTpl, $versionDonnees, $version);
$contenuSql = $this->eflore->recupererContenu($fichierDump);
$this->eflore->executerScripSql($contenuSql);
}
 
public function supprimerTous() {
$requete = "DROP TABLE IF EXISTS coste_meta, ".
" coste_acls, coste_links, coste_pages, coste_referrers, coste_triples, coste_users, ".
" coste_v1_00 ";
$this->bdd->requeter($requete);
}
 
public function nettoyerVersion1() {
$requete = "DROP TABLE IF EXISTS coste_correspondance_bdnff, coste_images_auteur_correspondance_bdnff, ".
" coste_images_correspondance_bdnff, coste_index, coste_index_general";
$this->bdd->requeter($requete);
}
 
public function creerVersion1() {
$this->chargerStructureSqlVersion('0.00', '0_00');
$this->chargerCosteImagesAuteurCorrespondanceBdnff();
$this->chargerCosteCorrespondanceBdnff();
}
 
private function chargerCosteImagesAuteurCorrespondanceBdnff() {
$fichierTsv = sprintf(Config::get('dossierTsvTpl'), '0.00').'coste_images_auteur_correspondance_bdnff.tsv';
$requete = "LOAD DATA INFILE '$fichierTsv' ".
"REPLACE INTO TABLE coste_images_auteur_correspondance_bdnff ".
'CHARACTER SET utf8 '.
'FIELDS '.
" TERMINATED BY '\t' ".
" ENCLOSED BY '\"' ".
" ESCAPED BY '\\\' ".
'IGNORE 1 LINES ';
$this->bdd->requeter($requete);
}
 
private function chargerCosteCorrespondanceBdnff() {
$fichierTsv = sprintf(Config::get('dossierTsvTpl'), '0.00').'coste_images_correspondance_bdnff.tsv';
$requete = "LOAD DATA INFILE '$fichierTsv' ".
"REPLACE INTO TABLE coste_images_correspondance_bdnff ".
'CHARACTER SET utf8 '.
'FIELDS '.
" TERMINATED BY '\t' ".
" ENCLOSED BY '' ".
" ESCAPED BY '\\\' ".
'IGNORE 1 LINES ';
$this->bdd->requeter($requete);
}
}
?>
/trunk/scripts/modules/coste/Index.php
217,7 → 217,7
$txt = '';
$txt = implode("\n", $lignes);
 
$fichierTsvIndexFinal = $this->dossierBase.self::DOSSIER_V2.'index.tsv';
$fichierTsvIndexFinal = $this->dossierBase.self::DOSSIER_V2.'coste_v2_00.tsv';
file_put_contents($fichierTsvIndexFinal, $txt);
}
}
/trunk/scripts/modules/coste/Version2.php
New file
0,0 → 1,70
<?php
class Version2 {
 
private $conteneur = null;
private $eflore = null;
private $bdd = null;
 
public function __construct(Conteneur $conteneur) {
$this->conteneur = $conteneur;
$this->eflore = $conteneur->getEfloreCommun();
$this->bdd = $conteneur->getBdd();
}
 
public function chargerTous() {
$this->chargerStructureSql();
}
 
public function chargerStructureSql() {
$this->eflore->chargerStructureSql();
}
 
public function chargerVersions() {
$versions = explode(',', Config::get('versions'));
$versionsDonnees = explode(',', Config::get('versionsDonnees'));
foreach ($versions as $id => $version) {
$versionDonnees = $versionsDonnees[$id];
$this->chargerStructureSqlVersion($versionDonnees, $version);
$this->chargerIndexVersion($versionDonnees, $version);
$this->chargerDumpWikiniVersion($versionDonnees, $version);
}
}
 
private function chargerStructureSqlVersion($versionDonnees, $version) {
$fichierSqlTpl = Config::get('chemins.structureSqlVersionTpl');
$fichierSql = sprintf($fichierSqlTpl, $versionDonnees, $version);
$contenuSql = $this->eflore->recupererContenu($fichierSql);
$this->eflore->executerScripSql($contenuSql);
}
 
private function chargerIndexVersion($versionDonnees, $version) {
$fichierTsvTpl = Config::get('chemins.costeTpl');
$fichierTsv = sprintf($fichierTsvTpl, $versionDonnees, $version);
$tableTpl = Config::get('tables.costeTpl');
$table = sprintf($tableTpl, $version);
$requete = "LOAD DATA INFILE '$fichierTsv' ".
"REPLACE INTO TABLE $table ".
'CHARACTER SET utf8 '.
'FIELDS '.
" TERMINATED BY '\t' ".
" ENCLOSED BY '' ".
" ESCAPED BY '\\\' ".
'IGNORE 1 LINES ';
$this->bdd->requeter($requete);
}
 
private function chargerDumpWikiniVersion($versionDonnees, $version) {
$fichierWikiTpl = Config::get('chemins.costeWikiniTpl');
$fichierDump = sprintf($fichierWikiTpl, $versionDonnees, $version);
$contenuSql = $this->eflore->recupererContenu($fichierDump);
$this->eflore->executerScripSql($contenuSql);
}
 
public function supprimerTous() {
$requete = "DROP TABLE IF EXISTS coste_meta, ".
" coste_acls, coste_links, coste_pages, coste_referrers, coste_triples, coste_users, ".
" coste_v2_00 ";
$this->bdd->requeter($requete);
}
}
?>
/trunk/scripts/modules/coste/Coste.php
22,42 → 22,57
$cmd = $this->getParametre('a');
switch ($cmd) {
case 'chargerTous' :
$this->chargerStructureSql();
$this->chargerVersions();
$version = $this->getClasseVersion();
$version->chargerTous();
break;
case 'chargerStructureSql' :
$this->chargerStructureSql();
$version = $this->getClasseVersion();
$version->chargerStructureSql();
break;
case 'chargerVersions' :
$this->chargerVersions();
$version = $this->getClasseVersion();
$version->chargerVersions();
break;
case 'supprimerTous' :
$this->supprimerTous();
$version = $this->getClasseVersion();
$version->supprimerTous();
break;
case 'creerV1' :
$this->creerVersion1();
$version = $this->getClasseVersion();
$version->creerVersion1();
break;
case 'nettoyerV1' :
$this->nettoyerVersion1();
$version = $this->getClasseVersion();
$version->nettoyerVersion1();
break;
case 'creerDscTxt' :
$this->creerDescriptionTxt();
$description = $this->getClasseDescription();
$description->genererDescriptionTxt();
break;
case 'statDscTxt' :
$this->verifierDescriptionTxt();
$description = $this->getClasseDescription();
$description->verifierDescriptionTxt();
break;
case 'correspondanceDsc' :
$this->genererCorrespondanceDescription();
$description = $this->getClasseDescription();
$description->genererCorrespondance();
break;
case 'fusionIndex' :
$this->fusionnerIndex();
$description = $this->getClasseIndex();
$description->fusionnerIndex();
break;
case 'uploadFichiersSp' :
$this->uploaderFichiersSp();
$wiki = $this->getClasseWiki();
$wiki->uploaderFichiersSp();
break;
case 'downloadWiki' :
$this->dowloaderWiki();
$wiki = $this->getClasseWiki();
$wiki->dowloaderPagesWiki();
break;
case 'uploadEflore' :
$wiki = $this->getClasseWiki();
$wiki->uploaderDansWikiEflore();
break;
default :
throw new Exception("Erreur : la commande '$cmd' n'existe pas!");
}
66,132 → 81,21
}
}
 
private function chargerVersions() {
$versions = explode(',', Config::get('versions'));
$versionsDonnees = explode(',', Config::get('versionsDonnees'));
foreach ($versions as $id => $version) {
$versionDonnees = $versionsDonnees[$id];
$this->chargerStructureSqlVersion($versionDonnees, $version);
$this->chargerIndexVersion($versionDonnees, $version);
$this->chargerDumpWikiniVersion($versionDonnees, $version);
}
private function getClasseVersion($version = '1') {
$version1 = $this->getClasse('Version');
return $version1;
}
 
private function chargerStructureSqlVersion($versionDonnees, $version) {
$fichierSqlTpl = Config::get('chemins.structureSqlVersionTpl');
$fichierSql = sprintf($fichierSqlTpl, $versionDonnees, $version);
$contenuSql = $this->recupererContenu($fichierSql);
$this->executerScripSql($contenuSql);
}
 
private function chargerIndexVersion($versionDonnees, $version) {
$fichierTsvTpl = Config::get('chemins.costeTpl');
$fichierTsv = sprintf($fichierTsvTpl, $versionDonnees, $version);
$tableTpl = Config::get('tables.costeTpl');
$table = sprintf($tableTpl, $version);
$requete = "LOAD DATA INFILE '$fichierTsv' ".
"REPLACE INTO TABLE $table ".
'CHARACTER SET utf8 '.
'FIELDS '.
" TERMINATED BY '\t' ".
" ENCLOSED BY '' ".
" ESCAPED BY '\\\' ".
'IGNORE 1 LINES ';
$this->getBdd()->requeter($requete);
}
 
private function chargerDumpWikiniVersion($versionDonnees, $version) {
$fichierWikiTpl = Config::get('chemins.costeWikiniTpl');
$fichierDump = sprintf($fichierWikiTpl, $versionDonnees, $version);
$contenuSql = $this->recupererContenu($fichierDump);
$this->executerScripSql($contenuSql);
}
 
private function supprimerTous() {
$requete = "DROP TABLE IF EXISTS coste_meta, ".
" coste_acls, coste_links, coste_pages, coste_referrers, coste_triples, coste_users, ".
" coste_v1_00 ";
$this->getBdd()->requeter($requete);
}
 
private function nettoyerVersion1() {
$requete = "DROP TABLE IF EXISTS coste_correspondance_bdnff, coste_images_auteur_correspondance_bdnff, ".
" coste_images_correspondance_bdnff, coste_index, coste_index_general";
$this->getBdd()->requeter($requete);
}
 
private function creerVersion1() {
$this->chargerStructureSqlVersion('0.00', '0_00');
$this->chargerCosteImagesAuteurCorrespondanceBdnff();
$this->chargerCosteCorrespondanceBdnff();
}
 
private function chargerCosteImagesAuteurCorrespondanceBdnff() {
$fichierTsv = sprintf(Config::get('dossierTsvTpl'), '0.00').'coste_images_auteur_correspondance_bdnff.tsv';
$requete = "LOAD DATA INFILE '$fichierTsv' ".
"REPLACE INTO TABLE coste_images_auteur_correspondance_bdnff ".
'CHARACTER SET utf8 '.
'FIELDS '.
" TERMINATED BY '\t' ".
" ENCLOSED BY '\"' ".
" ESCAPED BY '\\\' ".
'IGNORE 1 LINES ';
$this->getBdd()->requeter($requete);
}
 
private function chargerCosteCorrespondanceBdnff() {
$fichierTsv = sprintf(Config::get('dossierTsvTpl'), '0.00').'coste_images_correspondance_bdnff.tsv';
$requete = "LOAD DATA INFILE '$fichierTsv' ".
"REPLACE INTO TABLE coste_images_correspondance_bdnff ".
'CHARACTER SET utf8 '.
'FIELDS '.
" TERMINATED BY '\t' ".
" ENCLOSED BY '' ".
" ESCAPED BY '\\\' ".
'IGNORE 1 LINES ';
$this->getBdd()->requeter($requete);
}
 
private function creerDescriptionTxt() {
$description = $this->getClasseDescription();
$description->genererDescriptionTxt();
}
 
private function verifierDescriptionTxt() {
$description = $this->getClasseDescription();
$description->verifierDescriptionTxt();
}
 
private function genererCorrespondanceDescription() {
$description = $this->getClasseDescription();
$description->genererCorrespondance();
}
 
private function getClasseDescription() {
$description = $this->getClasse('Description');
return $description;
}
 
private function fusionnerIndex() {
$description = $this->getClasseIndex();
$description->fusionnerIndex();
}
 
private function getClasseIndex() {
$index = $this->getClasse('Index');
return $index;
}
 
private function uploaderFichiersSp() {
$wiki = $this->getClasseWiki();
$wiki->uploaderFichiersSp();
}
 
private function dowloaderWiki() {
$wiki = $this->getClasseWiki();
$wiki->dowloaderPagesWiki();
}
 
private function getClasseWiki() {
$wiki = $this->getClasse('Wiki');
return $wiki;
199,7 → 103,8
 
private function getClasse($classeNom) {
$conteneur = new Conteneur();
$conteneur->setParametre('-v', $this->getParametre('-v'));
$conteneur->setParametre('-v', $this->getParametre('-v'));
$conteneur->setParametre('scriptChemin', $this->getScriptChemin());
require_once dirname(__FILE__).'/'.$classeNom.'.php';
$objet = new $classeNom($conteneur);
return $objet;
/trunk/scripts/bibliotheque/Conteneur.php
43,7 → 43,7
 
public function getEfloreCommun() {
if (!isset($this->partages['EfloreCommun'])){
$this->partages['EfloreCommun'] = new EfloreCommun();
$this->partages['EfloreCommun'] = new EfloreCommun($this);
}
return $this->partages['EfloreCommun'];
}
61,5 → 61,12
}
return $this->partages['RestClient'];
}
 
public function getBdd() {
if (!isset($this->partages['Bdd'])){
$this->partages['Bdd'] = new Bdd();
}
return $this->partages['Bdd'];
}
}
?>
/trunk/scripts/bibliotheque/EfloreCommun.php
1,68 → 1,62
<?php
/**
*
* fonctions
*
* fonctions
* @author mathilde
*
*/
class EfloreCommun {
 
class EfloreCommun {
private $Conteneur = null;
private $Bdd = null;
private $projetNom = null;
private $projetNom = '';
private $scriptChemin = '';
 
public function __construct($conteneur) {
$this->Conteneur = $conteneur;
$this->Bdd = $this->Conteneur->getBdd();
}
 
public function initialiserProjet($projetNom) {
$this->projetNom = $projetNom;
$this->chargerConfigDuProjet();
}
 
//+------------------------------------------------------------------------------------------------------+
// Méthodes d'accès aux objets du Framework
/**
* Méthode de connection à la base de données sur demande.
* Tous les scripts n'ont pas besoin de s'y connecter.
*/
public function getBdd() {
if (! isset($this->Bdd)) {
$this->Bdd = new Bdd();
}
return $this->Bdd;
}
//+------------------------------------------------------------------------------------------------------+
// Méthodes communes aux projets d'eFlore
 
public function chargerConfigDuProjet() {
$fichierIni = $this->getScriptChemin().$this->getProjetNom().'.ini';
if (file_exists($fichierIni)) {
Config::charger($fichierIni);
} else {
$m = "Veuillez configurer le projet en créant le fichier '{$this->projetNom}.ini' ".
"dans le dossier du module de script du projet à partir du fichier '{$this->projetNom}.defaut.ini'.";
throw new Exception($m);
}
$scriptChemin = $this->Conteneur->getParametre('scriptChemin');
$fichierIni = $scriptChemin.$this->projetNom.'.ini';
if (file_exists($fichierIni)) {
Config::charger($fichierIni);
} else {
$m = "Veuillez configurer le projet en créant le fichier '{$this->projetNom}.ini' ".
"dans le dossier du module de script du projet à partir du fichier '{$this->projetNom}.defaut.ini'.";
throw new Exception($m);
}
}
 
//changée
public function chargerStructureSql($structure_sql) {
$contenuSql = $this->recupererContenu(Config::get($structure_sql));
$this->executerScripSql($contenuSql);
public function chargerStructureSql() {
$fichierStructureSql = $this->Conteneur->getParametre('chemins.structureSql');
$contenuSql = $this->recupererContenu($fichierStructureSql);
$this->executerScripSql($contenuSql);
}
 
public function executerScripSql($sql) {
$requetes = Outils::extraireRequetes($sql);
$requetes = Outils::extraireRequetes($sql);
foreach ($requetes as $requete) {
$this->getBdd()->requeter($requete);
$this->Bdd->requeter($requete);
}
}
}
 
public function recupererContenu($chemin) {
$contenu = file_get_contents($chemin);
if ($contenu === false){
throw new Exception("Impossible d'ouvrir le fichier SQL : $chemin");
$contenu = file_get_contents($chemin);
if ($contenu === false){
throw new Exception("Impossible d'ouvrir le fichier SQL : $chemin");
}
return $contenu;
}
return $contenu;
}
}
?>