Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 478 | Rev 484 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 478 Rev 479
1
<?php
1
<?php
2
class Version1 {
2
class Versions {
3
 
3
 
4
	private $conteneur = null;
4
	private $conteneur = null;
5
	private $eflore = null;
5
	private $eflore = null;
6
	private $bdd = null;
6
	private $bdd = null;
7
 
7
 
8
	public function __construct(Conteneur $conteneur) {
8
	public function __construct(Conteneur $conteneur) {
9
		$this->conteneur = $conteneur;
9
		$this->conteneur = $conteneur;
10
		$this->eflore = $conteneur->getEfloreCommun();
10
		$this->eflore = $conteneur->getEfloreCommun();
11
		$this->bdd = $conteneur->getBdd();
11
		$this->bdd = $conteneur->getBdd();
12
	}
12
	}
13
 
13
 
14
	public function chargerTous() {
14
	public function chargerTous() {
15
		$this->chargerStructureSql();
15
		$this->chargerStructureSql();
16
		$this->chargerVersions();
16
		$this->chargerVersions();
17
	}
17
	}
18
 
18
 
19
	public function chargerStructureSql() {
19
	public function chargerStructureSql() {
20
		$this->eflore->chargerStructureSql();
20
		$this->eflore->chargerStructureSql();
21
	}
21
	}
22
 
22
 
23
	public function chargerVersions() {
23
	public function chargerVersions() {
24
		$versions = explode(',', Config::get('versions'));
24
		$versions = explode(',', Config::get('versions'));
25
		$versionsDonnees = explode(',', Config::get('versionsDonnees'));
25
		$versionsDonnees = explode(',', Config::get('versionsDonnees'));
26
		foreach ($versions as $id => $version) {
26
		foreach ($versions as $id => $version) {
27
			$versionDonnees = $versionsDonnees[$id];
27
			$versionDonnees = $versionsDonnees[$id];
28
			$this->chargerStructureSqlVersion($versionDonnees, $version);
28
			$this->chargerStructureSqlVersion($versionDonnees, $version);
29
			$this->chargerIndexVersion($versionDonnees, $version);
29
			$this->chargerIndexVersion($versionDonnees, $version);
30
			$this->chargerDumpWikiniVersion($versionDonnees, $version);
30
			$this->chargerDumpWikiniVersion($versionDonnees, $version);
31
		}
31
		}
32
	}
32
	}
33
 
33
 
34
	private function chargerStructureSqlVersion($versionDonnees, $version) {
34
	private function chargerStructureSqlVersion($versionDonnees, $version) {
35
		$fichierSqlTpl = Config::get('chemins.structureSqlVersionTpl');
35
		$fichierSqlTpl = Config::get('chemins.structureSqlVersionTpl');
36
		$fichierSql = sprintf($fichierSqlTpl, $versionDonnees, $version);
36
		$fichierSql = sprintf($fichierSqlTpl, $versionDonnees, $version);
37
		$contenuSql = $this->eflore->recupererContenu($fichierSql);
37
		$contenuSql = $this->eflore->recupererContenu($fichierSql);
38
		$this->eflore->executerScripSql($contenuSql);
38
		$this->eflore->executerScripSql($contenuSql);
39
	}
39
	}
40
 
40
 
41
	private function chargerIndexVersion($versionDonnees, $version) {
41
	private function chargerIndexVersion($versionDonnees, $version) {
42
		$fichierTsvTpl = Config::get('chemins.costeTpl');
42
		$fichierTsvTpl = Config::get('chemins.costeTpl');
43
		$fichierTsv = sprintf($fichierTsvTpl, $versionDonnees, $version);
43
		$fichierTsv = sprintf($fichierTsvTpl, $versionDonnees, $version);
44
		$tableTpl = Config::get('tables.costeTpl');
44
		$tableTpl = Config::get('tables.costeTpl');
45
		$table = sprintf($tableTpl, $version);
45
		$table = sprintf($tableTpl, $version);
46
		$requete = "LOAD DATA INFILE '$fichierTsv' ".
46
		$requete = "LOAD DATA INFILE '$fichierTsv' ".
47
				"REPLACE INTO TABLE $table ".
47
				"REPLACE INTO TABLE $table ".
48
				'CHARACTER SET utf8 '.
48
				'CHARACTER SET utf8 '.
49
				'FIELDS '.
49
				'FIELDS '.
50
				"	TERMINATED BY '\t' ".
50
				"	TERMINATED BY '\t' ".
51
				"	ENCLOSED BY '' ".
51
				"	ENCLOSED BY '' ".
52
				"	ESCAPED BY '\\\' ".
52
				"	ESCAPED BY '\\\' ".
53
				'IGNORE 1 LINES ';
53
				'IGNORE 1 LINES ';
54
		$this->bdd->requeter($requete);
54
		$this->bdd->requeter($requete);
55
	}
55
	}
56
 
56
 
57
	private function chargerDumpWikiniVersion($versionDonnees, $version) {
57
	private function chargerDumpWikiniVersion($versionDonnees, $version) {
58
		$fichierWikiTpl = Config::get('chemins.costeWikiniTpl');
58
		$fichierWikiTpl = Config::get('chemins.costeWikiniTpl');
59
		$fichierDump = sprintf($fichierWikiTpl, $versionDonnees, $version);
59
		$fichierDump = sprintf($fichierWikiTpl, $versionDonnees, $version);
60
		$contenuSql = $this->eflore->recupererContenu($fichierDump);
60
		$contenuSql = $this->eflore->recupererContenu($fichierDump);
61
		$this->eflore->executerScripSql($contenuSql);
61
		$this->eflore->executerScripSql($contenuSql);
62
	}
62
	}
63
 
63
 
64
	public function supprimerTous() {
64
	public function supprimerTous() {
65
		$requete = "DROP TABLE IF EXISTS coste_meta, ".
65
		$requete = "DROP TABLE IF EXISTS coste_meta, ".
66
				"	coste_acls, coste_links, coste_pages, coste_referrers, coste_triples, coste_users, ".
66
				"	coste_acls, coste_links, coste_pages, coste_referrers, coste_triples, coste_users, ".
67
				"	coste_v1_00 ";
67
				"	coste_v1_00, coste_v2_00 ";
68
		$this->bdd->requeter($requete);
68
		$this->bdd->requeter($requete);
69
	}
69
	}
70
 
-
 
71
	public function nettoyerVersion1() {
-
 
72
		$requete = "DROP TABLE IF EXISTS coste_correspondance_bdnff, coste_images_auteur_correspondance_bdnff, ".
-
 
73
				"	coste_images_correspondance_bdnff, coste_index, coste_index_general";
-
 
74
		$this->bdd->requeter($requete);
-
 
75
	}
-
 
76
 
-
 
77
	public function creerVersion1() {
-
 
78
		$this->chargerStructureSqlVersion('0.00', '0_00');
-
 
79
		$this->chargerCosteImagesAuteurCorrespondanceBdnff();
-
 
80
		$this->chargerCosteCorrespondanceBdnff();
-
 
81
	}
-
 
82
 
-
 
83
	private function chargerCosteImagesAuteurCorrespondanceBdnff() {
-
 
84
		$fichierTsv = sprintf(Config::get('dossierTsvTpl'), '0.00').'coste_images_auteur_correspondance_bdnff.tsv';
-
 
85
		$requete = "LOAD DATA INFILE '$fichierTsv' ".
-
 
86
				"REPLACE INTO TABLE coste_images_auteur_correspondance_bdnff ".
-
 
87
				'CHARACTER SET utf8 '.
-
 
88
				'FIELDS '.
-
 
89
				"	TERMINATED BY '\t' ".
-
 
90
				"	ENCLOSED BY '\"' ".
-
 
91
				"	ESCAPED BY '\\\' ".
-
 
92
				'IGNORE 1 LINES ';
-
 
93
		$this->bdd->requeter($requete);
-
 
94
	}
-
 
95
 
-
 
96
	private function chargerCosteCorrespondanceBdnff() {
-
 
97
		$fichierTsv = sprintf(Config::get('dossierTsvTpl'), '0.00').'coste_images_correspondance_bdnff.tsv';
-
 
98
		$requete = "LOAD DATA INFILE '$fichierTsv' ".
-
 
99
				"REPLACE INTO TABLE coste_images_correspondance_bdnff ".
-
 
100
				'CHARACTER SET utf8 '.
-
 
101
				'FIELDS '.
-
 
102
				"	TERMINATED BY '\t' ".
-
 
103
				"	ENCLOSED BY '' ".
-
 
104
				"	ESCAPED BY '\\\' ".
-
 
105
				'IGNORE 1 LINES ';
-
 
106
		$this->bdd->requeter($requete);
-
 
107
	}
-
 
108
}
70
}
109
?>
71
?>