return Linker::linkKnown(
SpecialPage::getTitleFor( 'Log' ),
$this->msg( 'viewpagelogs' )->escaped(),
- array(),
- array( 'page' => $this->getTitle()->getPrefixedText() )
+ [],
+ [ 'page' => $this->getTitle()->getPrefixedText() ]
);
}
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();
}
if ( $useFileCache && 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' ] );
}
}
$out->addModules( 'mediawiki.action.history' );
if ( $config->get( 'UseMediaWikiUIEverywhere' ) ) {
$out = $this->getOutput();
- $out->addModuleStyles( array(
+ $out->addModuleStyles( [
'mediawiki.ui.input',
'mediawiki.ui.checkbox',
- ) );
+ ] );
}
// Handle atom/RSS feeds.
# 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;
* 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(),
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" .
$checkDeleted .
Html::submitButton(
$this->msg( 'historyaction-submit' )->text(),
- array(),
- array( 'mw-ui-progressive' )
+ [],
+ [ 'mw-ui-progressive' ]
) . "\n" .
'</fieldset></form>'
);
- 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 );
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 );
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 ]
);
}
* @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;
}
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'],
$queryInfo['options'],
$this->tagFilter
);
- Hooks::run( 'PageHistoryPager::getQueryInfo', array( &$this, &$queryInfo ) );
+ Hooks::run( 'PageHistoryPager::getQueryInfo', [ &$this, &$queryInfo ] );
return $queryInfo;
}
}
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;
$this->oldIdChecked = 0;
$this->getOutput()->wrapWikiMsg( "<div class='mw-history-legend'>\n$1\n</div>", '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";
// Button container stored in $this->buttons for re-use in getEndBody()
$this->buttons = '<div>';
$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
$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 .= '</div>';
$s .= $this->buttons;
# Note bug #20966, <button> is non-standard in IE<8
$element = Html::element(
'button',
- array(
+ [
'type' => 'submit',
'name' => $name,
'value' => '1',
'class' => "historysubmit mw-history-$name-button",
- ),
+ ],
$this->msg( $msg )->text()
) . "\n";
return $element;
* @param array $attributes Attributes
* @return string HTML output for the submit button
*/
- function submitButton( $message, $attributes = array() ) {
+ function submitButton( $message, $attributes = [] ) {
# Disable submit button if history has 1 revision only
if ( $this->getNumRows() > 1 ) {
return Html::submitButton( $message, $attributes );
$curLastlinks = $curlink . $this->historyPage->message['pipe-separator'] . $lastlink;
$histLinks = Html::rawElement(
'span',
- array( 'class' => 'mw-history-histlinks' ),
+ [ 'class' => 'mw-history-histlinks' ],
$this->msg( 'parentheses' )->rawParams( $curLastlinks )->escaped()
);
$s = $histLinks . $diffButtons;
$link = $this->revLink( $rev );
- $classes = array();
+ $classes = [];
$del = '';
$user = $this->getUser();
// If revision was hidden from sysops and we don't need the checkbox
// for anything else, disable it
if ( !$this->showTagEditUI && !$rev->userCan( Revision::DELETED_RESTRICTED, $user ) ) {
- $del = Xml::check( 'deleterevisions', false, array( 'disabled' => 'disabled' ) );
+ $del = Xml::check( 'deleterevisions', false, [ 'disabled' => 'disabled' ] );
// Otherwise, enable the checkbox...
} else {
$del = Xml::check( 'showhiderevisions', false,
- array( 'name' => 'ids[' . $rev->getId() . ']' ) );
+ [ 'name' => 'ids[' . $rev->getId() . ']' ] );
}
// User can only view deleted revisions...
} elseif ( $rev->getVisibility() && $user->isAllowed( 'deletedhistory' ) ) {
$del = Linker::revDeleteLinkDisabled( false );
// Otherwise, show the link...
} else {
- $query = array( 'type' => 'revision',
- 'target' => $this->getTitle()->getPrefixedDBkey(), 'ids' => $rev->getId() );
+ $query = [ 'type' => 'revision',
+ 'target' => $this->getTitle()->getPrefixedDBkey(), 'ids' => $rev->getId() ];
$del .= Linker::revDeleteLink( $query,
$rev->isDeleted( Revision::DELETED_RESTRICTED ), false );
}
$s .= $dirmark;
if ( $rev->isMinor() ) {
- $s .= ' ' . ChangesList::flag( 'minor' );
+ $s .= ' ' . ChangesList::flag( 'minor', $this->getContext() );
}
# Sometimes rev_len isn't populated
$classes[] = 'mw-history-line-updated';
}
- $tools = array();
+ $tools = [];
# Rollback and undo links
if ( $prevRev && $this->getTitle()->quickUserCan( 'edit', $user ) ) {
$rollbackLink = Linker::generateRollback(
$rev,
$this->getContext(),
- array( 'verify', 'noBrackets' )
+ [ 'verify', 'noBrackets' ]
);
if ( $rollbackLink ) {
$this->preventClickjacking();
) {
# Create undo tooltip for the first (=latest) line only
$undoTooltip = $latest
- ? array( 'title' => $this->msg( 'tooltip-undo' )->text() )
- : array();
+ ? [ 'title' => $this->msg( 'tooltip-undo' )->text() ]
+ : [];
$undolink = Linker::linkKnown(
$this->getTitle(),
$this->msg( 'editundo' )->escaped(),
$undoTooltip,
- array(
+ [
'action' => 'edit',
'undoafter' => $prevRev->getId(),
'undo' => $rev->getId()
- )
+ ]
);
$tools[] = "<span class=\"mw-history-undo\">{$undolink}</span>";
}
}
// Allow extension to add their own links here
- Hooks::run( 'HistoryRevisionTools', array( $rev, &$tools, $prevRev, $user ) );
+ Hooks::run( 'HistoryRevisionTools', [ $rev, &$tools, $prevRev, $user ] );
if ( $tools ) {
$s2 .= ' ' . $this->msg( 'parentheses' )->rawParams( $lang->pipeList( $tools ) )->escaped();
}
# Tags
- list( $tagSummary, $newClasses ) = ChangeTags::formatSummaryRow( $row->ts_tags, 'history' );
+ list( $tagSummary, $newClasses ) = ChangeTags::formatSummaryRow(
+ $row->ts_tags,
+ 'history',
+ $this->getContext()
+ );
$classes = array_merge( $classes, $newClasses );
if ( $tagSummary !== '' ) {
$s2 .= " $tagSummary";
$s .= ' <span class="mw-changeslist-separator">. .</span> ' . $s2;
}
- Hooks::run( 'PageHistoryLineEnding', array( $this, &$row, &$s, &$classes ) );
+ Hooks::run( 'PageHistoryLineEnding', [ $this, &$row, &$s, &$classes ] );
- $attribs = array();
+ $attribs = [];
if ( $classes ) {
$attribs['class'] = implode( ' ', $classes );
}
$link = Linker::linkKnown(
$this->getTitle(),
$date,
- array( 'class' => 'mw-changeslist-date' ),
- array( 'oldid' => $rev->getId() )
+ [ 'class' => 'mw-changeslist-date' ],
+ [ 'oldid' => $rev->getId() ]
);
} else {
$link = $date;
return Linker::linkKnown(
$this->getTitle(),
$cur,
- array(),
- array(
+ [],
+ [
'diff' => $this->getWikiPage()->getLatest(),
'oldid' => $rev->getId()
- )
+ ]
);
}
}
return Linker::linkKnown(
$this->getTitle(),
$last,
- array(),
- array(
+ [],
+ [
'diff' => $prevRev->getId(),
'oldid' => 'prev'
- )
+ ]
);
}
return Linker::linkKnown(
$this->getTitle(),
$last,
- array(),
- array(
+ [],
+ [
'diff' => $prevRev->getId(),
'oldid' => $next->rev_id
- )
+ ]
);
}
function diffButtons( $rev, $firstInList ) {
if ( $this->getNumRows() > 1 ) {
$id = $rev->getId();
- $radio = array( 'type' => 'radio', 'value' => $id );
+ $radio = [ 'type' => 'radio', 'value' => $id ];
/** @todo Move title texts to javascript */
if ( $firstInList ) {
$first = Xml::element( 'input',
- array_merge( $radio, array(
+ array_merge( $radio, [
'style' => 'visibility:hidden',
'name' => 'oldid',
- 'id' => 'mw-oldid-null' ) )
+ 'id' => 'mw-oldid-null' ] )
);
- $checkmark = array( 'checked' => 'checked' );
+ $checkmark = [ 'checked' => 'checked' ];
} else {
# Check visibility of old revisions
if ( !$rev->userCan( Revision::DELETED_TEXT, $this->getUser() ) ) {
$radio['disabled'] = 'disabled';
- $checkmark = array(); // We will check the next possible one
+ $checkmark = []; // We will check the next possible one
} elseif ( !$this->oldIdChecked ) {
- $checkmark = array( 'checked' => 'checked' );
+ $checkmark = [ 'checked' => 'checked' ];
$this->oldIdChecked = $id;
} else {
- $checkmark = array();
+ $checkmark = [];
}
$first = Xml::element( 'input',
- array_merge( $radio, $checkmark, array(
+ array_merge( $radio, $checkmark, [
'name' => 'oldid',
- 'id' => "mw-oldid-$id" ) ) );
- $checkmark = array();
+ 'id' => "mw-oldid-$id" ] ) );
+ $checkmark = [];
}
$second = Xml::element( 'input',
- array_merge( $radio, $checkmark, array(
+ array_merge( $radio, $checkmark, [
'name' => 'diff',
- 'id' => "mw-diff-$id" ) ) );
+ 'id' => "mw-diff-$id" ] ) );
return $first . $second;
} else {