/** * Generates and returns a single feed entry. * @param $row The wikilog article database entry. * @return A new WlSyndicationEntry object. */ public function formatFeedEntry( $row ) { global $wgMimeType; global $wgWikilogFeedSummary, $wgWikilogFeedContent; global $wgWikilogFeedCategories, $wgWikilogFeedRelated; global $wgWikilogEnableComments; # Make titles. $wikilogName = str_replace( '_', ' ', $row->wlw_title ); $wikilogTitle =& Title::makeTitle( $row->wlw_namespace, $row->wlw_title ); $itemName = str_replace( '_', ' ', $row->wlp_title ); $itemTitle =& Title::makeTitle( $row->page_namespace, $row->page_title ); # Retrieve article parser output list( $article, $parserOutput ) = WikilogUtils::parsedArticle( $itemTitle, true ); # Generate some fixed bits $authors = unserialize( $row->wlp_authors ); # Create new syndication entry. $entry = new WlSyndicationEntry( self::makeEntryId( $itemTitle ), $itemName, $row->wlp_updated, $itemTitle->getFullUrl() ); # Comments link. $cmtLink = array( 'href' => $itemTitle->getTalkPage()->getFullUrl(), 'type' => $wgMimeType ); if ( $wgWikilogEnableComments ) { $cmtLink['thr:count'] = $row->wlp_num_comments; if ( !is_null( $row->_wlp_last_comment_timestamp ) ) { $cmtLink['thr:updated'] = wfTimestamp( TS_ISO_8601, $row->_wlp_last_comment_timestamp ); } } $entry->addLinkRel( 'replies', $cmtLink ); # Source feed. if ( $this->mSiteFeed ) { $privfeed = $this->getWikilogFeedObject( $wikilogTitle, true ); if ( $privfeed ) { $entry->setSource( $privfeed ); } } # Retrieve summary and content. list( $summary, $content ) = WikilogUtils::splitSummaryContent( $parserOutput ); if ( $wgWikilogFeedSummary && $summary ) { $entry->setSummary( new WlTextConstruct( 'html', $summary ) ); } if ( $wgWikilogFeedContent && $content ) { $entry->setContent( new WlTextConstruct( 'html', $content ) ); } # Authors. foreach ( $authors as $user => $userid ) { $usertitle = Title::makeTitle( NS_USER, $user ); $entry->addAuthor( $user, $usertitle->getFullUrl() ); } # Automatic list of categories. if ( $wgWikilogFeedCategories ) { $this->addCategories( $entry, $row->wlp_page ); } # Automatic list of related links. if ( $wgWikilogFeedRelated ) { $externals = array_keys( $parserOutput->getExternalLinks() ); foreach ( $externals as $ext ) { $entry->addLinkRel( 'related', array( 'href' => $ext ) ); } } if ( $row->wlp_publish ) { $entry->setPublished( $row->wlp_pubdate ); } return $entry; }