X-Git-Url: https://scripts.mit.edu/gitweb/autoinstallsdev/mediawiki.git/blobdiff_plain/19e297c21b10b1b8a3acad5e73fc71dcb35db44a..6932310fd58ebef145fa01eb76edf7150284d8ea:/includes/specials/pagers/CategoryPager.php diff --git a/includes/specials/pagers/CategoryPager.php b/includes/specials/pagers/CategoryPager.php new file mode 100644 index 00000000..7db90c17 --- /dev/null +++ b/includes/specials/pagers/CategoryPager.php @@ -0,0 +1,115 @@ +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 ); + } + +}