mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-30 19:40:00 +02:00
Reformat codebase v4 (#2872)
Reformat code base to PSR12 Co-authored-by: rssbridge <noreply@github.com>
This commit is contained in:
@@ -1,67 +1,72 @@
|
||||
<?php
|
||||
class NextgovBridge extends FeedExpander {
|
||||
|
||||
const MAINTAINER = 'ORelio';
|
||||
const NAME = 'Nextgov Bridge';
|
||||
const URI = 'https://www.nextgov.com/';
|
||||
const DESCRIPTION = 'USA Federal technology news, best practices, and web 2.0 tools.';
|
||||
class NextgovBridge extends FeedExpander
|
||||
{
|
||||
const MAINTAINER = 'ORelio';
|
||||
const NAME = 'Nextgov Bridge';
|
||||
const URI = 'https://www.nextgov.com/';
|
||||
const DESCRIPTION = 'USA Federal technology news, best practices, and web 2.0 tools.';
|
||||
|
||||
const PARAMETERS = array( array(
|
||||
'category' => array(
|
||||
'name' => 'Category',
|
||||
'type' => 'list',
|
||||
'values' => array(
|
||||
'All' => 'all',
|
||||
'Technology News' => 'technology-news',
|
||||
'CIO Briefing' => 'cio-briefing',
|
||||
'Emerging Tech' => 'emerging-tech',
|
||||
'Cybersecurity' => 'cybersecurity',
|
||||
'IT Modernization' => 'it-modernization',
|
||||
'Policy' => 'policy',
|
||||
'Ideas' => 'ideas',
|
||||
)
|
||||
)
|
||||
));
|
||||
const PARAMETERS = [ [
|
||||
'category' => [
|
||||
'name' => 'Category',
|
||||
'type' => 'list',
|
||||
'values' => [
|
||||
'All' => 'all',
|
||||
'Technology News' => 'technology-news',
|
||||
'CIO Briefing' => 'cio-briefing',
|
||||
'Emerging Tech' => 'emerging-tech',
|
||||
'Cybersecurity' => 'cybersecurity',
|
||||
'IT Modernization' => 'it-modernization',
|
||||
'Policy' => 'policy',
|
||||
'Ideas' => 'ideas',
|
||||
]
|
||||
]
|
||||
]];
|
||||
|
||||
public function collectData(){
|
||||
$this->collectExpandableDatas(self::URI . 'rss/' . $this->getInput('category') . '/', 10);
|
||||
}
|
||||
public function collectData()
|
||||
{
|
||||
$this->collectExpandableDatas(self::URI . 'rss/' . $this->getInput('category') . '/', 10);
|
||||
}
|
||||
|
||||
protected function parseItem($newsItem){
|
||||
$item = parent::parseItem($newsItem);
|
||||
protected function parseItem($newsItem)
|
||||
{
|
||||
$item = parent::parseItem($newsItem);
|
||||
|
||||
$article_thumbnail = 'https://cdn.nextgov.com/nextgov/images/logo.png';
|
||||
$item['content'] = '<p><b>' . $item['content'] . '</b></p>';
|
||||
$article_thumbnail = 'https://cdn.nextgov.com/nextgov/images/logo.png';
|
||||
$item['content'] = '<p><b>' . $item['content'] . '</b></p>';
|
||||
|
||||
$namespaces = $newsItem->getNamespaces(true);
|
||||
if(isset($namespaces['media'])) {
|
||||
$media = $newsItem->children($namespaces['media']);
|
||||
if(isset($media->content)) {
|
||||
$attributes = $media->content->attributes();
|
||||
$item['content'] = '<p><img src="' . $attributes['url'] . '"></p>' . $item['content'];
|
||||
$article_thumbnail = str_replace(
|
||||
'large.jpg',
|
||||
'small.jpg',
|
||||
strval($attributes['url'])
|
||||
);
|
||||
}
|
||||
}
|
||||
$namespaces = $newsItem->getNamespaces(true);
|
||||
if (isset($namespaces['media'])) {
|
||||
$media = $newsItem->children($namespaces['media']);
|
||||
if (isset($media->content)) {
|
||||
$attributes = $media->content->attributes();
|
||||
$item['content'] = '<p><img src="' . $attributes['url'] . '"></p>' . $item['content'];
|
||||
$article_thumbnail = str_replace(
|
||||
'large.jpg',
|
||||
'small.jpg',
|
||||
strval($attributes['url'])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$item['enclosures'] = array($article_thumbnail);
|
||||
$item['content'] .= $this->extractContent($item['uri']);
|
||||
return $item;
|
||||
}
|
||||
$item['enclosures'] = [$article_thumbnail];
|
||||
$item['content'] .= $this->extractContent($item['uri']);
|
||||
return $item;
|
||||
}
|
||||
|
||||
private function extractContent($url){
|
||||
$article = getSimpleHTMLDOMCached($url);
|
||||
private function extractContent($url)
|
||||
{
|
||||
$article = getSimpleHTMLDOMCached($url);
|
||||
|
||||
if (!is_object($article))
|
||||
return 'Could not request Nextgov: ' . $url;
|
||||
if (!is_object($article)) {
|
||||
return 'Could not request Nextgov: ' . $url;
|
||||
}
|
||||
|
||||
$contents = $article->find('div.wysiwyg', 0);
|
||||
$contents = $contents->innertext;
|
||||
$contents = stripWithDelimiters($contents, '<div class="ad-container">', '</div>');
|
||||
$contents = stripWithDelimiters($contents, '<div', '</div>'); //ad outer div
|
||||
return trim(stripWithDelimiters($contents, '<script', '</script>'));
|
||||
}
|
||||
$contents = $article->find('div.wysiwyg', 0);
|
||||
$contents = $contents->innertext;
|
||||
$contents = stripWithDelimiters($contents, '<div class="ad-container">', '</div>');
|
||||
$contents = stripWithDelimiters($contents, '<div', '</div>'); //ad outer div
|
||||
return trim(stripWithDelimiters($contents, '<script', '</script>'));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user