diff options
author | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2014-01-07 20:21:43 +0100 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2014-01-07 20:21:43 +0100 |
commit | 8905191413f20e7fba1d635a06cf5ec2ff86cbb3 (patch) | |
tree | b867fbc45d1d1937d3144d03aa05f2a88758d44a /inc | |
parent | e1cf0fda27df031e478e55d6df08823d42fe2220 (diff) | |
download | wallabag-8905191413f20e7fba1d635a06cf5ec2ff86cbb3.tar.gz wallabag-8905191413f20e7fba1d635a06cf5ec2ff86cbb3.tar.zst wallabag-8905191413f20e7fba1d635a06cf5ec2ff86cbb3.zip |
[add] import from poche, thank you @tsadiq #388
Diffstat (limited to 'inc')
-rw-r--r-- | inc/poche/Poche.class.php | 49 | ||||
-rwxr-xr-x | inc/poche/config.inc.php.new | 2 |
2 files changed, 50 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])) { |
diff --git a/inc/poche/config.inc.php.new b/inc/poche/config.inc.php.new index c60d4f80..1c93be07 100755 --- a/inc/poche/config.inc.php.new +++ b/inc/poche/config.inc.php.new | |||
@@ -55,7 +55,9 @@ define ('PAGINATION', '10'); | |||
55 | define ('POCKET_FILE', '/ril_export.html'); | 55 | define ('POCKET_FILE', '/ril_export.html'); |
56 | define ('READABILITY_FILE', '/readability'); | 56 | define ('READABILITY_FILE', '/readability'); |
57 | define ('INSTAPAPER_FILE', '/instapaper-export.html'); | 57 | define ('INSTAPAPER_FILE', '/instapaper-export.html'); |
58 | define ('POCHE_FILE', '/poche-export'); | ||
58 | 59 | ||
59 | define ('IMPORT_POCKET_FILE', ROOT . POCKET_FILE); | 60 | define ('IMPORT_POCKET_FILE', ROOT . POCKET_FILE); |
60 | define ('IMPORT_READABILITY_FILE', ROOT . READABILITY_FILE); | 61 | define ('IMPORT_READABILITY_FILE', ROOT . READABILITY_FILE); |
61 | define ('IMPORT_INSTAPAPER_FILE', ROOT . INSTAPAPER_FILE); | 62 | define ('IMPORT_INSTAPAPER_FILE', ROOT . INSTAPAPER_FILE); |
63 | define ('IMPORT_POCHE_FILE', ROOT . POCHE_FILE); \ No newline at end of file | ||