MediaWiki  REL1_21
HistoryAction.php
Go to the documentation of this file.
00001 <?php
00036 class HistoryAction extends FormlessAction {
00037         const DIR_PREV = 0;
00038         const DIR_NEXT = 1;
00039 
00040         public function getName() {
00041                 return 'history';
00042         }
00043 
00044         public function requiresWrite() {
00045                 return false;
00046         }
00047 
00048         public function requiresUnblock() {
00049                 return false;
00050         }
00051 
00052         protected function getPageTitle() {
00053                 return $this->msg( 'history-title', $this->getTitle()->getPrefixedText() )->text();
00054         }
00055 
00056         protected function getDescription() {
00057                 // Creation of a subtitle link pointing to [[Special:Log]]
00058                 return Linker::linkKnown(
00059                         SpecialPage::getTitleFor( 'Log' ),
00060                         $this->msg( 'viewpagelogs' )->escaped(),
00061                         array(),
00062                         array( 'page' => $this->getTitle()->getPrefixedText() )
00063                 );
00064         }
00065 
00070         public function getArticle() {
00071                 return $this->page;
00072         }
00073 
00078         private function preCacheMessages() {
00079                 // Precache various messages
00080                 if ( !isset( $this->message ) ) {
00081                         $msgs = array( 'cur', 'last', 'pipe-separator' );
00082                         foreach ( $msgs as $msg ) {
00083                                 $this->message[$msg] = $this->msg( $msg )->escaped();
00084                         }
00085                 }
00086         }
00087 
00091         function onView() {
00092                 global $wgScript, $wgUseFileCache;
00093 
00094                 $out = $this->getOutput();
00095                 $request = $this->getRequest();
00096 
00100                 if ( $out->checkLastModified( $this->page->getTouched() ) ) {
00101                         return; // Client cache fresh and headers sent, nothing more to do.
00102                 }
00103 
00104                 wfProfileIn( __METHOD__ );
00105 
00106                 $this->preCacheMessages();
00107 
00108                 # Fill in the file cache if not set already
00109                 if ( $wgUseFileCache && HTMLFileCache::useFileCache( $this->getContext() ) ) {
00110                         $cache = HTMLFileCache::newFromTitle( $this->getTitle(), 'history' );
00111                         if ( !$cache->isCacheGood( /* Assume up to date */ ) ) {
00112                                 ob_start( array( &$cache, 'saveToFileCache' ) );
00113                         }
00114                 }
00115 
00116                 // Setup page variables.
00117                 $out->setFeedAppendQuery( 'action=history' );
00118                 $out->addModules( array( 'mediawiki.legacy.history', 'mediawiki.action.history' ) );
00119 
00120                 // Handle atom/RSS feeds.
00121                 $feedType = $request->getVal( 'feed' );
00122                 if ( $feedType ) {
00123                         $this->feed( $feedType );
00124                         wfProfileOut( __METHOD__ );
00125                         return;
00126                 }
00127 
00128                 // Fail nicely if article doesn't exist.
00129                 if ( !$this->page->exists() ) {
00130                         $out->addWikiMsg( 'nohistory' );
00131                         # show deletion/move log if there is an entry
00132                         LogEventsList::showLogExtract(
00133                                 $out,
00134                                 array( 'delete', 'move' ),
00135                                 $this->getTitle(),
00136                                 '',
00137                                 array( 'lim' => 10,
00138                                         'conds' => array( "log_action != 'revision'" ),
00139                                         'showIfEmpty' => false,
00140                                         'msgKey' => array( 'moveddeleted-notice' )
00141                                 )
00142                         );
00143                         wfProfileOut( __METHOD__ );
00144                         return;
00145                 }
00146 
00150                 $year = $request->getInt( 'year' );
00151                 $month = $request->getInt( 'month' );
00152                 $tagFilter = $request->getVal( 'tagfilter' );
00153                 $tagSelector = ChangeTags::buildTagFilterSelector( $tagFilter );
00154 
00158                 if ( $request->getBool( 'deleted' ) ) {
00159                         $conds = array( 'rev_deleted != 0' );
00160                 } else {
00161                         $conds = array();
00162                 }
00163                 if ( $this->getUser()->isAllowed( 'deletedhistory' ) ) {
00164                         $checkDeleted = Xml::checkLabel( $this->msg( 'history-show-deleted' )->text(),
00165                         'deleted', 'mw-show-deleted-only', $request->getBool( 'deleted' ) ) . "\n";
00166                 } else {
00167                         $checkDeleted = '';
00168                 }
00169 
00170                 // Add the general form
00171                 $action = htmlspecialchars( $wgScript );
00172                 $out->addHTML(
00173                         "<form action=\"$action\" method=\"get\" id=\"mw-history-searchform\">" .
00174                         Xml::fieldset(
00175                                 $this->msg( 'history-fieldset-title' )->text(),
00176                                 false,
00177                                 array( 'id' => 'mw-history-search' )
00178                         ) .
00179                         Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) . "\n" .
00180                         Html::hidden( 'action', 'history' ) . "\n" .
00181                         Xml::dateMenu( ( $year == null ? date( "Y" ) : $year ), $month ) . '&#160;' .
00182                         ( $tagSelector ? ( implode( '&#160;', $tagSelector ) . '&#160;' ) : '' ) .
00183                         $checkDeleted .
00184                         Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) . "\n" .
00185                         '</fieldset></form>'
00186                 );
00187 
00188                 wfRunHooks( 'PageHistoryBeforeList', array( &$this->page, $this->getContext() ) );
00189 
00190                 // Create and output the list.
00191                 $pager = new HistoryPager( $this, $year, $month, $tagFilter, $conds );
00192                 $out->addHTML(
00193                         $pager->getNavigationBar() .
00194                         $pager->getBody() .
00195                         $pager->getNavigationBar()
00196                 );
00197                 $out->preventClickjacking( $pager->getPreventClickjacking() );
00198 
00199                 wfProfileOut( __METHOD__ );
00200         }
00201 
00212         function fetchRevisions( $limit, $offset, $direction ) {
00213                 // Fail if article doesn't exist.
00214                 if( !$this->getTitle()->exists() ) {
00215                         return new FakeResultWrapper( array() );
00216                 }
00217 
00218                 $dbr = wfGetDB( DB_SLAVE );
00219 
00220                 if ( $direction == HistoryPage::DIR_PREV ) {
00221                         list( $dirs, $oper ) = array( "ASC", ">=" );
00222                 } else { /* $direction == HistoryPage::DIR_NEXT */
00223                         list( $dirs, $oper ) = array( "DESC", "<=" );
00224                 }
00225 
00226                 if ( $offset ) {
00227                         $offsets = array( "rev_timestamp $oper " . $dbr->addQuotes( $dbr->timestamp( $offset ) ) );
00228                 } else {
00229                         $offsets = array();
00230                 }
00231 
00232                 $page_id = $this->page->getId();
00233 
00234                 return $dbr->select( 'revision',
00235                         Revision::selectFields(),
00236                         array_merge( array( 'rev_page' => $page_id ), $offsets ),
00237                         __METHOD__,
00238                         array( 'ORDER BY' => "rev_timestamp $dirs",
00239                                 'USE INDEX' => 'page_timestamp', 'LIMIT' => $limit )
00240                 );
00241         }
00242 
00248         function feed( $type ) {
00249                 global $wgFeedClasses, $wgFeedLimit;
00250                 if ( !FeedUtils::checkFeedOutput( $type ) ) {
00251                         return;
00252                 }
00253                 $request = $this->getRequest();
00254 
00255                 $feed = new $wgFeedClasses[$type](
00256                         $this->getTitle()->getPrefixedText() . ' - ' .
00257                         $this->msg( 'history-feed-title' )->inContentLanguage()->text(),
00258                         $this->msg( 'history-feed-description' )->inContentLanguage()->text(),
00259                         $this->getTitle()->getFullUrl( 'action=history' )
00260                 );
00261 
00262                 // Get a limit on number of feed entries. Provide a sane default
00263                 // of 10 if none is defined (but limit to $wgFeedLimit max)
00264                 $limit = $request->getInt( 'limit', 10 );
00265                 if ( $limit > $wgFeedLimit || $limit < 1 ) {
00266                         $limit = 10;
00267                 }
00268                 $items = $this->fetchRevisions( $limit, 0, HistoryPage::DIR_NEXT );
00269 
00270                 // Generate feed elements enclosed between header and footer.
00271                 $feed->outHeader();
00272                 if ( $items->numRows() ) {
00273                         foreach ( $items as $row ) {
00274                                 $feed->outItem( $this->feedItem( $row ) );
00275                         }
00276                 } else {
00277                         $feed->outItem( $this->feedEmpty() );
00278                 }
00279                 $feed->outFooter();
00280         }
00281 
00282         function feedEmpty() {
00283                 return new FeedItem(
00284                         $this->msg( 'nohistory' )->inContentLanguage()->text(),
00285                         $this->msg( 'history-feed-empty' )->inContentLanguage()->parseAsBlock(),
00286                         $this->getTitle()->getFullUrl(),
00287                         wfTimestamp( TS_MW ),
00288                         '',
00289                         $this->getTitle()->getTalkPage()->getFullUrl()
00290                 );
00291         }
00292 
00301         function feedItem( $row ) {
00302                 $rev = new Revision( $row );
00303                 $rev->setTitle( $this->getTitle() );
00304                 $text = FeedUtils::formatDiffRow(
00305                         $this->getTitle(),
00306                         $this->getTitle()->getPreviousRevisionID( $rev->getId() ),
00307                         $rev->getId(),
00308                         $rev->getTimestamp(),
00309                         $rev->getComment()
00310                 );
00311                 if ( $rev->getComment() == '' ) {
00312                         global $wgContLang;
00313                         $title = $this->msg( 'history-feed-item-nocomment',
00314                                 $rev->getUserText(),
00315                                 $wgContLang->timeanddate( $rev->getTimestamp() ),
00316                                 $wgContLang->date( $rev->getTimestamp() ),
00317                                 $wgContLang->time( $rev->getTimestamp() ) )->inContentLanguage()->text();
00318                 } else {
00319                         $title = $rev->getUserText() .
00320                         $this->msg( 'colon-separator' )->inContentLanguage()->text() .
00321                         FeedItem::stripComment( $rev->getComment() );
00322                 }
00323                 return new FeedItem(
00324                         $title,
00325                         $text,
00326                         $this->getTitle()->getFullUrl( 'diff=' . $rev->getId() . '&oldid=prev' ),
00327                         $rev->getTimestamp(),
00328                         $rev->getUserText(),
00329                         $this->getTitle()->getTalkPage()->getFullUrl()
00330                 );
00331         }
00332 }
00333 
00338 class HistoryPager extends ReverseChronologicalPager {
00339         public $lastRow = false, $counter, $historyPage, $buttons, $conds;
00340         protected $oldIdChecked;
00341         protected $preventClickjacking = false;
00345         protected $parentLens;
00346 
00347         function __construct( $historyPage, $year = '', $month = '', $tagFilter = '', $conds = array() ) {
00348                 parent::__construct( $historyPage->getContext() );
00349                 $this->historyPage = $historyPage;
00350                 $this->tagFilter = $tagFilter;
00351                 $this->getDateCond( $year, $month );
00352                 $this->conds = $conds;
00353         }
00354 
00355         // For hook compatibility...
00356         function getArticle() {
00357                 return $this->historyPage->getArticle();
00358         }
00359 
00360         function getSqlComment() {
00361                 if ( $this->conds ) {
00362                         return 'history page filtered'; // potentially slow, see CR r58153
00363                 } else {
00364                         return 'history page unfiltered';
00365                 }
00366         }
00367 
00368         function getQueryInfo() {
00369                 $queryInfo = array(
00370                         'tables'  => array( 'revision', 'user' ),
00371                         'fields'  => array_merge( Revision::selectFields(), Revision::selectUserFields() ),
00372                         'conds'   => array_merge(
00373                                 array( 'rev_page' => $this->getWikiPage()->getId() ),
00374                                 $this->conds ),
00375                         'options' => array( 'USE INDEX' => array( 'revision' => 'page_timestamp' ) ),
00376                         'join_conds' => array(
00377                                 'user'        => Revision::userJoinCond(),
00378                                 'tag_summary' => array( 'LEFT JOIN', 'ts_rev_id=rev_id' ) ),
00379                 );
00380                 ChangeTags::modifyDisplayQuery(
00381                         $queryInfo['tables'],
00382                         $queryInfo['fields'],
00383                         $queryInfo['conds'],
00384                         $queryInfo['join_conds'],
00385                         $queryInfo['options'],
00386                         $this->tagFilter
00387                 );
00388                 wfRunHooks( 'PageHistoryPager::getQueryInfo', array( &$this, &$queryInfo ) );
00389                 return $queryInfo;
00390         }
00391 
00392         function getIndexField() {
00393                 return 'rev_timestamp';
00394         }
00395 
00396         function formatRow( $row ) {
00397                 if ( $this->lastRow ) {
00398                         $latest = ( $this->counter == 1 && $this->mIsFirst );
00399                         $firstInList = $this->counter == 1;
00400                         $this->counter++;
00401                         $s = $this->historyLine( $this->lastRow, $row,
00402                                 $this->getTitle()->getNotificationTimestamp( $this->getUser() ), $latest, $firstInList );
00403                 } else {
00404                         $s = '';
00405                 }
00406                 $this->lastRow = $row;
00407                 return $s;
00408         }
00409 
00410         function doBatchLookups() {
00411                 # Do a link batch query
00412                 $this->mResult->seek( 0 );
00413                 $batch = new LinkBatch();
00414                 $revIds = array();
00415                 foreach ( $this->mResult as $row ) {
00416                         if( $row->rev_parent_id ) {
00417                                 $revIds[] = $row->rev_parent_id;
00418                         }
00419                         if( !is_null( $row->user_name ) ) {
00420                                 $batch->add( NS_USER, $row->user_name );
00421                                 $batch->add( NS_USER_TALK, $row->user_name );
00422                         } else { # for anons or usernames of imported revisions
00423                                 $batch->add( NS_USER, $row->rev_user_text );
00424                                 $batch->add( NS_USER_TALK, $row->rev_user_text );
00425                         }
00426                 }
00427                 $this->parentLens = Revision::getParentLengths( $this->mDb, $revIds );
00428                 $batch->execute();
00429                 $this->mResult->seek( 0 );
00430         }
00431 
00437         function getStartBody() {
00438                 global $wgScript;
00439                 $this->lastRow = false;
00440                 $this->counter = 1;
00441                 $this->oldIdChecked = 0;
00442 
00443                 $this->getOutput()->wrapWikiMsg( "<div class='mw-history-legend'>\n$1\n</div>", 'histlegend' );
00444                 $s = Html::openElement( 'form', array( 'action' => $wgScript,
00445                         'id' => 'mw-history-compare' ) ) . "\n";
00446                 $s .= Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) . "\n";
00447                 $s .= Html::hidden( 'action', 'historysubmit' ) . "\n";
00448 
00449                 // Button container stored in $this->buttons for re-use in getEndBody()
00450                 $this->buttons = '<div>';
00451                 $this->buttons .= $this->submitButton( $this->msg( 'compareselectedversions' )->text(),
00452                         array( 'class' => 'historysubmit mw-history-compareselectedversions-button' )
00453                                 + Linker::tooltipAndAccesskeyAttribs( 'compareselectedversions' )
00454                 ) . "\n";
00455 
00456                 if ( $this->getUser()->isAllowed( 'deleterevision' ) ) {
00457                         $this->buttons .= $this->getRevisionButton( 'revisiondelete', 'showhideselectedversions' );
00458                 }
00459                 $this->buttons .= '</div>';
00460 
00461                 $s .= $this->buttons;
00462                 $s .= '<ul id="pagehistory">' . "\n";
00463                 return $s;
00464         }
00465 
00466         private function getRevisionButton( $name, $msg ) {
00467                 $this->preventClickjacking();
00468                 # Note bug #20966, <button> is non-standard in IE<8
00469                 $element = Html::element( 'button',
00470                         array(
00471                                 'type' => 'submit',
00472                                 'name' => $name,
00473                                 'value' => '1',
00474                                 'class' => "historysubmit mw-history-$name-button",
00475                         ),
00476                         $this->msg( $msg )->text()
00477                 ) . "\n";
00478                 return $element;
00479         }
00480 
00481         function getEndBody() {
00482                 if ( $this->lastRow ) {
00483                         $latest = $this->counter == 1 && $this->mIsFirst;
00484                         $firstInList = $this->counter == 1;
00485                         if ( $this->mIsBackwards ) {
00486                                 # Next row is unknown, but for UI reasons, probably exists if an offset has been specified
00487                                 if ( $this->mOffset == '' ) {
00488                                         $next = null;
00489                                 } else {
00490                                         $next = 'unknown';
00491                                 }
00492                         } else {
00493                                 # The next row is the past-the-end row
00494                                 $next = $this->mPastTheEndRow;
00495                         }
00496                         $this->counter++;
00497                         $s = $this->historyLine( $this->lastRow, $next,
00498                                 $this->getTitle()->getNotificationTimestamp( $this->getUser() ), $latest, $firstInList );
00499                 } else {
00500                         $s = '';
00501                 }
00502                 $s .= "</ul>\n";
00503                 # Add second buttons only if there is more than one rev
00504                 if ( $this->getNumRows() > 2 ) {
00505                         $s .= $this->buttons;
00506                 }
00507                 $s .= '</form>';
00508                 return $s;
00509         }
00510 
00518         function submitButton( $message, $attributes = array() ) {
00519                 # Disable submit button if history has 1 revision only
00520                 if ( $this->getNumRows() > 1 ) {
00521                         return Xml::submitButton( $message, $attributes );
00522                 } else {
00523                         return '';
00524                 }
00525         }
00526 
00539         function historyLine( $row, $next, $notificationtimestamp = false,
00540                 $latest = false, $firstInList = false )
00541         {
00542                 $rev = new Revision( $row );
00543                 $rev->setTitle( $this->getTitle() );
00544 
00545                 if ( is_object( $next ) ) {
00546                         $prevRev = new Revision( $next );
00547                         $prevRev->setTitle( $this->getTitle() );
00548                 } else {
00549                         $prevRev = null;
00550                 }
00551 
00552                 $curlink = $this->curLink( $rev, $latest );
00553                 $lastlink = $this->lastLink( $rev, $next );
00554                 $diffButtons = $this->diffButtons( $rev, $firstInList );
00555                 $histLinks = Html::rawElement(
00556                                 'span',
00557                                 array( 'class' => 'mw-history-histlinks' ),
00558                                 $this->msg( 'parentheses' )->rawParams( $curlink . $this->historyPage->message['pipe-separator'] . $lastlink )->escaped()
00559                 );
00560                 $s = $histLinks . $diffButtons;
00561 
00562                 $link = $this->revLink( $rev );
00563                 $classes = array();
00564 
00565                 $del = '';
00566                 $user = $this->getUser();
00567                 // Show checkboxes for each revision
00568                 if ( $user->isAllowed( 'deleterevision' ) ) {
00569                         $this->preventClickjacking();
00570                         // If revision was hidden from sysops, disable the checkbox
00571                         if ( !$rev->userCan( Revision::DELETED_RESTRICTED, $user ) ) {
00572                                 $del = Xml::check( 'deleterevisions', false, array( 'disabled' => 'disabled' ) );
00573                         // Otherwise, enable the checkbox...
00574                         } else {
00575                                 $del = Xml::check( 'showhiderevisions', false,
00576                                         array( 'name' => 'ids[' . $rev->getId() . ']' ) );
00577                         }
00578                 // User can only view deleted revisions...
00579                 } elseif ( $rev->getVisibility() && $user->isAllowed( 'deletedhistory' ) ) {
00580                         // If revision was hidden from sysops, disable the link
00581                         if ( !$rev->userCan( Revision::DELETED_RESTRICTED, $user ) ) {
00582                                 $del = Linker::revDeleteLinkDisabled( false );
00583                         // Otherwise, show the link...
00584                         } else {
00585                                 $query = array( 'type' => 'revision',
00586                                         'target' => $this->getTitle()->getPrefixedDBkey(), 'ids' => $rev->getId() );
00587                                 $del .= Linker::revDeleteLink( $query,
00588                                         $rev->isDeleted( Revision::DELETED_RESTRICTED ), false );
00589                         }
00590                 }
00591                 if ( $del ) {
00592                         $s .= " $del ";
00593                 }
00594 
00595                 $lang = $this->getLanguage();
00596                 $dirmark = $lang->getDirMark();
00597 
00598                 $s .= " $link";
00599                 $s .= $dirmark;
00600                 $s .= " <span class='history-user'>" .
00601                         Linker::revUserTools( $rev, true ) . "</span>";
00602                 $s .= $dirmark;
00603 
00604                 if ( $rev->isMinor() ) {
00605                         $s .= ' ' . ChangesList::flag( 'minor' );
00606                 }
00607 
00608                 # Sometimes rev_len isn't populated
00609                 if ( $rev->getSize() !== null ) {
00610                         # Size is always public data
00611                         $prevSize = isset( $this->parentLens[$row->rev_parent_id] )
00612                                 ? $this->parentLens[$row->rev_parent_id]
00613                                 : 0;
00614                         $sDiff = ChangesList::showCharacterDifference( $prevSize, $rev->getSize() );
00615                         $fSize = Linker::formatRevisionSize( $rev->getSize() );
00616                         $s .= ' <span class="mw-changeslist-separator">. .</span> ' . "$fSize $sDiff";
00617                 }
00618 
00619                 # Text following the character difference is added just before running hooks
00620                 $s2 = Linker::revComment( $rev, false, true );
00621 
00622                 if ( $notificationtimestamp && ( $row->rev_timestamp >= $notificationtimestamp ) ) {
00623                         $s2 .= ' <span class="updatedmarker">' . $this->msg( 'updatedmarker' )->escaped() . '</span>';
00624                         $classes[] = 'mw-history-line-updated';
00625                 }
00626 
00627                 $tools = array();
00628 
00629                 # Rollback and undo links
00630                 if ( $prevRev && $this->getTitle()->quickUserCan( 'edit', $user ) ) {
00631                         if ( $latest && $this->getTitle()->quickUserCan( 'rollback', $user ) ) {
00632                                 // Get a rollback link without the brackets
00633                                 $rollbackLink = Linker::generateRollback( $rev, $this->getContext(), array( 'verify', 'noBrackets' ) );
00634                                 if ( $rollbackLink ) {
00635                                         $this->preventClickjacking();
00636                                         $tools[] = $rollbackLink;
00637                                 }
00638                         }
00639 
00640                         if ( !$rev->isDeleted( Revision::DELETED_TEXT )
00641                                 && !$prevRev->isDeleted( Revision::DELETED_TEXT ) )
00642                         {
00643                                 # Create undo tooltip for the first (=latest) line only
00644                                 $undoTooltip = $latest
00645                                         ? array( 'title' => $this->msg( 'tooltip-undo' )->text() )
00646                                         : array();
00647                                 $undolink = Linker::linkKnown(
00648                                         $this->getTitle(),
00649                                         $this->msg( 'editundo' )->escaped(),
00650                                         $undoTooltip,
00651                                         array(
00652                                                 'action'    => 'edit',
00653                                                 'undoafter' => $prevRev->getId(),
00654                                                 'undo'      => $rev->getId()
00655                                         )
00656                                 );
00657                                 $tools[] = "<span class=\"mw-history-undo\">{$undolink}</span>";
00658                         }
00659                 }
00660                 // Allow extension to add their own links here
00661                 wfRunHooks( 'HistoryRevisionTools', array( $rev, &$tools ) );
00662 
00663                 if ( $tools ) {
00664                         $s2 .= ' '. $this->msg( 'parentheses' )->rawParams( $lang->pipeList( $tools ) )->escaped();
00665                 }
00666 
00667                 # Tags
00668                 list( $tagSummary, $newClasses ) = ChangeTags::formatSummaryRow( $row->ts_tags, 'history' );
00669                 $classes = array_merge( $classes, $newClasses );
00670                 if ( $tagSummary !== '' ) {
00671                         $s2 .= " $tagSummary";
00672                 }
00673 
00674                 # Include separator between character difference and following text
00675                 if ( $s2 !== '' ) {
00676                         $s .= ' <span class="mw-changeslist-separator">. .</span> ' . $s2;
00677                 }
00678 
00679                 wfRunHooks( 'PageHistoryLineEnding', array( $this, &$row, &$s, &$classes ) );
00680 
00681                 $attribs = array();
00682                 if ( $classes ) {
00683                         $attribs['class'] = implode( ' ', $classes );
00684                 }
00685 
00686                 return Xml::tags( 'li', $attribs, $s ) . "\n";
00687         }
00688 
00695         function revLink( $rev ) {
00696                 $date = $this->getLanguage()->userTimeAndDate( $rev->getTimestamp(), $this->getUser() );
00697                 $date = htmlspecialchars( $date );
00698                 if ( $rev->userCan( Revision::DELETED_TEXT, $this->getUser() ) ) {
00699                         $link = Linker::linkKnown(
00700                                 $this->getTitle(),
00701                                 $date,
00702                                 array( 'class' => 'mw-changeslist-date' ),
00703                                 array( 'oldid' => $rev->getId() )
00704                         );
00705                 } else {
00706                         $link = $date;
00707                 }
00708                 if ( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
00709                         $link = "<span class=\"history-deleted\">$link</span>";
00710                 }
00711                 return $link;
00712         }
00713 
00721         function curLink( $rev, $latest ) {
00722                 $cur = $this->historyPage->message['cur'];
00723                 if ( $latest || !$rev->userCan( Revision::DELETED_TEXT, $this->getUser() ) ) {
00724                         return $cur;
00725                 } else {
00726                         return Linker::linkKnown(
00727                                 $this->getTitle(),
00728                                 $cur,
00729                                 array(),
00730                                 array(
00731                                         'diff' => $this->getWikiPage()->getLatest(),
00732                                         'oldid' => $rev->getId()
00733                                 )
00734                         );
00735                 }
00736         }
00737 
00745         function lastLink( $prevRev, $next ) {
00746                 $last = $this->historyPage->message['last'];
00747                 # $next may either be a Row, null, or "unkown"
00748                 $nextRev = is_object( $next ) ? new Revision( $next ) : $next;
00749                 if ( is_null( $next ) ) {
00750                         # Probably no next row
00751                         return $last;
00752                 } elseif ( $next === 'unknown' ) {
00753                         # Next row probably exists but is unknown, use an oldid=prev link
00754                         return Linker::linkKnown(
00755                                 $this->getTitle(),
00756                                 $last,
00757                                 array(),
00758                                 array(
00759                                         'diff' => $prevRev->getId(),
00760                                         'oldid' => 'prev'
00761                                 )
00762                         );
00763                 } elseif ( !$prevRev->userCan( Revision::DELETED_TEXT, $this->getUser() )
00764                         || !$nextRev->userCan( Revision::DELETED_TEXT, $this->getUser() ) )
00765                 {
00766                         return $last;
00767                 } else {
00768                         return Linker::linkKnown(
00769                                 $this->getTitle(),
00770                                 $last,
00771                                 array(),
00772                                 array(
00773                                         'diff' => $prevRev->getId(),
00774                                         'oldid' => $next->rev_id
00775                                 )
00776                         );
00777                 }
00778         }
00779 
00788         function diffButtons( $rev, $firstInList ) {
00789                 if ( $this->getNumRows() > 1 ) {
00790                         $id = $rev->getId();
00791                         $radio = array( 'type'  => 'radio', 'value' => $id );
00793                         if ( $firstInList ) {
00794                                 $first = Xml::element( 'input',
00795                                         array_merge( $radio, array(
00796                                                 'style' => 'visibility:hidden',
00797                                                 'name'  => 'oldid',
00798                                                 'id' => 'mw-oldid-null' ) )
00799                                 );
00800                                 $checkmark = array( 'checked' => 'checked' );
00801                         } else {
00802                                 # Check visibility of old revisions
00803                                 if ( !$rev->userCan( Revision::DELETED_TEXT, $this->getUser() ) ) {
00804                                         $radio['disabled'] = 'disabled';
00805                                         $checkmark = array(); // We will check the next possible one
00806                                 } elseif ( !$this->oldIdChecked ) {
00807                                         $checkmark = array( 'checked' => 'checked' );
00808                                         $this->oldIdChecked = $id;
00809                                 } else {
00810                                         $checkmark = array();
00811                                 }
00812                                 $first = Xml::element( 'input',
00813                                         array_merge( $radio, $checkmark, array(
00814                                                 'name'  => 'oldid',
00815                                                 'id' => "mw-oldid-$id" ) ) );
00816                                 $checkmark = array();
00817                         }
00818                         $second = Xml::element( 'input',
00819                                 array_merge( $radio, $checkmark, array(
00820                                         'name'  => 'diff',
00821                                         'id' => "mw-diff-$id" ) ) );
00822                         return $first . $second;
00823                 } else {
00824                         return '';
00825                 }
00826         }
00827 
00831         function preventClickjacking( $enable = true ) {
00832                 $this->preventClickjacking = $enable;
00833         }
00834 
00839         function getPreventClickjacking() {
00840                 return $this->preventClickjacking;
00841         }
00842 }
00843 
00847 class HistoryPage extends HistoryAction {
00848         public function __construct( Page $article ) { # Just to make it public
00849                 parent::__construct( $article );
00850         }
00851 
00852         public function history() {
00853                 $this->onView();
00854         }
00855 }