Subversion Repositories eFlore/Projets.eflore-projets

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
478 jpm 1
<?php
2
class Version2 {
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->chargerStructureSql();
16
	}
17
 
18
	public function chargerStructureSql() {
19
		$this->eflore->chargerStructureSql();
20
	}
21
 
22
	public function chargerVersions() {
23
		$versions = explode(',', Config::get('versions'));
24
		$versionsDonnees = explode(',', Config::get('versionsDonnees'));
25
		foreach ($versions as $id => $version) {
26
			$versionDonnees = $versionsDonnees[$id];
27
			$this->chargerStructureSqlVersion($versionDonnees, $version);
28
			$this->chargerIndexVersion($versionDonnees, $version);
29
			$this->chargerDumpWikiniVersion($versionDonnees, $version);
30
		}
31
	}
32
 
33
	private function chargerStructureSqlVersion($versionDonnees, $version) {
34
		$fichierSqlTpl = Config::get('chemins.structureSqlVersionTpl');
35
		$fichierSql = sprintf($fichierSqlTpl, $versionDonnees, $version);
36
		$contenuSql = $this->eflore->recupererContenu($fichierSql);
37
		$this->eflore->executerScripSql($contenuSql);
38
	}
39
 
40
	private function chargerIndexVersion($versionDonnees, $version) {
41
		$fichierTsvTpl = Config::get('chemins.costeTpl');
42
		$fichierTsv = sprintf($fichierTsvTpl, $versionDonnees, $version);
43
		$tableTpl = Config::get('tables.costeTpl');
44
		$table = sprintf($tableTpl, $version);
45
		$requete = "LOAD DATA INFILE '$fichierTsv' ".
46
				"REPLACE INTO TABLE $table ".
47
				'CHARACTER SET utf8 '.
48
				'FIELDS '.
49
				"	TERMINATED BY '\t' ".
50
				"	ENCLOSED BY '' ".
51
				"	ESCAPED BY '\\\' ".
52
				'IGNORE 1 LINES ';
53
		$this->bdd->requeter($requete);
54
	}
55
 
56
	private function chargerDumpWikiniVersion($versionDonnees, $version) {
57
		$fichierWikiTpl = Config::get('chemins.costeWikiniTpl');
58
		$fichierDump = sprintf($fichierWikiTpl, $versionDonnees, $version);
59
		$contenuSql = $this->eflore->recupererContenu($fichierDump);
60
		$this->eflore->executerScripSql($contenuSql);
61
	}
62
 
63
	public function supprimerTous() {
64
		$requete = "DROP TABLE IF EXISTS coste_meta, ".
65
				"	coste_acls, coste_links, coste_pages, coste_referrers, coste_triples, coste_users, ".
66
				"	coste_v2_00 ";
67
		$this->bdd->requeter($requete);
68
	}
69
}
70
?>