2014-05-26 00:30:46 +02:00
|
|
|
<?php
|
2016-02-14 13:43:58 +01:00
|
|
|
class DilbertBridge extends BridgeAbstract {
|
2014-05-26 00:30:46 +02:00
|
|
|
|
2016-08-30 11:23:55 +02:00
|
|
|
const MAINTAINER = 'kranack';
|
|
|
|
const NAME = 'Dilbert Daily Strip';
|
|
|
|
const URI = 'http://dilbert.com';
|
2016-09-25 17:04:28 +02:00
|
|
|
const CACHE_TIMEOUT = 21600; // 6h
|
2016-08-30 11:23:55 +02:00
|
|
|
const DESCRIPTION = 'The Unofficial Dilbert Daily Comic Strip';
|
2015-01-30 18:12:28 +01:00
|
|
|
|
2016-08-25 01:24:53 +02:00
|
|
|
public function collectData(){
|
2016-02-14 13:43:58 +01:00
|
|
|
|
2016-07-08 19:06:35 +02:00
|
|
|
$html = $this->getSimpleHTMLDOM($this->getURI()) or $this->returnServerError('Could not request Dilbert: '.$this->getURI());
|
2016-02-14 13:43:58 +01:00
|
|
|
|
|
|
|
foreach ($html->find('section.comic-item') as $element) {
|
|
|
|
|
|
|
|
$img = $element->find('img', 0);
|
2016-05-14 12:40:27 +02:00
|
|
|
$link = $element->find('a', 0);
|
2016-02-14 13:43:58 +01:00
|
|
|
$comic = $img->src;
|
2016-05-14 12:40:27 +02:00
|
|
|
$title = $link->alt;
|
|
|
|
$url = $link->href;
|
2016-02-14 13:43:58 +01:00
|
|
|
$date = substr($url, 25);
|
|
|
|
if (empty($title))
|
2016-05-14 12:40:27 +02:00
|
|
|
$title = 'Dilbert Comic Strip on '.$date;
|
2016-02-14 13:43:58 +01:00
|
|
|
$date = strtotime($date);
|
|
|
|
|
2016-08-22 18:55:59 +02:00
|
|
|
$item = array();
|
|
|
|
$item['uri'] = $url;
|
|
|
|
$item['title'] = $title;
|
|
|
|
$item['author'] = 'Scott Adams';
|
|
|
|
$item['timestamp'] = $date;
|
|
|
|
$item['content'] = '<img src="'.$comic.'" alt="'.$img->alt.'" />';
|
2014-05-26 00:30:46 +02:00
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|