X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Factions%2FHistoryAction.php;h=c1763fa1be33d38cda7643bd57c05510f7b0ceb4;hb=69ae945e8d39972a07bea89ddb64bc0189b43ac2;hp=43260d0d121333ebcaf49cadf91e9ce8becb4cee;hpb=74174fca253b9a759d7402f09b7fc37d5de0e9be;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/actions/HistoryAction.php b/includes/actions/HistoryAction.php
index 43260d0d12..c1763fa1be 100644
--- a/includes/actions/HistoryAction.php
+++ b/includes/actions/HistoryAction.php
@@ -61,8 +61,8 @@ class HistoryAction extends FormlessAction {
return Linker::linkKnown(
SpecialPage::getTitleFor( 'Log' ),
$this->msg( 'viewpagelogs' )->escaped(),
- array(),
- array( 'page' => $this->getTitle()->getPrefixedText() )
+ [],
+ [ 'page' => $this->getTitle()->getPrefixedText() ]
);
}
@@ -80,7 +80,7 @@ class HistoryAction extends FormlessAction {
private function preCacheMessages() {
// Precache various messages
if ( !isset( $this->message ) ) {
- $msgs = array( 'cur', 'last', 'pipe-separator' );
+ $msgs = [ 'cur', 'last', 'pipe-separator' ];
foreach ( $msgs as $msg ) {
$this->message[$msg] = $this->msg( $msg )->escaped();
}
@@ -105,23 +105,26 @@ class HistoryAction extends FormlessAction {
$config = $this->context->getConfig();
# Fill in the file cache if not set already
- $useFileCache = $config->get( 'UseFileCache' );
- if ( $useFileCache && HTMLFileCache::useFileCache( $this->getContext() ) ) {
+ if ( HTMLFileCache::useFileCache( $this->getContext() ) ) {
$cache = new HTMLFileCache( $this->getTitle(), 'history' );
if ( !$cache->isCacheGood( /* Assume up to date */ ) ) {
- ob_start( array( &$cache, 'saveToFileCache' ) );
+ ob_start( [ &$cache, 'saveToFileCache' ] );
}
}
// Setup page variables.
$out->setFeedAppendQuery( 'action=history' );
$out->addModules( 'mediawiki.action.history' );
+ $out->addModuleStyles( [
+ 'mediawiki.action.history.styles',
+ 'mediawiki.special.changeslist',
+ ] );
if ( $config->get( 'UseMediaWikiUIEverywhere' ) ) {
$out = $this->getOutput();
- $out->addModuleStyles( array(
+ $out->addModuleStyles( [
'mediawiki.ui.input',
'mediawiki.ui.checkbox',
- ) );
+ ] );
}
// Handle atom/RSS feeds.
@@ -136,18 +139,22 @@ class HistoryAction extends FormlessAction {
// Fail nicely if article doesn't exist.
if ( !$this->page->exists() ) {
+ global $wgSend404Code;
+ if ( $wgSend404Code ) {
+ $out->setStatusCode( 404 );
+ }
$out->addWikiMsg( 'nohistory' );
# show deletion/move log if there is an entry
LogEventsList::showLogExtract(
$out,
- array( 'delete', 'move' ),
+ [ 'delete', 'move' ],
$this->getTitle(),
'',
- array( 'lim' => 10,
- 'conds' => array( "log_action != 'revision'" ),
+ [ 'lim' => 10,
+ 'conds' => [ "log_action != 'revision'" ],
'showIfEmpty' => false,
- 'msgKey' => array( 'moveddeleted-notice' )
- )
+ 'msgKey' => [ 'moveddeleted-notice' ]
+ ]
);
return;
@@ -165,9 +172,9 @@ class HistoryAction extends FormlessAction {
* Option to show only revisions that have been (partially) hidden via RevisionDelete
*/
if ( $request->getBool( 'deleted' ) ) {
- $conds = array( 'rev_deleted != 0' );
+ $conds = [ 'rev_deleted != 0' ];
} else {
- $conds = array();
+ $conds = [];
}
if ( $this->getUser()->isAllowed( 'deletedhistory' ) ) {
$checkDeleted = Xml::checkLabel( $this->msg( 'history-show-deleted' )->text(),
@@ -183,7 +190,7 @@ class HistoryAction extends FormlessAction {
Xml::fieldset(
$this->msg( 'history-fieldset-title' )->text(),
false,
- array( 'id' => 'mw-history-search' )
+ [ 'id' => 'mw-history-search' ]
) .
Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) . "\n" .
Html::hidden( 'action', 'history' ) . "\n" .
@@ -195,13 +202,13 @@ class HistoryAction extends FormlessAction {
$checkDeleted .
Html::submitButton(
$this->msg( 'historyaction-submit' )->text(),
- array(),
- array( 'mw-ui-progressive' )
+ [],
+ [ 'mw-ui-progressive' ]
) . "\n" .
''
);
- Hooks::run( 'PageHistoryBeforeList', array( &$this->page, $this->getContext() ) );
+ Hooks::run( 'PageHistoryBeforeList', [ &$this->page, $this->getContext() ] );
// Create and output the list.
$pager = new HistoryPager( $this, $year, $month, $tagFilter, $conds );
@@ -211,7 +218,6 @@ class HistoryAction extends FormlessAction {
$pager->getNavigationBar()
);
$out->preventClickjacking( $pager->getPreventClickjacking() );
-
}
/**
@@ -227,31 +233,31 @@ class HistoryAction extends FormlessAction {
function fetchRevisions( $limit, $offset, $direction ) {
// Fail if article doesn't exist.
if ( !$this->getTitle()->exists() ) {
- return new FakeResultWrapper( array() );
+ return new FakeResultWrapper( [] );
}
- $dbr = wfGetDB( DB_SLAVE );
+ $dbr = wfGetDB( DB_REPLICA );
if ( $direction === self::DIR_PREV ) {
- list( $dirs, $oper ) = array( "ASC", ">=" );
+ list( $dirs, $oper ) = [ "ASC", ">=" ];
} else { /* $direction === self::DIR_NEXT */
- list( $dirs, $oper ) = array( "DESC", "<=" );
+ list( $dirs, $oper ) = [ "DESC", "<=" ];
}
if ( $offset ) {
- $offsets = array( "rev_timestamp $oper " . $dbr->addQuotes( $dbr->timestamp( $offset ) ) );
+ $offsets = [ "rev_timestamp $oper " . $dbr->addQuotes( $dbr->timestamp( $offset ) ) ];
} else {
- $offsets = array();
+ $offsets = [];
}
$page_id = $this->page->getId();
return $dbr->select( 'revision',
Revision::selectFields(),
- array_merge( array( 'rev_page' => $page_id ), $offsets ),
+ array_merge( [ 'rev_page' => $page_id ], $offsets ),
__METHOD__,
- array( 'ORDER BY' => "rev_timestamp $dirs",
- 'USE INDEX' => 'page_timestamp', 'LIMIT' => $limit )
+ [ 'ORDER BY' => "rev_timestamp $dirs",
+ 'USE INDEX' => 'page_timestamp', 'LIMIT' => $limit ]
);
}
@@ -380,7 +386,7 @@ class HistoryPager extends ReverseChronologicalPager {
* @param string $tagFilter
* @param array $conds
*/
- function __construct( $historyPage, $year = '', $month = '', $tagFilter = '', $conds = array() ) {
+ function __construct( $historyPage, $year = '', $month = '', $tagFilter = '', $conds = [] ) {
parent::__construct( $historyPage->getContext() );
$this->historyPage = $historyPage;
$this->tagFilter = $tagFilter;
@@ -403,15 +409,15 @@ class HistoryPager extends ReverseChronologicalPager {
}
function getQueryInfo() {
- $queryInfo = array(
- 'tables' => array( 'revision', 'user' ),
+ $queryInfo = [
+ 'tables' => [ 'revision', 'user' ],
'fields' => array_merge( Revision::selectFields(), Revision::selectUserFields() ),
'conds' => array_merge(
- array( 'rev_page' => $this->getWikiPage()->getId() ),
+ [ 'rev_page' => $this->getWikiPage()->getId() ],
$this->conds ),
- 'options' => array( 'USE INDEX' => array( 'revision' => 'page_timestamp' ) ),
- 'join_conds' => array( 'user' => Revision::userJoinCond() ),
- );
+ 'options' => [ 'USE INDEX' => [ 'revision' => 'page_timestamp' ] ],
+ 'join_conds' => [ 'user' => Revision::userJoinCond() ],
+ ];
ChangeTags::modifyDisplayQuery(
$queryInfo['tables'],
$queryInfo['fields'],
@@ -420,7 +426,7 @@ class HistoryPager extends ReverseChronologicalPager {
$queryInfo['options'],
$this->tagFilter
);
- Hooks::run( 'PageHistoryPager::getQueryInfo', array( &$this, &$queryInfo ) );
+ Hooks::run( 'PageHistoryPager::getQueryInfo', [ &$this, &$queryInfo ] );
return $queryInfo;
}
@@ -454,14 +460,14 @@ class HistoryPager extends ReverseChronologicalPager {
}
function doBatchLookups() {
- if ( !Hooks::run( 'PageHistoryPager::doBatchLookups', array( $this, $this->mResult ) ) ) {
+ if ( !Hooks::run( 'PageHistoryPager::doBatchLookups', [ $this, $this->mResult ] ) ) {
return;
}
# Do a link batch query
$this->mResult->seek( 0 );
$batch = new LinkBatch();
- $revIds = array();
+ $revIds = [];
foreach ( $this->mResult as $row ) {
if ( $row->rev_parent_id ) {
$revIds[] = $row->rev_parent_id;
@@ -490,8 +496,8 @@ class HistoryPager extends ReverseChronologicalPager {
$this->oldIdChecked = 0;
$this->getOutput()->wrapWikiMsg( "
\n$1\n
", 'histlegend' );
- $s = Html::openElement( 'form', array( 'action' => wfScript(),
- 'id' => 'mw-history-compare' ) ) . "\n";
+ $s = Html::openElement( 'form', [ 'action' => wfScript(),
+ 'id' => 'mw-history-compare' ] ) . "\n";
$s .= Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) . "\n";
$s .= Html::hidden( 'action', 'historysubmit' ) . "\n";
$s .= Html::hidden( 'type', 'revision' ) . "\n";
@@ -499,7 +505,7 @@ class HistoryPager extends ReverseChronologicalPager {
// Button container stored in $this->buttons for re-use in getEndBody()
$this->buttons = '';
$className = 'historysubmit mw-history-compareselectedversions-button';
- $attrs = array( 'class' => $className )
+ $attrs = [ 'class' => $className ]
+ Linker::tooltipAndAccesskeyAttribs( 'compareselectedversions' );
$this->buttons .= $this->submitButton( $this->msg( 'compareselectedversions' )->text(),
$attrs
@@ -514,9 +520,14 @@ class HistoryPager extends ReverseChronologicalPager {
$actionButtons .= $this->getRevisionButton( 'editchangetags', 'history-edit-tags' );
}
if ( $actionButtons ) {
- $this->buttons .= Xml::tags( 'div', array( 'class' =>
- 'mw-history-revisionactions' ), $actionButtons );
+ $this->buttons .= Xml::tags( 'div', [ 'class' =>
+ 'mw-history-revisionactions' ], $actionButtons );
}
+
+ if ( $user->isAllowed( 'deleterevision' ) || $this->showTagEditUI ) {
+ $this->buttons .= ( new ListToggle( $this->getOutput() ) )->getHTML();
+ }
+
$this->buttons .= '
';
$s .= $this->buttons;
@@ -530,12 +541,12 @@ class HistoryPager extends ReverseChronologicalPager {
# Note bug #20966,