protected function outputHTMLForm( $namespace = NS_MAIN,
$from = '', $to = '', $hideRedirects = false
) {
- $fields = array(
- 'from' => array(
+ $fields = [
+ 'from' => [
'type' => 'text',
'name' => 'from',
'id' => 'nsfrom',
'size' => 30,
'label-message' => 'allpagesfrom',
'default' => str_replace( '_', ' ', $from ),
- ),
- 'to' => array(
+ ],
+ 'to' => [
'type' => 'text',
'name' => 'to',
'id' => 'nsto',
'size' => 30,
'label-message' => 'allpagesto',
'default' => str_replace( '_', ' ', $to ),
- ),
- 'namespace' => array(
+ ],
+ 'namespace' => [
'type' => 'namespaceselect',
'name' => 'namespace',
'id' => 'namespace',
'label-message' => 'namespace',
'all' => null,
'value' => $namespace,
- ),
- 'hideredirects' => array(
+ ],
+ 'hideredirects' => [
'type' => 'check',
'name' => 'hideredirects',
'id' => 'hidredirects',
'label-message' => 'allpages-hide-redirects',
'value' => $hideRedirects,
- ),
- );
+ ],
+ ];
$form = HTMLForm::factory( 'table', $fields, $this->getContext() );
$form->setMethod( 'get' )
->setWrapperLegendMsg( 'allpages' )
list( $namespace, $fromKey, $from ) = $fromList;
list( , $toKey, $to ) = $toList;
- $dbr = wfGetDB( DB_SLAVE );
- $filterConds = array( 'page_namespace' => $namespace );
+ $dbr = wfGetDB( DB_REPLICA );
+ $filterConds = [ 'page_namespace' => $namespace ];
if ( $hideredirects ) {
$filterConds['page_is_redirect'] = 0;
}
}
$res = $dbr->select( 'page',
- array( 'page_namespace', 'page_title', 'page_is_redirect', 'page_id' ),
+ [ 'page_namespace', 'page_title', 'page_is_redirect', 'page_id' ],
$conds,
__METHOD__,
- array(
+ [
'ORDER BY' => 'page_title',
'LIMIT' => $this->maxPerPage + 1,
'USE INDEX' => 'name_title',
- )
+ ]
);
+ $linkRenderer = $this->getLinkRenderer();
if ( $res->numRows() > 0 ) {
- $out = Html::openElement( 'ul', array( 'class' => 'mw-allpages-chunk' ) );
+ $out = Html::openElement( 'ul', [ 'class' => 'mw-allpages-chunk' ] );
while ( ( $n < $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) {
$t = Title::newFromRow( $s );
$out .= '<li' .
( $s->page_is_redirect ? ' class="allpagesredirect"' : '' ) .
'>' .
- Linker::link( $t ) .
+ $linkRenderer->makeLink( $t ) .
"</li>\n";
} else {
$out .= '<li>[[' . htmlspecialchars( $s->page_title ) . "]]</li>\n";
if ( $res->numRows() > 2 ) {
// Only apply CSS column styles if there's more than 2 entries.
// Otherwise, rendering is broken as "mw-allpages-body"'s CSS column count is 3.
- $out = Html::rawElement( 'div', array( 'class' => 'mw-allpages-body' ), $out );
+ $out = Html::rawElement( 'div', [ 'class' => 'mw-allpages-body' ], $out );
}
} else {
$out = '';
'page_title',
$prevConds,
__METHOD__,
- array( 'ORDER BY' => 'page_title DESC', 'OFFSET' => $this->maxPerPage - 1 )
+ [ 'ORDER BY' => 'page_title DESC', 'OFFSET' => $this->maxPerPage - 1 ]
);
if ( $prevKey === false ) {
'page_title',
$prevConds,
__METHOD__,
- array( 'ORDER BY' => 'page_title' )
+ [ 'ORDER BY' => 'page_title' ]
);
}
return;
}
- $navLinks = array();
+ $navLinks = [];
$self = $this->getPageTitle();
+ $linkRenderer = $this->getLinkRenderer();
// Generate a "previous page" link if needed
if ( $prevTitle ) {
- $query = array( 'from' => $prevTitle->getText() );
+ $query = [ 'from' => $prevTitle->getText() ];
if ( $namespace ) {
$query['namespace'] = $namespace;
$query['hideredirects'] = $hideredirects;
}
- $navLinks[] = Linker::linkKnown(
+ $navLinks[] = $linkRenderer->makeKnownLink(
$self,
- $this->msg( 'prevpage', $prevTitle->getText() )->escaped(),
- array(),
+ $this->msg( 'prevpage', $prevTitle->getText() )->text(),
+ [],
$query
);
if ( $n == $this->maxPerPage && $s = $res->fetchObject() ) {
# $s is the first link of the next chunk
$t = Title::makeTitle( $namespace, $s->page_title );
- $query = array( 'from' => $t->getText() );
+ $query = [ 'from' => $t->getText() ];
if ( $namespace ) {
$query['namespace'] = $namespace;
$query['hideredirects'] = $hideredirects;
}
- $navLinks[] = Linker::linkKnown(
+ $navLinks[] = $linkRenderer->makeKnownLink(
$self,
- $this->msg( 'nextpage', $t->getText() )->escaped(),
- array(),
+ $this->msg( 'nextpage', $t->getText() )->text(),
+ [],
$query
);
}
if ( count( $navLinks ) ) {
// Add pagination links
$pagination = Html::rawElement( 'div',
- array( 'class' => 'mw-allpages-nav' ),
+ [ 'class' => 'mw-allpages-nav' ],
$this->getLanguage()->pipeList( $navLinks )
);
protected function getNamespaceKeyAndText( $ns, $text ) {
if ( $text == '' ) {
# shortcut for common case
- return array( $ns, '', '' );
+ return [ $ns, '', '' ];
}
$t = Title::makeTitleSafe( $ns, $text );
if ( $t && $t->isLocal() ) {
- return array( $t->getNamespace(), $t->getDBkey(), $t->getText() );
+ return [ $t->getNamespace(), $t->getDBkey(), $t->getText() ];
} elseif ( $t ) {
return null;
}
$text = preg_replace( '/(#|$)/', 'X$1', $text );
$t = Title::makeTitleSafe( $ns, $text );
if ( $t && $t->isLocal() ) {
- return array( $t->getNamespace(), '', '' );
+ return [ $t->getNamespace(), '', '' ];
} else {
return null;
}
* @return string[] Matching subpages
*/
public function prefixSearchSubpages( $search, $limit, $offset ) {
- if ( $search === '' ) {
- 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() {