/** @var Title */
protected $target;
- protected $limits = array( 20, 50, 100, 250, 500 );
+ protected $limits = [ 20, 50, 100, 250, 500 ];
public function __construct() {
parent::__construct( 'Whatlinkshere' );
$fetchlinks = ( !$hidelinks || !$hideredirs );
// Build query conds in concert for all three tables...
- $conds['pagelinks'] = array(
+ $conds['pagelinks'] = [
'pl_namespace' => $target->getNamespace(),
'pl_title' => $target->getDBkey(),
- );
- $conds['templatelinks'] = array(
+ ];
+ $conds['templatelinks'] = [
'tl_namespace' => $target->getNamespace(),
'tl_title' => $target->getDBkey(),
- );
- $conds['imagelinks'] = array(
+ ];
+ $conds['imagelinks'] = [
'il_to' => $target->getDBkey(),
- );
+ ];
$namespace = $this->opts->getValue( 'namespace' );
$invert = $this->opts->getValue( 'invert' );
) {
// Read an extra row as an at-end check
$queryLimit = $limit + 1;
- $on = array(
+ $on = [
"rd_from = $fromCol",
'rd_title' => $target->getDBkey(),
'rd_interwiki = ' . $dbr->addQuotes( '' ) . ' OR rd_interwiki IS NULL'
- );
+ ];
$on['rd_namespace'] = $target->getNamespace();
// Inner LIMIT is 2X in case of stale backlinks with wrong namespaces
- $subQuery = $dbr->selectSqlText(
- array( $table, 'redirect', 'page' ),
- array( $fromCol, 'rd_from' ),
+ $subQuery = $dbr->selectSQLText(
+ [ $table, 'redirect', 'page' ],
+ [ $fromCol, 'rd_from' ],
$conds[$table],
__CLASS__ . '::showIndirectLinks',
// Force JOIN order per T106682 to avoid large filesorts
- array( 'ORDER BY' => $fromCol, 'LIMIT' => 2 * $queryLimit, 'STRAIGHT_JOIN' ),
- array(
- 'page' => array( 'INNER JOIN', "$fromCol = page_id" ),
- 'redirect' => array( 'LEFT JOIN', $on )
- )
+ [ 'ORDER BY' => $fromCol, 'LIMIT' => 2 * $queryLimit, 'STRAIGHT_JOIN' ],
+ [
+ 'page' => [ 'INNER JOIN', "$fromCol = page_id" ],
+ 'redirect' => [ 'LEFT JOIN', $on ]
+ ]
);
return $dbr->select(
- array( 'page', 'temp_backlink_range' => "($subQuery)" ),
- array( 'page_id', 'page_namespace', 'page_title', 'rd_from', 'page_is_redirect' ),
- array(),
+ [ 'page', 'temp_backlink_range' => "($subQuery)" ],
+ [ 'page_id', 'page_namespace', 'page_title', 'rd_from', 'page_is_redirect' ],
+ [],
__CLASS__ . '::showIndirectLinks',
- array( 'ORDER BY' => 'page_id', 'LIMIT' => $queryLimit ),
- array( 'page' => array( 'INNER JOIN', "$fromCol = page_id" ) )
+ [ 'ORDER BY' => 'page_id', 'LIMIT' => $queryLimit ],
+ [ 'page' => [ 'INNER JOIN', "$fromCol = page_id" ] ]
);
};
}
protected function listStart( $level ) {
- return Xml::openElement( 'ul', ( $level ? array() : array( 'id' => 'mw-whatlinkshere-list' ) ) );
+ return Xml::openElement( 'ul', ( $level ? [] : [ 'id' => 'mw-whatlinkshere-list' ] ) );
}
protected function listItem( $row, $nt, $target, $notClose = false ) {
# local message cache
static $msgcache = null;
if ( $msgcache === null ) {
- static $msgs = array( 'isredirect', 'istemplate', 'semicolon-separator',
- 'whatlinkshere-links', 'isimage', 'editlink' );
- $msgcache = array();
+ static $msgs = [ 'isredirect', 'istemplate', 'semicolon-separator',
+ 'whatlinkshere-links', 'isimage', 'editlink' ];
+ $msgcache = [];
foreach ( $msgs as $msg ) {
$msgcache[$msg] = $this->msg( $msg )->escaped();
}
}
if ( $row->rd_from ) {
- $query = array( 'redirect' => 'no' );
+ $query = [ 'redirect' => 'no' ];
} else {
- $query = array();
+ $query = [];
}
$link = Linker::linkKnown(
$nt,
null,
- $row->page_is_redirect ? array( 'class' => 'mw-redirect' ) : array(),
+ $row->page_is_redirect ? [ 'class' => 'mw-redirect' ] : [],
$query
);
// Display properties (redirect or template)
$propsText = '';
- $props = array();
+ $props = [];
if ( $row->rd_from ) {
$props[] = $msgcache['isredirect'];
}
$props[] = $msgcache['isimage'];
}
- Hooks::run( 'WhatLinksHereProps', array( $row, $nt, $target, &$props ) );
+ Hooks::run( 'WhatLinksHereProps', [ $row, $nt, $target, &$props ] );
if ( count( $props ) ) {
$propsText = $this->msg( 'parentheses' )
}
// always show a "<- Links" link
- $links = array(
+ $links = [
'links' => Linker::linkKnown(
$title,
$text,
- array(),
- array( 'target' => $target->getPrefixedText() )
+ [],
+ [ 'target' => $target->getPrefixedText() ]
),
- );
+ ];
// if the page is editable, add an edit link
if (
$links['edit'] = Linker::linkKnown(
$target,
$editText,
- array(),
- array( 'action' => 'edit' )
+ [],
+ [ 'action' => 'edit' ]
);
}
return Linker::linkKnown(
$this->selfTitle,
$text,
- array(),
+ [],
$query
);
}
unset( $changed['target'] ); // Already in the request title
if ( 0 != $prevId ) {
- $overrides = array( 'from' => $this->opts->getValue( 'back' ) );
+ $overrides = [ 'from' => $this->opts->getValue( 'back' ) ];
$prev = $this->makeSelfLink( $prev, array_merge( $changed, $overrides ) );
}
if ( 0 != $nextId ) {
- $overrides = array( 'from' => $nextId, 'back' => $prevId );
+ $overrides = [ 'from' => $nextId, 'back' => $prevId ];
$next = $this->makeSelfLink( $next, array_merge( $changed, $overrides ) );
}
- $limitLinks = array();
+ $limitLinks = [];
$lang = $this->getLanguage();
foreach ( $this->limits as $limit ) {
$prettyLimit = htmlspecialchars( $lang->formatNum( $limit ) );
- $overrides = array( 'limit' => $limit );
+ $overrides = [ 'limit' => $limit ];
$limitLinks[] = $this->makeSelfLink( $prettyLimit, array_merge( $changed, $overrides ) );
}
// We get nicer value from the title object
$this->opts->consumeValue( 'target' );
// Reset these for new requests
- $this->opts->consumeValues( array( 'back', 'from' ) );
+ $this->opts->consumeValues( [ 'back', 'from' ] );
$target = $this->target ? $this->target->getPrefixedText() : '';
$namespace = $this->opts->consumeValue( 'namespace' );
$nsinvert = $this->opts->consumeValue( 'invert' );
# Build up the form
- $f = Xml::openElement( 'form', array( 'action' => wfScript() ) );
+ $f = Xml::openElement( 'form', [ 'action' => wfScript() ] );
# Values that should not be forgotten
$f .= Html::hidden( 'title', $this->getPageTitle()->getPrefixedText() );
# Target input (.mw-searchInput enables suggestions)
$f .= Xml::inputLabel( $this->msg( 'whatlinkshere-page' )->text(), 'target',
- 'mw-whatlinkshere-target', 40, $target, array( 'class' => 'mw-searchInput' ) );
+ 'mw-whatlinkshere-target', 40, $target, [ 'class' => 'mw-searchInput' ] );
$f .= ' ';
# Namespace selector
$f .= Html::namespaceSelector(
- array(
+ [
'selected' => $namespace,
'all' => '',
'label' => $this->msg( 'namespace' )->text()
- ), array(
+ ], [
'name' => 'namespace',
'id' => 'namespace',
'class' => 'namespaceselector',
- )
+ ]
);
$f .= ' ' .
'invert',
'nsinvert',
$nsinvert,
- array( 'title' => $this->msg( 'tooltip-whatlinkshere-invert' )->text() )
+ [ 'title' => $this->msg( 'tooltip-whatlinkshere-invert' )->text() ]
);
$f .= ' ';
$changed = $this->opts->getChangedValues();
unset( $changed['target'] ); // Already in the request title
- $links = array();
- $types = array( 'hidetrans', 'hidelinks', 'hideredirs' );
+ $links = [];
+ $types = [ 'hidetrans', 'hidelinks', 'hideredirs' ];
if ( $this->target->getNamespace() == NS_FILE ) {
$types[] = 'hideimages';
}
foreach ( $types as $type ) {
$chosen = $this->opts->getValue( $type );
$msg = $chosen ? $show : $hide;
- $overrides = array( $type => !$chosen );
+ $overrides = [ $type => !$chosen ];
$links[] = $this->msg( "whatlinkshere-{$type}" )->rawParams(
$this->makeSelfLink( $msg, array_merge( $changed, $overrides ) ) )->escaped();
}
* @return string[] Matching subpages
*/
public function prefixSearchSubpages( $search, $limit, $offset ) {
- $title = Title::newFromText( $search );
- if ( !$title || !$title->canExist() ) {
- // No prefix suggestion in special and media namespace
- return array();
- }
- // Autocomplete subpage the same as a normal search
- $prefixSearcher = new StringPrefixSearch;
- $result = $prefixSearcher->search( $search, $limit, array(), $offset );
- return $result;
+ return $this->prefixSearchString( $search, $limit, $offset );
}
protected function getGroupName() {