Schwag
* 1st january, 1770
* Guybrush Threepwood
*
path/to/treasure.jpg
*
All I got was this lousy t-shirt!
*
*
* FIXME: It currently fails at grabbing the image (see 20020214.xml)
*/
public function __construct($data, $filename, $processContent = false) {
$vars = array();
preg_match("/(.*)<\/NAME>.* # Grab the title
(.*)<\/DATE>.* # Grab the date
(.*)<\/AUTHOR>.* # Grab the author
(?:
(.*)<\/IMG>.*)? # image if set (only once)
(.*)<\/BODY> # Grab the body
/sUx", $data, $vars);
if (count($vars) == 6) {
$this->_title = $processContent ? $this->processText($vars[1]) : $vars[1];
/* Store the date as an unix timestamp*/
$this->_date = date_timestamp_get(date_create_from_format("M d, Y", $vars[2]));
$this->_author = $vars[3];
$this->_image = $vars[4];
$this->_content = $processContent ? $this->processText($vars[5]) : $vars[5];
}
$this->_filename = basename($filename);
}
/**
* Search and replace specific text from the title and content of a news item.
* Used to filter out entities from the RSS/atom feeds that are not in the XML
* standard.
*
* Check:
* http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references
* for a list of valid entities for both XML and HTML
*/
function processText($text) {
return html_entity_decode($text, ENT_COMPAT, 'UTF-8');
}
/* Get the title. */
public function getTitle() {
return $this->_title;
}
/* Get the date. */
public function getDate() {
return $this->_date;
}
/* Get the author. */
public function getAuthor() {
return $this->_author;
}
/* Get the optional image. */
public function getImage() {
return $this->_image;
}
/* Get the content. */
public function getContent() {
return $this->_content;
}
/* Get the filename. */
public function getFilename() {
return $this->_filename;
}
}
?>