diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 76a73be2b..e033ad749 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -847,6 +847,52 @@ class Poche Tools::redirect(); } + /** + * import from Poche exported file + * @param string $targetFile the file used for importing + * @return boolean + */ + private function importFromPoche($targetFile) + { + $str_data = file_get_contents($targetFile); + $data = json_decode($str_data,true); + Tools::logm('starting import from Poche'); + + + $sequence = ''; + if (STORAGE == 'postgres') { + $sequence = 'entries_id_seq'; + } + + $count = 0; + foreach ($data as $value) { + + $url = new Url(base64_encode($value['url'])); + $favorite = ($value['is_fav'] == -1); + $archive = ($value['is_read'] == -1); + + # we can add the url + if (!is_null($url) && $url->isCorrect()) { + + $this->action('add', $url, 0, TRUE); + + $count++; + if ($favorite) { + $last_id = $this->store->getLastId($sequence); + $this->action('toggle_fav', $url, $last_id, TRUE); + } + if ($archive) { + $last_id = $this->store->getLastId($sequence); + $this->action('toggle_archive', $url, $last_id, TRUE); + } + } + + } + $this->messages->add('s', _('import from Poche completed. ' . $count . ' new links.')); + Tools::logm('import from Poche completed'); + Tools::redirect(); + } + /** * import datas into your poche * @param string $from name of the service to import : pocket, instapaper or readability @@ -858,7 +904,8 @@ class Poche $providers = array( 'pocket' => 'importFromPocket', 'readability' => 'importFromReadability', - 'instapaper' => 'importFromInstapaper' + 'instapaper' => 'importFromInstapaper', + 'poche' => 'importFromPoche', ); if (! isset($providers[$from])) { diff --git a/inc/poche/config.inc.php.new b/inc/poche/config.inc.php.new index c60d4f800..1c93be07e 100755 --- a/inc/poche/config.inc.php.new +++ b/inc/poche/config.inc.php.new @@ -55,7 +55,9 @@ define ('PAGINATION', '10'); define ('POCKET_FILE', '/ril_export.html'); define ('READABILITY_FILE', '/readability'); define ('INSTAPAPER_FILE', '/instapaper-export.html'); +define ('POCHE_FILE', '/poche-export'); define ('IMPORT_POCKET_FILE', ROOT . POCKET_FILE); define ('IMPORT_READABILITY_FILE', ROOT . READABILITY_FILE); define ('IMPORT_INSTAPAPER_FILE', ROOT . INSTAPAPER_FILE); +define ('IMPORT_POCHE_FILE', ROOT . POCHE_FILE); \ No newline at end of file diff --git a/themes/default/config.twig b/themes/default/config.twig index 10df726e0..ef615d39b 100644 --- a/themes/default/config.twig +++ b/themes/default/config.twig @@ -105,8 +105,9 @@

{% trans "More info in the official docs:" %} inthepoche.com

{% trans "Export your poche data" %}