mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-15 03:10:55 +00:00
[FilterMore] limit number of entries
This commit is contained in:
parent
d6ec70a444
commit
707a8324e5
@ -86,6 +86,7 @@ class FilterMoreBridge extends FeedExpander
|
||||
],
|
||||
'defaultValue' => 'asc',
|
||||
],
|
||||
'limit' => self::LIMIT,
|
||||
|
||||
]];
|
||||
|
||||
@ -158,6 +159,7 @@ class FilterMoreBridge extends FeedExpander
|
||||
public function collectExpandableDatas($url, $maxItems = -1)
|
||||
{
|
||||
parent::collectExpandableDatas($url, $maxItems);
|
||||
$limit = (int)($this->getInput('limit') ?: 10);
|
||||
if ($this->getInput('sort_by') === 'random') {
|
||||
shuffle($this->items);
|
||||
} elseif ($this->getInput('sort_by') !== 'none') {
|
||||
@ -171,6 +173,9 @@ class FilterMoreBridge extends FeedExpander
|
||||
if ($this->getInput('sort_dir') === 'desc') {
|
||||
$this->items = array_reverse($this->items);
|
||||
}
|
||||
if ($limit > 0) {
|
||||
$this->items = array_slice($this->items, 0, $limit);
|
||||
}
|
||||
}
|
||||
|
||||
private function cmp($a, $b)
|
||||
|
Loading…
Reference in New Issue
Block a user