43 $wgOut->addWikiMsg(
'feed-unavailable' );
48 $wgOut->addWikiMsg(
'feed-invalid' );
63 $titleObj = Title::makeTitle( $row->rc_namespace, $row->rc_title );
64 $timestamp =
wfTimestamp( TS_MW, $row->rc_timestamp );
66 if ( $row->rc_type ==
RC_LOG ) {
71 $row->rc_last_oldid, $row->rc_this_oldid,
73 $row->rc_deleted & RevisionRecord::DELETED_COMMENT
74 ?
wfMessage(
'rev-deleted-comment' )->escaped()
75 : CommentStore::getStore()->getComment(
'rc_comment', $row )->text,
92 $comment, $actiontext =
''
97 $completeText =
'<p>' . implode(
' ',
107 $accErrors =
$title->getUserPermissionsErrors(
'read', $anon,
true );
111 if (
$title->getNamespace() < 0 || $accErrors || !$newid ) {
112 return $completeText;
119 $rev = Revision::newFromId( $oldid );
124 $context = clone RequestContext::getMain();
127 $contentHandler = $rev->getContentHandler();
128 $de = $contentHandler->createDifferenceEngine(
$context, $oldid, $newid );
129 $diffText = $de->getDiff(
132 $wgLang->timeanddate( $timestamp ),
134 $wgLang->time( $timestamp ) )->text() );
141 } elseif ( $diffText ===
false ) {
143 $diffText =
"<p>Can't load revision $newid</p>";
146 $diffText = UtfNormal\Validator::cleanUp( $diffText );
150 $rev = Revision::newFromId( $newid );
152 $newContent = ContentHandler::getForTitle(
$title )->makeEmptyContent();
154 $newContent = $rev->getContent();
159 $text = $newContent->getText();
164 $html = nl2br( htmlspecialchars( $text ) );
174 if ( $html ===
null ) {
179 $diffText =
'<p><b>' .
wfMessage(
'newpage' )->text() .
'</b></p>' .
180 '<div>' . $html .
'</div>';
183 $completeText .= $diffText;
185 return $completeText;
198 $queryParameters = [
'diff' => $newid ];
199 if ( $oldid !=
null ) {
200 $queryParameters[
'oldid'] = $oldid;
202 $diffUrl =
$title->getFullURL( $queryParameters );
204 $diffLink = Html::element(
'a', [
'href' => $diffUrl ],
205 wfMessage(
'showdiff' )->inContentLanguage()->text() );
220 'diff' =>
'background-color: #fff; color: #222;',
221 'diff-otitle' =>
'background-color: #fff; color: #222; text-align: center;',
222 'diff-ntitle' =>
'background-color: #fff; color: #222; text-align: center;',
223 'diff-addedline' =>
'color: #222; font-size: 88%; border-style: solid; '
224 .
'border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; '
225 .
'vertical-align: top; white-space: pre-wrap;',
226 'diff-deletedline' =>
'color: #222; font-size: 88%; border-style: solid; '
227 .
'border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; '
228 .
'vertical-align: top; white-space: pre-wrap;',
229 'diff-context' =>
'background-color: #f8f9fa; color: #222; font-size: 88%; '
230 .
'border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; '
231 .
'border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;',
232 'diffchange' =>
'font-weight: bold; text-decoration: none;',
235 foreach ( $styles as $class => $style ) {
236 $text = preg_replace(
"/(<[^>]+)class=(['\"])$class\\2([^>]*>)/",
237 "\\1style=\"$style\"\\3", $text );
$wgFeedDiffCutoff
When generating Recentchanges RSS/Atom feed, diffs will not be generated for pages larger than this s...
$wgFeedClasses
Available feeds objects.
$wgFeed
Provide syndication feeds (RSS, Atom) for, e.g., Recentchanges, Newpages.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Helper functions for feeds.
static formatDiff( $row)
Format a diff for the newsfeed.
static checkFeedOutput( $type)
Check whether feeds can be used and that $type is a valid feed type.
static formatDiffRow( $title, $oldid, $newid, $timestamp, $comment, $actiontext='')
Really format a diff for the newsfeed.
static applyDiffStyle( $text)
Hacky application of diff styles for the feeds.
static getDiffLink(Title $title, $newid, $oldid=null)
Generates a diff link.
static formatComment( $comment, $title=null, $local=false, $wikiId=null)
This function is called by all recent changes variants, by the page history, and by the user contribu...
Content object implementation for representing flat text.
Represents a title within MediaWiki.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...