aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas.loeuillet@gmail.com>2014-01-07 20:21:43 +0100
committerNicolas LÅ“uillet <nicolas.loeuillet@gmail.com>2014-01-07 20:21:43 +0100
commit8905191413f20e7fba1d635a06cf5ec2ff86cbb3 (patch)
treeb867fbc45d1d1937d3144d03aa05f2a88758d44a
parente1cf0fda27df031e478e55d6df08823d42fe2220 (diff)
downloadwallabag-8905191413f20e7fba1d635a06cf5ec2ff86cbb3.tar.gz
wallabag-8905191413f20e7fba1d635a06cf5ec2ff86cbb3.tar.zst
wallabag-8905191413f20e7fba1d635a06cf5ec2ff86cbb3.zip
[add] import from poche, thank you @tsadiq #388
-rw-r--r--inc/poche/Poche.class.php49
-rwxr-xr-xinc/poche/config.inc.php.new2
-rw-r--r--themes/default/config.twig5
3 files changed, 53 insertions, 3 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');
55define ('POCKET_FILE', '/ril_export.html'); 55define ('POCKET_FILE', '/ril_export.html');
56define ('READABILITY_FILE', '/readability'); 56define ('READABILITY_FILE', '/readability');
57define ('INSTAPAPER_FILE', '/instapaper-export.html'); 57define ('INSTAPAPER_FILE', '/instapaper-export.html');
58define ('POCHE_FILE', '/poche-export');
58 59
59define ('IMPORT_POCKET_FILE', ROOT . POCKET_FILE); 60define ('IMPORT_POCKET_FILE', ROOT . POCKET_FILE);
60define ('IMPORT_READABILITY_FILE', ROOT . READABILITY_FILE); 61define ('IMPORT_READABILITY_FILE', ROOT . READABILITY_FILE);
61define ('IMPORT_INSTAPAPER_FILE', ROOT . INSTAPAPER_FILE); 62define ('IMPORT_INSTAPAPER_FILE', ROOT . INSTAPAPER_FILE);
63define ('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 10df726e..ef615d39 100644
--- a/themes/default/config.twig
+++ b/themes/default/config.twig
@@ -105,8 +105,9 @@
105 <p>{% trans "More info in the official docs:" %} <a href="http://doc.inthepoche.com/doku.php?id=users:migrate">inthepoche.com</a></p> 105 <p>{% trans "More info in the official docs:" %} <a href="http://doc.inthepoche.com/doku.php?id=users:migrate">inthepoche.com</a></p>
106 <ul> 106 <ul>
107 <li><a href="./?import&amp;from=pocket">{% trans "Import from Pocket" %}</a> {{ '(you must have a %s file on your server)'|trans|format(constant('POCKET_FILE')) }}</li> 107 <li><a href="./?import&amp;from=pocket">{% trans "Import from Pocket" %}</a> {{ '(you must have a %s file on your server)'|trans|format(constant('POCKET_FILE')) }}</li>
108 <li><a href="./?import&amp;from=readability">{% trans "Import from Readability" %}</a> {{ '(you must have a %s file on your server)'|trans|format(constant('READABILITY_FILE')) }}</li> 108 <li><a href="./?import&amp;from=readability">{% trans "Import from Readability" %}</a> {{ '(you must have a %s file on your server)'|trans|format(constant('READABILITY_FILE')) }}</li>
109 <li><a href="./?import&amp;from=instapaper">{% trans "Import from Instapaper" %}</a> {{ '(you must have a %s file on your server)'|trans|format(constant('INSTAPAPER_FILE')) }}</li> 109 <li><a href="./?import&amp;from=instapaper">{% trans "Import from Instapaper" %}</a> {{ '(you must have a %s file on your server)'|trans|format(constant('INSTAPAPER_FILE')) }}</li>
110 <li><a href="./?import&amp;from=poche">{% trans "Import from poche" %}</a> {{ '(you must have a %s file on your server)'|trans|format(constant('POCHE_FILE')) }}</li>
110 </ul> 111 </ul>
111 112
112 <h2>{% trans "Export your poche data" %}</h2> 113 <h2>{% trans "Export your poche data" %}</h2>