Expose $wgMaxArticleSize in siteinfo query api
[mediawiki.git] / includes / specials / pagers / CategoryPager.php
blobb78fed89d5701c884de30af76d37c382516bbbb7
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
18 * @file
19 * @ingroup Pager
21 use MediaWiki\Linker\LinkRenderer;
23 /**
24 * @ingroup Pager
26 class CategoryPager extends AlphabeticPager {
28 /**
29 * @var LinkRenderer
31 protected $linkRenderer;
33 /**
34 * @param IContextSource $context
35 * @param string $from
36 * @param LinkRenderer $linkRenderer
38 public function __construct( IContextSource $context, $from, LinkRenderer $linkRenderer
39 ) {
40 parent::__construct( $context );
41 $from = str_replace( ' ', '_', $from );
42 if ( $from !== '' ) {
43 $from = Title::capitalize( $from, NS_CATEGORY );
44 $this->setOffset( $from );
45 $this->setIncludeOffset( true );
48 $this->linkRenderer = $linkRenderer;
51 function getQueryInfo() {
52 return [
53 'tables' => [ 'category' ],
54 'fields' => [ 'cat_title', 'cat_pages' ],
55 'conds' => [ 'cat_pages > 0' ],
56 'options' => [ 'USE INDEX' => 'cat_title' ],
60 function getIndexField() {
61 return 'cat_title';
64 function getDefaultQuery() {
65 parent::getDefaultQuery();
66 unset( $this->mDefaultQuery['from'] );
68 return $this->mDefaultQuery;
71 /* Override getBody to apply LinksBatch on resultset before actually outputting anything. */
72 public function getBody() {
73 $batch = new LinkBatch;
75 $this->mResult->rewind();
77 foreach ( $this->mResult as $row ) {
78 $batch->addObj( new TitleValue( NS_CATEGORY, $row->cat_title ) );
80 $batch->execute();
81 $this->mResult->rewind();
83 return parent::getBody();
86 function formatRow( $result ) {
87 $title = new TitleValue( NS_CATEGORY, $result->cat_title );
88 $text = $title->getText();
89 $link = $this->linkRenderer->makeLink( $title, $text );
91 $count = $this->msg( 'nmembers' )->numParams( $result->cat_pages )->escaped();
92 return Html::rawElement( 'li', null, $this->getLanguage()->specialList( $link, $count ) ) . "\n";
95 public function getStartForm( $from ) {
96 return Xml::tags(
97 'form',
98 [ 'method' => 'get', 'action' => wfScript() ],
99 Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
100 Xml::fieldset(
101 $this->msg( 'categories' )->text(),
102 Xml::inputLabel(
103 $this->msg( 'categoriesfrom' )->text(),
104 'from', 'from', 20, $from, [ 'class' => 'mw-ui-input-inline' ] ) .
105 ' ' .
106 Html::submitButton(
107 $this->msg( 'categories-submit' )->text(),
108 [], [ 'mw-ui-progressive' ]