Blame | Last modification | View Log | RSS feed
<?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);
}
}
?>