/** * 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; }
function formatRow( $row ) { global $wgParser; # Retrieve article parser output and other data. $item = WikilogItem::newFromRow( $row ); list( $article, $parserOutput ) = WikilogUtils::parsedArticle( $item->mTitle ); list( $summary, $content ) = WikilogUtils::splitSummaryContent( $parserOutput ); if ( empty( $summary ) ) { $summary = $content; $hasMore = false; } else { $hasMore = true; } # Some general data. $authors = WikilogUtils::authorList( array_keys( $item->mAuthors ) ); $tags = implode( wfMsgForContent( 'comma-separator' ), array_keys( $item->mTags ) ); $comments = WikilogUtils::getCommentsWikiText( $item ); $divclass = 'wl-entry' . ( $item->getIsPublished() ? '' : ' wl-draft' ); $itemPubdate = $item->getPublishDate(); list( $publishedDate, $publishedTime, $publishedTz ) = WikilogUtils::getLocalDateTime( $itemPubdate ); $itemUpdated = $item->getUpdatedDate(); list( $updatedDate, $updatedTime, ) = WikilogUtils::getLocalDateTime( $itemUpdated ); # Template parameters. $vars = array( 'class' => $divclass, 'wikilogTitle' => $item->mParentName, 'wikilogPage' => $item->mParentTitle->getPrefixedText(), 'title' => $item->mName, 'page' => $item->mTitle->getPrefixedText(), 'authors' => $authors, 'tags' => $tags, 'published' => $item->getIsPublished() ? '*' : '', 'date' => $publishedDate, 'time' => $publishedTime, 'tz' => $publishedTz, 'updatedDate' => $updatedDate, 'updatedTime' => $updatedTime, 'summary' => $wgParser->insertStripItem( $summary ), 'hasMore' => $hasMore ? '*' : '', 'comments' => $comments ); $frame = $wgParser->getPreprocessor()->newCustomFrame( $vars ); $text = $frame->expand( $this->mTemplate ); return $this->parse( $text ); }