setOffset( $from ); $this->setIncludeOffset( true ); } $this->linkRenderer = $linkRenderer; } function getQueryInfo() { return [ 'tables' => [ 'category' ], 'fields' => [ 'cat_title', 'cat_pages' ], '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( new TitleValue( 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->makeLink( $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 ) { $formDescriptor = [ 'from' => [ 'type' => 'title', 'namespace' => NS_CATEGORY, 'relative' => true, 'label-message' => 'categoriesfrom', 'name' => 'from', 'id' => 'from', 'size' => 20, 'default' => $from, ], ]; $htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() ) ->setSubmitTextMsg( 'categories-submit' ) ->setWrapperLegendMsg( 'categories' ) ->setMethod( 'get' ); return $htmlForm->prepareForm()->getHTML( false ); } }