45 $wgOut->addWikiMsg(
'feed-unavailable' );
50 $wgOut->addWikiMsg(
'feed-invalid' );
65 $titleObj = Title::makeTitle( $row->rc_namespace, $row->rc_title );
66 $timestamp =
wfTimestamp( TS_MW, $row->rc_timestamp );
68 if ( $row->rc_type ==
RC_LOG ) {
73 $row->rc_last_oldid, $row->rc_this_oldid,
75 $row->rc_deleted & RevisionRecord::DELETED_COMMENT
76 ?
wfMessage(
'rev-deleted-comment' )->escaped()
77 : CommentStore::getStore()->getComment(
'rc_comment', $row )->text,
94 $comment, $actiontext =
''
99 $completeText =
'<p>' . implode(
' ',
109 $services = MediaWikiServices::getInstance();
110 $permManager = $services->getPermissionManager();
111 $accErrors = $permManager->getPermissionErrors(
119 if (
$title->getNamespace() < 0 || $accErrors || !$newid ) {
120 return $completeText;
123 $revLookup = $services->getRevisionLookup();
124 $contentHandlerFactory = $services->getContentHandlerFactory();
129 $revRecord = $revLookup->getRevisionById( $oldid );
134 $context = clone RequestContext::getMain();
135 $context->setTitle(
$title );
137 $model = $revRecord->getSlot(
141 $contentHandler = $contentHandlerFactory->getContentHandler( $model );
142 $de = $contentHandler->createDifferenceEngine( $context, $oldid, $newid );
143 $diffText = $de->getDiff(
146 $wgLang->timeanddate( $timestamp ),
148 $wgLang->time( $timestamp ) )->text() );
155 } elseif ( $diffText ===
false ) {
157 $diffText =
"<p>Can't load revision $newid</p>";
160 $diffText = UtfNormal\Validator::cleanUp( $diffText );
164 $revRecord = $revLookup->getRevisionById( $newid );
166 $newContent = $contentHandlerFactory
167 ->getContentHandler(
$title->getContentModel() )
168 ->makeEmptyContent();
170 $newContent = $revRecord->getContent( SlotRecord::MAIN );
175 $text = $newContent->getText();
180 $html = nl2br( htmlspecialchars( $text ) );
190 if ( $html ===
null ) {
195 $diffText =
'<p><b>' .
wfMessage(
'newpage' )->text() .
'</b></p>' .
196 '<div>' . $html .
'</div>';
199 $completeText .= $diffText;
201 return $completeText;
214 $queryParameters = [
'diff' => $newid ];
215 if ( $oldid !=
null ) {
216 $queryParameters[
'oldid'] = $oldid;
218 $diffUrl =
$title->getFullURL( $queryParameters );
220 $diffLink = Html::element(
'a', [
'href' => $diffUrl ],
221 wfMessage(
'showdiff' )->inContentLanguage()->text() );
236 'diff' =>
'background-color: #fff; color: #202122;',
237 'diff-otitle' =>
'background-color: #fff; color: #202122; text-align: center;',
238 'diff-ntitle' =>
'background-color: #fff; color: #202122; text-align: center;',
239 'diff-addedline' =>
'color: #202122; font-size: 88%; border-style: solid; '
240 .
'border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; '
241 .
'vertical-align: top; white-space: pre-wrap;',
242 'diff-deletedline' =>
'color: #202122; font-size: 88%; border-style: solid; '
243 .
'border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; '
244 .
'vertical-align: top; white-space: pre-wrap;',
245 'diff-context' =>
'background-color: #f8f9fa; color: #202122; font-size: 88%; '
246 .
'border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; '
247 .
'border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;',
248 'diffchange' =>
'font-weight: bold; text-decoration: none;',
251 foreach ( $styles as $class => $style ) {
252 $text = preg_replace(
"/(<[^>]+)class=(['\"])$class\\2([^>]*>)/",
253 "\\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,...