diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-01-16 20:04:56 +0100 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-01-16 20:04:56 +0100 |
commit | b68f0a81e54ce023d2779c0dd1f4c717ec94147a (patch) | |
tree | 86565b386339d527273df781a21f999376f33167 /inc | |
parent | af5c371e951ae2bc9ccd9a7164e0c04101b39ace (diff) | |
parent | 7fe8a9adc44a73221959263b08b516ec20bf85a0 (diff) | |
download | wallabag-b68f0a81e54ce023d2779c0dd1f4c717ec94147a.tar.gz wallabag-b68f0a81e54ce023d2779c0dd1f4c717ec94147a.tar.zst wallabag-b68f0a81e54ce023d2779c0dd1f4c717ec94147a.zip |
Merge pull request #1003 from vpmalley/dev
[RSS] introducing query param 'limit' for max items in RSS feed
Diffstat (limited to 'inc')
-rwxr-xr-x | inc/poche/Poche.class.php | 14 | ||||
-rwxr-xr-x | inc/poche/Routing.class.php | 3 |
2 files changed, 12 insertions, 5 deletions
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 20897c61..6a742019 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php | |||
@@ -784,10 +784,11 @@ class Poche | |||
784 | * | 784 | * |
785 | * @param $token | 785 | * @param $token |
786 | * @param $user_id | 786 | * @param $user_id |
787 | * @param $tag_id | 787 | * @param $tag_id if $type is 'tag', the id of the tag to generate feed for |
788 | * @param string $type | 788 | * @param string $type the type of feed to generate |
789 | * @param int $limit the maximum number of items (0 means all) | ||
789 | */ | 790 | */ |
790 | public function generateFeeds($token, $user_id, $tag_id, $type = 'home') | 791 | public function generateFeeds($token, $user_id, $tag_id, $type = 'home', $limit = 0) |
791 | { | 792 | { |
792 | $allowed_types = array('home', 'fav', 'archive', 'tag'); | 793 | $allowed_types = array('home', 'fav', 'archive', 'tag'); |
793 | $config = $this->store->getConfigUser($user_id); | 794 | $config = $this->store->getConfigUser($user_id); |
@@ -814,8 +815,13 @@ class Poche | |||
814 | $entries = $this->store->getEntriesByView($type, $user_id); | 815 | $entries = $this->store->getEntriesByView($type, $user_id); |
815 | } | 816 | } |
816 | 817 | ||
818 | // if $limit is set to zero, use all entries | ||
819 | if (0 == $limit) { | ||
820 | $limit = count($entries); | ||
821 | } | ||
817 | if (count($entries) > 0) { | 822 | if (count($entries) > 0) { |
818 | foreach ($entries as $entry) { | 823 | for ($i = 0; $i < min(count($entries), $limit); $i++) { |
824 | $entry = $entries[$i]; | ||
819 | $newItem = $feed->createNewItem(); | 825 | $newItem = $feed->createNewItem(); |
820 | $newItem->setTitle($entry['title']); | 826 | $newItem->setTitle($entry['title']); |
821 | $newItem->setSource(Tools::getPocheUrl() . '?view=view&id=' . $entry['id']); | 827 | $newItem->setSource(Tools::getPocheUrl() . '?view=view&id=' . $entry['id']); |
diff --git a/inc/poche/Routing.class.php b/inc/poche/Routing.class.php index 5acd08ba..be06a433 100755 --- a/inc/poche/Routing.class.php +++ b/inc/poche/Routing.class.php | |||
@@ -102,7 +102,8 @@ class Routing | |||
102 | $this->wallabag->login($this->referer); | 102 | $this->wallabag->login($this->referer); |
103 | } elseif (isset($_GET['feed']) && isset($_GET['user_id'])) { | 103 | } elseif (isset($_GET['feed']) && isset($_GET['user_id'])) { |
104 | $tag_id = (isset($_GET['tag_id']) ? intval($_GET['tag_id']) : 0); | 104 | $tag_id = (isset($_GET['tag_id']) ? intval($_GET['tag_id']) : 0); |
105 | $this->wallabag->generateFeeds($_GET['token'], filter_var($_GET['user_id'],FILTER_SANITIZE_NUMBER_INT), $tag_id, $_GET['type']); | 105 | $limit = (isset($_GET['limit']) ? intval($_GET['limit']) : 0); |
106 | $this->wallabag->generateFeeds($_GET['token'], filter_var($_GET['user_id'],FILTER_SANITIZE_NUMBER_INT), $tag_id, $_GET['type'], $limit); | ||
106 | } | 107 | } |
107 | 108 | ||
108 | //allowed ONLY to logged in user | 109 | //allowed ONLY to logged in user |