items);$i++) {
if ($this->items[$i]->author!="") {
$from = $this->items[$i]->author;
} else {
$from = $this->title;
}
$itemDate = new FeedDate($this->items[$i]->date);
$feed.= "From ".strtr(MBOXCreator::qp_enc($from)," ","_")." ".date("D M d H:i:s Y",$itemDate->unix())."\n";
$feed.= "Content-Type: text/plain;\n";
$feed.= " charset=\"".$this->encoding."\"\n";
$feed.= "Content-Transfer-Encoding: quoted-printable\n";
$feed.= "Content-Type: text/plain\n";
$feed.= "From: \"".MBOXCreator::qp_enc($from)."\"\n";
$feed.= "Date: ".$itemDate->rfc822()."\n";
$feed.= "Subject: ".MBOXCreator::qp_enc(FeedCreator::iTrunc($this->items[$i]->title,100))."\n";
$feed.= "\n";
$body = chunk_split(MBOXCreator::qp_enc($this->items[$i]->description));
$feed.= preg_replace("~\nFrom ([^\n]*)(\n?)~","\n>From $1$2\n",$body);
$feed.= "\n";
$feed.= "\n";
}
return $feed;
}
/*
* Generate a filename for the feed cache file. Overridden from FeedCreator to prevent XML data types.
* @return string the feed cache filename
* @since 1.4
* @access private
*/
function _generateFilename() {
$fileInfo = pathinfo($_SERVER["PHP_SELF"]);
return substr($fileInfo["basename"],0,-(strlen($fileInfo["extension"])+1)).".mbox";
}
}
/*
* OPMLCreator is a FeedCreator that implements OPML 1.0.
*
* @see http://opml.scripting.com/spec
* @author Dirk Clemens, Kai Blankenhorn
* @since 1.5
*/
class OPMLCreator extends FeedCreator {
function OPMLCreator() {
$this->encoding = "utf-8";
}
function createFeed() {
$feed = "encoding."\"?>\n";
$feed.= $this->_createGeneratorComment();
$feed.= $this->_createStylesheetReferences();
$feed.= "\n";
$feed.= " \n";
$feed.= " ".htmlspecialchars($this->title)."\n";
if ($this->pubDate!="") {
$date = new FeedDate($this->pubDate);
$feed.= " ".$date->rfc822()."\n";
}
if ($this->lastBuildDate!="") {
$date = new FeedDate($this->lastBuildDate);
$feed.= " ".$date->rfc822()."\n";
}
if ($this->editor!="") {
$feed.= " ".$this->editor."\n";
}
if ($this->editorEmail!="") {
$feed.= " ".$this->editorEmail."\n";
}
$feed.= " \n";
$feed.= " \n";
for ($i=0;$iitems);$i++) {
$feed.= " items[$i]->title,"\n\r"," ")));
$feed.= " title=\"".$title."\"";
$feed.= " text=\"".$title."\"";
//$feed.= " description=\"".htmlspecialchars($this->items[$i]->description)."\"";
$feed.= " url=\"".htmlspecialchars($this->items[$i]->link)."\"";
$feed.= "/>\n";
}
$feed.= " \n";
$feed.= "\n";
return $feed;
}
}
/*
* HTMLCreator is a FeedCreator that writes an HTML feed file to a specific
* location, overriding the createFeed method of the parent FeedCreator.
* The HTML produced can be included over http by scripting languages, or serve
* as the source for an IFrame.
* All output by this class is embedded in tags to enable formatting
* using CSS.
*
* @author Pascal Van Hecke
* @since 1.7
*/
class HTMLCreator extends FeedCreator {
var $contentType = "text/html";
/*
* Contains HTML to be output at the start of the feed's html representation.
*/
var $header;
/*
* Contains HTML to be output at the end of the feed's html representation.
*/
var $footer ;
/*
* Contains HTML to be output between entries. A separator is only used in
* case of multiple entries.
*/
var $separator;
/*
* Used to prefix the stylenames to make sure they are unique
* and do not clash with stylenames on the users' page.
*/
var $stylePrefix;
/*
* Determines whether the links open in a new window or not.
*/
var $openInNewWindow = true;
var $imageAlign ="right";
/*
* In case of very simple output you may want to get rid of the style tags,
* hence this variable. There's no equivalent on item level, but of course you can
* add strings to it while iterating over the items ($this->stylelessOutput .= ...)
* and when it is non-empty, ONLY the styleless output is printed, the rest is ignored
* in the function createFeed().
*/
var $stylelessOutput ="";
/*
* Writes the HTML.
* @return string the scripts's complete text
*/
function createFeed() {
// if there is styleless output, use the content of this variable and ignore the rest
if ($this->stylelessOutput!="") {
return $this->stylelessOutput;
}
//if no stylePrefix is set, generate it yourself depending on the script name
if ($this->stylePrefix=="") {
$this->stylePrefix = str_replace(".", "_", $this->_generateFilename())."_";
}
//set an openInNewWindow_token_to be inserted or not
if ($this->openInNewWindow) {
$targetInsert = " target='_blank'";
}
// use this array to put the lines in and implode later with "document.write" javascript
$feedArray = array();
if ($this->image!=null) {
$imageStr = "".
"
image->width) {
$imageStr .=" width='".$this->image->width. "' ";
}
if ($this->image->height) {
$imageStr .=" height='".$this->image->height."' ";
}
$imageStr .="/>";
$feedArray[] = $imageStr;
}
if ($this->title) {
$feedArray[] = "";
}
if ($this->getDescription()) {
$feedArray[] = "".
str_replace("]]>", "", str_replace("getDescription())).
"
";
}
if ($this->header) {
$feedArray[] = "";
}
for ($i=0;$iitems);$i++) {
if ($this->separator and $i > 0) {
$feedArray[] = "".$this->separator."
";
}
if ($this->items[$i]->title) {
if ($this->items[$i]->link) {
$feedArray[] =
"";
} else {
$feedArray[] =
"".
FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)),100).
"
";
}
}
if ($this->items[$i]->getDescription()) {
$feedArray[] =
"".
str_replace("]]>", "", str_replace("items[$i]->getDescription())).
"
";
}
}
if ($this->footer) {
$feedArray[] = "";
}
$feed= "".join($feedArray, "\r\n");
return $feed;
}
/*
* Overrrides parent to produce .html extensions
*
* @return string the feed cache filename
* @since 1.4
* @access private
*/
function _generateFilename() {
$fileInfo = pathinfo($_SERVER["PHP_SELF"]);
return substr($fileInfo["basename"],0,-(strlen($fileInfo["extension"])+1)).".html";
}
}
/*
* JSCreator is a class that writes a js file to a specific
* location, overriding the createFeed method of the parent HTMLCreator.
*
* @author Pascal Van Hecke
*/
class JSCreator extends HTMLCreator {
var $contentType = "text/javascript";
/*
* writes the javascript
* @return string the scripts's complete text
*/
function createFeed()
{
$feed = parent::createFeed();
$feedArray = explode("\n",$feed);
$jsFeed = "";
foreach ($feedArray as $value) {
$jsFeed .= "document.write('".trim(addslashes($value))."');\n";
}
return $jsFeed;
}
/*
* Overrrides parent to produce .js extensions
*
* @return string the feed cache filename
* @since 1.4
* @access private
*/
function _generateFilename() {
$fileInfo = pathinfo($_SERVER["PHP_SELF"]);
return substr($fileInfo["basename"],0,-(strlen($fileInfo["extension"])+1)).".js";
}
}
?>