Go to the documentation of this file.
47 if ( $output ===
null ) {
54 $output->addWikiMsg(
'feed-unavailable' );
59 $output->addWikiMsg(
'feed-invalid' );
75 $timestamp =
wfTimestamp( TS_MW, $row->rc_timestamp );
77 if ( $row->rc_type ==
RC_LOG ) {
82 $row->rc_last_oldid, $row->rc_this_oldid,
84 $row->rc_deleted & RevisionRecord::DELETED_COMMENT
85 ?
wfMessage(
'rev-deleted-comment' )->escaped()
103 $comment, $actiontext =
''
108 $completeText =
'<p>' . implode(
' ',
118 $services = MediaWikiServices::getInstance();
119 $permManager = $services->getPermissionManager();
120 $accErrors = $permManager->getPermissionErrors(
128 if (
$title->getNamespace() < 0 || $accErrors || !$newid ) {
129 return $completeText;
132 $revLookup = $services->getRevisionLookup();
133 $contentHandlerFactory = $services->getContentHandlerFactory();
138 $revRecord = $revLookup->getRevisionById( $oldid );
144 $context->setTitle(
$title );
146 $model = $revRecord->getSlot(
150 $contentHandler = $contentHandlerFactory->getContentHandler( $model );
151 $de = $contentHandler->createDifferenceEngine( $context, $oldid, $newid );
152 $diffText = $de->getDiff(
155 $wgLang->timeanddate( $timestamp ),
157 $wgLang->time( $timestamp ) )->text() );
164 } elseif ( $diffText ===
false ) {
166 $diffText =
"<p>Can't load revision $newid</p>";
169 $diffText = UtfNormal\Validator::cleanUp( $diffText );
173 $revRecord = $revLookup->getRevisionById( $newid );
175 $newContent = $contentHandlerFactory
176 ->getContentHandler(
$title->getContentModel() )
177 ->makeEmptyContent();
179 $newContent = $revRecord->getContent( SlotRecord::MAIN );
184 $text = $newContent->getText();
189 $html = nl2br( htmlspecialchars( $text ) );
199 if ( $html ===
null ) {
204 $diffText =
'<p><b>' .
wfMessage(
'newpage' )->text() .
'</b></p>' .
205 '<div>' . $html .
'</div>';
208 $completeText .= $diffText;
210 return $completeText;
223 $queryParameters = [
'diff' => $newid ];
224 if ( $oldid !=
null ) {
225 $queryParameters[
'oldid'] = $oldid;
227 $diffUrl =
$title->getFullURL( $queryParameters );
230 wfMessage(
'showdiff' )->inContentLanguage()->text() );
245 'diff' =>
'background-color: #fff; color: #202122;',
246 'diff-otitle' =>
'background-color: #fff; color: #202122; text-align: center;',
247 'diff-ntitle' =>
'background-color: #fff; color: #202122; text-align: center;',
248 'diff-addedline' =>
'color: #202122; font-size: 88%; border-style: solid; '
249 .
'border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; '
250 .
'vertical-align: top; white-space: pre-wrap;',
251 'diff-deletedline' =>
'color: #202122; font-size: 88%; border-style: solid; '
252 .
'border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; '
253 .
'vertical-align: top; white-space: pre-wrap;',
254 'diff-context' =>
'background-color: #f8f9fa; color: #202122; font-size: 88%; '
255 .
'border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; '
256 .
'border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;',
257 'diffchange' =>
'font-weight: bold; text-decoration: none;',
260 foreach ( $styles as $class => $style ) {
261 $text = preg_replace(
'/(<\w+\b[^<>]*)\bclass=([\'"])(?:[^\'"]*\s)?' .
262 preg_quote( $class ) .
'(?:\s[^\'"]*)?\2(?=[^<>]*>)/',
263 '$1style="' . $style .
'"', $text );
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
static formatDiffRow( $title, $oldid, $newid, $timestamp, $comment, $actiontext='')
Really format a diff for the newsfeed.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
$wgFeedClasses
Available feeds objects.
Helper functions for feeds.
$wgFeedDiffCutoff
When generating Recentchanges RSS/Atom feed, diffs will not be generated for pages larger than this s...
static getDiffLink(Title $title, $newid, $oldid=null)
Generates a diff link.
static checkFeedOutput( $type, $output=null)
Check whether feeds can be used and that $type is a valid feed type.
static getMain()
Get the RequestContext object associated with the main request.
Content object implementation for representing flat text.
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...
static formatDiff( $row)
Format a diff for the newsfeed.
Represents a title within MediaWiki.
static applyDiffStyle( $text)
Hacky application of diff styles for the feeds.
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
$wgFeed
Provide syndication feeds (RSS, Atom) for, e.g., Recentchanges, Newpages.