aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc')
-rw-r--r--inc/poche/Poche.class.php115
-rw-r--r--inc/poche/Tools.class.php5
2 files changed, 66 insertions, 54 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index 9e407d41..5c3eda80 100644
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -118,8 +118,6 @@ class Poche
118 $this->store->archiveById($id); 118 $this->store->archiveById($id);
119 Tools::logm('archive link #' . $id); 119 Tools::logm('archive link #' . $id);
120 break; 120 break;
121 case 'import':
122 break;
123 default: 121 default:
124 break; 122 break;
125 } 123 }
@@ -131,18 +129,6 @@ class Poche
131 129
132 switch ($view) 130 switch ($view)
133 { 131 {
134 case 'install':
135 Tools::logm('install mode');
136 break;
137 case 'import';
138 Tools::logm('import mode');
139 break;
140 case 'export':
141 $entries = $this->store->retrieveAll();
142 // $tpl->assign('export', Tools::renderJson($entries));
143 // $tpl->draw('export');
144 Tools::logm('export view');
145 break;
146 case 'config': 132 case 'config':
147 Tools::logm('config view'); 133 Tools::logm('config view');
148 break; 134 break;
@@ -224,59 +210,80 @@ class Poche
224 Tools::redirect(); 210 Tools::redirect();
225 } 211 }
226 212
227 public function import($from) 213 private function importFromInstapaper()
228 { 214 {
229 if ($from == 'pocket') { 215 Tools::logm('import from instapaper completed');
230 $html = new simple_html_dom(); 216 Tools::redirect();
231 $html->load_file('./ril_export.html'); 217 }
232 218
233 $read = 0; 219 private function importFromPocket()
234 $errors = array(); 220 {
235 foreach($html->find('ul') as $ul) 221 $html = new simple_html_dom();
222 $html->load_file('./ril_export.html');
223
224 $read = 0;
225 $errors = array();
226 foreach($html->find('ul') as $ul)
227 {
228 foreach($ul->find('li') as $li)
236 { 229 {
237 foreach($ul->find('li') as $li) 230 $a = $li->find('a');
238 { 231 $url = new Url(base64_encode($a[0]->href));
239 $a = $li->find('a'); 232 $this->action('add', $url);
240 $url = new Url($a[0]->href); 233 if ($read == '1') {
241 $this->action('add', $url); 234 $last_id = $this->store->getLastId();
242 if ($read == '1') { 235 $this->store->archiveById($last_id);
243 $last_id = $this->store->lastInsertId();
244 $sql_update = "UPDATE entries SET is_read=~is_read WHERE id=?";
245 $params_update = array($last_id);
246 $query_update = $this->store->prepare($sql_update);
247 $query_update->execute($params_update);
248 }
249 } 236 }
250 # Pocket génère un fichier HTML avec deux <ul>
251 # Le premier concerne les éléments non lus
252 # Le second concerne les éléments archivés
253 $read = 1;
254 } 237 }
255 logm('import from pocket completed'); 238 # Pocket génère un fichier HTML avec deux <ul>
256 Tools::redirect(); 239 # Le premier concerne les éléments non lus
240 # Le second concerne les éléments archivés
241 $read = 1;
257 } 242 }
258 else if ($from == 'readability') { 243 Tools::logm('import from pocket completed');
259 # TODO finaliser tout ça ici 244 Tools::redirect();
260 $str_data = file_get_contents("readability"); 245 }
261 $data = json_decode($str_data,true);
262 246
263 foreach ($data as $key => $value) { 247 private function importFromReadability()
264 $url = ''; 248 {
265 foreach ($value as $key2 => $value2) { 249 # TODO finaliser tout ça ici
266 if ($key2 == 'article__url') { 250 # noms des variables + gestion des articles lus
267 $url = new Url($value2); 251 $str_data = file_get_contents("./readability");
268 } 252 $data = json_decode($str_data,true);
253
254 foreach ($data as $key => $value) {
255 $url = '';
256 foreach ($value as $key2 => $value2) {
257 if ($key2 == 'article__url') {
258 $url = new Url(base64_encode($value2));
269 } 259 }
270 if ($url != '')
271 action_to_do('add', $url);
272 } 260 }
273 logm('import from Readability completed'); 261 if ($url->isCorrect())
274 Tools::redirect(); 262 $this->action('add', $url);
275 } 263 }
264 Tools::logm('import from Readability completed');
265 Tools::redirect();
276 } 266 }
277 267
278 public function export() 268 public function import($from)
279 { 269 {
270 if ($from == 'pocket') {
271 $this->importFromPocket();
272 }
273 else if ($from == 'readability') {
274 $this->importFromReadability();
275 }
276 else if ($from == 'instapaper') {
277 $this->importFromInstapaper();
278 }
279 }
280 280
281 public function export()
282 {
283 $entries = $this->store->retrieveAll();
284 echo $this->tpl->render('export.twig', array(
285 'export' => Tools::renderJson($entries),
286 ));
287 Tools::logm('export view');
281 } 288 }
282} \ No newline at end of file 289} \ No newline at end of file
diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php
index c277035f..1ff4ba55 100644
--- a/inc/poche/Tools.class.php
+++ b/inc/poche/Tools.class.php
@@ -205,4 +205,9 @@ class Tools
205 { 205 {
206 return sha1($string . SALT); 206 return sha1($string . SALT);
207 } 207 }
208
209 public static function checkVar($var)
210 {
211 return ((isset ($_REQUEST["$var"])) ? htmlentities($_REQUEST["$var"]) : '');
212 }
208} \ No newline at end of file 213} \ No newline at end of file