/** * Output a single feed entry. */ function outEntry( WlSyndicationEntry $entry ) { echo Xml::openElement( 'item' ) . "\n"; echo Xml::element( 'guid', array( 'isPermaLink' => "false" ), $entry->getId() ) . "\n"; echo $this->formatTextData( 'title', $entry->getTitle() ); foreach ( $entry->getLinks() as $rel => $links ) { if ( $rel == 'alternate' ) { if ( !empty( $links ) ) { # RSS only supports a single link element. $link = array_shift( $links ); echo Xml::element( 'link', null, $link['href'] ) . "\n"; } } elseif ( $rel == 'enclosure' ) { if ( !empty( $links ) ) { # RSS only supports a single enclosure element. $link = array_shift( $links ); $attribs = array( 'url' => $link['href'], 'type' => $link['type'], 'length' => $link['length'] ); echo Xml::element( 'enclosure', $attribs ) . "\n"; } } elseif ( $rel == 'replies' ) { if ( !empty( $links ) ) { # RSS only supports a single comments element. $link = array_shift( $links ); echo Xml::element( 'comments', null, $link['href'] ) . "\n"; } } else { # For other links, we use the atom namespace. foreach ( $links as $link ) { echo Xml::element( 'atom:link', array( 'rel' => $rel ) + $link ) . "\n"; } } } foreach ( $entry->getAuthors() as $author ) { echo Xml::element( 'dc:creator', null, $author['name'] ) . "\n"; } foreach ( $entry->getCategories() as $category ) { $content = str_replace( '_', ' ', $category['term'] ); $attribs = array(); if ( isset( $category['scheme'] ) ) { $attribs['domain'] = $category['scheme']; } echo Xml::element( 'category', $attribs, $content ) . "\n"; } # Use either published or updated dates for the pubDate element. $date = $entry->getPublished() ? $entry->getPublished() : $entry->getUpdated(); echo Xml::element( 'pubDate', null, $this->formatTime( $date ) ) . "\n"; # RSS source feed. $source = $entry->getSource(); if ( $source instanceof WlSyndicationFeed ) { $s_title = $source->getTitle(); $s_links = $source->getLinks( 'self' ); $s_url = array_shift( $s_links ); echo Xml::element( 'source', array( 'url' => $s_url['href'] ), $s_title instanceof WlTextConstruct ? $s_title->getText() : $s_title ) . "\n"; } # If only summary or only content is provided, prefer the standard # description element for either. If both are provided, put the # summary in the description element and the content in the extension # content:encoded element. $content = $description = null; if ( $entry->getSummary() && $entry->getContent() ) { $description = $entry->getSummary(); $content = $entry->getContent(); } elseif ( $entry->getSummary() ) { $description = $entry->getSummary(); } elseif ( $entry->getContent() ) { $description = $entry->getContent(); } if ( $description ) { if ( $description instanceof WlTextConstruct ) { echo Xml::element( 'description', null, $description->getHTML() ); } else { echo Xml::element( 'description', null, htmlspecialchars( $description ) ); } } if ( $content ) { if ( $content instanceof WlTextConstruct ) { echo Xml::element( 'content:encoded', null, $content->getHTML() ); } else { echo Xml::element( 'content:encoded', null, htmlspecialchars( $content ) ); } } echo Xml::closeElement( 'item' ) . "\n"; }