Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 477 | Rev 484 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 477 Rev 478
Line 1... Line 1...
1
<?php
1
<?php
2
class Wiki {
2
class Wiki {
Line 3... Line 3...
3
 
3
 
-
 
4
	const URL_WIKI = 'http://www.tela-botanica.org/wikini/florecoste/api/rest/0.5/pages';
4
	const URL_WIKI = 'http://www.tela-botanica.org/wikini/florecoste/api/rest/0.5/pages';
5
	const URL_WIKI_EFLORE = 'http://www.tela-botanica.org/wikini/Coste/api/rest/0.5/pages';
5
	const DOSSIER_V2 = '../../../donnees/coste/2.00/';
6
	const DOSSIER_V2 = '../../../donnees/coste/2.00/';
Line 6... Line 7...
6
	const DOSSIER_DSC_TXT = '../../../donnees/coste/descriptions/txt/';
7
	const DOSSIER_DSC_TXT = '../../../donnees/coste/descriptions/txt/';
7
 
8
 
Line 36... Line 37...
36
					$envoyes[$tag] = 'OK';
37
					$envoyes[$tag] = 'OK';
37
				} else {
38
				} else {
38
					$this->messages->traiterErreur("Le fichier $fichier est introuvable.");
39
					$this->messages->traiterErreur("Le fichier $fichier est introuvable.");
39
				}
40
				}
40
			}
41
			}
41
			$this->messages->afficherAvancement("Upload des fichiers dans le wikini");
42
			$this->messages->afficherAvancement("Upload des fichiers d'espèce dans le wikini");
42
		}
43
		}
-
 
44
		echo "\n";
43
	}
45
	}
Line 44... Line 46...
44
 
46
 
45
	public function dowloaderPagesWiki() {
47
	public function dowloaderPagesWiki() {
46
		$this->chargerIndex();
48
		$this->chargerIndex();
Line 64... Line 66...
64
					$envoyes[$tagCle] = 'OK';
66
					$envoyes[$tagCle] = 'OK';
65
				}
67
				}
66
			}
68
			}
67
			$this->messages->afficherAvancement("Download des fichiers en cours");
69
			$this->messages->afficherAvancement("Download des fichiers en cours");
68
		}
70
		}
-
 
71
		echo "\n";
-
 
72
	}
-
 
73
 
-
 
74
	public function uploaderDansWikiEflore() {
-
 
75
		$this->chargerIndex();
-
 
76
		$envoyes = array();
-
 
77
		foreach ($this->index as $nom) {
-
 
78
			$tagDsc = $nom['page_wiki_dsc'];
-
 
79
			if (isset($envoyes[$tagDsc]) == false) {
-
 
80
				$fichier = $this->dossierBase.self::DOSSIER_V2.'/dsc/'.$tagDsc.'.txt';
-
 
81
				if (file_exists($fichier) === true) {
-
 
82
					$txt = file_get_contents($fichier);
-
 
83
					$donnees = array('pageTag' => $tagDsc, 'pageContenu' => $txt);
-
 
84
					$this->restClient->ajouter(self::URL_WIKI_EFLORE, $donnees);
-
 
85
					$envoyes[$tagDsc] = 'OK';
-
 
86
				} else {
-
 
87
					$this->messages->traiterErreur("Le fichier $fichier est introuvable.");
-
 
88
				}
-
 
89
			}
-
 
90
 
-
 
91
			$tagCle = $nom['page_wiki_cle'];
-
 
92
			if (isset($envoyes[$tagCle]) == false) {
-
 
93
				$fichier = $this->dossierBase.self::DOSSIER_V2.'/cle/'.$tagCle.'.txt';
-
 
94
				if (file_exists($fichier) === true) {
-
 
95
					$txt = file_get_contents($fichier);
-
 
96
					$donnees = array('pageTag' => $tagCle, 'pageContenu' => $txt);
-
 
97
					$this->restClient->ajouter(self::URL_WIKI_EFLORE, $donnees);
-
 
98
					$envoyes[$tagCle] = 'OK';
-
 
99
				} else {
-
 
100
					$this->messages->traiterErreur("Le fichier $fichier est introuvable.");
-
 
101
				}
-
 
102
			}
-
 
103
			$this->messages->afficherAvancement("Upload des textes dans le wikini eFlore");
-
 
104
		}
-
 
105
		echo "\n";
69
	}
106
	}
Line 70... Line 107...
70
 
107
 
71
	private function telechargerTxt($url) {
108
	private function telechargerTxt($url) {
72
		$json = $this->restClient->consulter($url);
109
		$json = $this->restClient->consulter($url);