1st Upload
This commit is contained in:
48
EvercadeBridge.php
Normal file
48
EvercadeBridge.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
class EvercadeBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = 'Akamaru';
|
||||
const NAME = 'Evercade News';
|
||||
const URI = 'https://evercade.co.uk/blog';
|
||||
const CACHE_TIMEOUT = 21600; // 21600 = 6h
|
||||
const DESCRIPTION = 'All the news from Evercade and our community';
|
||||
|
||||
public function getIcon(){
|
||||
return 'https://evercade.co.uk/wp-content/themes/evercade/img/icons/favicon.ico';
|
||||
}
|
||||
|
||||
public function collectData() {
|
||||
// Retrieve webpage
|
||||
$pageUrl = self::URI;
|
||||
$html = getSimpleHTMLDOM($pageUrl)
|
||||
or returnServerError('Could not request webpage: ' . $pageUrl);
|
||||
|
||||
// Process articles
|
||||
foreach($html->find('div.an-article') as $element) {
|
||||
|
||||
if(count($this->items) >= 10) {
|
||||
break;
|
||||
}
|
||||
|
||||
$article_title = trim(strip_tags($element->find('h2', 0)->innertext));
|
||||
$article_uri = substr($element->find('a', 0)->href, 0);
|
||||
//$article_thumbnail = self::URI . substr($element->find('img', 0)->src, 3);
|
||||
//$article_content = '<img src="'. $article_thumbnail .'"></a>';
|
||||
$article_content = trim(strip_tags($element->find('p.excerpt', 0)->innertext));
|
||||
//$article_timestamp = strtotime($element->find('time', 0)->attr['datetime']);
|
||||
$article_uid = trim(strip_tags($element->find('h2', 0)->innertext));
|
||||
|
||||
// Store article in items array
|
||||
if (!empty($article_title)) {
|
||||
$item = array();
|
||||
$item['uri'] = $article_uri;
|
||||
$item['title'] = $article_title;
|
||||
//$item['enclosures'] = array($article_thumbnail);
|
||||
$item['content'] = $article_content;
|
||||
//$item['timestamp'] = $article_timestamp;
|
||||
$item['uid'] = $article_uid;
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user