MediaWiki REL1_30
HistoryAction.php
Go to the documentation of this file.
1<?php
29
41 const DIR_PREV = 0;
42 const DIR_NEXT = 1;
43
45 public $message;
46
47 public function getName() {
48 return 'history';
49 }
50
51 public function requiresWrite() {
52 return false;
53 }
54
55 public function requiresUnblock() {
56 return false;
57 }
58
59 protected function getPageTitle() {
60 return $this->msg( 'history-title', $this->getTitle()->getPrefixedText() )->text();
61 }
62
63 protected function getDescription() {
64 // Creation of a subtitle link pointing to [[Special:Log]]
65 return MediaWikiServices::getInstance()->getLinkRenderer()->makeKnownLink(
67 $this->msg( 'viewpagelogs' )->text(),
68 [],
69 [ 'page' => $this->getTitle()->getPrefixedText() ]
70 );
71 }
72
76 public function getArticle() {
77 return $this->page;
78 }
79
84 private function preCacheMessages() {
85 // Precache various messages
86 if ( !isset( $this->message ) ) {
87 $msgs = [ 'cur', 'last', 'pipe-separator' ];
88 foreach ( $msgs as $msg ) {
89 $this->message[$msg] = $this->msg( $msg )->escaped();
90 }
91 }
92 }
93
97 function onView() {
98 $out = $this->getOutput();
99 $request = $this->getRequest();
100
104 if ( $out->checkLastModified( $this->page->getTouched() ) ) {
105 return; // Client cache fresh and headers sent, nothing more to do.
106 }
107
108 $this->preCacheMessages();
109 $config = $this->context->getConfig();
110
111 # Fill in the file cache if not set already
112 if ( HTMLFileCache::useFileCache( $this->getContext() ) ) {
113 $cache = new HTMLFileCache( $this->getTitle(), 'history' );
114 if ( !$cache->isCacheGood( /* Assume up to date */ ) ) {
115 ob_start( [ &$cache, 'saveToFileCache' ] );
116 }
117 }
118
119 // Setup page variables.
120 $out->setFeedAppendQuery( 'action=history' );
121 $out->addModules( 'mediawiki.action.history' );
122 $out->addModuleStyles( [
123 'mediawiki.action.history.styles',
124 'mediawiki.special.changeslist',
125 ] );
126 if ( $config->get( 'UseMediaWikiUIEverywhere' ) ) {
127 $out = $this->getOutput();
128 $out->addModuleStyles( [
129 'mediawiki.ui.input',
130 'mediawiki.ui.checkbox',
131 ] );
132 }
133
134 // Handle atom/RSS feeds.
135 $feedType = $request->getVal( 'feed' );
136 if ( $feedType ) {
137 $this->feed( $feedType );
138
139 return;
140 }
141
142 $this->addHelpLink( '//meta.wikimedia.org/wiki/Special:MyLanguage/Help:Page_history', true );
143
144 // Fail nicely if article doesn't exist.
145 if ( !$this->page->exists() ) {
146 global $wgSend404Code;
147 if ( $wgSend404Code ) {
148 $out->setStatusCode( 404 );
149 }
150 $out->addWikiMsg( 'nohistory' );
151
153
154 # show deletion/move log if there is an entry
156 $out,
157 [ 'delete', 'move' ],
158 $this->getTitle(),
159 '',
160 [ 'lim' => 10,
161 'conds' => [ 'log_action != ' . $dbr->addQuotes( 'revision' ) ],
162 'showIfEmpty' => false,
163 'msgKey' => [ 'moveddeleted-notice' ]
164 ]
165 );
166
167 return;
168 }
169
173 $year = $request->getInt( 'year' );
174 $month = $request->getInt( 'month' );
175 $tagFilter = $request->getVal( 'tagfilter' );
176 $tagSelector = ChangeTags::buildTagFilterSelector( $tagFilter, false, $this->getContext() );
177
181 if ( $request->getBool( 'deleted' ) ) {
182 $conds = [ 'rev_deleted != 0' ];
183 } else {
184 $conds = [];
185 }
186 if ( $this->getUser()->isAllowed( 'deletedhistory' ) ) {
187 $checkDeleted = Xml::checkLabel( $this->msg( 'history-show-deleted' )->text(),
188 'deleted', 'mw-show-deleted-only', $request->getBool( 'deleted' ) ) . "\n";
189 } else {
190 $checkDeleted = '';
191 }
192
193 // Add the general form
194 $action = htmlspecialchars( wfScript() );
195 $content = Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) . "\n";
196 $content .= Html::hidden( 'action', 'history' ) . "\n";
197 $content .= Xml::dateMenu(
198 ( $year == null ? MWTimestamp::getLocalInstance()->format( 'Y' ) : $year ),
199 $month
200 ) . '&#160;';
201 $content .= $tagSelector ? ( implode( '&#160;', $tagSelector ) . '&#160;' ) : '';
202 $content .= $checkDeleted . Html::submitButton(
203 $this->msg( 'historyaction-submit' )->text(),
204 [],
205 [ 'mw-ui-progressive' ]
206 );
207 $out->addHTML(
208 "<form action=\"$action\" method=\"get\" id=\"mw-history-searchform\">" .
209 Xml::fieldset(
210 $this->msg( 'history-fieldset-title' )->text(),
211 $content,
212 [ 'id' => 'mw-history-search' ]
213 ) .
214 '</form>'
215 );
216
217 Hooks::run( 'PageHistoryBeforeList', [ &$this->page, $this->getContext() ] );
218
219 // Create and output the list.
220 $pager = new HistoryPager( $this, $year, $month, $tagFilter, $conds );
221 $out->addHTML(
222 $pager->getNavigationBar() .
223 $pager->getBody() .
224 $pager->getNavigationBar()
225 );
226 $out->preventClickjacking( $pager->getPreventClickjacking() );
227 }
228
239 function fetchRevisions( $limit, $offset, $direction ) {
240 // Fail if article doesn't exist.
241 if ( !$this->getTitle()->exists() ) {
242 return new FakeResultWrapper( [] );
243 }
244
246
247 if ( $direction === self::DIR_PREV ) {
248 list( $dirs, $oper ) = [ "ASC", ">=" ];
249 } else { /* $direction === self::DIR_NEXT */
250 list( $dirs, $oper ) = [ "DESC", "<=" ];
251 }
252
253 if ( $offset ) {
254 $offsets = [ "rev_timestamp $oper " . $dbr->addQuotes( $dbr->timestamp( $offset ) ) ];
255 } else {
256 $offsets = [];
257 }
258
259 $page_id = $this->page->getId();
260
261 return $dbr->select( 'revision',
263 array_merge( [ 'rev_page' => $page_id ], $offsets ),
264 __METHOD__,
265 [ 'ORDER BY' => "rev_timestamp $dirs",
266 'USE INDEX' => 'page_timestamp', 'LIMIT' => $limit ]
267 );
268 }
269
275 function feed( $type ) {
277 return;
278 }
279 $request = $this->getRequest();
280
281 $feedClasses = $this->context->getConfig()->get( 'FeedClasses' );
283 $feed = new $feedClasses[$type](
284 $this->getTitle()->getPrefixedText() . ' - ' .
285 $this->msg( 'history-feed-title' )->inContentLanguage()->text(),
286 $this->msg( 'history-feed-description' )->inContentLanguage()->text(),
287 $this->getTitle()->getFullURL( 'action=history' )
288 );
289
290 // Get a limit on number of feed entries. Provide a sane default
291 // of 10 if none is defined (but limit to $wgFeedLimit max)
292 $limit = $request->getInt( 'limit', 10 );
293 $limit = min(
294 max( $limit, 1 ),
295 $this->context->getConfig()->get( 'FeedLimit' )
296 );
297
298 $items = $this->fetchRevisions( $limit, 0, self::DIR_NEXT );
299
300 // Generate feed elements enclosed between header and footer.
301 $feed->outHeader();
302 if ( $items->numRows() ) {
303 foreach ( $items as $row ) {
304 $feed->outItem( $this->feedItem( $row ) );
305 }
306 } else {
307 $feed->outItem( $this->feedEmpty() );
308 }
309 $feed->outFooter();
310 }
311
312 function feedEmpty() {
313 return new FeedItem(
314 $this->msg( 'nohistory' )->inContentLanguage()->text(),
315 $this->msg( 'history-feed-empty' )->inContentLanguage()->parseAsBlock(),
316 $this->getTitle()->getFullURL(),
317 wfTimestamp( TS_MW ),
318 '',
319 $this->getTitle()->getTalkPage()->getFullURL()
320 );
321 }
322
331 function feedItem( $row ) {
332 $rev = new Revision( $row );
333 $rev->setTitle( $this->getTitle() );
335 $this->getTitle(),
336 $this->getTitle()->getPreviousRevisionID( $rev->getId() ),
337 $rev->getId(),
338 $rev->getTimestamp(),
339 $rev->getComment()
340 );
341 if ( $rev->getComment() == '' ) {
342 global $wgContLang;
343 $title = $this->msg( 'history-feed-item-nocomment',
344 $rev->getUserText(),
345 $wgContLang->timeanddate( $rev->getTimestamp() ),
346 $wgContLang->date( $rev->getTimestamp() ),
347 $wgContLang->time( $rev->getTimestamp() ) )->inContentLanguage()->text();
348 } else {
349 $title = $rev->getUserText() .
350 $this->msg( 'colon-separator' )->inContentLanguage()->text() .
351 FeedItem::stripComment( $rev->getComment() );
352 }
353
354 return new FeedItem(
355 $title,
356 $text,
357 $this->getTitle()->getFullURL( 'diff=' . $rev->getId() . '&oldid=prev' ),
358 $rev->getTimestamp(),
359 $rev->getUserText(),
360 $this->getTitle()->getTalkPage()->getFullURL()
361 );
362 }
363}
364
373 public $lastRow = false;
374
376
377 protected $oldIdChecked;
378
379 protected $preventClickjacking = false;
383 protected $parentLens;
384
386 protected $showTagEditUI;
387
395 function __construct( $historyPage, $year = '', $month = '', $tagFilter = '', $conds = [] ) {
396 parent::__construct( $historyPage->getContext() );
397 $this->historyPage = $historyPage;
398 $this->tagFilter = $tagFilter;
399 $this->getDateCond( $year, $month );
400 $this->conds = $conds;
401 $this->showTagEditUI = ChangeTags::showTagEditingUI( $this->getUser() );
402 }
403
404 // For hook compatibility...
405 function getArticle() {
406 return $this->historyPage->getArticle();
407 }
408
409 function getSqlComment() {
410 if ( $this->conds ) {
411 return 'history page filtered'; // potentially slow, see CR r58153
412 } else {
413 return 'history page unfiltered';
414 }
415 }
416
417 function getQueryInfo() {
418 $queryInfo = [
419 'tables' => [ 'revision', 'user' ],
420 'fields' => array_merge( Revision::selectFields(), Revision::selectUserFields() ),
421 'conds' => array_merge(
422 [ 'rev_page' => $this->getWikiPage()->getId() ],
423 $this->conds ),
424 'options' => [ 'USE INDEX' => [ 'revision' => 'page_timestamp' ] ],
425 'join_conds' => [ 'user' => Revision::userJoinCond() ],
426 ];
428 $queryInfo['tables'],
429 $queryInfo['fields'],
430 $queryInfo['conds'],
431 $queryInfo['join_conds'],
432 $queryInfo['options'],
433 $this->tagFilter
434 );
435
436 // Avoid PHP 7.1 warning of passing $this by reference
437 $historyPager = $this;
438 Hooks::run( 'PageHistoryPager::getQueryInfo', [ &$historyPager, &$queryInfo ] );
439
440 return $queryInfo;
441 }
442
443 function getIndexField() {
444 return 'rev_timestamp';
445 }
446
451 function formatRow( $row ) {
452 if ( $this->lastRow ) {
453 $latest = ( $this->counter == 1 && $this->mIsFirst );
454 $firstInList = $this->counter == 1;
455 $this->counter++;
456
457 $notifTimestamp = $this->getConfig()->get( 'ShowUpdatedMarker' )
458 ? $this->getTitle()->getNotificationTimestamp( $this->getUser() )
459 : false;
460
461 $s = $this->historyLine(
462 $this->lastRow, $row, $notifTimestamp, $latest, $firstInList );
463 } else {
464 $s = '';
465 }
466 $this->lastRow = $row;
467
468 return $s;
469 }
470
471 function doBatchLookups() {
472 if ( !Hooks::run( 'PageHistoryPager::doBatchLookups', [ $this, $this->mResult ] ) ) {
473 return;
474 }
475
476 # Do a link batch query
477 $this->mResult->seek( 0 );
478 $batch = new LinkBatch();
479 $revIds = [];
480 foreach ( $this->mResult as $row ) {
481 if ( $row->rev_parent_id ) {
482 $revIds[] = $row->rev_parent_id;
483 }
484 if ( !is_null( $row->user_name ) ) {
485 $batch->add( NS_USER, $row->user_name );
486 $batch->add( NS_USER_TALK, $row->user_name );
487 } else { # for anons or usernames of imported revisions
488 $batch->add( NS_USER, $row->rev_user_text );
489 $batch->add( NS_USER_TALK, $row->rev_user_text );
490 }
491 }
492 $this->parentLens = Revision::getParentLengths( $this->mDb, $revIds );
493 $batch->execute();
494 $this->mResult->seek( 0 );
495 }
496
502 function getStartBody() {
503 $this->lastRow = false;
504 $this->counter = 1;
505 $this->oldIdChecked = 0;
506
507 $this->getOutput()->wrapWikiMsg( "<div class='mw-history-legend'>\n$1\n</div>", 'histlegend' );
508 $s = Html::openElement( 'form', [ 'action' => wfScript(),
509 'id' => 'mw-history-compare' ] ) . "\n";
510 $s .= Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) . "\n";
511 $s .= Html::hidden( 'action', 'historysubmit' ) . "\n";
512 $s .= Html::hidden( 'type', 'revision' ) . "\n";
513
514 // Button container stored in $this->buttons for re-use in getEndBody()
515 $this->buttons = '<div>';
516 $className = 'historysubmit mw-history-compareselectedversions-button';
517 $attrs = [ 'class' => $className ]
518 + Linker::tooltipAndAccesskeyAttribs( 'compareselectedversions' );
519 $this->buttons .= $this->submitButton( $this->msg( 'compareselectedversions' )->text(),
520 $attrs
521 ) . "\n";
522
523 $user = $this->getUser();
524 $actionButtons = '';
525 if ( $user->isAllowed( 'deleterevision' ) ) {
526 $actionButtons .= $this->getRevisionButton( 'revisiondelete', 'showhideselectedversions' );
527 }
528 if ( $this->showTagEditUI ) {
529 $actionButtons .= $this->getRevisionButton( 'editchangetags', 'history-edit-tags' );
530 }
531 if ( $actionButtons ) {
532 $this->buttons .= Xml::tags( 'div', [ 'class' =>
533 'mw-history-revisionactions' ], $actionButtons );
534 }
535
536 if ( $user->isAllowed( 'deleterevision' ) || $this->showTagEditUI ) {
537 $this->buttons .= ( new ListToggle( $this->getOutput() ) )->getHTML();
538 }
539
540 $this->buttons .= '</div>';
541
543 $s .= '<ul id="pagehistory">' . "\n";
544
545 return $s;
546 }
547
548 private function getRevisionButton( $name, $msg ) {
549 $this->preventClickjacking();
550 # Note bug #20966, <button> is non-standard in IE<8
551 $element = Html::element(
552 'button',
553 [
554 'type' => 'submit',
555 'name' => $name,
556 'value' => '1',
557 'class' => "historysubmit mw-history-$name-button",
558 ],
559 $this->msg( $msg )->text()
560 ) . "\n";
561 return $element;
562 }
563
564 function getEndBody() {
565 if ( $this->lastRow ) {
566 $latest = $this->counter == 1 && $this->mIsFirst;
567 $firstInList = $this->counter == 1;
568 if ( $this->mIsBackwards ) {
569 # Next row is unknown, but for UI reasons, probably exists if an offset has been specified
570 if ( $this->mOffset == '' ) {
571 $next = null;
572 } else {
573 $next = 'unknown';
574 }
575 } else {
576 # The next row is the past-the-end row
577 $next = $this->mPastTheEndRow;
578 }
579 $this->counter++;
580
581 $notifTimestamp = $this->getConfig()->get( 'ShowUpdatedMarker' )
582 ? $this->getTitle()->getNotificationTimestamp( $this->getUser() )
583 : false;
584
585 $s = $this->historyLine(
586 $this->lastRow, $next, $notifTimestamp, $latest, $firstInList );
587 } else {
588 $s = '';
589 }
590 $s .= "</ul>\n";
591 # Add second buttons only if there is more than one rev
592 if ( $this->getNumRows() > 2 ) {
594 }
595 $s .= '</form>';
596
597 return $s;
598 }
599
607 function submitButton( $message, $attributes = [] ) {
608 # Disable submit button if history has 1 revision only
609 if ( $this->getNumRows() > 1 ) {
610 return Html::submitButton( $message, $attributes );
611 } else {
612 return '';
613 }
614 }
615
630 function historyLine( $row, $next, $notificationtimestamp = false,
631 $latest = false, $firstInList = false ) {
632 $rev = new Revision( $row );
633 $rev->setTitle( $this->getTitle() );
634
635 if ( is_object( $next ) ) {
636 $prevRev = new Revision( $next );
637 $prevRev->setTitle( $this->getTitle() );
638 } else {
639 $prevRev = null;
640 }
641
642 $curlink = $this->curLink( $rev, $latest );
643 $lastlink = $this->lastLink( $rev, $next );
644 $curLastlinks = $curlink . $this->historyPage->message['pipe-separator'] . $lastlink;
645 $histLinks = Html::rawElement(
646 'span',
647 [ 'class' => 'mw-history-histlinks' ],
648 $this->msg( 'parentheses' )->rawParams( $curLastlinks )->escaped()
649 );
650
651 $diffButtons = $this->diffButtons( $rev, $firstInList );
652 $s = $histLinks . $diffButtons;
653
654 $link = $this->revLink( $rev );
655 $classes = [];
656
657 $del = '';
658 $user = $this->getUser();
659 $canRevDelete = $user->isAllowed( 'deleterevision' );
660 // Show checkboxes for each revision, to allow for revision deletion and
661 // change tags
662 if ( $canRevDelete || $this->showTagEditUI ) {
663 $this->preventClickjacking();
664 // If revision was hidden from sysops and we don't need the checkbox
665 // for anything else, disable it
666 if ( !$this->showTagEditUI && !$rev->userCan( Revision::DELETED_RESTRICTED, $user ) ) {
667 $del = Xml::check( 'deleterevisions', false, [ 'disabled' => 'disabled' ] );
668 // Otherwise, enable the checkbox...
669 } else {
670 $del = Xml::check( 'showhiderevisions', false,
671 [ 'name' => 'ids[' . $rev->getId() . ']' ] );
672 }
673 // User can only view deleted revisions...
674 } elseif ( $rev->getVisibility() && $user->isAllowed( 'deletedhistory' ) ) {
675 // If revision was hidden from sysops, disable the link
676 if ( !$rev->userCan( Revision::DELETED_RESTRICTED, $user ) ) {
677 $del = Linker::revDeleteLinkDisabled( false );
678 // Otherwise, show the link...
679 } else {
680 $query = [ 'type' => 'revision',
681 'target' => $this->getTitle()->getPrefixedDBkey(), 'ids' => $rev->getId() ];
683 $rev->isDeleted( Revision::DELETED_RESTRICTED ), false );
684 }
685 }
686 if ( $del ) {
687 $s .= " $del ";
688 }
689
690 $lang = $this->getLanguage();
691 $dirmark = $lang->getDirMark();
692
693 $s .= " $link";
694 $s .= $dirmark;
695 $s .= " <span class='history-user'>" .
696 Linker::revUserTools( $rev, true ) . "</span>";
697 $s .= $dirmark;
698
699 if ( $rev->isMinor() ) {
700 $s .= ' ' . ChangesList::flag( 'minor', $this->getContext() );
701 }
702
703 # Sometimes rev_len isn't populated
704 if ( $rev->getSize() !== null ) {
705 # Size is always public data
706 $prevSize = isset( $this->parentLens[$row->rev_parent_id] )
707 ? $this->parentLens[$row->rev_parent_id]
708 : 0;
709 $sDiff = ChangesList::showCharacterDifference( $prevSize, $rev->getSize() );
710 $fSize = Linker::formatRevisionSize( $rev->getSize() );
711 $s .= ' <span class="mw-changeslist-separator">. .</span> ' . "$fSize $sDiff";
712 }
713
714 # Text following the character difference is added just before running hooks
715 $s2 = Linker::revComment( $rev, false, true );
716
717 if ( $notificationtimestamp && ( $row->rev_timestamp >= $notificationtimestamp ) ) {
718 $s2 .= ' <span class="updatedmarker">' . $this->msg( 'updatedmarker' )->escaped() . '</span>';
719 $classes[] = 'mw-history-line-updated';
720 }
721
722 $tools = [];
723
724 # Rollback and undo links
725 if ( $prevRev && $this->getTitle()->quickUserCan( 'edit', $user ) ) {
726 if ( $latest && $this->getTitle()->quickUserCan( 'rollback', $user ) ) {
727 // Get a rollback link without the brackets
728 $rollbackLink = Linker::generateRollback(
729 $rev,
730 $this->getContext(),
731 [ 'verify', 'noBrackets' ]
732 );
733 if ( $rollbackLink ) {
734 $this->preventClickjacking();
735 $tools[] = $rollbackLink;
736 }
737 }
738
739 if ( !$rev->isDeleted( Revision::DELETED_TEXT )
740 && !$prevRev->isDeleted( Revision::DELETED_TEXT )
741 ) {
742 # Create undo tooltip for the first (=latest) line only
743 $undoTooltip = $latest
744 ? [ 'title' => $this->msg( 'tooltip-undo' )->text() ]
745 : [];
746 $undolink = MediaWikiServices::getInstance()->getLinkRenderer()->makeKnownLink(
747 $this->getTitle(),
748 $this->msg( 'editundo' )->text(),
749 $undoTooltip,
750 [
751 'action' => 'edit',
752 'undoafter' => $prevRev->getId(),
753 'undo' => $rev->getId()
754 ]
755 );
756 $tools[] = "<span class=\"mw-history-undo\">{$undolink}</span>";
757 }
758 }
759 // Allow extension to add their own links here
760 Hooks::run( 'HistoryRevisionTools', [ $rev, &$tools, $prevRev, $user ] );
761
762 if ( $tools ) {
763 $s2 .= ' ' . $this->msg( 'parentheses' )->rawParams( $lang->pipeList( $tools ) )->escaped();
764 }
765
766 # Tags
767 list( $tagSummary, $newClasses ) = ChangeTags::formatSummaryRow(
768 $row->ts_tags,
769 'history',
770 $this->getContext()
771 );
772 $classes = array_merge( $classes, $newClasses );
773 if ( $tagSummary !== '' ) {
774 $s2 .= " $tagSummary";
775 }
776
777 # Include separator between character difference and following text
778 if ( $s2 !== '' ) {
779 $s .= ' <span class="mw-changeslist-separator">. .</span> ' . $s2;
780 }
781
782 $attribs = [ 'data-mw-revid' => $rev->getId() ];
783
784 Hooks::run( 'PageHistoryLineEnding', [ $this, &$row, &$s, &$classes, &$attribs ] );
785 $attribs = wfArrayFilterByKey( $attribs, [ Sanitizer::class, 'isReservedDataAttribute' ] );
786
787 if ( $classes ) {
788 $attribs['class'] = implode( ' ', $classes );
789 }
790
791 return Xml::tags( 'li', $attribs, $s ) . "\n";
792 }
793
800 function revLink( $rev ) {
801 $date = $this->getLanguage()->userTimeAndDate( $rev->getTimestamp(), $this->getUser() );
802 if ( $rev->userCan( Revision::DELETED_TEXT, $this->getUser() ) ) {
803 $link = MediaWikiServices::getInstance()->getLinkRenderer()->makeKnownLink(
804 $this->getTitle(),
805 $date,
806 [ 'class' => 'mw-changeslist-date' ],
807 [ 'oldid' => $rev->getId() ]
808 );
809 } else {
810 $link = htmlspecialchars( $date );
811 }
812 if ( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
813 $link = "<span class=\"history-deleted\">$link</span>";
814 }
815
816 return $link;
817 }
818
826 function curLink( $rev, $latest ) {
827 $cur = $this->historyPage->message['cur'];
828 if ( $latest || !$rev->userCan( Revision::DELETED_TEXT, $this->getUser() ) ) {
829 return $cur;
830 } else {
831 return MediaWikiServices::getInstance()->getLinkRenderer()->makeKnownLink(
832 $this->getTitle(),
833 $cur,
834 [],
835 [
836 'diff' => $this->getWikiPage()->getLatest(),
837 'oldid' => $rev->getId()
838 ]
839 );
840 }
841 }
842
852 function lastLink( $prevRev, $next ) {
853 $last = $this->historyPage->message['last'];
854
855 if ( $next === null ) {
856 # Probably no next row
857 return $last;
858 }
859
860 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
861 if ( $next === 'unknown' ) {
862 # Next row probably exists but is unknown, use an oldid=prev link
863 return $linkRenderer->makeKnownLink(
864 $this->getTitle(),
865 $last,
866 [],
867 [
868 'diff' => $prevRev->getId(),
869 'oldid' => 'prev'
870 ]
871 );
872 }
873
874 $nextRev = new Revision( $next );
875
876 if ( !$prevRev->userCan( Revision::DELETED_TEXT, $this->getUser() )
877 || !$nextRev->userCan( Revision::DELETED_TEXT, $this->getUser() )
878 ) {
879 return $last;
880 }
881
882 return $linkRenderer->makeKnownLink(
883 $this->getTitle(),
884 $last,
885 [],
886 [
887 'diff' => $prevRev->getId(),
888 'oldid' => $next->rev_id
889 ]
890 );
891 }
892
901 function diffButtons( $rev, $firstInList ) {
902 if ( $this->getNumRows() > 1 ) {
903 $id = $rev->getId();
904 $radio = [ 'type' => 'radio', 'value' => $id ];
906 if ( $firstInList ) {
907 $first = Xml::element( 'input',
908 array_merge( $radio, [
909 'style' => 'visibility:hidden',
910 'name' => 'oldid',
911 'id' => 'mw-oldid-null' ] )
912 );
913 $checkmark = [ 'checked' => 'checked' ];
914 } else {
915 # Check visibility of old revisions
916 if ( !$rev->userCan( Revision::DELETED_TEXT, $this->getUser() ) ) {
917 $radio['disabled'] = 'disabled';
918 $checkmark = []; // We will check the next possible one
919 } elseif ( !$this->oldIdChecked ) {
920 $checkmark = [ 'checked' => 'checked' ];
921 $this->oldIdChecked = $id;
922 } else {
923 $checkmark = [];
924 }
925 $first = Xml::element( 'input',
926 array_merge( $radio, $checkmark, [
927 'name' => 'oldid',
928 'id' => "mw-oldid-$id" ] ) );
929 $checkmark = [];
930 }
931 $second = Xml::element( 'input',
932 array_merge( $radio, $checkmark, [
933 'name' => 'diff',
934 'id' => "mw-diff-$id" ] ) );
935
936 return $first . $second;
937 } else {
938 return '';
939 }
940 }
941
946 function preventClickjacking( $enable = true ) {
947 $this->preventClickjacking = $enable;
948 }
949
957
958}
$wgSend404Code
Some web hosts attempt to rewrite all responses with a 404 (not found) status code,...
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfArrayFilterByKey(array $arr, callable $callback)
Like array_filter with ARRAY_FILTER_USE_KEY, but works pre-5.6.
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.
$page
Page on which we're performing the action.
Definition Action.php:44
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Definition Action.php:388
getTitle()
Shortcut to get the Title object from the page.
Definition Action.php:246
getContext()
Get the IContextSource in use here.
Definition Action.php:178
getOutput()
Get the OutputPage being used for this instance.
Definition Action.php:207
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
Definition Action.php:256
getUser()
Shortcut to get the User being used for this instance.
Definition Action.php:217
static exists( $name)
Check if a given action is recognised, even if it's disabled.
Definition Action.php:169
getRequest()
Get the WebRequest being used for this instance.
Definition Action.php:197
static buildTagFilterSelector( $selected='', $ooui=false, IContextSource $context=null)
Build a text box to select a change tag.
static modifyDisplayQuery(&$tables, &$fields, &$conds, &$join_conds, &$options, $filter_tag='')
Applies all tags-related changes to a query.
static formatSummaryRow( $tags, $page, IContextSource $context=null)
Creates HTML for the given tags.
static showTagEditingUI(User $user)
Indicate whether change tag editing UI is relevant.
static showCharacterDifference( $old, $new, IContextSource $context=null)
Show formatted char difference.
static flag( $flag, IContextSource $context=null)
Make an "<abbr>" element for a given change flag.
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
getUser()
Get the User object.
getConfig()
Get the Config object.
getTitle()
Get the Title object.
getOutput()
Get the OutputPage object.
getWikiPage()
Get the WikiPage object.
getLanguage()
Get the Language object.
getContext()
Get the base IContextSource object.
A base class for basic support for outputting syndication feeds in RSS and other formats.
Definition Feed.php:38
static stripComment( $text)
Quickie hack... strip out wikilinks to more legible form from the comment.
Definition Feed.php:178
static checkFeedOutput( $type)
Check whether feeds can be used and that $type is a valid feed type.
Definition FeedUtils.php:56
static formatDiffRow( $title, $oldid, $newid, $timestamp, $comment, $actiontext='')
Really format a diff for the newsfeed.
An action which just does something, without showing a form first.
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.
feed( $type)
Output a subscription feed listing recent edits to this page.
preCacheMessages()
As we use the same small set of messages in various methods and that they are called often,...
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.
fetchRevisions( $limit, $offset, $direction)
Fetch an array of revisions, specified by a given limit, offset and direction.
feedItem( $row)
Generate a FeedItem object from a given revision table row Borrows Recent Changes' feed generation fu...
getDescription()
Returns the description that goes below the <h1> tag.
requiresUnblock()
Whether this action can still be executed by a blocked user.
preventClickjacking( $enable=true)
This is called if a write operation is possible from the generated HTML.
getRevisionButton( $name, $msg)
doBatchLookups()
Called from getBody(), before getStartBody() is called and after doQuery() was called.
lastLink( $prevRev, $next)
Create a diff-to-previous link for this revision for this page.
__construct( $historyPage, $year='', $month='', $tagFilter='', $conds=[])
getEndBody()
Hook into getBody() for the end of the list.
diffButtons( $rev, $firstInList)
Create radio buttons for page history.
submitButton( $message, $attributes=[])
Creates a submit button.
historyLine( $row, $next, $notificationtimestamp=false, $latest=false, $firstInList=false)
Returns a row from the history printout.
revLink( $rev)
Create a link to view this revision of the page.
bool $showTagEditUI
Whether to show the tag editing UI.
getSqlComment()
Get some text to go in brackets in the "function name" part of the SQL comment.
curLink( $rev, $latest)
Create a diff-to-current link for this revision for this page.
getPreventClickjacking()
Get the "prevent clickjacking" flag.
getIndexField()
This function should be overridden to return the name of the index fi- eld.
getQueryInfo()
This function should be overridden to provide all parameters needed for the main paged query.
getStartBody()
Creates begin of history list with a submit button.
bool stdClass $lastRow
$mIsFirst
True if the current result set is the first one.
getNumRows()
Get the number of rows in the result set.
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Definition LinkBatch.php:34
static generateRollback( $rev, IContextSource $context=null, $options=[ 'verify'])
Generate a rollback link for a given revision.
Definition Linker.php:1691
static revDeleteLinkDisabled( $delete=true)
Creates a dead (show/hide) link for deleting revisions/log entries.
Definition Linker.php:2093
static revComment(Revision $rev, $local=false, $isPublic=false)
Wrap and format the given revision's comment block, if the current user is allowed to view it.
Definition Linker.php:1470
static tooltipAndAccesskeyAttribs( $name, array $msgParams=[])
Returns the attributes for the tooltip and access key.
Definition Linker.php:2111
static revUserTools( $rev, $isPublic=false)
Generate a user tool link cluster if the current user is allowed to view it.
Definition Linker.php:1060
static formatRevisionSize( $size)
Definition Linker.php:1493
static revDeleteLink( $query=[], $restricted=false, $delete=true)
Creates a (show/hide) link for deleting revisions/log entries.
Definition Linker.php:2071
Class for generating clickable toggle links for a list of checkboxes.
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
static getLocalInstance( $ts=false)
Get a timestamp instance in the server local timezone ($wgLocaltimezone)
MediaWikiServices is the service locator for the application scope of MediaWiki.
Efficient paging for SQL queries.
getDateCond( $year, $month, $day=-1)
Set and return the mOffset timestamp such that we can get all revisions with a timestamp up to the sp...
static userJoinCond()
Return the value of a select() JOIN conds array for the user table.
Definition Revision.php:431
static selectFields()
Return the list of revision fields that should be selected to create a new revision.
Definition Revision.php:452
static selectUserFields()
Return the list of user fields that should be selected from user table.
Definition Revision.php:544
const DELETED_TEXT
Definition Revision.php:90
const DELETED_RESTRICTED
Definition Revision.php:93
static getParentLengths( $db, array $revIds)
Do a batched query to get the parent revision lengths.
Definition Revision.php:554
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,...
Overloads the relevant methods of the real ResultsWrapper so it doesn't go anywhere near an actual da...
Result wrapper for grabbing data queried from an IDatabase object.
if(! $regexes) $dbr
Definition cleanup.php:94
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition deferred.txt:11
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
Definition design.txt:57
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
Definition design.txt:18
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
Definition hooks.txt:2775
if the prop value should be in the metadata multi language array format
Definition hooks.txt:1646
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Definition hooks.txt:862
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition hooks.txt:2989
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
Definition hooks.txt:1984
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition hooks.txt:1610
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after in associative array form before processing starts Return false to skip default processing and return $ret $linkRenderer
Definition hooks.txt:2026
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
Definition hooks.txt:1760
const NS_USER_TALK
Definition Defines.php:68
$batch
Definition linkcache.txt:23
$cache
Definition mcc.php:33
$last
const DB_REPLICA
Definition defines.php:25
if(!isset( $args[0])) $lang