1*572dd708SAndreas Gohr<?php 2*572dd708SAndreas Gohr 3*572dd708SAndreas Gohr/** 4*572dd708SAndreas Gohr * OPMLCreator is a FeedCreator that implements OPML 1.0. 5*572dd708SAndreas Gohr * 6*572dd708SAndreas Gohr * @see http://opml.scripting.com/spec 7*572dd708SAndreas Gohr * @author Dirk Clemens, Kai Blankenhorn 8*572dd708SAndreas Gohr * @since 1.5 9*572dd708SAndreas Gohr */ 10*572dd708SAndreas Gohrclass OPMLCreator extends FeedCreator 11*572dd708SAndreas Gohr{ 12*572dd708SAndreas Gohr 13*572dd708SAndreas Gohr /** 14*572dd708SAndreas Gohr * OPMLCreator constructor. 15*572dd708SAndreas Gohr */ 16*572dd708SAndreas Gohr public function __construct() 17*572dd708SAndreas Gohr { 18*572dd708SAndreas Gohr $this->encoding = "utf-8"; 19*572dd708SAndreas Gohr } 20*572dd708SAndreas Gohr 21*572dd708SAndreas Gohr /** @inheritdoc */ 22*572dd708SAndreas Gohr public function createFeed() 23*572dd708SAndreas Gohr { 24*572dd708SAndreas Gohr $feed = "<?xml version=\"1.0\" encoding=\"".$this->encoding."\"?>\n"; 25*572dd708SAndreas Gohr $feed .= $this->_createGeneratorComment(); 26*572dd708SAndreas Gohr $feed .= $this->_createStylesheetReferences(); 27*572dd708SAndreas Gohr $feed .= "<opml xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n"; 28*572dd708SAndreas Gohr $feed .= " <head>\n"; 29*572dd708SAndreas Gohr $feed .= " <title>".htmlspecialchars($this->title)."</title>\n"; 30*572dd708SAndreas Gohr if ($this->pubDate != "") { 31*572dd708SAndreas Gohr $date = new FeedDate($this->pubDate); 32*572dd708SAndreas Gohr $feed .= " <dateCreated>".$date->rfc822()."</dateCreated>\n"; 33*572dd708SAndreas Gohr } 34*572dd708SAndreas Gohr if ($this->lastBuildDate != "") { 35*572dd708SAndreas Gohr $date = new FeedDate($this->lastBuildDate); 36*572dd708SAndreas Gohr $feed .= " <dateModified>".$date->rfc822()."</dateModified>\n"; 37*572dd708SAndreas Gohr } 38*572dd708SAndreas Gohr if ($this->editor != "") { 39*572dd708SAndreas Gohr $feed .= " <ownerName>".$this->editor."</ownerName>\n"; 40*572dd708SAndreas Gohr } 41*572dd708SAndreas Gohr if ($this->editorEmail != "") { 42*572dd708SAndreas Gohr $feed .= " <ownerEmail>".$this->editorEmail."</ownerEmail>\n"; 43*572dd708SAndreas Gohr } 44*572dd708SAndreas Gohr $feed .= " </head>\n"; 45*572dd708SAndreas Gohr $feed .= " <body>\n"; 46*572dd708SAndreas Gohr for ($i = 0; $i < count($this->items); $i++) { 47*572dd708SAndreas Gohr $feed .= " <outline type=\"rss\" "; 48*572dd708SAndreas Gohr $title = htmlspecialchars(strip_tags(strtr($this->items[$i]->title, "\n\r", " "))); 49*572dd708SAndreas Gohr $feed .= " title=\"".$title."\""; 50*572dd708SAndreas Gohr $feed .= " text=\"".$title."\""; 51*572dd708SAndreas Gohr 52*572dd708SAndreas Gohr if (isset($this->items[$i]->xmlUrl)) { 53*572dd708SAndreas Gohr $feed .= " xmlUrl=\"".htmlspecialchars($this->items[$i]->xmlUrl)."\""; 54*572dd708SAndreas Gohr } 55*572dd708SAndreas Gohr 56*572dd708SAndreas Gohr if (isset($this->items[$i]->link)) { 57*572dd708SAndreas Gohr $feed .= " url=\"".htmlspecialchars($this->items[$i]->link)."\""; 58*572dd708SAndreas Gohr } 59*572dd708SAndreas Gohr 60*572dd708SAndreas Gohr $feed .= "/>\n"; 61*572dd708SAndreas Gohr } 62*572dd708SAndreas Gohr $feed .= " </body>\n"; 63*572dd708SAndreas Gohr $feed .= "</opml>\n"; 64*572dd708SAndreas Gohr 65*572dd708SAndreas Gohr return $feed; 66*572dd708SAndreas Gohr } 67*572dd708SAndreas Gohr} 68