59 if ( $output ===
null ) {
66 $output->addWikiMsg(
'feed-unavailable' );
70 if ( !isset( $feedClasses[$type] ) ) {
71 $output->addWikiMsg(
'feed-invalid' );
87 public static function formatDiff( $row, $formattedComment =
null ) {
89 $timestamp =
wfTimestamp( TS_MW, $row->rc_timestamp );
91 if ( $row->rc_type ==
RC_LOG ) {
96 $formattedComment =
wfMessage(
'rev-deleted-comment' )->escaped();
97 } elseif ( $formattedComment ===
null ) {
99 $formattedComment = $services->getCommentFormatter()->format(
100 $services->getCommentStore()->getComment(
'rc_comment', $row )->text );
103 $row->rc_last_oldid, $row->rc_this_oldid,
124 $comment, $actiontext =
''
127 ->format( $comment );
129 $formattedComment, $actiontext );
145 $title, $oldid, $newid, $timestamp, $formattedComment, $actiontext =
''
150 $unwrappedText = implode(
152 array_filter( [ $actiontext, $formattedComment ] )
161 $permManager = $services->getPermissionManager();
162 $accErrors = $permManager->getPermissionErrors(
170 if ( $title->getNamespace() < 0 || $accErrors || !$newid ) {
171 return $completeText;
174 $revLookup = $services->getRevisionLookup();
175 $contentHandlerFactory = $services->getContentHandlerFactory();
179 if ( $feedDiffCutoff > 0 ) {
180 $revRecord = $revLookup->getRevisionById( $oldid );
186 $context->setTitle( $title );
188 $model = $revRecord->getSlot(
192 $contentHandler = $contentHandlerFactory->getContentHandler( $model );
193 $de = $contentHandler->createDifferenceEngine( $context, $oldid, $newid );
194 $lang = $context->getLanguage();
195 $user = $context->getUser();
196 $diffText = $de->getDiff(
197 $context->msg(
'previousrevision' )->text(),
198 $context->msg(
'revisionasof',
199 $lang->userTimeAndDate( $timestamp, $user ),
200 $lang->userDate( $timestamp, $user ),
201 $lang->userTime( $timestamp, $user ) )->text() );
205 if ( $feedDiffCutoff <= 0 || ( strlen( $diffText ) > $feedDiffCutoff ) ) {
208 } elseif ( $diffText ===
false ) {
213 "Can't load revision $newid"
217 $diffText = UtfNormal\Validator::cleanUp( $diffText );
221 $revRecord = $revLookup->getRevisionById( $newid );
222 if ( $feedDiffCutoff <= 0 || $revRecord ===
null ) {
223 $newContent = $contentHandlerFactory
224 ->getContentHandler( $title->getContentModel() )
225 ->makeEmptyContent();
232 $text = $newContent->getText();
234 if ( $feedDiffCutoff <= 0 || strlen( $text ) > $feedDiffCutoff ) {
237 $html = nl2br( htmlspecialchars( $text ) );
247 if ( $html ===
null ) {
260 $completeText .= $diffText;
262 return $completeText;
275 $queryParameters = [
'diff' => $newid ];
276 if ( $oldid !=
null ) {
277 $queryParameters[
'oldid'] = $oldid;
279 $diffUrl = $title->
getFullURL( $queryParameters );
282 wfMessage(
'showdiff' )->inContentLanguage()->text() );
297 'diff' =>
'background-color: #fff; color: #202122;',
298 'diff-otitle' =>
'background-color: #fff; color: #202122; text-align: center;',
299 'diff-ntitle' =>
'background-color: #fff; color: #202122; text-align: center;',
300 'diff-addedline' =>
'color: #202122; font-size: 88%; border-style: solid; '
301 .
'border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; '
302 .
'vertical-align: top; white-space: pre-wrap;',
303 'diff-deletedline' =>
'color: #202122; font-size: 88%; border-style: solid; '
304 .
'border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; '
305 .
'vertical-align: top; white-space: pre-wrap;',
306 'diff-context' =>
'background-color: #f8f9fa; color: #202122; font-size: 88%; '
307 .
'border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; '
308 .
'border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;',
309 'diffchange' =>
'font-weight: bold; text-decoration: none;',
312 foreach ( $styles as $class => $style ) {
313 $text = preg_replace(
'/(<\w+\b[^<>]*)\bclass=([\'"])(?:[^\'"]*\s)?' .
314 preg_quote( $class ) .
'(?:\s[^\'"]*)?\2(?=[^<>]*>)/',
315 '$1style="' . $style .
'"', $text );
326 class_alias( FeedUtils::class,
'FeedUtils' );
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.
if(!defined( 'MW_NO_SESSION') &&! $wgCommandLineMode) $wgOut
An IContextSource implementation which will inherit context from another source but allow individual ...
A class containing constants representing the names of configuration variables.
const FeedClasses
Name constant for the FeedClasses setting, for use with Config::get()
const Feed
Name constant for the Feed setting, for use with Config::get()
const FeedDiffCutoff
Name constant for the FeedDiffCutoff setting, for use with Config::get()
This is one of the Core classes and should be read at least once by any new developers.
Group all the pieces relevant to the context of a request into one instance.
static getMain()
Get the RequestContext object associated with the main request.
Content object implementation for representing flat text.