/** * Convert a FeedItem to an FeedSMItem. * This is to make sitemap feed get along with normal MediaWiki feeds. * @param FeedItem Original item. * @return FeedSMItem Converted item. */ public static function newFromFeedItem(FeedItem $item) { // @todo FIXME: This is borked (esp. on history), but better than a fatal (not by much). // maybe try and get title from url? $title = Title::newFromText($item->getTitle()); if (!$title) { throw new MWException('Error getting title object from string in FeedItem.'); } $date = $item->getDate(); return new FeedSMItem($title, $date); }
/** * Output a given item. * @param FeedItem $item */ function outItem($item) { global $wgMimeType; // @codingStandardsIgnoreStart Ignore long lines and formatting issues. ?> <entry> <id><?php print $item->getUniqueId(); ?> </id> <title><?php print $item->getTitle(); ?> </title> <link rel="alternate" type="<?php print $wgMimeType; ?> " href="<?php print wfExpandUrl($item->getUrl(), PROTO_CURRENT); ?> "/> <?php if ($item->getDate()) { ?> <updated><?php print $this->formatTime($item->getDate()); ?> Z</updated> <?php } ?> <summary type="html"><?php print $item->getDescription(); ?> </summary> <?php if ($item->getAuthor()) { ?> <author><name><?php print $item->getAuthor(); ?> </name></author><?php } ?> </entry> <?php /* @todo FIXME: Need to add comments <?php if( $item->getComments() ) { ?><dc:comment><?php print $item->getComments() ?></dc:comment><?php }?> */ }
public function toXml(FeedItem $item) { return '<item>' . ($item->getPublished() ? '<pubDate>' . date('r', $item->getPublished()->toStamp()) . '</pubDate>' : null) . ($item->getId() ? '<guid isPermaLink="false">' . $item->getId() . '</guid>' : null) . '<title>' . $item->getTitle() . '</title>' . ($item->getLink() ? '<link>' . str_replace("&", "&", $item->getLink()) . '</link>' : null) . ($item->getSummary() ? '<description>' . $item->getSummary() . '</description>' : null) . ($item->getCategory() ? '<category>' . $item->getCategory() . '</category>' : null) . '</item>'; }