diff options
Diffstat (limited to 'inc/poche')
-rwxr-xr-x | inc/poche/Database.class.php | 6 | ||||
-rwxr-xr-x | inc/poche/Poche.class.php | 7 |
2 files changed, 10 insertions, 3 deletions
diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php index a80eea97..d1044a6e 100755 --- a/inc/poche/Database.class.php +++ b/inc/poche/Database.class.php | |||
@@ -77,7 +77,7 @@ class Database { | |||
77 | } | 77 | } |
78 | else { | 78 | else { |
79 | $sql = ' | 79 | $sql = ' |
80 | CREATE TABLE tags ( | 80 | CREATE TABLE IF NOT EXISTS tags ( |
81 | id bigserial primary key, | 81 | id bigserial primary key, |
82 | value varchar(255) NOT NULL | 82 | value varchar(255) NOT NULL |
83 | ); | 83 | ); |
@@ -110,7 +110,7 @@ class Database { | |||
110 | } | 110 | } |
111 | else { | 111 | else { |
112 | $sql = ' | 112 | $sql = ' |
113 | CREATE TABLE tags_entries ( | 113 | CREATE TABLE IF NOT EXISTS tags_entries ( |
114 | id bigserial primary key, | 114 | id bigserial primary key, |
115 | entry_id integer NOT NULL, | 115 | entry_id integer NOT NULL, |
116 | tag_id integer NOT NULL | 116 | tag_id integer NOT NULL |
@@ -407,7 +407,7 @@ class Database { | |||
407 | public function getLastId($column = '') { | 407 | public function getLastId($column = '') { |
408 | return $this->getHandle()->lastInsertId($column); | 408 | return $this->getHandle()->lastInsertId($column); |
409 | } | 409 | } |
410 | 410 | ||
411 | public function search($term, $user_id, $limit = '') { | 411 | public function search($term, $user_id, $limit = '') { |
412 | $search = '%'.$term.'%'; | 412 | $search = '%'.$term.'%'; |
413 | $sql_action = "SELECT * FROM entries WHERE user_id=? AND (content LIKE ? OR title LIKE ? OR url LIKE ?) "; //searches in content, title and URL | 413 | $sql_action = "SELECT * FROM entries WHERE user_id=? AND (content LIKE ? OR title LIKE ? OR url LIKE ?) "; //searches in content, title and URL |
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 613377c6..3a4e78d6 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php | |||
@@ -832,6 +832,8 @@ class Poche | |||
832 | } | 832 | } |
833 | 833 | ||
834 | if ( isset($_FILES['file']) ) { | 834 | if ( isset($_FILES['file']) ) { |
835 | Tools::logm('Import stated: parsing file'); | ||
836 | |||
835 | // assume, that file is in json format | 837 | // assume, that file is in json format |
836 | $str_data = file_get_contents($_FILES['file']['tmp_name']); | 838 | $str_data = file_get_contents($_FILES['file']['tmp_name']); |
837 | $data = json_decode($str_data, true); | 839 | $data = json_decode($str_data, true); |
@@ -897,6 +899,7 @@ class Poche | |||
897 | if ( $i > 0 ) { | 899 | if ( $i > 0 ) { |
898 | $this->messages->add('s', _('Articles inserted: ').$i._('. Please note, that some may be marked as "read".')); | 900 | $this->messages->add('s', _('Articles inserted: ').$i._('. Please note, that some may be marked as "read".')); |
899 | } | 901 | } |
902 | Tools::logm('Import of articles finished: '.$i.' articles added (w/o content if not provided).'); | ||
900 | } | 903 | } |
901 | //file parsing finished here | 904 | //file parsing finished here |
902 | 905 | ||
@@ -907,12 +910,14 @@ class Poche | |||
907 | if ( $recordsDownloadRequired == 0 ) { | 910 | if ( $recordsDownloadRequired == 0 ) { |
908 | //nothing to download | 911 | //nothing to download |
909 | $this->messages->add('s', _('Import finished.')); | 912 | $this->messages->add('s', _('Import finished.')); |
913 | Tools::logm('Import finished completely'); | ||
910 | Tools::redirect(); | 914 | Tools::redirect(); |
911 | } | 915 | } |
912 | else { | 916 | else { |
913 | //if just inserted - don't download anything, download will start in next reload | 917 | //if just inserted - don't download anything, download will start in next reload |
914 | if ( !isset($_FILES['file']) ) { | 918 | if ( !isset($_FILES['file']) ) { |
915 | //download next batch | 919 | //download next batch |
920 | Tools::logm('Fetching next batch of articles...'); | ||
916 | $items = $this->store->retrieveUnfetchedEntries($this->user->getId(), IMPORT_LIMIT); | 921 | $items = $this->store->retrieveUnfetchedEntries($this->user->getId(), IMPORT_LIMIT); |
917 | 922 | ||
918 | $config = HTMLPurifier_Config::createDefault(); | 923 | $config = HTMLPurifier_Config::createDefault(); |
@@ -921,6 +926,7 @@ class Poche | |||
921 | 926 | ||
922 | foreach ($items as $item) { | 927 | foreach ($items as $item) { |
923 | $url = new Url(base64_encode($item['url'])); | 928 | $url = new Url(base64_encode($item['url'])); |
929 | Tools::logm('Fetching article '.$item['id']); | ||
924 | $content = Tools::getPageContent($url); | 930 | $content = Tools::getPageContent($url); |
925 | 931 | ||
926 | $title = (($content['rss']['channel']['item']['title'] != '') ? $content['rss']['channel']['item']['title'] : _('Untitled')); | 932 | $title = (($content['rss']['channel']['item']['title'] != '') ? $content['rss']['channel']['item']['title'] : _('Untitled')); |
@@ -931,6 +937,7 @@ class Poche | |||
931 | $body = $purifier->purify($body); | 937 | $body = $purifier->purify($body); |
932 | 938 | ||
933 | $this->store->updateContentAndTitle($item['id'], $title, $body, $this->user->getId()); | 939 | $this->store->updateContentAndTitle($item['id'], $title, $body, $this->user->getId()); |
940 | Tools::logm('Article '.$item['id'].' updated.'); | ||
934 | } | 941 | } |
935 | 942 | ||
936 | } | 943 | } |