61 lines
2.1 KiB
PHP
61 lines
2.1 KiB
PHP
<?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('a.single-post-archive') as $element) {
|
|
|
|
if(count($this->items) >= 10) {
|
|
break;
|
|
}
|
|
|
|
$article_title = trim(strip_tags($element->find('div.post-name span', 0)->innertext));
|
|
$article_uri = $element->href;
|
|
$article_content = '';
|
|
if ($element->find('div.excerpt', 0)) {
|
|
$article_content = trim(strip_tags($element->find('div.excerpt', 0)->innertext));
|
|
}
|
|
$article_date = '';
|
|
if ($element->find('span.post-date', 0)) {
|
|
$article_date = $element->find('span.post-date', 0)->innertext;
|
|
}
|
|
$article_author = '';
|
|
if ($element->find('span.author-name', 0)) {
|
|
$article_author = $element->find('span.author-name', 0)->innertext;
|
|
}
|
|
$article_uid = $article_title;
|
|
|
|
// Store article in items array
|
|
if (!empty($article_title)) {
|
|
$item = array();
|
|
$item['uri'] = $article_uri;
|
|
$item['title'] = $article_title;
|
|
$item['content'] = $article_content;
|
|
$item['uid'] = $article_uid;
|
|
if (!empty($article_date)) {
|
|
$item['timestamp'] = strtotime($article_date);
|
|
}
|
|
if (!empty($article_author)) {
|
|
$item['author'] = $article_author;
|
|
}
|
|
$this->items[] = $item;
|
|
}
|
|
}
|
|
}
|
|
}
|