aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/poche
diff options
context:
space:
mode:
Diffstat (limited to 'inc/poche')
-rwxr-xr-xinc/poche/Database.class.php4
-rwxr-xr-xinc/poche/Poche.class.php53
-rwxr-xr-xinc/poche/Routing.class.php3
-rw-r--r--inc/poche/WallabagEBooks.class.php3
-rwxr-xr-xinc/poche/config.inc.default.php2
5 files changed, 49 insertions, 16 deletions
diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php
index f6ba4708..6bac0f5d 100755
--- a/inc/poche/Database.class.php
+++ b/inc/poche/Database.class.php
@@ -293,7 +293,7 @@ class Database {
293 $sql_limit = "LIMIT ".$limit." OFFSET 0"; 293 $sql_limit = "LIMIT ".$limit." OFFSET 0";
294 } 294 }
295 295
296 $sql = "SELECT * FROM entries WHERE (content = '' OR content IS NULL) AND title LIKE 'Untitled - Import%' AND user_id=? ORDER BY id " . $sql_limit; 296 $sql = "SELECT * FROM entries WHERE (content = '' OR content IS NULL) AND title LIKE '%Import%' AND user_id=? ORDER BY id " . $sql_limit;
297 $query = $this->executeQuery($sql, array($user_id)); 297 $query = $this->executeQuery($sql, array($user_id));
298 $entries = $query->fetchAll(); 298 $entries = $query->fetchAll();
299 299
@@ -302,7 +302,7 @@ class Database {
302 302
303 public function retrieveUnfetchedEntriesCount($user_id) 303 public function retrieveUnfetchedEntriesCount($user_id)
304 { 304 {
305 $sql = "SELECT count(*) FROM entries WHERE (content = '' OR content IS NULL) AND title LIKE 'Untitled - Import%' AND user_id=?"; 305 $sql = "SELECT count(*) FROM entries WHERE (content = '' OR content IS NULL) AND title LIKE '%Import%' AND user_id=?";
306 $query = $this->executeQuery($sql, array($user_id)); 306 $query = $this->executeQuery($sql, array($user_id));
307 list($count) = $query->fetch(); 307 list($count) = $query->fetch();
308 308
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index e89e9d30..b26826f1 100755
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -214,9 +214,9 @@ class Poche
214 } 214 }
215 215
216 if ($autoclose == TRUE) { 216 if ($autoclose == TRUE) {
217 Tools::redirect('?view=home'); 217 Tools::redirect('?view=home&closewin=true');
218 } else { 218 } else {
219 Tools::redirect('?view=home&closewin=true'); 219 Tools::redirect('?view=home');
220 } 220 }
221 return $last_id; 221 return $last_id;
222 break; 222 break;
@@ -356,6 +356,27 @@ class Poche
356 $this->messages->add('s', _('The tag has been successfully deleted')); 356 $this->messages->add('s', _('The tag has been successfully deleted'));
357 Tools::redirect(); 357 Tools::redirect();
358 break; 358 break;
359
360 case 'reload_article' :
361 Tools::logm('reload article');
362 $id = $_GET['id'];
363 $entry = $this->store->retrieveOneById($id, $this->user->getId());
364 Tools::logm('reload url ' . $entry['url']);
365 $url = new Url(base64_encode($entry['url']));
366 $this->action('add', $url);
367 break;
368
369 /* For some unknown reason I can't get displayView() to work here (it redirects to home view afterwards). So here's a dirty fix which redirects directly to URL */
370 case 'random':
371 $id = 0;
372 while ($this->store->retrieveOneById($id,$this->user->getId()) == null) {
373 $count = $this->store->getEntriesByViewCount($view, $this->user->getId());
374 $id = rand(1,$count);
375 }
376 Tools::logm('get a random article');
377 Tools::redirect('?view=view&id=' . $id);
378 //$this->displayView('view', $id);
379 break;
359 default: 380 default:
360 break; 381 break;
361 } 382 }
@@ -738,17 +759,23 @@ class Poche
738 $purifier = $this->_getPurifier(); 759 $purifier = $this->_getPurifier();
739 foreach($items as $item) { 760 foreach($items as $item) {
740 $url = new Url(base64_encode($item['url'])); 761 $url = new Url(base64_encode($item['url']));
741 Tools::logm('Fetching article ' . $item['id']); 762 if( $url->isCorrect() )
742 $content = Tools::getPageContent($url); 763 {
743 $title = (($content['rss']['channel']['item']['title'] != '') ? $content['rss']['channel']['item']['title'] : _('Untitled')); 764 Tools::logm('Fetching article ' . $item['id']);
744 $body = (($content['rss']['channel']['item']['description'] != '') ? $content['rss']['channel']['item']['description'] : _('Undefined')); 765 $content = Tools::getPageContent($url);
745 766 $title = (($content['rss']['channel']['item']['title'] != '') ? $content['rss']['channel']['item']['title'] : _('Untitled'));
746 // clean content to prevent xss attack 767 $body = (($content['rss']['channel']['item']['description'] != '') ? $content['rss']['channel']['item']['description'] : _('Undefined'));
747 768
748 $title = $purifier->purify($title); 769 // clean content to prevent xss attack
749 $body = $purifier->purify($body); 770
750 $this->store->updateContentAndTitle($item['id'], $title, $body, $this->user->getId()); 771 $title = $purifier->purify($title);
751 Tools::logm('Article ' . $item['id'] . ' updated.'); 772 $body = $purifier->purify($body);
773 $this->store->updateContentAndTitle($item['id'], $title, $body, $this->user->getId());
774 Tools::logm('Article ' . $item['id'] . ' updated.');
775 } else
776 {
777 Tools::logm('Unvalid URL (' . $item['url'] .') to fetch for article ' . $item['id']);
778 }
752 } 779 }
753 } 780 }
754 } 781 }
diff --git a/inc/poche/Routing.class.php b/inc/poche/Routing.class.php
index b8cab0ec..82ff20d6 100755
--- a/inc/poche/Routing.class.php
+++ b/inc/poche/Routing.class.php
@@ -33,6 +33,7 @@ class Routing
33 $this->view = Tools::checkVar('view', 'home'); 33 $this->view = Tools::checkVar('view', 'home');
34 $this->action = Tools::checkVar('action'); 34 $this->action = Tools::checkVar('action');
35 $this->id = Tools::checkVar('id'); 35 $this->id = Tools::checkVar('id');
36 $this->autoclose = Tools::checkVar('autoclose',FALSE);
36 $_SESSION['sort'] = Tools::checkVar('sort', 'id'); 37 $_SESSION['sort'] = Tools::checkVar('sort', 'id');
37 $this->url = new Url((isset ($_GET['url'])) ? $_GET['url'] : ''); 38 $this->url = new Url((isset ($_GET['url'])) ? $_GET['url'] : '');
38 } 39 }
@@ -64,7 +65,7 @@ class Routing
64 $tplVars = array(); 65 $tplVars = array();
65 66
66 if (\Session::isLogged()) { 67 if (\Session::isLogged()) {
67 $this->wallabag->action($this->action, $this->url, $this->id); 68 $this->wallabag->action($this->action, $this->url, $this->id, FALSE, $this->autoclose);
68 $tplFile = Tools::getTplFile($this->view); 69 $tplFile = Tools::getTplFile($this->view);
69 $tplVars = array_merge($this->vars, $this->wallabag->displayView($this->view, $this->id)); 70 $tplVars = array_merge($this->vars, $this->wallabag->displayView($this->view, $this->id));
70 } elseif(isset($_SERVER['PHP_AUTH_USER'])) { 71 } elseif(isset($_SERVER['PHP_AUTH_USER'])) {
diff --git a/inc/poche/WallabagEBooks.class.php b/inc/poche/WallabagEBooks.class.php
index d31939a1..55831571 100644
--- a/inc/poche/WallabagEBooks.class.php
+++ b/inc/poche/WallabagEBooks.class.php
@@ -202,6 +202,9 @@ class WallabagMobi extends WallabagEBooks
202 } 202 }
203 $mobi->setContentProvider($content); 203 $mobi->setContentProvider($content);
204 204
205 // the browser inside Kindle Devices doesn't likes special caracters either, we limit to A-z/0-9
206 $this->bookFileName = preg_replace('/[^A-Za-z0-9\-]/', '', $this->bookFileName);
207
205 // we offer file to download 208 // we offer file to download
206 $mobi->download($this->bookFileName.'.mobi'); 209 $mobi->download($this->bookFileName.'.mobi');
207 Tools::logm('Mobi file produced'); 210 Tools::logm('Mobi file produced');
diff --git a/inc/poche/config.inc.default.php b/inc/poche/config.inc.default.php
index a159e713..91b50c24 100755
--- a/inc/poche/config.inc.default.php
+++ b/inc/poche/config.inc.default.php
@@ -44,6 +44,7 @@
44@define ('SHARE_MAIL', TRUE); 44@define ('SHARE_MAIL', TRUE);
45@define ('SHARE_SHAARLI', FALSE); 45@define ('SHARE_SHAARLI', FALSE);
46@define ('SHAARLI_URL', 'http://myshaarliurl.com'); 46@define ('SHAARLI_URL', 'http://myshaarliurl.com');
47@define ('SHARE_EVERNOTE', FALSE);
47@define ('SHARE_DIASPORA', FALSE); 48@define ('SHARE_DIASPORA', FALSE);
48@define ('DIASPORA_URL', 'http://diasporapod.com'); # Don't add a / at the end 49@define ('DIASPORA_URL', 'http://diasporapod.com'); # Don't add a / at the end
49@define ('FLATTR', TRUE); 50@define ('FLATTR', TRUE);
@@ -62,6 +63,7 @@
62@define ('SHOW_PRINTLINK', '1'); 63@define ('SHOW_PRINTLINK', '1');
63// display or not percent of read in article view. Affects only default theme. 64// display or not percent of read in article view. Affects only default theme.
64@define ('SHOW_READPERCENT', '1'); 65@define ('SHOW_READPERCENT', '1');
66@define ('RELOAD_ARTICLE', TRUE);
65@define ('ABS_PATH', 'assets/'); 67@define ('ABS_PATH', 'assets/');
66 68
67@define ('DEFAULT_THEME', 'baggy'); 69@define ('DEFAULT_THEME', 'baggy');