setOffset( $from ); $this->setIncludeOffset( true ); } $this->linkRenderer = $linkRenderer; } function getQueryInfo() { return [ 'tables' => [ 'category' ], 'fields' => [ 'cat_title', 'cat_pages' ], 'conds' => [ 'cat_pages > 0' ], 'options' => [ 'USE INDEX' => 'cat_title' ], ]; } function getIndexField() { return 'cat_title'; } function getDefaultQuery() { parent::getDefaultQuery(); unset( $this->mDefaultQuery['from'] ); return $this->mDefaultQuery; } /* Override getBody to apply LinksBatch on resultset before actually outputting anything. */ public function getBody() { $batch = new LinkBatch; $this->mResult->rewind(); foreach ( $this->mResult as $row ) { $batch->addObj( Title::makeTitleSafe( NS_CATEGORY, $row->cat_title ) ); } $batch->execute(); $this->mResult->rewind(); return parent::getBody(); } function formatRow( $result ) { $title = new TitleValue( NS_CATEGORY, $result->cat_title ); $text = $title->getText(); $link = $this->linkRenderer->renderHtmlLink( $title, $text ); $count = $this->msg( 'nmembers' )->numParams( $result->cat_pages )->escaped(); return Html::rawElement( 'li', null, $this->getLanguage()->specialList( $link, $count ) ) . "\n"; } public function getStartForm( $from ) { return Xml::tags( 'form', [ 'method' => 'get', 'action' => wfScript() ], Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . Xml::fieldset( $this->msg( 'categories' )->text(), Xml::inputLabel( $this->msg( 'categoriesfrom' )->text(), 'from', 'from', 20, $from, [ 'class' => 'mw-ui-input-inline' ] ) . ' ' . Html::submitButton( $this->msg( 'categories-submit' )->text(), [], [ 'mw-ui-progressive' ] ) ) ); } }