aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/poche/Poche.class.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/poche/Poche.class.php')
-rw-r--r--inc/poche/Poche.class.php35
1 files changed, 24 insertions, 11 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index 1d8aaca2..4371c3d3 100644
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -211,6 +211,7 @@ class Poche
211 } 211 }
212 break; 212 break;
213 default: 213 default:
214 Tools::logm('action ' . $action . 'doesn\'t exist');
214 break; 215 break;
215 } 216 }
216 } 217 }
@@ -440,9 +441,11 @@ class Poche
440 $str_data = file_get_contents("./readability"); 441 $str_data = file_get_contents("./readability");
441 $data = json_decode($str_data,true); 442 $data = json_decode($str_data,true);
442 Tools::logm('starting import from Readability'); 443 Tools::logm('starting import from Readability');
443 444 $count = 0;
444 foreach ($data as $key => $value) { 445 foreach ($data as $key => $value) {
445 $url = ''; 446 $url = NULL;
447 $favorite = FALSE;
448 $archive = FALSE;
446 foreach ($value as $attr => $attr_value) { 449 foreach ($value as $attr => $attr_value) {
447 if ($attr == 'article__url') { 450 if ($attr == 'article__url') {
448 $url = new Url(base64_encode($attr_value)); 451 $url = new Url(base64_encode($attr_value));
@@ -451,20 +454,30 @@ class Poche
451 if (STORAGE == 'postgres') { 454 if (STORAGE == 'postgres') {
452 $sequence = 'entries_id_seq'; 455 $sequence = 'entries_id_seq';
453 } 456 }
454 // if ($attr_value == 'favorite' && $attr_value == 'true') { 457 if ($attr_value == 'true') {
455 // $last_id = $this->store->getLastId($sequence); 458 if ($attr == 'favorite') {
456 // $this->store->favoriteById($last_id); 459 $favorite = TRUE;
457 // $this->action('toogle_fav', $url, $last_id, TRUE); 460 }
458 // } 461 if ($attr == 'archive') {
459 if ($attr_value == 'archive' && $attr_value == 'true') { 462 $archive = TRUE;
463 }
464 }
465 }
466 # we can add the url
467 if (!is_null($url) && $url->isCorrect()) {
468 $this->action('add', $url, 0, TRUE);
469 $count++;
470 if ($favorite) {
471 $last_id = $this->store->getLastId($sequence);
472 $this->action('toggle_fav', $url, $last_id, TRUE);
473 }
474 if ($archive) {
460 $last_id = $this->store->getLastId($sequence); 475 $last_id = $this->store->getLastId($sequence);
461 $this->action('toggle_archive', $url, $last_id, TRUE); 476 $this->action('toggle_archive', $url, $last_id, TRUE);
462 } 477 }
463 } 478 }
464 if ($url->isCorrect())
465 $this->action('add', $url, 0, TRUE);
466 } 479 }
467 $this->messages->add('s', _('import from Readability completed')); 480 $this->messages->add('s', _('import from Readability completed. ' . $count . ' new links.'));
468 Tools::logm('import from Readability completed'); 481 Tools::logm('import from Readability completed');
469 Tools::redirect(); 482 Tools::redirect();
470 } 483 }