aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/poche/Poche.class.php
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2015-02-13 17:14:08 +0100
committerThomas Citharel <tcit@tcit.fr>2015-02-13 17:14:08 +0100
commit57068585c0a1164f1ae7ae399f3d5a68a4e9d46d (patch)
tree479969a1a9888c34285e0f84a8186561ebe980e7 /inc/poche/Poche.class.php
parent1be071f9f0fba7c93f114a886ff19199955a3f02 (diff)
parentaf13787e74ea45d7edc1005810f15a8baa428a77 (diff)
downloadwallabag-57068585c0a1164f1ae7ae399f3d5a68a4e9d46d.tar.gz
wallabag-57068585c0a1164f1ae7ae399f3d5a68a4e9d46d.tar.zst
wallabag-57068585c0a1164f1ae7ae399f3d5a68a4e9d46d.zip
Merge branch 'dev' into sendmailatregistration
Diffstat (limited to 'inc/poche/Poche.class.php')
-rwxr-xr-xinc/poche/Poche.class.php53
1 files changed, 40 insertions, 13 deletions
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 }