From 63c35580c7d60e2278ee6fe9ba2d4440ff0308d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Sun, 4 Aug 2013 22:35:08 +0200 Subject: twig implementation --- inc/poche/Poche.class.php | 115 ++++++++++++++++++++++++---------------------- inc/poche/Tools.class.php | 5 ++ 2 files changed, 66 insertions(+), 54 deletions(-) (limited to 'inc') 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 $this->store->archiveById($id); Tools::logm('archive link #' . $id); break; - case 'import': - break; default: break; } @@ -131,18 +129,6 @@ class Poche switch ($view) { - case 'install': - Tools::logm('install mode'); - break; - case 'import'; - Tools::logm('import mode'); - break; - case 'export': - $entries = $this->store->retrieveAll(); - // $tpl->assign('export', Tools::renderJson($entries)); - // $tpl->draw('export'); - Tools::logm('export view'); - break; case 'config': Tools::logm('config view'); break; @@ -224,59 +210,80 @@ class Poche Tools::redirect(); } - public function import($from) + private function importFromInstapaper() { - if ($from == 'pocket') { - $html = new simple_html_dom(); - $html->load_file('./ril_export.html'); + Tools::logm('import from instapaper completed'); + Tools::redirect(); + } - $read = 0; - $errors = array(); - foreach($html->find('ul') as $ul) + private function importFromPocket() + { + $html = new simple_html_dom(); + $html->load_file('./ril_export.html'); + + $read = 0; + $errors = array(); + foreach($html->find('ul') as $ul) + { + foreach($ul->find('li') as $li) { - foreach($ul->find('li') as $li) - { - $a = $li->find('a'); - $url = new Url($a[0]->href); - $this->action('add', $url); - if ($read == '1') { - $last_id = $this->store->lastInsertId(); - $sql_update = "UPDATE entries SET is_read=~is_read WHERE id=?"; - $params_update = array($last_id); - $query_update = $this->store->prepare($sql_update); - $query_update->execute($params_update); - } + $a = $li->find('a'); + $url = new Url(base64_encode($a[0]->href)); + $this->action('add', $url); + if ($read == '1') { + $last_id = $this->store->getLastId(); + $this->store->archiveById($last_id); } - # Pocket génère un fichier HTML avec deux