40 private const DIR_PREV = 0;
41 private const DIR_NEXT = 1;
59 return $this->
msg(
'history-title', $this->
getTitle()->getPrefixedText() )->text();
64 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
65 $subtitle = $linkRenderer->makeKnownLink(
67 $this->
msg(
'viewpagelogs' )->text(),
69 [
'page' => $this->
getTitle()->getPrefixedText() ]
77 . $this->
msg(
'word-separator' )->escaped()
78 . $this->
msg(
'parentheses' )
79 ->rawParams( $this->
getLanguage()->pipeList( $links ) )
82 return Html::rawElement(
'div', [
'class' =>
'mw-history-subtitle' ], $subtitle );
89 private function preCacheMessages() {
91 if ( !isset( $this->message ) ) {
93 $msgs = [
'cur',
'tooltip-cur',
'last',
'tooltip-last',
'pipe-separator' ];
94 foreach ( $msgs as $msg ) {
95 $this->message[$msg] = $this->
msg( $msg )->escaped();
104 private function getTimestampFromRequest(
WebRequest $request ) {
106 $year = $request->
getInt(
'year' );
107 $month = $request->
getInt(
'month' );
109 if ( $year !== 0 || $month !== 0 ) {
113 if ( $month < 1 || $month > 12 ) {
118 $day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
121 $month = str_pad( (
string)$month, 2,
"0", STR_PAD_LEFT );
122 $day = str_pad( (
string)$day, 2,
"0", STR_PAD_LEFT );
125 $before = $request->
getVal(
'date-range-to' );
127 $parts = explode(
'-', $before );
130 if ( count( $parts ) === 3 ) {
135 return $year && $month && $day ? $year .
'-' . $month .
'-' . $day :
'';
145 $config = $this->context->getConfig();
146 $services = MediaWikiServices::getInstance();
155 $watchlistManager = $services->getWatchlistManager();
156 $hasUnseenRevisionMarkers = $config->get( MainConfigNames::ShowUpdatedMarker ) &&
157 $watchlistManager->getTitleNotificationTimestamp(
162 !$hasUnseenRevisionMarkers &&
163 $out->checkLastModified( $this->getWikiPage()->getTouched() )
168 $this->preCacheMessages();
170 # Fill in the file cache if not set already
173 if ( !
$cache->isCacheGood( ) ) {
174 ob_start( [ &
$cache,
'saveToFileCache' ] );
179 $out->setFeedAppendQuery(
'action=history' );
180 $out->addModules(
'mediawiki.action.history' );
181 $out->addModuleStyles( [
182 'mediawiki.interface.helpers.styles',
183 'mediawiki.action.history.styles',
184 'mediawiki.special.changeslist',
186 if ( $config->get( MainConfigNames::UseMediaWikiUIEverywhere ) ) {
187 $out->addModuleStyles( [
188 'mediawiki.ui.input',
189 'mediawiki.ui.checkbox',
194 $feedType = $request->
getRawVal(
'feed' );
195 if ( $feedType !==
null ) {
196 $this->feed( $feedType );
201 'https://meta.wikimedia.org/wiki/Special:MyLanguage/Help:Page_history',
207 $send404Code = $config->get( MainConfigNames::Send404Code );
208 if ( $send404Code ) {
209 $out->setStatusCode( 404 );
211 $out->addWikiMsg(
'nohistory' );
215 # show deletion/move log if there is an entry
216 LogEventsList::showLogExtract(
218 [
'delete',
'move',
'protect' ],
222 'conds' => [
'log_action != ' .
$dbr->addQuotes(
'revision' ) ],
223 'showIfEmpty' =>
false,
224 'msgKey' => [
'moveddeleted-notice' ]
231 $ts = $this->getTimestampFromRequest( $request );
232 $tagFilter = $request->
getVal(
'tagfilter' );
237 if ( $request->
getBool(
'deleted' ) ) {
238 $conds = [
'rev_deleted != 0' ];
248 'default' =>
'history',
253 'label' => $this->
msg(
'date-range-to' )->text(),
254 'name' =>
'date-range-to',
257 'label-message' =>
'tag-filter',
258 'type' =>
'tagfilter',
260 'name' =>
'tagfilter',
261 'value' => $tagFilter,
264 if ( $this->
getAuthority()->isAllowed(
'deletedhistory' ) ) {
267 'label' => $this->
msg(
'history-show-deleted' )->text(),
268 'default' => $request->
getBool(
'deleted' ),
278 ->setCollapsibleOptions(
true )
279 ->setId(
'mw-history-searchform' )
280 ->setSubmitTextMsg(
'historyaction-submit' )
281 ->setWrapperAttributes( [
'id' =>
'mw-history-search' ] )
282 ->setWrapperLegendMsg(
'history-fieldset-title' )
285 $out->addHTML( $htmlForm->getHTML(
false ) );
293 $dateComponents = explode(
'-', $ts );
294 if ( count( $dateComponents ) > 1 ) {
295 $y = (int)$dateComponents[0];
296 $m = (int)$dateComponents[1];
297 $d = (int)$dateComponents[2];
310 $services->getLinkBatchFactory(),
312 $services->getCommentFormatter()
315 $pager->getNavigationBar() .
317 $pager->getNavigationBar()
319 $out->setPreventClickjacking( $pager->getPreventClickjacking() );
334 private function fetchRevisions( $limit, $offset, $direction ) {
342 if ( $direction === self::DIR_PREV ) {
343 list( $dirs, $oper ) = [
"ASC",
">=" ];
345 list( $dirs, $oper ) = [
"DESC",
"<=" ];
349 $offsets = [
"rev_timestamp $oper " .
$dbr->addQuotes(
$dbr->timestamp( $offset ) ) ];
356 $revQuery = MediaWikiServices::getInstance()->getRevisionStore()->getQueryInfo();
358 $res =
$dbr->newSelectQueryBuilder()
360 ->where( [
'rev_page' => $page_id ] )
361 ->andWhere( $offsets )
362 ->useIndex( [
'revision' =>
'rev_page_timestamp' ] )
363 ->orderBy( [
'rev_timestamp' ], $dirs )
365 ->caller( __METHOD__ )
376 private function feed(
$type ) {
382 $feedClasses = $this->context->getConfig()->get( MainConfigNames::FeedClasses );
384 $feed =
new $feedClasses[
$type](
385 $this->
getTitle()->getPrefixedText() .
' - ' .
386 $this->
msg(
'history-feed-title' )->inContentLanguage()->text(),
387 $this->
msg(
'history-feed-description' )->inContentLanguage()->text(),
388 $this->
getTitle()->getFullURL(
'action=history' )
393 $limit = $request->
getInt(
'limit', 10 );
396 $this->context->getConfig()->get( MainConfigNames::FeedLimit )
399 $items = $this->fetchRevisions( $limit, 0, self::DIR_NEXT );
402 $formattedComments = MediaWikiServices::getInstance()->getRowCommentFormatter()
403 ->formatRows( $items,
'rev_comment' );
407 if ( $items->numRows() ) {
408 foreach ( $items as $i => $row ) {
409 $feed->outItem( $this->feedItem( $row, $formattedComments[$i] ) );
412 $feed->outItem( $this->feedEmpty() );
417 private function feedEmpty() {
419 $this->
msg(
'nohistory' )->inContentLanguage()->text(),
420 $this->
msg(
'history-feed-empty' )->inContentLanguage()->parseAsBlock(),
424 $this->
getTitle()->getTalkPage()->getFullURL()
437 private function feedItem( $row, $formattedComment ) {
438 $revisionStore = MediaWikiServices::getInstance()->getRevisionStore();
439 $rev = $revisionStore->newRevisionFromRow( $row, 0, $this->
getTitle() );
440 $prevRev = $revisionStore->getPreviousRevision( $rev );
441 $revComment = $rev->getComment() ===
null ? null : $rev->getComment()->text;
444 $prevRev ? $prevRev->getId() : false,
449 $revUserText = $rev->getUser() ? $rev->getUser()->getName() :
'';
450 if ( $revComment ==
'' ) {
451 $contLang = MediaWikiServices::getInstance()->getContentLanguage();
452 $title = $this->
msg(
'history-feed-item-nocomment',
454 $contLang->timeanddate( $rev->getTimestamp() ),
455 $contLang->date( $rev->getTimestamp() ),
456 $contLang->time( $rev->getTimestamp() )
457 )->inContentLanguage()->text();
460 $this->
msg(
'colon-separator' )->inContentLanguage()->text() .
467 $this->
getTitle()->getFullURL(
'diff=' . $rev->getId() .
'&oldid=prev' ),
468 $rev->getTimestamp(),
470 $this->getTitle()->getTalkPage()->getFullURL()
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
getWikiPage()
Get a WikiPage object.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
getTitle()
Shortcut to get the Title object from the page.
getContext()
Get the IContextSource in use here.
getOutput()
Get the OutputPage being used for this instance.
getUser()
Shortcut to get the User being used for this instance.
static exists(string $name)
Check if a given action is recognised, even if it's disabled.
getArticle()
Get a Article object.
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
array $fields
The fields used to create the HTMLForm.
getLanguage()
Shortcut to get the user Language being used for this instance.
getAuthority()
Shortcut to get the Authority executing this instance.
getRequest()
Get the WebRequest being used for this instance.
A base class for outputting syndication feeds (e.g.
static stripComment( $text)
Quickie hack... strip out wikilinks to more legible form from the comment.
static formatDiffRow2( $title, $oldid, $newid, $timestamp, $formattedComment, $actiontext='')
Really really format a diff for the newsfeed.
static checkFeedOutput( $type, $output=null)
Check whether feeds can be used and that $type is a valid feed type.
Page view caching in the file system.
static useFileCache(IContextSource $context, $mode=self::MODE_NORMAL)
Check if pages can be cached for this request/user.
This class handles printing the history page for an article.
onView()
Print the history page for an article.
array $message
Array of message keys and strings.
getName()
Return the name of the action this object responds to.
requiresWrite()
Whether this action requires the wiki not to be locked.
getPageTitle()
Returns the name that goes in the <h1> page title.
getDescription()
Returns the description that goes below the <h1> element.
requiresUnblock()
Whether this action can still be executed by a blocked user.
static getLocalInstance( $ts=false)
Get a timestamp instance in the server local timezone ($wgLocaltimezone)
A class containing constants representing the names of configuration variables.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
getVal( $name, $default=null)
Fetch a text string and partially normalized it.
getBool( $name, $default=false)
Fetch a boolean value from the input or return $default if not set.
getInt( $name, $default=0)
Fetch an integer value from the input or return $default if not set.
getRawVal( $name, $default=null)
Fetch a string WITHOUT any Unicode or line break normalization.