[DesoutterBridge] Add feed item limit
This bridge currently takes a very long time to process all news items on the page, when in many cases only one or two had been added since the last check. This commit adds a new parameter 'limit', which defines the maximum number of items to add to the feed. This is an optional paramter that defaults to 3.
This commit is contained in:
parent
46d5895d1d
commit
c0df9815c7
1 changed files with 10 additions and 0 deletions
|
@ -116,6 +116,12 @@ class DesoutterBridge extends BridgeAbstract {
|
|||
'name' => 'Load full articles',
|
||||
'type' => 'checkbox',
|
||||
'title' => 'Enable to load the full article for each item'
|
||||
),
|
||||
'limit' => array(
|
||||
'name' => 'Limit',
|
||||
'type' => 'number',
|
||||
'defaultValue' => 3,
|
||||
'title' => "Maximum number of items to return in the feed.\n0 = unlimited"
|
||||
)
|
||||
)
|
||||
);
|
||||
|
@ -156,6 +162,8 @@ class DesoutterBridge extends BridgeAbstract {
|
|||
|
||||
$this->title = html_entity_decode($html->find('title', 0)->plaintext, ENT_QUOTES);
|
||||
|
||||
$limit = $this->getInput('limit') ?: 0;
|
||||
|
||||
foreach($html->find('article') as $article) {
|
||||
$item = array();
|
||||
|
||||
|
@ -169,6 +177,8 @@ class DesoutterBridge extends BridgeAbstract {
|
|||
}
|
||||
|
||||
$this->items[] = $item;
|
||||
|
||||
if ($limit > 0 && count($this->items) >= $limit) break;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue