diff options
author | Vincent Malley <vincent.malley@insalien.org> | 2015-01-16 11:42:39 -0500 |
---|---|---|
committer | Vincent Malley <vincent.malley@insalien.org> | 2015-01-16 11:42:39 -0500 |
commit | 7fe8a9adc44a73221959263b08b516ec20bf85a0 (patch) | |
tree | 86565b386339d527273df781a21f999376f33167 /inc/poche/Poche.class.php | |
parent | af5c371e951ae2bc9ccd9a7164e0c04101b39ace (diff) | |
download | wallabag-7fe8a9adc44a73221959263b08b516ec20bf85a0.tar.gz wallabag-7fe8a9adc44a73221959263b08b516ec20bf85a0.tar.zst wallabag-7fe8a9adc44a73221959263b08b516ec20bf85a0.zip |
[RSS] introducing query param 'limit' to restrict the number of items to display in RSS feeds.
Diffstat (limited to 'inc/poche/Poche.class.php')
-rwxr-xr-x | inc/poche/Poche.class.php | 14 |
1 files changed, 10 insertions, 4 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']); |