diff options
Diffstat (limited to 'inc/poche/Poche.class.php')
-rwxr-xr-x | inc/poche/Poche.class.php | 53 |
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 | } |