2014-05-26 02:30:46 +04:00
|
|
|
<?php
|
2016-02-14 15:43:58 +03:00
|
|
|
class DilbertBridge extends BridgeAbstract {
|
2014-05-26 02:30:46 +04:00
|
|
|
|
2016-08-27 22:03:26 +03:00
|
|
|
public $maintainer = 'kranack';
|
|
|
|
public $name = 'Dilbert Daily Strip';
|
|
|
|
public $uri = 'http://dilbert.com';
|
|
|
|
public $description = 'The Unofficial Dilbert Daily Comic Strip';
|
2015-01-30 20:12:28 +03:00
|
|
|
|
2016-08-25 02:24:53 +03:00
|
|
|
public function collectData(){
|
2016-02-14 15:43:58 +03:00
|
|
|
|
2016-07-08 20:06:35 +03:00
|
|
|
$html = $this->getSimpleHTMLDOM($this->getURI()) or $this->returnServerError('Could not request Dilbert: '.$this->getURI());
|
2016-02-14 15:43:58 +03:00
|
|
|
|
|
|
|
foreach ($html->find('section.comic-item') as $element) {
|
|
|
|
|
|
|
|
$img = $element->find('img', 0);
|
2016-05-14 13:40:27 +03:00
|
|
|
$link = $element->find('a', 0);
|
2016-02-14 15:43:58 +03:00
|
|
|
$comic = $img->src;
|
2016-05-14 13:40:27 +03:00
|
|
|
$title = $link->alt;
|
|
|
|
$url = $link->href;
|
2016-02-14 15:43:58 +03:00
|
|
|
$date = substr($url, 25);
|
|
|
|
if (empty($title))
|
2016-05-14 13:40:27 +03:00
|
|
|
$title = 'Dilbert Comic Strip on '.$date;
|
2016-02-14 15:43:58 +03:00
|
|
|
$date = strtotime($date);
|
|
|
|
|
2016-08-22 19:55:59 +03: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 02:30:46 +04:00
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-14 15:43:58 +03:00
|
|
|
public function getCacheDuration() {
|
|
|
|
return 21600; // 6 hours
|
2014-05-26 02:30:46 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|