geforkt von blallo/rss-bridge
a4b9611e66
- Do not add spaces after opening or before closing parenthesis // Wrong if( !is_null($var) ) { ... } // Right if(!is_null($var)) { ... } - Add space after closing parenthesis // Wrong if(true){ ... } // Right if(true) { ... } - Add body into new line - Close body in new line // Wrong if(true) { ... } // Right if(true) { ... } Notice: Spaces after keywords are not detected: // Wrong (not detected) // -> space after 'if' and missing space after 'else' if (true) { ... } else{ ... } // Right if(true) { ... } else { ... }
36 Zeilen
992 B
PHP
36 Zeilen
992 B
PHP
<?php
|
|
class DilbertBridge extends BridgeAbstract {
|
|
|
|
const MAINTAINER = 'kranack';
|
|
const NAME = 'Dilbert Daily Strip';
|
|
const URI = 'http://dilbert.com';
|
|
const CACHE_TIMEOUT = 21600; // 6h
|
|
const DESCRIPTION = 'The Unofficial Dilbert Daily Comic Strip';
|
|
|
|
public function collectData(){
|
|
|
|
$html = getSimpleHTMLDOM($this->getURI())
|
|
or returnServerError('Could not request Dilbert: ' . $this->getURI());
|
|
|
|
foreach($html->find('section.comic-item') as $element) {
|
|
|
|
$img = $element->find('img', 0);
|
|
$link = $element->find('a', 0);
|
|
$comic = $img->src;
|
|
$title = $link->alt;
|
|
$url = $link->href;
|
|
$date = substr($url, 25);
|
|
if (empty($title))
|
|
$title = 'Dilbert Comic Strip on ' . $date;
|
|
$date = strtotime($date);
|
|
|
|
$item = array();
|
|
$item['uri'] = $url;
|
|
$item['title'] = $title;
|
|
$item['author'] = 'Scott Adams';
|
|
$item['timestamp'] = $date;
|
|
$item['content'] = '<img src="' . $comic . '" alt="' . $img->alt . '" />';
|
|
$this->items[] = $item;
|
|
}
|
|
}
|
|
}
|