2016-07-26 21:20:13 +02:00
|
|
|
<?php
|
2016-09-05 18:43:56 +02:00
|
|
|
class NextgovBridge extends FeedExpander {
|
2016-07-26 21:20:13 +02:00
|
|
|
|
2016-08-30 11:23:55 +02:00
|
|
|
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.';
|
2016-07-26 21:20:13 +02:00
|
|
|
|
2016-08-30 11:23:55 +02:00
|
|
|
const PARAMETERS = array( array(
|
2016-08-27 21:03:26 +02:00
|
|
|
'category'=>array(
|
2016-08-22 01:25:56 +02:00
|
|
|
'name'=>'Category',
|
|
|
|
'type'=>'list',
|
|
|
|
'values'=>array(
|
2016-08-27 21:03:26 +02:00
|
|
|
'All'=>'all',
|
|
|
|
'Technology News'=>'technology-news',
|
|
|
|
'CIO Briefing'=>'cio-briefing',
|
|
|
|
'Emerging Tech'=>'emerging-tech',
|
|
|
|
'Cloud'=>'cloud-computing',
|
|
|
|
'Cybersecurity'=>'cybersecurity',
|
|
|
|
'Mobile'=>'mobile',
|
|
|
|
'Health'=>'health',
|
|
|
|
'Defense'=>'defense',
|
|
|
|
'Big Data'=>'big-data'
|
2016-08-22 01:25:56 +02:00
|
|
|
)
|
2016-08-27 21:03:26 +02:00
|
|
|
)
|
|
|
|
));
|
2016-07-26 21:20:13 +02:00
|
|
|
|
2016-08-25 01:24:53 +02:00
|
|
|
public function collectData(){
|
2016-09-05 20:26:45 +02:00
|
|
|
$this->collectExpandableDatas(self::URI . 'rss/' . $this->getInput('category') . '/', 10);
|
2016-09-05 18:43:56 +02:00
|
|
|
}
|
2016-07-26 21:20:13 +02:00
|
|
|
|
2016-09-05 18:43:56 +02:00
|
|
|
protected function parseItem($newsItem){
|
|
|
|
$item = $this->parseRSS_2_0_Item($newsItem);
|
2016-07-26 21:20:13 +02:00
|
|
|
|
2016-09-05 18:43:56 +02:00
|
|
|
$item['content'] = '';
|
2016-07-26 21:20:13 +02:00
|
|
|
|
2016-09-05 18:43:56 +02:00
|
|
|
$namespaces = $newsItem->getNamespaces(true);
|
|
|
|
if(isset($namespaces['media'])){
|
|
|
|
$media = $newsItem->children($namespaces['media']);
|
|
|
|
if(isset($media->content)){
|
|
|
|
$attributes = $media->content->attributes();
|
|
|
|
$item['content'] = '<img src="' . $attributes['url'] . '">';
|
2016-08-29 13:57:02 +02:00
|
|
|
}
|
2016-09-05 18:43:56 +02:00
|
|
|
}
|
2016-07-26 21:20:13 +02:00
|
|
|
|
2016-09-05 18:43:56 +02:00
|
|
|
$item['content'] .= $this->ExtractContent($item['uri']);
|
|
|
|
return $item;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function StripWithDelimiters($string, $start, $end) {
|
|
|
|
while (strpos($string, $start) !== false) {
|
|
|
|
$section_to_remove = substr($string, strpos($string, $start));
|
|
|
|
$section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end));
|
|
|
|
$string = str_replace($section_to_remove, '', $string);
|
|
|
|
} return $string;
|
|
|
|
}
|
2016-07-26 21:20:13 +02:00
|
|
|
|
2016-09-05 18:43:56 +02:00
|
|
|
private function ExtractContent($url){
|
2016-09-10 19:11:09 +02:00
|
|
|
$article = $this->getSimpleHTMLDOMCached($url)
|
2016-09-05 18:43:56 +02:00
|
|
|
or $this->returnServerError('Could not request Nextgov: ' . $url);
|
2016-07-26 21:20:13 +02:00
|
|
|
|
2016-09-05 18:43:56 +02:00
|
|
|
$contents = $article->find('div.wysiwyg', 0)->innertext;
|
|
|
|
$contents = $this->StripWithDelimiters($contents, '<div class="ad-container">', '</div>');
|
|
|
|
$contents = $this->StripWithDelimiters($contents, '<div', '</div>'); //ad outer div
|
|
|
|
return $this->StripWithDelimiters($contents, '<script', '</script>');
|
|
|
|
$contents = ($article_thumbnail == '' ? '' : '<p><img src="'.$article_thumbnail.'" /></p>')
|
|
|
|
.'<p><b>'.$article_subtitle.'</b></p>'
|
|
|
|
.trim($contents);
|
2016-07-26 21:20:13 +02:00
|
|
|
}
|
2016-08-09 14:57:42 +02:00
|
|
|
}
|