| Line 6... |
Line 6... |
| 6 |
private $URL_WIKI = '';
|
6 |
private $URL_WIKI = '';
|
| 7 |
private $URL_WIKI_EFLORE = '';
|
7 |
private $URL_WIKI_EFLORE = '';
|
| 8 |
private $conteneur = null;
|
8 |
private $conteneur = null;
|
| 9 |
private $outils = null;
|
9 |
private $outils = null;
|
| 10 |
private $messages = null;
|
10 |
private $messages = null;
|
| 11 |
private $restClient = null;
|
11 |
private $restClient = null;
|
| - |
|
12 |
private $bdd = null;
|
| 12 |
private $dossierBase = '';
|
13 |
private $dossierBase = '';
|
| 13 |
private $index = array();
|
14 |
private $index = array();
|
| Line 14... |
Line 15... |
| 14 |
|
15 |
|
| 15 |
public function __construct(Conteneur $conteneur) {
|
16 |
public function __construct(Conteneur $conteneur) {
|
| Line 18... |
Line 19... |
| 18 |
$this->conteneur = $conteneur;
|
19 |
$this->conteneur = $conteneur;
|
| 19 |
$this->URL_WIKI = $this->conteneur->getParametre('wiki.travail');
|
20 |
$this->URL_WIKI = $this->conteneur->getParametre('wiki.travail');
|
| 20 |
$this->URL_WIKI_EFLORE = $this->conteneur->getParametre('wiki.eflore');
|
21 |
$this->URL_WIKI_EFLORE = $this->conteneur->getParametre('wiki.eflore');
|
| 21 |
$this->outils = $conteneur->getOutils();
|
22 |
$this->outils = $conteneur->getOutils();
|
| 22 |
$this->messages = $conteneur->getMessages();
|
23 |
$this->messages = $conteneur->getMessages();
|
| 23 |
$this->restClient = $conteneur->getRestClient();
|
24 |
$this->restClient = $conteneur->getRestClient();
|
| - |
|
25 |
$this->bdd = $conteneur->getBdd();
|
| 24 |
$this->dossierBase = dirname(__FILE__).'/';
|
26 |
$this->dossierBase = dirname(__FILE__).'/';
|
| 25 |
}
|
27 |
}
|
| Line 26... |
Line 28... |
| 26 |
|
28 |
|
| 27 |
public function uploaderFichiersSp() {
|
29 |
public function uploaderFichiersSp() {
|
| Line 92... |
Line 94... |
| 92 |
$tagCle = $nom['page_wiki_cle'];
|
94 |
$tagCle = $nom['page_wiki_cle'];
|
| 93 |
if (isset($envoyes[$tagCle]) == false) {
|
95 |
if (isset($envoyes[$tagCle]) == false) {
|
| 94 |
$fichier = $this->dossierBase.self::DOSSIER_V2.'cle/'.$tagCle.'.txt';
|
96 |
$fichier = $this->dossierBase.self::DOSSIER_V2.'cle/'.$tagCle.'.txt';
|
| 95 |
if (file_exists($fichier) === true) {
|
97 |
if (file_exists($fichier) === true) {
|
| 96 |
$txt = file_get_contents($fichier);
|
98 |
$txt = file_get_contents($fichier);
|
| 97 |
$this->envoyerPage($tagDsc, $txt);
|
99 |
$this->envoyerPage($tagCle, $txt);
|
| 98 |
$envoyes[$tagCle] = 'OK';
|
100 |
$envoyes[$tagCle] = 'OK';
|
| 99 |
} else {
|
101 |
} else {
|
| 100 |
$this->messages->traiterErreur("Le fichier $fichier est introuvable.");
|
102 |
$this->messages->traiterErreur("Le fichier $fichier est introuvable.");
|
| 101 |
}
|
103 |
}
|
| 102 |
}
|
104 |
}
|
| 103 |
$this->messages->afficherAvancement("Upload des textes dans le wikini eFlore");
|
105 |
$this->messages->afficherAvancement("Upload des textes dans le wikini eFlore");
|
| 104 |
}
|
106 |
}
|
| 105 |
echo "\n";
|
107 |
echo "\n";
|
| 106 |
}
|
108 |
}
|
| Line -... |
Line 109... |
| - |
|
109 |
|
| - |
|
110 |
public function chargerTxtDansWikiEflore() {
|
| - |
|
111 |
$this->chargerIndex();
|
| - |
|
112 |
$envoyes = array();
|
| - |
|
113 |
foreach ($this->index as $nom) {
|
| - |
|
114 |
$tagDsc = $nom['page_wiki_dsc'];
|
| - |
|
115 |
if (isset($envoyes[$tagDsc]) == false) {
|
| - |
|
116 |
$fichier = $this->dossierBase.self::DOSSIER_V2.'dsc/'.$tagDsc.'.txt';
|
| - |
|
117 |
if (file_exists($fichier) === true) {
|
| - |
|
118 |
$txt = file_get_contents($fichier);
|
| - |
|
119 |
$this->enregistrerPage($tagDsc, $txt);
|
| - |
|
120 |
$envoyes[$tagDsc] = 'OK';
|
| - |
|
121 |
} else {
|
| - |
|
122 |
$this->messages->traiterErreur("Le fichier $fichier est introuvable.");
|
| - |
|
123 |
}
|
| - |
|
124 |
}
|
| - |
|
125 |
|
| - |
|
126 |
$tagCle = $nom['page_wiki_cle'];
|
| - |
|
127 |
if (isset($envoyes[$tagCle]) == false) {
|
| - |
|
128 |
$fichier = $this->dossierBase.self::DOSSIER_V2.'cle/'.$tagCle.'.txt';
|
| - |
|
129 |
if (file_exists($fichier) === true) {
|
| - |
|
130 |
$txt = file_get_contents($fichier);
|
| - |
|
131 |
$this->enregistrerPage($tagCle, $txt);
|
| - |
|
132 |
$envoyes[$tagCle] = 'OK';
|
| - |
|
133 |
} else {
|
| - |
|
134 |
$this->messages->traiterErreur("Le fichier $fichier est introuvable.");
|
| - |
|
135 |
}
|
| - |
|
136 |
}
|
| - |
|
137 |
$this->messages->afficherAvancement("Enregistrement des textes dans le wikini eFlore");
|
| - |
|
138 |
}
|
| - |
|
139 |
echo "\n";
|
| - |
|
140 |
}
|
| - |
|
141 |
|
| - |
|
142 |
public function chargerIndexDansWikiEflore() {
|
| - |
|
143 |
$index = $this->creerIndex();
|
| - |
|
144 |
foreach ($index as $titre => $txt) {
|
| - |
|
145 |
$this->enregistrerPage($titre, $txt);
|
| - |
|
146 |
}
|
| - |
|
147 |
}
|
| 107 |
|
148 |
|
| - |
|
149 |
public function uploaderIndexDansWikiEflore() {
|
| - |
|
150 |
$index = $this->creerIndex();
|
| - |
|
151 |
foreach ($index as $titre => $txt) {
|
| - |
|
152 |
$this->envoyerPage($titre, $txt);
|
| - |
|
153 |
}
|
| - |
|
154 |
}
|
| - |
|
155 |
|
| 108 |
public function uploaderIndexDansWikiEflore() {
|
156 |
public function creerIndex() {
|
| 109 |
$this->chargerIndex();
|
157 |
$this->chargerIndex();
|
| 110 |
$envoyes = array();
|
158 |
$envoyes = array();
|
| 111 |
$pageIndexFamille = "==Index Famille Coste==\n\n";
|
159 |
$pageIndexFamille = "==Index Famille Coste==\n\n";
|
| 112 |
$pageIndexGenre = "==Index Genre Coste==\n\n";
|
160 |
$pageIndexGenre = "==Index Genre Coste==\n\n";
|
| 113 |
$pageIndexEspece = "==Index Espèce Coste==\n\n";
|
161 |
$pageIndexEspece = "==Index Espèce Coste==\n\n";
|
| 114 |
foreach ($this->index as $nom) {
|
162 |
foreach ($this->index as $nom) {
|
| 115 |
$indentation = $this->getIndentationTxtLien($nom);
|
163 |
$indentation = $this->getIndentationTxtLien($nom);
|
| Line 116... |
Line 164... |
| 116 |
$txtLien = $this->getTxtLienGenerique($nom);
|
164 |
$txtLien = $this->getTxtLienGenerique($nom);
|
| 117 |
|
165 |
|
| 118 |
$tagDsc = $nom['page_wiki_dsc'];
|
166 |
$tagDsc = $nom['page_wiki_dsc'];
|
| 119 |
if (isset($envoyes[$tagDsc]) == false) {
|
167 |
if (isset($envoyes[$tagDsc]) == false) {
|
| 120 |
$fichier = $this->dossierBase.self::DOSSIER_V2.'dsc/'.$tagDsc.'.txt';
|
168 |
$fichier = $this->dossierBase.self::DOSSIER_V2.'dsc/'.$tagDsc.'.txt';
|
| 121 |
if ($nom['rang'] <= 180) {
|
169 |
if ($nom['rang'] <= 180) {
|
| 122 |
$pageIndexFamille .= "$indentation- [[$tagDsc $txtLien]]\n";
|
170 |
$pageIndexFamille .= "$indentation- [[$tagDsc $txtLien]]\n";
|
| 123 |
} elseif ($nom['rang'] == 220) {
|
171 |
} elseif ($nom['rang'] == 220) {
|
| 124 |
$pageIndexGenre .= "$indentation- [[$tagDsc $txtLien]]\n";
|
172 |
$pageIndexGenre .= "$indentation- [[$tagDsc $txtLien]]\n";
|
| 125 |
} else {
|
173 |
} else {
|
| 126 |
$pageIndexEspece .= "$indentation- [[$tagDsc $txtLien]]\n";
|
174 |
$pageIndexEspece .= "$indentation- [[$tagDsc $txtLien]]\n";
|
| 127 |
}
|
175 |
}
|
| Line 128... |
Line 176... |
| 128 |
$envoyes[$tagDsc] = 'OK';
|
176 |
$envoyes[$tagDsc] = 'OK';
|
| 129 |
}
|
177 |
}
|
| 130 |
|
178 |
|
| 131 |
$tagCle = $nom['page_wiki_cle'];
|
179 |
$tagCle = $nom['page_wiki_cle'];
|
| 132 |
if (isset($envoyes[$tagCle]) == false) {
|
180 |
if (isset($envoyes[$tagCle]) == false) {
|
| 133 |
$fichier = $this->dossierBase.self::DOSSIER_V2.'cle/'.$tagCle.'.txt';
|
181 |
$fichier = $this->dossierBase.self::DOSSIER_V2.'cle/'.$tagCle.'.txt';
|
| 134 |
$indentation = $indentation.' ';
|
182 |
$indentation = $indentation.' ';
|
| 135 |
if ($nom['rang'] <= 180) {
|
183 |
if ($nom['rang'] <= 180) {
|
| 136 |
$pageIndexFamille = rtrim($pageIndexFamille, "\n");
|
184 |
$pageIndexFamille = rtrim($pageIndexFamille, "\n");
|
| 137 |
$pageIndexFamille .= " - [[$tagCle Clé]]\n";
|
185 |
$pageIndexFamille .= " - [[$tagCle Clé]]\n";
|
| 138 |
} elseif ($nom['rang'] == 220) {
|
186 |
} elseif ($nom['rang'] == 220) {
|
| 139 |
$pageIndexGenre = rtrim($pageIndexGenre, "\n");
|
187 |
$pageIndexGenre = rtrim($pageIndexGenre, "\n");
|
| 140 |
$pageIndexGenre .= " - [[$tagCle Clé]]\n";
|
188 |
$pageIndexGenre .= " - [[$tagCle Clé]]\n";
|
| 141 |
}
|
189 |
}
|
| 142 |
$envoyes[$tagCle] = 'OK';
|
190 |
$envoyes[$tagCle] = 'OK';
|
| 143 |
}
|
- |
|
| 144 |
$this->messages->afficherAvancement("Upload des index dans le wikini eFlore");
|
191 |
}
|
| - |
|
192 |
$this->messages->afficherAvancement("Création des pages d'index pour le wikini eFlore");
|
| 145 |
}
|
193 |
}
|
| 146 |
$this->envoyerPage('IndexFamille', $pageIndexFamille);
|
194 |
echo "\n";
|
| 147 |
$this->envoyerPage('IndexGenre', $pageIndexGenre);
|
195 |
|
| Line 148... |
Line 196... |
| 148 |
$this->envoyerPage('IndexEspece', $pageIndexEspece);
|
196 |
$index = array('IndexFamille' => $pageIndexFamille, 'IndexGenre' => $pageIndexGenre, 'IndexEspece' => $pageIndexEspece);
|
| 149 |
echo "\n";
|
197 |
return $index;
|
| 150 |
}
|
198 |
}
|
| Line 178... |
Line 226... |
| 178 |
private function envoyerPage($titre, $txt) {
|
226 |
private function envoyerPage($titre, $txt) {
|
| 179 |
$donnees = array('pageTag' => $titre, 'pageContenu' => $txt);
|
227 |
$donnees = array('pageTag' => $titre, 'pageContenu' => $txt);
|
| 180 |
$this->restClient->ajouter($this->URL_WIKI_EFLORE, $donnees);
|
228 |
$this->restClient->ajouter($this->URL_WIKI_EFLORE, $donnees);
|
| 181 |
}
|
229 |
}
|
| Line -... |
Line 230... |
| - |
|
230 |
|
| - |
|
231 |
private function enregistrerPage($titre, $txt) {
|
| - |
|
232 |
$titre = $this->bdd->proteger($titre);
|
| - |
|
233 |
$time = $this->bdd->proteger(date('Y-m-d H:i:s'));
|
| - |
|
234 |
$txt = $this->bdd->proteger($txt);
|
| - |
|
235 |
$requete = "INSERT INTO `coste_pages` (`tag`, `time`, `body`, `body_r`, `owner`, `user`, `latest`, `handler`, `comment_on`) VALUES ".
|
| - |
|
236 |
"($titre, $time, $txt, '', '', 'ScriptEflore', 'Y', 'page', '')";
|
| - |
|
237 |
$this->bdd->requeter($requete);
|
| - |
|
238 |
}
|
| 182 |
|
239 |
|
| 183 |
private function telechargerTxt($url) {
|
240 |
private function telechargerTxt($url) {
|
| 184 |
$json = $this->restClient->consulter($url);
|
241 |
$json = $this->restClient->consulter($url);
|
| 185 |
$donnees = json_decode($json, true);
|
242 |
$donnees = json_decode($json, true);
|
| 186 |
return $donnees['texte'];
|
243 |
return $donnees['texte'];
|