/**
	 * Generates and returns a single feed entry.
	 * @param $row The wikilog comment database entry.
	 * @return A new WlSyndicationEntry object.
	 */
	function formatFeedEntry( $row ) {
		global $wgMimeType;

		# Create comment object.
		$item = $this->mSingleItem ? $this->mSingleItem : WikilogItem::newFromRow( $row );
		$comment = WikilogComment::newFromRow( $item, $row );

		# Prepare some strings.
		if ( $comment->mUserID ) {
			$usertext = $comment->mUserText;
		} else {
			$usertext = wfMsgForContent( 'wikilog-comment-anonsig',
				$comment->mUserText, ''/*talk*/, $comment->mAnonName
			);
		}
		if ( $this->mSingleItem ) {
			$title = wfMsgForContent( 'wikilog-comment-feed-title1',
				$comment->mID, $usertext
			);
		} else {
			$title = wfMsgForContent( 'wikilog-comment-feed-title2',
				$comment->mID, $usertext, $comment->mItem->mName
			);
		}

		# Create new syndication entry.
		$entry = new WlSyndicationEntry(
			self::makeEntryId( $comment ),
			$title,
			$comment->mUpdated,
			$comment->getCommentArticleTitle()->getFullUrl()
		);

		# Comment text.
		if ( $comment->mCommentRev ) {
			list( $article, $parserOutput ) = WikilogUtils::parsedArticle( $comment->mCommentTitle, true );
			$content = Sanitizer::removeHTMLcomments( $parserOutput->getText() );
			if ( $content ) {
				$entry->setContent( new WlTextConstruct( 'html', $content ) );
			}
		}

		# Author.
		$usertitle = Title::makeTitle( NS_USER, $comment->mUserText );
		$useruri = $usertitle->exists() ? $usertitle->getFullUrl() : null;
		$entry->addAuthor( $usertext, $useruri );

		# Timestamp
		$entry->setPublished( $comment->mTimestamp );

		return $entry;
	}
	/**
	 * Format a single comment in HTML.
	 *
	 * @param $comment Comment to be formatted.
	 * @param $highlight Whether the comment should be highlighted.
	 * @return Generated HTML.
	 */
	public function formatComment( $comment, $highlight = false ) {
		global $wgUser, $wgOut;

		$hidden = WikilogComment::$statusMap[ $comment->mStatus ];

		# div class.
		$divclass = array( 'wl-comment' );
		if ( !$comment->isVisible() ) {
			$divclass[] = "wl-comment-{$hidden}";
		}
		if ( $comment->mUserID ) {
			$divclass[] = 'wl-comment-by-user';
			if ( isset( $comment->mItem->mAuthors[$comment->mUserText] ) ) {
				$divclass[] = 'wl-comment-by-author';
			}
		} else {
			$divclass[] = 'wl-comment-by-anon';
		}

		# If user is has moderator privileges and the comment is pending
		# approval, highlight it.
		if ( $this->mAllowModeration && $comment->mStatus == WikilogComment::S_PENDING ) {
			$highlight = true;
		}

		if ( !$comment->isVisible() && !$this->mAllowModeration ) {
			# Placeholder.
			$status = wfMsg( "wikilog-comment-{$hidden}" );
			$html = WikilogUtils::wrapDiv( 'wl-comment-placeholder', $status );
		} else {
			# The comment.
			$params = $this->getCommentMsgParams( $comment );
			$html = $this->formatCommentHeader( $comment, $params );

			if ( $comment->mID && $comment->mCommentRev ) {
				list( $article, $parserOutput ) = WikilogUtils::parsedArticle( $comment->mCommentTitle );
				$text = $parserOutput->getText();
			} else {
				$text = $comment->getText();
			}

			if ( $text ) {
				$html .= WikilogUtils::wrapDiv( 'wl-comment-text', $text );
			}

			$html .= $this->formatCommentFooter( $comment, $params );
			$html .= $this->getCommentToolLinks( $comment );
		}

		# Enclose everything in a div.
		if ( $highlight ) {
			$divclass[] = 'wl-comment-highlight';
		}
		return Xml::tags( 'div', array(
			'class' => implode( ' ', $divclass ),
			'id' => ( $comment->mID ? "c{$comment->mID}" : 'cpreview' )
		), $html );
	}
	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 );
	}