- else if ($from == 'readability') {
- # TODO finaliser tout ça ici
- $str_data = file_get_contents("readability");
- $data = json_decode($str_data,true);
-
- foreach ($data as $key => $value) {
- $url = '';
- foreach ($value as $key2 => $value2) {
- if ($key2 == 'article__url') {
- $url = new Url($value2);
+ $this->messages->add('s', _('import from instapaper completed'));
+ Tools::logm('import from instapaper completed');
+ Tools::redirect();
+ }
+
+ /**
+ * import from Pocket. poche needs a ./ril_export.html file
+ * @todo add the return value
+ * @return boolean
+ */
+ private function importFromPocket()
+ {
+ # TODO gestion des articles favs
+ $html = new simple_html_dom();
+ $html->load_file('./ril_export.html');
+ Tools::logm('starting import from pocket');
+
+ $read = 0;
+ $errors = array();
+ foreach($html->find('ul') as $ul)
+ {
+ foreach($ul->find('li') as $li)
+ {
+ $a = $li->find('a');
+ $url = new Url(base64_encode($a[0]->href));
+ $this->action('add', $url, 0, TRUE);
+ if ($read == '1') {
+ $sequence = '';
+ if (STORAGE == 'postgres') {
+ $sequence = 'entries_id_seq';
+ }
+ $last_id = $this->store->getLastId($sequence);
+ $this->action('toggle_archive', $url, $last_id, TRUE);
+ }
+ }
+
+ # the second <ul> is for read links
+ $read = 1;
+ }
+ $this->messages->add('s', _('import from pocket completed'));
+ Tools::logm('import from pocket completed');
+ Tools::redirect();
+ }
+
+ /**
+ * import from Readability. poche needs a ./readability file
+ * @todo add the return value
+ * @return boolean
+ */
+ private function importFromReadability()
+ {
+ # TODO gestion des articles lus / favs
+ $str_data = file_get_contents("./readability");
+ $data = json_decode($str_data,true);
+ Tools::logm('starting import from Readability');
+ $count = 0;
+ foreach ($data as $key => $value) {
+ $url = NULL;
+ $favorite = FALSE;
+ $archive = FALSE;
+ foreach ($value as $attr => $attr_value) {
+ if ($attr == 'article__url') {
+ $url = new Url(base64_encode($attr_value));
+ }
+ $sequence = '';
+ if (STORAGE == 'postgres') {
+ $sequence = 'entries_id_seq';
+ }
+ if ($attr_value == 'true') {
+ if ($attr == 'favorite') {
+ $favorite = TRUE;
+ }
+ if ($attr == 'archive') {
+ $archive = TRUE;