478 |
jpm |
1 |
<?php
|
479 |
jpm |
2 |
class Versions {
|
478 |
jpm |
3 |
|
|
|
4 |
private $conteneur = null;
|
|
|
5 |
private $eflore = null;
|
|
|
6 |
private $bdd = null;
|
|
|
7 |
|
|
|
8 |
public function __construct(Conteneur $conteneur) {
|
|
|
9 |
$this->conteneur = $conteneur;
|
|
|
10 |
$this->eflore = $conteneur->getEfloreCommun();
|
|
|
11 |
$this->bdd = $conteneur->getBdd();
|
|
|
12 |
}
|
|
|
13 |
|
|
|
14 |
public function chargerTous() {
|
|
|
15 |
$this->chargerVersions();
|
|
|
16 |
}
|
|
|
17 |
|
|
|
18 |
public function chargerVersions() {
|
|
|
19 |
$versions = explode(',', Config::get('versions'));
|
|
|
20 |
$versionsDonnees = explode(',', Config::get('versionsDonnees'));
|
|
|
21 |
foreach ($versions as $id => $version) {
|
|
|
22 |
$versionDonnees = $versionsDonnees[$id];
|
|
|
23 |
$this->chargerStructureSqlVersion($versionDonnees, $version);
|
|
|
24 |
$this->chargerIndexVersion($versionDonnees, $version);
|
|
|
25 |
$this->chargerDumpWikiniVersion($versionDonnees, $version);
|
|
|
26 |
}
|
|
|
27 |
}
|
|
|
28 |
|
|
|
29 |
private function chargerStructureSqlVersion($versionDonnees, $version) {
|
|
|
30 |
$fichierSqlTpl = Config::get('chemins.structureSqlVersionTpl');
|
|
|
31 |
$fichierSql = sprintf($fichierSqlTpl, $versionDonnees, $version);
|
|
|
32 |
$contenuSql = $this->eflore->recupererContenu($fichierSql);
|
676 |
jpm |
33 |
$this->eflore->executerScriptSql($contenuSql);
|
478 |
jpm |
34 |
}
|
|
|
35 |
|
|
|
36 |
private function chargerIndexVersion($versionDonnees, $version) {
|
|
|
37 |
$fichierTsvTpl = Config::get('chemins.costeTpl');
|
|
|
38 |
$fichierTsv = sprintf($fichierTsvTpl, $versionDonnees, $version);
|
|
|
39 |
$tableTpl = Config::get('tables.costeTpl');
|
|
|
40 |
$table = sprintf($tableTpl, $version);
|
|
|
41 |
$requete = "LOAD DATA INFILE '$fichierTsv' ".
|
|
|
42 |
"REPLACE INTO TABLE $table ".
|
|
|
43 |
'CHARACTER SET utf8 '.
|
|
|
44 |
'FIELDS '.
|
|
|
45 |
" TERMINATED BY '\t' ".
|
|
|
46 |
" ENCLOSED BY '' ".
|
|
|
47 |
" ESCAPED BY '\\\' ".
|
|
|
48 |
'IGNORE 1 LINES ';
|
|
|
49 |
$this->bdd->requeter($requete);
|
|
|
50 |
}
|
|
|
51 |
|
|
|
52 |
private function chargerDumpWikiniVersion($versionDonnees, $version) {
|
920 |
jpm |
53 |
$versionMajeure = (int) substr($version, 0, 1);
|
|
|
54 |
if ($versionMajeure < 2) {
|
|
|
55 |
$fichierWikiTpl = Config::get('chemins.costeWikiniTpl');
|
|
|
56 |
$fichierDump = sprintf($fichierWikiTpl, $versionDonnees, $version);
|
|
|
57 |
$contenuSql = $this->eflore->recupererContenu($fichierDump);
|
|
|
58 |
$this->eflore->executerScriptSql($contenuSql);
|
|
|
59 |
}
|
478 |
jpm |
60 |
}
|
|
|
61 |
|
|
|
62 |
public function supprimerTous() {
|
|
|
63 |
$requete = "DROP TABLE IF EXISTS coste_meta, ".
|
484 |
jpm |
64 |
" coste_correspondance_bdnff, coste_images_auteur_correspondance_bdnff, ".
|
|
|
65 |
" coste_images_correspondance_bdnff, coste_index, coste_index_general, ".
|
478 |
jpm |
66 |
" coste_acls, coste_links, coste_pages, coste_referrers, coste_triples, coste_users, ".
|
479 |
jpm |
67 |
" coste_v1_00, coste_v2_00 ";
|
478 |
jpm |
68 |
$this->bdd->requeter($requete);
|
|
|
69 |
}
|
|
|
70 |
}
|
|
|
71 |
?>
|