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.php49
1 files changed, 48 insertions, 1 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index 76a73be2..e033ad74 100644
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -848,6 +848,52 @@ class Poche
848 } 848 }
849 849
850 /** 850 /**
851 * import from Poche exported file
852 * @param string $targetFile the file used for importing
853 * @return boolean
854 */
855 private function importFromPoche($targetFile)
856 {
857 $str_data = file_get_contents($targetFile);
858 $data = json_decode($str_data,true);
859 Tools::logm('starting import from Poche');
860
861
862 $sequence = '';
863 if (STORAGE == 'postgres') {
864 $sequence = 'entries_id_seq';
865 }
866
867 $count = 0;
868 foreach ($data as $value) {
869
870 $url = new Url(base64_encode($value['url']));
871 $favorite = ($value['is_fav'] == -1);
872 $archive = ($value['is_read'] == -1);
873
874 # we can add the url
875 if (!is_null($url) && $url->isCorrect()) {
876
877 $this->action('add', $url, 0, TRUE);
878
879 $count++;
880 if ($favorite) {
881 $last_id = $this->store->getLastId($sequence);
882 $this->action('toggle_fav', $url, $last_id, TRUE);
883 }
884 if ($archive) {
885 $last_id = $this->store->getLastId($sequence);
886 $this->action('toggle_archive', $url, $last_id, TRUE);
887 }
888 }
889
890 }
891 $this->messages->add('s', _('import from Poche completed. ' . $count . ' new links.'));
892 Tools::logm('import from Poche completed');
893 Tools::redirect();
894 }
895
896 /**
851 * import datas into your poche 897 * import datas into your poche
852 * @param string $from name of the service to import : pocket, instapaper or readability 898 * @param string $from name of the service to import : pocket, instapaper or readability
853 * @todo add the return value 899 * @todo add the return value
@@ -858,7 +904,8 @@ class Poche
858 $providers = array( 904 $providers = array(
859 'pocket' => 'importFromPocket', 905 'pocket' => 'importFromPocket',
860 'readability' => 'importFromReadability', 906 'readability' => 'importFromReadability',
861 'instapaper' => 'importFromInstapaper' 907 'instapaper' => 'importFromInstapaper',
908 'poche' => 'importFromPoche',
862 ); 909 );
863 910
864 if (! isset($providers[$from])) { 911 if (! isset($providers[$from])) {