* Changed action=history to use an Action subclass

* Use local context instead of global variables
* Removed obsolete aliases PageHistory and PageHistoryPager; no longer used
* Made Action::getContext() and related methods public for the call in HistoryPager's constructor and also for consistency with other classes
This commit is contained in:
Alexandre Emsenhuber 2011-10-23 09:21:02 +00:00
parent 3eb71daab0
commit 9e230f3076
5 changed files with 108 additions and 105 deletions

View file

@ -99,7 +99,7 @@ abstract class Action {
* Get the IContextSource in use here * Get the IContextSource in use here
* @return IContextSource * @return IContextSource
*/ */
protected final function getContext() { public final function getContext() {
if ( $this->context instanceof IContextSource ) { if ( $this->context instanceof IContextSource ) {
return $this->context; return $this->context;
} }
@ -111,7 +111,7 @@ abstract class Action {
* *
* @return WebRequest * @return WebRequest
*/ */
protected final function getRequest() { public final function getRequest() {
return $this->getContext()->getRequest(); return $this->getContext()->getRequest();
} }
@ -120,7 +120,7 @@ abstract class Action {
* *
* @return OutputPage * @return OutputPage
*/ */
protected final function getOutput() { public final function getOutput() {
return $this->getContext()->getOutput(); return $this->getContext()->getOutput();
} }
@ -129,7 +129,7 @@ abstract class Action {
* *
* @return User * @return User
*/ */
protected final function getUser() { public final function getUser() {
return $this->getContext()->getUser(); return $this->getContext()->getUser();
} }
@ -138,7 +138,7 @@ abstract class Action {
* *
* @return Skin * @return Skin
*/ */
protected final function getSkin() { public final function getSkin() {
return $this->getContext()->getSkin(); return $this->getContext()->getSkin();
} }
@ -147,7 +147,7 @@ abstract class Action {
* *
* @return Skin * @return Skin
*/ */
protected final function getLang() { public final function getLang() {
return $this->getContext()->getLang(); return $this->getContext()->getLang();
} }
@ -155,7 +155,7 @@ abstract class Action {
* Shortcut to get the Title object from the page * Shortcut to get the Title object from the page
* @return Title * @return Title
*/ */
protected final function getTitle() { public final function getTitle() {
return $this->page->getTitle(); return $this->page->getTitle();
} }
@ -165,7 +165,7 @@ abstract class Action {
* *
* @return Message object * @return Message object
*/ */
protected final function msg() { public final function msg() {
$params = func_get_args(); $params = func_get_args();
return call_user_func_array( array( $this->getContext(), 'msg' ), $params ); return call_user_func_array( array( $this->getContext(), 'msg' ), $params );
} }

View file

@ -93,8 +93,6 @@ $wgAutoloadLocalClasses = array(
'HistoryBlob' => 'includes/HistoryBlob.php', 'HistoryBlob' => 'includes/HistoryBlob.php',
'HistoryBlobCurStub' => 'includes/HistoryBlob.php', 'HistoryBlobCurStub' => 'includes/HistoryBlob.php',
'HistoryBlobStub' => 'includes/HistoryBlob.php', 'HistoryBlobStub' => 'includes/HistoryBlob.php',
'HistoryPage' => 'includes/HistoryPage.php',
'HistoryPager' => 'includes/HistoryPage.php',
'Hooks' => 'includes/Hooks.php', 'Hooks' => 'includes/Hooks.php',
'Html' => 'includes/Html.php', 'Html' => 'includes/Html.php',
'HTMLCheckField' => 'includes/HTMLForm.php', 'HTMLCheckField' => 'includes/HTMLForm.php',
@ -160,8 +158,6 @@ $wgAutoloadLocalClasses = array(
'OldChangesList' => 'includes/ChangesList.php', 'OldChangesList' => 'includes/ChangesList.php',
'OutputPage' => 'includes/OutputPage.php', 'OutputPage' => 'includes/OutputPage.php',
'Page' => 'includes/WikiPage.php', 'Page' => 'includes/WikiPage.php',
'PageHistory' => 'includes/HistoryPage.php',
'PageHistoryPager' => 'includes/HistoryPage.php',
'PageQueryPage' => 'includes/PageQueryPage.php', 'PageQueryPage' => 'includes/PageQueryPage.php',
'Pager' => 'includes/Pager.php', 'Pager' => 'includes/Pager.php',
'PasswordError' => 'includes/User.php', 'PasswordError' => 'includes/User.php',
@ -257,6 +253,9 @@ $wgAutoloadLocalClasses = array(
# includes/actions # includes/actions
'CreditsAction' => 'includes/actions/CreditsAction.php', 'CreditsAction' => 'includes/actions/CreditsAction.php',
'DeletetrackbackAction' => 'includes/actions/DeletetrackbackAction.php', 'DeletetrackbackAction' => 'includes/actions/DeletetrackbackAction.php',
'HistoryAction' => 'includes/actions/HistoryAction.php',
'HistoryPage' => 'includes/actions/HistoryAction.php',
'HistoryPager' => 'includes/actions/HistoryAction.php',
'InfoAction' => 'includes/actions/InfoAction.php', 'InfoAction' => 'includes/actions/InfoAction.php',
'MarkpatrolledAction' => 'includes/actions/MarkpatrolledAction.php', 'MarkpatrolledAction' => 'includes/actions/MarkpatrolledAction.php',
'PurgeAction' => 'includes/actions/PurgeAction.php', 'PurgeAction' => 'includes/actions/PurgeAction.php',

View file

@ -5241,6 +5241,7 @@ $wgMaxRedirectLinksRetrieved = 500;
$wgActions = array( $wgActions = array(
'credits' => true, 'credits' => true,
'deletetrackback' => true, 'deletetrackback' => true,
'history' => true,
'info' => true, 'info' => true,
'markpatrolled' => true, 'markpatrolled' => true,
'purge' => true, 'purge' => true,

View file

@ -501,13 +501,6 @@ class MediaWiki {
} }
} }
break; break;
case 'history':
if ( $request->getFullRequestURL() == $title->getInternalURL( 'action=history' ) ) {
$output->setSquidMaxage( $wgSquidMaxage );
}
$history = new HistoryPage( $article, $this->context );
$history->history();
break;
default: default:
if ( wfRunHooks( 'UnknownAction', array( $act, $article ) ) ) { if ( wfRunHooks( 'UnknownAction', array( $act, $article ) ) ) {
$output->showErrorPage( 'nosuchaction', 'nosuchactiontext' ); $output->showErrorPage( 'nosuchaction', 'nosuchactiontext' );

View file

@ -15,23 +15,38 @@
* history. * history.
* *
*/ */
class HistoryPage extends ContextSource { class HistoryAction extends FormlessAction {
const DIR_PREV = 0; const DIR_PREV = 0;
const DIR_NEXT = 1; const DIR_NEXT = 1;
/** Contains the Page object. Passed on construction. */ public function getName() {
protected $article; return 'history';
}
/** public function getRestriction() {
* Construct a new HistoryPage. return 'read';
* }
* @param $article Article
*/ public function requiresWrite() {
function __construct( Page $page, IContextSource $context ) { return false;
$this->article = $page; }
$this->context = clone $context; // don't clobber the main context
$this->context->setTitle( $page->getTitle() ); // must match public function requiresUnblock() {
$this->preCacheMessages(); return false;
}
protected function getPageTitle() {
return $this->msg( 'history-title', $this->getTitle()->getPrefixedText() )->text();
}
protected function getDescription() {
// Creation of a subtitle link pointing to [[Special:Log]]
return Linker::linkKnown(
SpecialPage::getTitleFor( 'Log' ),
$this->msg( 'viewpagelogs' )->escaped(),
array(),
array( 'page' => $this->getTitle()->getPrefixedText() )
);
} }
/** /**
@ -39,7 +54,7 @@ class HistoryPage extends ContextSource {
* @return Page * @return Page
*/ */
public function getArticle() { public function getArticle() {
return $this->article; return $this->page;
} }
/** /**
@ -51,7 +66,7 @@ class HistoryPage extends ContextSource {
if ( !isset( $this->message ) ) { if ( !isset( $this->message ) ) {
$msgs = array( 'cur', 'last', 'pipe-separator' ); $msgs = array( 'cur', 'last', 'pipe-separator' );
foreach ( $msgs as $msg ) { foreach ( $msgs as $msg ) {
$this->message[$msg] = wfMsgExt( $msg, array( 'escapenoentities' ) ); $this->message[$msg] = $this->msg( $msg )->escaped();
} }
} }
} }
@ -60,20 +75,27 @@ class HistoryPage extends ContextSource {
* Print the history page for an article. * Print the history page for an article.
* @return nothing * @return nothing
*/ */
function history() { function onView() {
global $wgScript, $wgUseFileCache; global $wgScript, $wgUseFileCache, $wgSquidMaxage;
$out = $this->getOutput(); $out = $this->getOutput();
$request = $this->getRequest(); $request = $this->getRequest();
/** /**
* Allow client caching. * Allow client caching.
*/ */
if ( $out->checkLastModified( $this->article->getTouched() ) ) { if ( $out->checkLastModified( $this->page->getTouched() ) ) {
return; // Client cache fresh and headers sent, nothing more to do. return; // Client cache fresh and headers sent, nothing more to do.
} }
wfProfileIn( __METHOD__ ); wfProfileIn( __METHOD__ );
if ( $request->getFullRequestURL() == $this->getTitle()->getInternalURL( 'action=history' ) ) {
$out->setSquidMaxage( $wgSquidMaxage );
}
$this->preCacheMessages();
# Fill in the file cache if not set already # Fill in the file cache if not set already
if ( $wgUseFileCache && HTMLFileCache::useFileCache( $this->getContext() ) ) { if ( $wgUseFileCache && HTMLFileCache::useFileCache( $this->getContext() ) ) {
$cache = HTMLFileCache::newFromTitle( $this->getTitle(), 'history' ); $cache = HTMLFileCache::newFromTitle( $this->getTitle(), 'history' );
@ -83,24 +105,9 @@ class HistoryPage extends ContextSource {
} }
// Setup page variables. // Setup page variables.
$out->setPageTitle( wfMsg( 'history-title', $this->getTitle()->getPrefixedText() ) );
$out->setPageTitleActionText( wfMsg( 'history_short' ) );
$out->setArticleFlag( false );
$out->setArticleRelated( true );
$out->setRobotPolicy( 'noindex,nofollow' );
$out->setFeedAppendQuery( 'action=history' ); $out->setFeedAppendQuery( 'action=history' );
$out->addModules( array( 'mediawiki.legacy.history', 'mediawiki.action.history' ) ); $out->addModules( array( 'mediawiki.legacy.history', 'mediawiki.action.history' ) );
// Creation of a subtitle link pointing to [[Special:Log]]
$logPage = SpecialPage::getTitleFor( 'Log' );
$logLink = Linker::linkKnown(
$logPage,
wfMsgHtml( 'viewpagelogs' ),
array(),
array( 'page' => $this->getTitle()->getPrefixedText() )
);
$out->setSubtitle( $logLink );
// Handle atom/RSS feeds. // Handle atom/RSS feeds.
$feedType = $request->getVal( 'feed' ); $feedType = $request->getVal( 'feed' );
if ( $feedType ) { if ( $feedType ) {
@ -143,7 +150,7 @@ class HistoryPage extends ContextSource {
} else { } else {
$conds = array(); $conds = array();
} }
$checkDeleted = Xml::checkLabel( wfMsg( 'history-show-deleted' ), $checkDeleted = Xml::checkLabel( $this->msg( 'history-show-deleted' )->text(),
'deleted', 'mw-show-deleted-only', $request->getBool( 'deleted' ) ) . "\n"; 'deleted', 'mw-show-deleted-only', $request->getBool( 'deleted' ) ) . "\n";
// Add the general form // Add the general form
@ -151,7 +158,7 @@ class HistoryPage extends ContextSource {
$out->addHTML( $out->addHTML(
"<form action=\"$action\" method=\"get\" id=\"mw-history-searchform\">" . "<form action=\"$action\" method=\"get\" id=\"mw-history-searchform\">" .
Xml::fieldset( Xml::fieldset(
wfMsg( 'history-fieldset-title' ), $this->msg( 'history-fieldset-title' )->text(),
false, false,
array( 'id' => 'mw-history-search' ) array( 'id' => 'mw-history-search' )
) . ) .
@ -160,7 +167,7 @@ class HistoryPage extends ContextSource {
Xml::dateMenu( $year, $month ) . '&#160;' . Xml::dateMenu( $year, $month ) . '&#160;' .
( $tagSelector ? ( implode( '&#160;', $tagSelector ) . '&#160;' ) : '' ) . ( $tagSelector ? ( implode( '&#160;', $tagSelector ) . '&#160;' ) : '' ) .
$checkDeleted . $checkDeleted .
Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n" . Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) . "\n" .
'</fieldset></form>' '</fieldset></form>'
); );
@ -243,7 +250,7 @@ class HistoryPage extends ContextSource {
// Generate feed elements enclosed between header and footer. // Generate feed elements enclosed between header and footer.
$feed->outHeader(); $feed->outHeader();
if ( $items ) { if ( $items->numRows() ) {
foreach ( $items as $row ) { foreach ( $items as $row ) {
$feed->outItem( $this->feedItem( $row ) ); $feed->outItem( $this->feedItem( $row ) );
} }
@ -310,14 +317,13 @@ class HistoryPage extends ContextSource {
* @ingroup Pager * @ingroup Pager
*/ */
class HistoryPager extends ReverseChronologicalPager { class HistoryPager extends ReverseChronologicalPager {
public $lastRow = false, $counter, $historyPage, $title, $buttons, $conds; public $lastRow = false, $counter, $historyPage, $buttons, $conds;
protected $oldIdChecked; protected $oldIdChecked;
protected $preventClickjacking = false; protected $preventClickjacking = false;
function __construct( $historyPage, $year = '', $month = '', $tagFilter = '', $conds = array() ) { function __construct( $historyPage, $year = '', $month = '', $tagFilter = '', $conds = array() ) {
parent::__construct(); parent::__construct( $historyPage->getContext() );
$this->historyPage = $historyPage; $this->historyPage = $historyPage;
$this->title = $this->historyPage->getTitle();
$this->tagFilter = $tagFilter; $this->tagFilter = $tagFilter;
$this->getDateCond( $year, $month ); $this->getDateCond( $year, $month );
$this->conds = $conds; $this->conds = $conds;
@ -328,10 +334,6 @@ class HistoryPager extends ReverseChronologicalPager {
return $this->historyPage->getArticle(); return $this->historyPage->getArticle();
} }
function getTitle() {
return $this->title;
}
function getSqlComment() { function getSqlComment() {
if ( $this->conds ) { if ( $this->conds ) {
return 'history page filtered'; // potentially slow, see CR r58153 return 'history page filtered'; // potentially slow, see CR r58153
@ -345,7 +347,7 @@ class HistoryPager extends ReverseChronologicalPager {
'tables' => array( 'revision', 'user' ), 'tables' => array( 'revision', 'user' ),
'fields' => array_merge( Revision::selectFields(), Revision::selectUserFields() ), 'fields' => array_merge( Revision::selectFields(), Revision::selectUserFields() ),
'conds' => array_merge( 'conds' => array_merge(
array( 'rev_page' => $this->title->getArticleID() ), array( 'rev_page' => $this->getTitle()->getArticleID() ),
$this->conds ), $this->conds ),
'options' => array( 'USE INDEX' => array( 'revision' => 'page_timestamp' ) ), 'options' => array( 'USE INDEX' => array( 'revision' => 'page_timestamp' ) ),
'join_conds' => array( 'join_conds' => array(
@ -374,7 +376,7 @@ class HistoryPager extends ReverseChronologicalPager {
$firstInList = $this->counter == 1; $firstInList = $this->counter == 1;
$this->counter++; $this->counter++;
$s = $this->historyLine( $this->lastRow, $row, $s = $this->historyLine( $this->lastRow, $row,
$this->title->getNotificationTimestamp(), $latest, $firstInList ); $this->getTitle()->getNotificationTimestamp( $this->getUser() ), $latest, $firstInList );
} else { } else {
$s = ''; $s = '';
} }
@ -401,27 +403,27 @@ class HistoryPager extends ReverseChronologicalPager {
* @return string HTML output * @return string HTML output
*/ */
function getStartBody() { function getStartBody() {
global $wgScript, $wgUser, $wgOut; global $wgScript;
$this->lastRow = false; $this->lastRow = false;
$this->counter = 1; $this->counter = 1;
$this->oldIdChecked = 0; $this->oldIdChecked = 0;
$wgOut->wrapWikiMsg( "<div class='mw-history-legend'>\n$1\n</div>", 'histlegend' ); $this->getOutput()->wrapWikiMsg( "<div class='mw-history-legend'>\n$1\n</div>", 'histlegend' );
$s = Html::openElement( 'form', array( 'action' => $wgScript, $s = Html::openElement( 'form', array( 'action' => $wgScript,
'id' => 'mw-history-compare' ) ) . "\n"; 'id' => 'mw-history-compare' ) ) . "\n";
$s .= Html::hidden( 'title', $this->title->getPrefixedDbKey() ) . "\n"; $s .= Html::hidden( 'title', $this->getTitle()->getPrefixedDbKey() ) . "\n";
$s .= Html::hidden( 'action', 'historysubmit' ) . "\n"; $s .= Html::hidden( 'action', 'historysubmit' ) . "\n";
$s .= '<div>' . $this->submitButton( wfMsg( 'compareselectedversions' ), $s .= '<div>' . $this->submitButton( $this->msg( 'compareselectedversions' )->text(),
array( 'class' => 'historysubmit' ) ) . "\n"; array( 'class' => 'historysubmit' ) ) . "\n";
$this->buttons = '<div>'; $this->buttons = '<div>';
$this->buttons .= $this->submitButton( wfMsg( 'compareselectedversions' ), $this->buttons .= $this->submitButton( $this->msg( 'compareselectedversions' )->text(),
array( 'class' => 'historysubmit' ) array( 'class' => 'historysubmit' )
+ Linker::tooltipAndAccesskeyAttribs( 'compareselectedversions' ) + Linker::tooltipAndAccesskeyAttribs( 'compareselectedversions' )
) . "\n"; ) . "\n";
if ( $wgUser->isAllowed( 'deleterevision' ) ) { if ( $this->getUser()->isAllowed( 'deleterevision' ) ) {
$s .= $this->getRevisionButton( 'revisiondelete', 'showhideselectedversions' ); $s .= $this->getRevisionButton( 'revisiondelete', 'showhideselectedversions' );
} }
$this->buttons .= '</div>'; $this->buttons .= '</div>';
@ -439,7 +441,7 @@ class HistoryPager extends ReverseChronologicalPager {
'value' => '1', 'value' => '1',
'class' => "mw-history-$name-button", 'class' => "mw-history-$name-button",
), ),
wfMsg( $msg ) $this->msg( $msg )->text()
) . "\n"; ) . "\n";
$this->buttons .= $element; $this->buttons .= $element;
return $element; return $element;
@ -462,7 +464,7 @@ class HistoryPager extends ReverseChronologicalPager {
} }
$this->counter++; $this->counter++;
$s = $this->historyLine( $this->lastRow, $next, $s = $this->historyLine( $this->lastRow, $next,
$this->title->getNotificationTimestamp(), $latest, $firstInList ); $this->getTitle()->getNotificationTimestamp( $this->getUser() ), $latest, $firstInList );
} else { } else {
$s = ''; $s = '';
} }
@ -506,9 +508,8 @@ class HistoryPager extends ReverseChronologicalPager {
function historyLine( $row, $next, $notificationtimestamp = false, function historyLine( $row, $next, $notificationtimestamp = false,
$latest = false, $firstInList = false ) $latest = false, $firstInList = false )
{ {
global $wgUser, $wgLang;
$rev = new Revision( $row ); $rev = new Revision( $row );
$rev->setTitle( $this->title ); $rev->setTitle( $this->getTitle() );
$curlink = $this->curLink( $rev, $latest ); $curlink = $this->curLink( $rev, $latest );
$lastlink = $this->lastLink( $rev, $next ); $lastlink = $this->lastLink( $rev, $next );
@ -524,11 +525,12 @@ class HistoryPager extends ReverseChronologicalPager {
$classes = array(); $classes = array();
$del = ''; $del = '';
$user = $this->getUser();
// Show checkboxes for each revision // Show checkboxes for each revision
if ( $wgUser->isAllowed( 'deleterevision' ) ) { if ( $user->isAllowed( 'deleterevision' ) ) {
$this->preventClickjacking(); $this->preventClickjacking();
// If revision was hidden from sysops, disable the checkbox // If revision was hidden from sysops, disable the checkbox
if ( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) { if ( !$rev->userCan( Revision::DELETED_RESTRICTED, $user ) ) {
$del = Xml::check( 'deleterevisions', false, array( 'disabled' => 'disabled' ) ); $del = Xml::check( 'deleterevisions', false, array( 'disabled' => 'disabled' ) );
// Otherwise, enable the checkbox... // Otherwise, enable the checkbox...
} else { } else {
@ -536,14 +538,14 @@ class HistoryPager extends ReverseChronologicalPager {
array( 'name' => 'ids[' . $rev->getId() . ']' ) ); array( 'name' => 'ids[' . $rev->getId() . ']' ) );
} }
// User can only view deleted revisions... // User can only view deleted revisions...
} elseif ( $rev->getVisibility() && $wgUser->isAllowed( 'deletedhistory' ) ) { } elseif ( $rev->getVisibility() && $user->isAllowed( 'deletedhistory' ) ) {
// If revision was hidden from sysops, disable the link // If revision was hidden from sysops, disable the link
if ( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) { if ( !$rev->userCan( Revision::DELETED_RESTRICTED, $user ) ) {
$cdel = Linker::revDeleteLinkDisabled( false ); $cdel = Linker::revDeleteLinkDisabled( false );
// Otherwise, show the link... // Otherwise, show the link...
} else { } else {
$query = array( 'type' => 'revision', $query = array( 'type' => 'revision',
'target' => $this->title->getPrefixedDbkey(), 'ids' => $rev->getId() ); 'target' => $this->getTitle()->getPrefixedDbkey(), 'ids' => $rev->getId() );
$del .= Linker::revDeleteLink( $query, $del .= Linker::revDeleteLink( $query,
$rev->isDeleted( Revision::DELETED_RESTRICTED ), false ); $rev->isDeleted( Revision::DELETED_RESTRICTED ), false );
} }
@ -552,7 +554,8 @@ class HistoryPager extends ReverseChronologicalPager {
$s .= " $del "; $s .= " $del ";
} }
$dirmark = $wgLang->getDirMark(); $lang = $this->getLang();
$dirmark = $lang->getDirMark();
$s .= " $link"; $s .= " $link";
$s .= $dirmark; $s .= $dirmark;
@ -571,30 +574,31 @@ class HistoryPager extends ReverseChronologicalPager {
$s .= Linker::revComment( $rev, false, true ); $s .= Linker::revComment( $rev, false, true );
if ( $notificationtimestamp && ( $row->rev_timestamp >= $notificationtimestamp ) ) { if ( $notificationtimestamp && ( $row->rev_timestamp >= $notificationtimestamp ) ) {
$s .= ' <span class="updatedmarker">' . wfMsgHtml( 'updatedmarker' ) . '</span>'; $s .= ' <span class="updatedmarker">' . $this->msg( 'updatedmarker' )->escaped() . '</span>';
} }
$tools = array(); $tools = array();
# Rollback and undo links # Rollback and undo links
if ( !is_null( $next ) && is_object( $next ) ) { if ( !is_null( $next ) && is_object( $next ) &&
if ( $latest && $this->title->userCan( 'rollback' ) && $this->title->userCan( 'edit' ) ) { !count( $this->getTitle()->getUserPermissionsErrors( 'edit', $this->getUser() ) ) )
{
if ( $latest && !count( $this->getTitle()->getUserPermissionsErrors( 'rollback', $this->getUser() ) ) ) {
$this->preventClickjacking(); $this->preventClickjacking();
$tools[] = '<span class="mw-rollback-link">' . $tools[] = '<span class="mw-rollback-link">' .
Linker::buildRollbackLink( $rev ) . '</span>'; Linker::buildRollbackLink( $rev ) . '</span>';
} }
if ( $this->title->quickUserCan( 'edit' ) if ( !$rev->isDeleted( Revision::DELETED_TEXT )
&& !$rev->isDeleted( Revision::DELETED_TEXT )
&& !$next->rev_deleted & Revision::DELETED_TEXT ) && !$next->rev_deleted & Revision::DELETED_TEXT )
{ {
# Create undo tooltip for the first (=latest) line only # Create undo tooltip for the first (=latest) line only
$undoTooltip = $latest $undoTooltip = $latest
? array( 'title' => wfMsg( 'tooltip-undo' ) ) ? array( 'title' => $this->msg( 'tooltip-undo' )->text() )
: array(); : array();
$undolink = Linker::linkKnown( $undolink = Linker::linkKnown(
$this->title, $this->getTitle(),
wfMsgHtml( 'editundo' ), $this->msg( 'editundo' )->escaped(),
$undoTooltip, $undoTooltip,
array( array(
'action' => 'edit', 'action' => 'edit',
@ -607,7 +611,7 @@ class HistoryPager extends ReverseChronologicalPager {
} }
if ( $tools ) { if ( $tools ) {
$s .= ' (' . $wgLang->pipeList( $tools ) . ')'; $s .= ' (' . $lang->pipeList( $tools ) . ')';
} }
# Tags # Tags
@ -632,12 +636,11 @@ class HistoryPager extends ReverseChronologicalPager {
* @return String * @return String
*/ */
function revLink( $rev ) { function revLink( $rev ) {
global $wgLang; $date = $this->getLang()->userTimeAndDate( $rev->getTimestamp(), $this->getUser() );
$date = $wgLang->timeanddate( wfTimestamp( TS_MW, $rev->getTimestamp() ), true );
$date = htmlspecialchars( $date ); $date = htmlspecialchars( $date );
if ( $rev->userCan( Revision::DELETED_TEXT ) ) { if ( $rev->userCan( Revision::DELETED_TEXT, $this->getUser() ) ) {
$link = Linker::linkKnown( $link = Linker::linkKnown(
$this->title, $this->getTitle(),
$date, $date,
array(), array(),
array( 'oldid' => $rev->getId() ) array( 'oldid' => $rev->getId() )
@ -660,15 +663,15 @@ class HistoryPager extends ReverseChronologicalPager {
*/ */
function curLink( $rev, $latest ) { function curLink( $rev, $latest ) {
$cur = $this->historyPage->message['cur']; $cur = $this->historyPage->message['cur'];
if ( $latest || !$rev->userCan( Revision::DELETED_TEXT ) ) { if ( $latest || !$rev->userCan( Revision::DELETED_TEXT, $this->getUser() ) ) {
return $cur; return $cur;
} else { } else {
return Linker::linkKnown( return Linker::linkKnown(
$this->title, $this->getTitle(),
$cur, $cur,
array(), array(),
array( array(
'diff' => $this->title->getLatestRevID(), 'diff' => $this->getTitle()->getLatestRevID(),
'oldid' => $rev->getId() 'oldid' => $rev->getId()
) )
); );
@ -692,7 +695,7 @@ class HistoryPager extends ReverseChronologicalPager {
} elseif ( $next === 'unknown' ) { } elseif ( $next === 'unknown' ) {
# Next row probably exists but is unknown, use an oldid=prev link # Next row probably exists but is unknown, use an oldid=prev link
return Linker::linkKnown( return Linker::linkKnown(
$this->title, $this->getTitle(),
$last, $last,
array(), array(),
array( array(
@ -700,13 +703,13 @@ class HistoryPager extends ReverseChronologicalPager {
'oldid' => 'prev' 'oldid' => 'prev'
) )
); );
} elseif ( !$prevRev->userCan( Revision::DELETED_TEXT ) } elseif ( !$prevRev->userCan( Revision::DELETED_TEXT, $this->getUser() )
|| !$nextRev->userCan( Revision::DELETED_TEXT ) ) || !$nextRev->userCan( Revision::DELETED_TEXT, $this->getUser() ) )
{ {
return $last; return $last;
} else { } else {
return Linker::linkKnown( return Linker::linkKnown(
$this->title, $this->getTitle(),
$last, $last,
array(), array(),
array( array(
@ -740,7 +743,7 @@ class HistoryPager extends ReverseChronologicalPager {
$checkmark = array( 'checked' => 'checked' ); $checkmark = array( 'checked' => 'checked' );
} else { } else {
# Check visibility of old revisions # Check visibility of old revisions
if ( !$rev->userCan( Revision::DELETED_TEXT ) ) { if ( !$rev->userCan( Revision::DELETED_TEXT, $this->getUser() ) ) {
$radio['disabled'] = 'disabled'; $radio['disabled'] = 'disabled';
$checkmark = array(); // We will check the next possible one $checkmark = array(); // We will check the next possible one
} elseif ( !$this->oldIdChecked ) { } elseif ( !$this->oldIdChecked ) {
@ -781,7 +784,14 @@ class HistoryPager extends ReverseChronologicalPager {
} }
/** /**
* Backwards-compatibility aliases * Backwards-compatibility alias
*/ */
class PageHistory extends HistoryPage {} class HistoryPage extends HistoryAction {
class PageHistoryPager extends HistoryPager {} public function __construct( Page $article ) { # Just to make it public
parent::__construct( $article );
}
public function history() {
$this->onView();
}
}