*/ class RSSCreator091 extends FeedCreator { /** @var string Stores this RSS feed's version number. */ protected $RSSVersion; /** * RSSCreator091 constructor. */ function __construct() { $this->_setRSSVersion("0.91"); $this->contentType = "application/rss+xml"; } /** * Sets this RSS feed's version number. * * @param string $version */ protected function _setRSSVersion($version) { $this->RSSVersion = $version; } /** @inheritdoc */ public function createFeed() { $feed = "encoding."\"?>\n"; $feed .= $this->_createGeneratorComment(); $feed .= $this->_createStylesheetReferences(); $feed .= "RSSVersion."\""; if (count($this->items) > 0 && !empty($this->items[0]->lat) ) { $feed .= " xmlns:georss=\"http://www.georss.org/georss/\"\n"; } if (count($this->items) > 0 && isset($this->items[0]->additionalElements['xcal:dtstart']) ) { $feed .= " xmlns:xcal=\"urn:ietf:params:xml:ns:xcal\"\n"; } $feed .= ">\n"; if ($this->format == 'BASE') { $feed .= " \n"; } else { $feed .= " \n"; } $feed .= " ".FeedCreator::iTrunc(htmlspecialchars((string) $this->title), 100)."\n"; $this->descriptionTruncSize = 500; $feed .= " ".$this->getDescription()."\n"; $feed .= " ".$this->link."\n"; $now = new FeedDate(); $feed .= " ".htmlspecialchars( $this->lastBuildDate ?: $now->rfc822() )."\n"; $feed .= " ".FEEDCREATOR_VERSION."\n"; if ($this->image != null) { $feed .= " \n"; $feed .= " ".$this->image->url."\n"; $feed .= " ".FeedCreator::iTrunc(htmlspecialchars($this->image->title), 100)."\n"; $feed .= " ".$this->image->link."\n"; if ($this->image->width != "") { $feed .= " ".$this->image->width."\n"; } if ($this->image->height != "") { $feed .= " ".$this->image->height."\n"; } if ($this->image->description != "") { $feed .= " ".htmlspecialchars($this->image->description)."\n"; } $feed .= " \n"; } if ($this->language != "") { $feed .= " ".$this->language."\n"; } if ($this->copyright != "") { $feed .= " ".FeedCreator::iTrunc( htmlspecialchars($this->copyright), 100 )."\n"; } if ($this->editor != "") { $feed .= " ".FeedCreator::iTrunc( htmlspecialchars($this->editor), 100 )."\n"; } if ($this->webmaster != "") { $feed .= " ".FeedCreator::iTrunc( htmlspecialchars($this->webmaster), 100 )."\n"; } if ($this->pubDate != "") { $pubDate = new FeedDate($this->pubDate); $feed .= " ".htmlspecialchars($pubDate->rfc822())."\n"; } if ($this->category != "") { $feed .= " ".htmlspecialchars($this->category)."\n"; } if ($this->docs != "") { $feed .= " ".FeedCreator::iTrunc(htmlspecialchars($this->docs), 500)."\n"; } if ($this->ttl != "") { $feed .= " ".htmlspecialchars($this->ttl)."\n"; } if ($this->rating != "") { $feed .= " ".FeedCreator::iTrunc(htmlspecialchars($this->rating), 500)."\n"; } if ($this->skipHours != "") { $feed .= " ".htmlspecialchars($this->skipHours)."\n"; } if ($this->skipDays != "") { $feed .= " ".htmlspecialchars($this->skipDays)."\n"; } $feed .= $this->_createAdditionalElements($this->additionalElements, " "); for ($i = 0; $i < count($this->items); $i++) { $feed .= " \n"; $feed .= " ".FeedCreator::iTrunc( htmlspecialchars(strip_tags((string) $this->items[$i]->title)), 100 )."\n"; $feed .= " ".htmlspecialchars((string) $this->items[$i]->link)."\n"; $feed .= " ".$this->items[$i]->getDescription()."\n"; $creator = $this->getAuthor($this->items[$i]->author, $this->items[$i]->authorEmail); if ($creator) { $feed .= " ".htmlspecialchars($creator)."\n"; } /* // on hold if ($this->items[$i]->source!="") { $feed.= " ".htmlspecialchars($this->items[$i]->source)."\n"; } */ if ($this->items[$i]->lat != "") { $feed .= " ".$this->items[$i]->lat." ".$this->items[$i]->long."\n"; } if (is_array($this->items[$i]->category)) { foreach ($this->items[$i]->category as $cat) { $feed .= " ".htmlspecialchars($cat)."\n"; } } else { if ($this->items[$i]->category != "") { $feed .= " ".htmlspecialchars($this->items[$i]->category)."\n"; } } if ($this->items[$i]->comments != "") { $feed .= " ".htmlspecialchars($this->items[$i]->comments)."\n"; } if ($this->items[$i]->date != "") { $itemDate = new FeedDate($this->items[$i]->date); $feed .= " ".htmlspecialchars($itemDate->rfc822())."\n"; } if ($this->items[$i]->guid != "") { $feed .= " ".htmlspecialchars($this->items[$i]->guid)."\n"; } if ($this->items[$i]->thumb != "") { $feed .= " ".htmlspecialchars($this->items[$i]->thumb)."\n"; } $feed .= $this->_createAdditionalElements($this->items[$i]->additionalElements, " "); $feed .= " \n"; } $feed .= " \n"; $feed .= "\n"; return $feed; } /** * Compose the RSS-0.91 and RSS-2.0 author field. * * @author Joe Lapp */ function getAuthor($author, $email) { if ($author && $email) { return $email.' ('.$author.')'; } return $email; } }