mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-12 03:24:01 +02:00
Reformat codebase v4 (#2872)
Reformat code base to PSR12 Co-authored-by: rssbridge <noreply@github.com>
This commit is contained in:
@@ -1,79 +1,87 @@
|
||||
<?php
|
||||
|
||||
class HeiseBridge extends FeedExpander {
|
||||
const MAINTAINER = 'Dreckiger-Dan';
|
||||
const NAME = 'Heise Online Bridge';
|
||||
const URI = 'https://heise.de/';
|
||||
const CACHE_TIMEOUT = 1800; // 30min
|
||||
const DESCRIPTION = 'Returns the full articles instead of only the intro';
|
||||
const PARAMETERS = array(array(
|
||||
'category' => array(
|
||||
'name' => 'Category',
|
||||
'type' => 'list',
|
||||
'values' => array(
|
||||
'Alle News'
|
||||
=> 'https://www.heise.de/newsticker/heise-atom.xml',
|
||||
'Top-News'
|
||||
=> 'https://www.heise.de/newsticker/heise-top-atom.xml',
|
||||
'Internet-Störungen'
|
||||
=> 'https://www.heise.de/netze/netzwerk-tools/imonitor-internet-stoerungen/feed/aktuelle-meldungen/',
|
||||
'Alle News von heise Developer'
|
||||
=> 'https://www.heise.de/developer/rss/news-atom.xml'
|
||||
)
|
||||
),
|
||||
'limit' => array(
|
||||
'name' => 'Limit',
|
||||
'type' => 'number',
|
||||
'required' => false,
|
||||
'title' => 'Specify number of full articles to return',
|
||||
'defaultValue' => 5
|
||||
)
|
||||
));
|
||||
const LIMIT = 5;
|
||||
class HeiseBridge extends FeedExpander
|
||||
{
|
||||
const MAINTAINER = 'Dreckiger-Dan';
|
||||
const NAME = 'Heise Online Bridge';
|
||||
const URI = 'https://heise.de/';
|
||||
const CACHE_TIMEOUT = 1800; // 30min
|
||||
const DESCRIPTION = 'Returns the full articles instead of only the intro';
|
||||
const PARAMETERS = [[
|
||||
'category' => [
|
||||
'name' => 'Category',
|
||||
'type' => 'list',
|
||||
'values' => [
|
||||
'Alle News'
|
||||
=> 'https://www.heise.de/newsticker/heise-atom.xml',
|
||||
'Top-News'
|
||||
=> 'https://www.heise.de/newsticker/heise-top-atom.xml',
|
||||
'Internet-Störungen'
|
||||
=> 'https://www.heise.de/netze/netzwerk-tools/imonitor-internet-stoerungen/feed/aktuelle-meldungen/',
|
||||
'Alle News von heise Developer'
|
||||
=> 'https://www.heise.de/developer/rss/news-atom.xml'
|
||||
]
|
||||
],
|
||||
'limit' => [
|
||||
'name' => 'Limit',
|
||||
'type' => 'number',
|
||||
'required' => false,
|
||||
'title' => 'Specify number of full articles to return',
|
||||
'defaultValue' => 5
|
||||
]
|
||||
]];
|
||||
const LIMIT = 5;
|
||||
|
||||
public function collectData() {
|
||||
$this->collectExpandableDatas(
|
||||
$this->getInput('category'),
|
||||
$this->getInput('limit') ?: static::LIMIT
|
||||
);
|
||||
}
|
||||
public function collectData()
|
||||
{
|
||||
$this->collectExpandableDatas(
|
||||
$this->getInput('category'),
|
||||
$this->getInput('limit') ?: static::LIMIT
|
||||
);
|
||||
}
|
||||
|
||||
protected function parseItem($feedItem) {
|
||||
$item = parent::parseItem($feedItem);
|
||||
$item['uri'] = explode('?', $item['uri'])[0] . '?seite=all';
|
||||
protected function parseItem($feedItem)
|
||||
{
|
||||
$item = parent::parseItem($feedItem);
|
||||
$item['uri'] = explode('?', $item['uri'])[0] . '?seite=all';
|
||||
|
||||
if (strpos($item['uri'], 'https://www.heise.de') !== 0) {
|
||||
return $item;
|
||||
}
|
||||
if (strpos($item['uri'], 'https://www.heise.de') !== 0) {
|
||||
return $item;
|
||||
}
|
||||
|
||||
$article = getSimpleHTMLDOMCached($item['uri']);
|
||||
$article = getSimpleHTMLDOMCached($item['uri']);
|
||||
|
||||
if ($article) {
|
||||
$article = defaultLinkTo($article, $item['uri']);
|
||||
$item = $this->addArticleToItem($item, $article);
|
||||
}
|
||||
if ($article) {
|
||||
$article = defaultLinkTo($article, $item['uri']);
|
||||
$item = $this->addArticleToItem($item, $article);
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
return $item;
|
||||
}
|
||||
|
||||
private function addArticleToItem($item, $article) {
|
||||
$authors = $article->find('.a-creator__names', 0)->find('.a-creator__name');
|
||||
if ($authors)
|
||||
$item['author'] = implode(', ', array_map(function ($e) { return $e->plaintext; }, $authors ));
|
||||
private function addArticleToItem($item, $article)
|
||||
{
|
||||
$authors = $article->find('.a-creator__names', 0)->find('.a-creator__name');
|
||||
if ($authors) {
|
||||
$item['author'] = implode(', ', array_map(function ($e) {
|
||||
return $e->plaintext;
|
||||
}, $authors));
|
||||
}
|
||||
|
||||
$content = $article->find('div[class*="article-content"]', 0);
|
||||
$content = $article->find('div[class*="article-content"]', 0);
|
||||
|
||||
if ($content == null)
|
||||
$content = $article->find('#article_content', 0);
|
||||
if ($content == null) {
|
||||
$content = $article->find('#article_content', 0);
|
||||
}
|
||||
|
||||
foreach($content->find('p, h3, ul, table, pre, img') as $element) {
|
||||
$item['content'] .= $element;
|
||||
}
|
||||
foreach ($content->find('p, h3, ul, table, pre, img') as $element) {
|
||||
$item['content'] .= $element;
|
||||
}
|
||||
|
||||
foreach($content->find('img') as $img) {
|
||||
$item['enclosures'][] = $img->src;
|
||||
}
|
||||
foreach ($content->find('img') as $img) {
|
||||
$item['enclosures'][] = $img->src;
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
return $item;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user