* @param array $until An array with 3 keys for until of each section (since 1.17)
* @param array $query
*/
- function __construct( $title, IContextSource $context, $from = array(),
- $until = array(), $query = array()
+ function __construct( $title, IContextSource $context, $from = [],
+ $until = [], $query = []
) {
$this->title = $title;
$this->setContext( $context );
- $this->getOutput()->addModuleStyles( array(
+ $this->getOutput()->addModuleStyles( [
'mediawiki.action.view.categoryPage.styles'
- ) );
+ ] );
$this->from = $from;
$this->until = $until;
$this->limit = $context->getConfig()->get( 'CategoryPagingLimit' );
}
$lang = $this->getLanguage();
- $langAttribs = array( 'lang' => $lang->getHtmlCode(), 'dir' => $lang->getDir() );
+ $attribs = [
+ 'class' => 'mw-category-generated',
+ 'lang' => $lang->getHtmlCode(),
+ 'dir' => $lang->getDir()
+ ];
# put a div around the headings which are in the user language
- $r = Html::openElement( 'div', $langAttribs ) . $r . '</div>';
+ $r = Html::openElement( 'div', $attribs ) . $r . '</div>';
return $r;
}
function clearCategoryState() {
- $this->articles = array();
- $this->articles_start_char = array();
- $this->children = array();
- $this->children_start_char = array();
+ $this->articles = [];
+ $this->articles_start_char = [];
+ $this->children = [];
+ $this->children_start_char = [];
if ( $this->showGallery ) {
// Note that null for mode is taken to mean use default.
$mode = $this->getRequest()->getVal( 'gallerymode', null );
$this->gallery->setHideBadImages();
} else {
- $this->imgsNoGallery = array();
- $this->imgsNoGallery_start_char = array();
+ $this->imgsNoGallery = [];
+ $this->imgsNoGallery_start_char = [];
}
}
function generateLink( $type, Title $title, $isRedirect, $html = null ) {
$link = null;
- Hooks::run( 'CategoryViewer::generateLink', array( $type, $title, $html, &$link ) );
+ Hooks::run( 'CategoryViewer::generateLink', [ $type, $title, $html, &$link ] );
if ( $link === null ) {
$link = Linker::link( $title, $html );
}
function doCategoryQuery() {
$dbr = wfGetDB( DB_SLAVE, 'category' );
- $this->nextPage = array(
+ $this->nextPage = [
'page' => null,
'subcat' => null,
'file' => null,
- );
- $this->prevPage = array(
+ ];
+ $this->prevPage = [
'page' => null,
'subcat' => null,
'file' => null,
- );
+ ];
- $this->flip = array( 'page' => false, 'subcat' => false, 'file' => false );
+ $this->flip = [ 'page' => false, 'subcat' => false, 'file' => false ];
- foreach ( array( 'page', 'subcat', 'file' ) as $type ) {
+ foreach ( [ 'page', 'subcat', 'file' ] as $type ) {
# Get the sortkeys for start/end, if applicable. Note that if
# the collation in the database differs from the one
# set in $wgCategoryCollation, pagination might go totally haywire.
- $extraConds = array( 'cl_type' => $type );
+ $extraConds = [ 'cl_type' => $type ];
if ( isset( $this->from[$type] ) && $this->from[$type] !== null ) {
$extraConds[] = 'cl_sortkey >= '
. $dbr->addQuotes( $this->collation->getSortKey( $this->from[$type] ) );
}
$res = $dbr->select(
- array( 'page', 'categorylinks', 'category' ),
- array( 'page_id', 'page_title', 'page_namespace', 'page_len',
+ [ 'page', 'categorylinks', 'category' ],
+ [ 'page_id', 'page_title', 'page_namespace', 'page_len',
'page_is_redirect', 'cl_sortkey', 'cat_id', 'cat_title',
'cat_subcats', 'cat_pages', 'cat_files',
- 'cl_sortkey_prefix', 'cl_collation' ),
- array_merge( array( 'cl_to' => $this->title->getDBkey() ), $extraConds ),
+ 'cl_sortkey_prefix', 'cl_collation' ],
+ array_merge( [ 'cl_to' => $this->title->getDBkey() ], $extraConds ),
__METHOD__,
- array(
- 'USE INDEX' => array( 'categorylinks' => 'cl_sortkey' ),
+ [
+ 'USE INDEX' => [ 'categorylinks' => 'cl_sortkey' ],
'LIMIT' => $this->limit + 1,
'ORDER BY' => $this->flip[$type] ? 'cl_sortkey DESC' : 'cl_sortkey',
- ),
- array(
- 'categorylinks' => array( 'INNER JOIN', 'cl_from = page_id' ),
- 'category' => array( 'LEFT JOIN', array(
+ ],
+ [
+ 'categorylinks' => [ 'INNER JOIN', 'cl_from = page_id' ],
+ 'category' => [ 'LEFT JOIN', [
'cat_title = page_title',
'page_namespace' => NS_CATEGORY
- ) )
- )
+ ] ]
+ ]
);
- Hooks::run( 'CategoryViewer::doCategoryQuery', array( $type, $res ) );
+ Hooks::run( 'CategoryViewer::doCategoryQuery', [ $type, $res ] );
$count = 0;
foreach ( $res as $row ) {
$r = '';
$rescnt = count( $this->children );
$dbcnt = $this->cat->getSubcatCount();
+ // This function should be called even if the result isn't used, it has side-effects
$countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'subcat' );
if ( $rescnt > 0 ) {
$dbcnt = $this->cat->getPageCount() - $this->cat->getSubcatCount()
- $this->cat->getFileCount();
$rescnt = count( $this->articles );
+ // This function should be called even if the result isn't used, it has side-effects
$countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'article' );
if ( $rescnt > 0 ) {
function getImageSection() {
$r = '';
$rescnt = $this->showGallery ? $this->gallery->count() : count( $this->imgsNoGallery );
- if ( $rescnt > 0 ) {
- $dbcnt = $this->cat->getFileCount();
- $countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'file' );
+ $dbcnt = $this->cat->getFileCount();
+ // This function should be called even if the result isn't used, it has side-effects
+ $countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'file' );
+ if ( $rescnt > 0 ) {
$r .= "<div id=\"mw-category-media\">\n";
$r .= '<h2>' .
$this->msg(
}
$pageLang = $this->title->getPageLanguage();
- $attribs = array( 'lang' => $pageLang->getHtmlCode(), 'dir' => $pageLang->getDir(),
- 'class' => 'mw-content-' . $pageLang->getDir() );
+ $attribs = [ 'lang' => $pageLang->getHtmlCode(), 'dir' => $pageLang->getDir(),
+ 'class' => 'mw-content-' . $pageLang->getDir() ];
$list = Html::rawElement( 'div', $attribs, $list );
return $list;
static function columnList( $articles, $articles_start_char ) {
$columns = array_combine( $articles, $articles_start_char );
- $ret = Html::openElement( 'div', array( 'class' => 'mw-category' ) );
+ $ret = Html::openElement( 'div', [ 'class' => 'mw-category' ] );
- $colContents = array();
+ $colContents = [];
# Kind of like array_flip() here, but we keep duplicates in an
# array instead of dropping them.
foreach ( $columns as $article => $char ) {
if ( !isset( $colContents[$char] ) ) {
- $colContents[$char] = array();
+ $colContents[$char] = [];
}
$colContents[$char][] = $article;
}
$prevLink = Linker::linkKnown(
$this->addFragmentToTitle( $this->title, $type ),
$prevLink,
- array(),
+ [],
$prevQuery
);
}
$nextLink = Linker::linkKnown(
$this->addFragmentToTitle( $this->title, $type ),
$nextLink,
- array(),
+ [],
$lastQuery
);
}