Merge changes Ic13414f0,I26085bfc
[lhc/web/wiklou.git] / includes / CategoryViewer.php
1 <?php
2 /**
3 * List and paging of category members.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 */
22
23 class CategoryViewer extends ContextSource {
24 var $limit, $from, $until,
25 $articles, $articles_start_char,
26 $children, $children_start_char,
27 $showGallery, $imgsNoGalley,
28 $imgsNoGallery_start_char,
29 $imgsNoGallery;
30
31 /**
32 * @var Array
33 */
34 var $nextPage;
35
36 /**
37 * @var Array
38 */
39 var $flip;
40
41 /**
42 * @var Title
43 */
44 var $title;
45
46 /**
47 * @var Collation
48 */
49 var $collation;
50
51 /**
52 * @var ImageGallery
53 */
54 var $gallery;
55
56 /**
57 * Category object for this page
58 * @var Category
59 */
60 private $cat;
61
62 /**
63 * The original query array, to be used in generating paging links.
64 * @var array
65 */
66 private $query;
67
68 /**
69 * Constructor
70 *
71 * @since 1.19 $context is a second, required parameter
72 * @param $title Title
73 * @param $context IContextSource
74 * @param array $from An array with keys page, subcat,
75 * and file for offset of results of each section (since 1.17)
76 * @param array $until An array with 3 keys for until of each section (since 1.17)
77 * @param $query Array
78 */
79 function __construct( $title, IContextSource $context, $from = array(), $until = array(), $query = array() ) {
80 global $wgCategoryPagingLimit;
81 $this->title = $title;
82 $this->setContext( $context );
83 $this->from = $from;
84 $this->until = $until;
85 $this->limit = $wgCategoryPagingLimit;
86 $this->cat = Category::newFromTitle( $title );
87 $this->query = $query;
88 $this->collation = Collation::singleton();
89 unset( $this->query['title'] );
90 }
91
92 /**
93 * Format the category data list.
94 *
95 * @return string HTML output
96 */
97 public function getHTML() {
98 global $wgCategoryMagicGallery;
99 wfProfileIn( __METHOD__ );
100
101 $this->showGallery = $wgCategoryMagicGallery && !$this->getOutput()->mNoGallery;
102
103 $this->clearCategoryState();
104 $this->doCategoryQuery();
105 $this->finaliseCategoryState();
106
107 $r = $this->getSubcategorySection() .
108 $this->getPagesSection() .
109 $this->getImageSection();
110
111 if ( $r == '' ) {
112 // If there is no category content to display, only
113 // show the top part of the navigation links.
114 // @todo FIXME: Cannot be completely suppressed because it
115 // is unknown if 'until' or 'from' makes this
116 // give 0 results.
117 $r = $r . $this->getCategoryTop();
118 } else {
119 $r = $this->getCategoryTop() .
120 $r .
121 $this->getCategoryBottom();
122 }
123
124 // Give a proper message if category is empty
125 if ( $r == '' ) {
126 $r = $this->msg( 'category-empty' )->parseAsBlock();
127 }
128
129 $lang = $this->getLanguage();
130 $langAttribs = array( 'lang' => $lang->getCode(), 'dir' => $lang->getDir() );
131 # put a div around the headings which are in the user language
132 $r = Html::openElement( 'div', $langAttribs ) . $r . '</div>';
133
134 wfProfileOut( __METHOD__ );
135 return $r;
136 }
137
138 function clearCategoryState() {
139 $this->articles = array();
140 $this->articles_start_char = array();
141 $this->children = array();
142 $this->children_start_char = array();
143 if ( $this->showGallery ) {
144 // Note that null for mode is taken to mean use default.
145 $mode = $this->getRequest()->getVal( 'gallerymode', null );
146 try {
147 $this->gallery = ImageGalleryBase::factory( $mode );
148 } catch ( MWException $e ) {
149 // User specified something invalid, fallback to default.
150 $this->gallery = ImageGalleryBase::factory();
151 }
152
153 $this->gallery->setHideBadImages();
154 $this->gallery->setContext( $this->getContext() );
155 } else {
156 $this->imgsNoGallery = array();
157 $this->imgsNoGallery_start_char = array();
158 }
159 }
160
161 /**
162 * Add a subcategory to the internal lists, using a Category object
163 * @param $cat Category
164 * @param $sortkey
165 * @param $pageLength
166 */
167 function addSubcategoryObject( Category $cat, $sortkey, $pageLength ) {
168 // Subcategory; strip the 'Category' namespace from the link text.
169 $title = $cat->getTitle();
170
171 $link = Linker::link( $title, htmlspecialchars( $title->getText() ) );
172 if ( $title->isRedirect() ) {
173 // This didn't used to add redirect-in-category, but might
174 // as well be consistent with the rest of the sections
175 // on a category page.
176 $link = '<span class="redirect-in-category">' . $link . '</span>';
177 }
178 $this->children[] = $link;
179
180 $this->children_start_char[] =
181 $this->getSubcategorySortChar( $cat->getTitle(), $sortkey );
182 }
183
184 /**
185 * Add a subcategory to the internal lists, using a title object
186 * @deprecated since 1.17 kept for compatibility, use addSubcategoryObject instead
187 */
188 function addSubcategory( Title $title, $sortkey, $pageLength ) {
189 wfDeprecated( __METHOD__, '1.17' );
190 $this->addSubcategoryObject( Category::newFromTitle( $title ), $sortkey, $pageLength );
191 }
192
193 /**
194 * Get the character to be used for sorting subcategories.
195 * If there's a link from Category:A to Category:B, the sortkey of the resulting
196 * entry in the categorylinks table is Category:A, not A, which it SHOULD be.
197 * Workaround: If sortkey == "Category:".$title, than use $title for sorting,
198 * else use sortkey...
199 *
200 * @param Title $title
201 * @param string $sortkey The human-readable sortkey (before transforming to icu or whatever).
202 * @return string
203 */
204 function getSubcategorySortChar( $title, $sortkey ) {
205 global $wgContLang;
206
207 if ( $title->getPrefixedText() == $sortkey ) {
208 $word = $title->getDBkey();
209 } else {
210 $word = $sortkey;
211 }
212
213 $firstChar = $this->collation->getFirstLetter( $word );
214
215 return $wgContLang->convert( $firstChar );
216 }
217
218 /**
219 * Add a page in the image namespace
220 * @param $title Title
221 * @param $sortkey
222 * @param $pageLength
223 * @param $isRedirect bool
224 */
225 function addImage( Title $title, $sortkey, $pageLength, $isRedirect = false ) {
226 global $wgContLang;
227 if ( $this->showGallery ) {
228 $flip = $this->flip['file'];
229 if ( $flip ) {
230 $this->gallery->insert( $title );
231 } else {
232 $this->gallery->add( $title );
233 }
234 } else {
235 $link = Linker::link( $title );
236 if ( $isRedirect ) {
237 // This seems kind of pointless given 'mw-redirect' class,
238 // but keeping for back-compatibility with user css.
239 $link = '<span class="redirect-in-category">' . $link . '</span>';
240 }
241 $this->imgsNoGallery[] = $link;
242
243 $this->imgsNoGallery_start_char[] = $wgContLang->convert(
244 $this->collation->getFirstLetter( $sortkey ) );
245 }
246 }
247
248 /**
249 * Add a miscellaneous page
250 * @param $title
251 * @param $sortkey
252 * @param $pageLength
253 * @param $isRedirect bool
254 */
255 function addPage( $title, $sortkey, $pageLength, $isRedirect = false ) {
256 global $wgContLang;
257
258 $link = Linker::link( $title );
259 if ( $isRedirect ) {
260 // This seems kind of pointless given 'mw-redirect' class,
261 // but keeping for back-compatibility with user css.
262 $link = '<span class="redirect-in-category">' . $link . '</span>';
263 }
264 $this->articles[] = $link;
265
266 $this->articles_start_char[] = $wgContLang->convert(
267 $this->collation->getFirstLetter( $sortkey ) );
268 }
269
270 function finaliseCategoryState() {
271 if ( $this->flip['subcat'] ) {
272 $this->children = array_reverse( $this->children );
273 $this->children_start_char = array_reverse( $this->children_start_char );
274 }
275 if ( $this->flip['page'] ) {
276 $this->articles = array_reverse( $this->articles );
277 $this->articles_start_char = array_reverse( $this->articles_start_char );
278 }
279 if ( !$this->showGallery && $this->flip['file'] ) {
280 $this->imgsNoGallery = array_reverse( $this->imgsNoGallery );
281 $this->imgsNoGallery_start_char = array_reverse( $this->imgsNoGallery_start_char );
282 }
283 }
284
285 function doCategoryQuery() {
286 $dbr = wfGetDB( DB_SLAVE, 'category' );
287
288 $this->nextPage = array(
289 'page' => null,
290 'subcat' => null,
291 'file' => null,
292 );
293 $this->flip = array( 'page' => false, 'subcat' => false, 'file' => false );
294
295 foreach ( array( 'page', 'subcat', 'file' ) as $type ) {
296 # Get the sortkeys for start/end, if applicable. Note that if
297 # the collation in the database differs from the one
298 # set in $wgCategoryCollation, pagination might go totally haywire.
299 $extraConds = array( 'cl_type' => $type );
300 if ( isset( $this->from[$type] ) && $this->from[$type] !== null ) {
301 $extraConds[] = 'cl_sortkey >= '
302 . $dbr->addQuotes( $this->collation->getSortKey( $this->from[$type] ) );
303 } elseif ( isset( $this->until[$type] ) && $this->until[$type] !== null ) {
304 $extraConds[] = 'cl_sortkey < '
305 . $dbr->addQuotes( $this->collation->getSortKey( $this->until[$type] ) );
306 $this->flip[$type] = true;
307 }
308
309 $res = $dbr->select(
310 array( 'page', 'categorylinks', 'category' ),
311 array( 'page_id', 'page_title', 'page_namespace', 'page_len',
312 'page_is_redirect', 'cl_sortkey', 'cat_id', 'cat_title',
313 'cat_subcats', 'cat_pages', 'cat_files',
314 'cl_sortkey_prefix', 'cl_collation' ),
315 array_merge( array( 'cl_to' => $this->title->getDBkey() ), $extraConds ),
316 __METHOD__,
317 array(
318 'USE INDEX' => array( 'categorylinks' => 'cl_sortkey' ),
319 'LIMIT' => $this->limit + 1,
320 'ORDER BY' => $this->flip[$type] ? 'cl_sortkey DESC' : 'cl_sortkey',
321 ),
322 array(
323 'categorylinks' => array( 'INNER JOIN', 'cl_from = page_id' ),
324 'category' => array( 'LEFT JOIN', array(
325 'cat_title = page_title',
326 'page_namespace' => NS_CATEGORY
327 ))
328 )
329 );
330
331 $count = 0;
332 foreach ( $res as $row ) {
333 $title = Title::newFromRow( $row );
334 if ( $row->cl_collation === '' ) {
335 // Hack to make sure that while updating from 1.16 schema
336 // and db is inconsistent, that the sky doesn't fall.
337 // See r83544. Could perhaps be removed in a couple decades...
338 $humanSortkey = $row->cl_sortkey;
339 } else {
340 $humanSortkey = $title->getCategorySortkey( $row->cl_sortkey_prefix );
341 }
342
343 if ( ++$count > $this->limit ) {
344 # We've reached the one extra which shows that there
345 # are additional pages to be had. Stop here...
346 $this->nextPage[$type] = $humanSortkey;
347 break;
348 }
349
350 if ( $title->getNamespace() == NS_CATEGORY ) {
351 $cat = Category::newFromRow( $row, $title );
352 $this->addSubcategoryObject( $cat, $humanSortkey, $row->page_len );
353 } elseif ( $title->getNamespace() == NS_FILE ) {
354 $this->addImage( $title, $humanSortkey, $row->page_len, $row->page_is_redirect );
355 } else {
356 $this->addPage( $title, $humanSortkey, $row->page_len, $row->page_is_redirect );
357 }
358 }
359 }
360 }
361
362 /**
363 * @return string
364 */
365 function getCategoryTop() {
366 $r = $this->getCategoryBottom();
367 return $r === ''
368 ? $r
369 : "<br style=\"clear:both;\"/>\n" . $r;
370 }
371
372 /**
373 * @return string
374 */
375 function getSubcategorySection() {
376 # Don't show subcategories section if there are none.
377 $r = '';
378 $rescnt = count( $this->children );
379 $dbcnt = $this->cat->getSubcatCount();
380 $countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'subcat' );
381
382 if ( $rescnt > 0 ) {
383 # Showing subcategories
384 $r .= "<div id=\"mw-subcategories\">\n";
385 $r .= '<h2>' . $this->msg( 'subcategories' )->text() . "</h2>\n";
386 $r .= $countmsg;
387 $r .= $this->getSectionPagingLinks( 'subcat' );
388 $r .= $this->formatList( $this->children, $this->children_start_char );
389 $r .= $this->getSectionPagingLinks( 'subcat' );
390 $r .= "\n</div>";
391 }
392 return $r;
393 }
394
395 /**
396 * @return string
397 */
398 function getPagesSection() {
399 $ti = wfEscapeWikiText( $this->title->getText() );
400 # Don't show articles section if there are none.
401 $r = '';
402
403 # @todo FIXME: Here and in the other two sections: we don't need to bother
404 # with this rigmarole if the entire category contents fit on one page
405 # and have already been retrieved. We can just use $rescnt in that
406 # case and save a query and some logic.
407 $dbcnt = $this->cat->getPageCount() - $this->cat->getSubcatCount()
408 - $this->cat->getFileCount();
409 $rescnt = count( $this->articles );
410 $countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'article' );
411
412 if ( $rescnt > 0 ) {
413 $r = "<div id=\"mw-pages\">\n";
414 $r .= '<h2>' . $this->msg( 'category_header', $ti )->text() . "</h2>\n";
415 $r .= $countmsg;
416 $r .= $this->getSectionPagingLinks( 'page' );
417 $r .= $this->formatList( $this->articles, $this->articles_start_char );
418 $r .= $this->getSectionPagingLinks( 'page' );
419 $r .= "\n</div>";
420 }
421 return $r;
422 }
423
424 /**
425 * @return string
426 */
427 function getImageSection() {
428 $r = '';
429 $rescnt = $this->showGallery ? $this->gallery->count() : count( $this->imgsNoGallery );
430 if ( $rescnt > 0 ) {
431 $dbcnt = $this->cat->getFileCount();
432 $countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'file' );
433
434 $r .= "<div id=\"mw-category-media\">\n";
435 $r .= '<h2>' . $this->msg( 'category-media-header', wfEscapeWikiText( $this->title->getText() ) )->text() . "</h2>\n";
436 $r .= $countmsg;
437 $r .= $this->getSectionPagingLinks( 'file' );
438 if ( $this->showGallery ) {
439 $r .= $this->gallery->toHTML();
440 } else {
441 $r .= $this->formatList( $this->imgsNoGallery, $this->imgsNoGallery_start_char );
442 }
443 $r .= $this->getSectionPagingLinks( 'file' );
444 $r .= "\n</div>";
445 }
446 return $r;
447 }
448
449 /**
450 * Get the paging links for a section (subcats/pages/files), to go at the top and bottom
451 * of the output.
452 *
453 * @param string $type 'page', 'subcat', or 'file'
454 * @return String: HTML output, possibly empty if there are no other pages
455 */
456 private function getSectionPagingLinks( $type ) {
457 if ( isset( $this->until[$type] ) && $this->until[$type] !== null ) {
458 return $this->pagingLinks( $this->nextPage[$type], $this->until[$type], $type );
459 } elseif ( $this->nextPage[$type] !== null || ( isset( $this->from[$type] ) && $this->from[$type] !== null ) ) {
460 return $this->pagingLinks( $this->from[$type], $this->nextPage[$type], $type );
461 } else {
462 return '';
463 }
464 }
465
466 /**
467 * @return string
468 */
469 function getCategoryBottom() {
470 return '';
471 }
472
473 /**
474 * Format a list of articles chunked by letter, either as a
475 * bullet list or a columnar format, depending on the length.
476 *
477 * @param $articles Array
478 * @param $articles_start_char Array
479 * @param $cutoff Int
480 * @return String
481 * @private
482 */
483 function formatList( $articles, $articles_start_char, $cutoff = 6 ) {
484 $list = '';
485 if ( count( $articles ) > $cutoff ) {
486 $list = self::columnList( $articles, $articles_start_char );
487 } elseif ( count( $articles ) > 0 ) {
488 // for short lists of articles in categories.
489 $list = self::shortList( $articles, $articles_start_char );
490 }
491
492 $pageLang = $this->title->getPageLanguage();
493 $attribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir(),
494 'class' => 'mw-content-' . $pageLang->getDir() );
495 $list = Html::rawElement( 'div', $attribs, $list );
496
497 return $list;
498 }
499
500 /**
501 * Format a list of articles chunked by letter in a three-column
502 * list, ordered vertically.
503 *
504 * TODO: Take the headers into account when creating columns, so they're
505 * more visually equal.
506 *
507 * More distant TODO: Scrap this and use CSS columns, whenever IE finally
508 * supports those.
509 *
510 * @param $articles Array
511 * @param $articles_start_char Array
512 * @return String
513 * @private
514 */
515 static function columnList( $articles, $articles_start_char ) {
516 $columns = array_combine( $articles, $articles_start_char );
517 # Split into three columns
518 $columns = array_chunk( $columns, ceil( count( $columns ) / 3 ), true /* preserve keys */ );
519
520 $ret = '<table style="width: 100%;"><tr style="vertical-align: top;">';
521 $prevchar = null;
522
523 foreach ( $columns as $column ) {
524 $ret .= '<td style="width: 33.3%;">';
525 $colContents = array();
526
527 # Kind of like array_flip() here, but we keep duplicates in an
528 # array instead of dropping them.
529 foreach ( $column as $article => $char ) {
530 if ( !isset( $colContents[$char] ) ) {
531 $colContents[$char] = array();
532 }
533 $colContents[$char][] = $article;
534 }
535
536 $first = true;
537 foreach ( $colContents as $char => $articles ) {
538 # Change space to non-breaking space to keep headers aligned
539 $h3char = $char === ' ' ? '&#160;' : htmlspecialchars( $char );
540
541 $ret .= '<h3>' . $h3char;
542 if ( $first && $char === $prevchar ) {
543 # We're continuing a previous chunk at the top of a new
544 # column, so add " cont." after the letter.
545 $ret .= ' ' . wfMessage( 'listingcontinuesabbrev' )->escaped();
546 }
547 $ret .= "</h3>\n";
548
549 $ret .= '<ul><li>';
550 $ret .= implode( "</li>\n<li>", $articles );
551 $ret .= '</li></ul>';
552
553 $first = false;
554 $prevchar = $char;
555 }
556
557 $ret .= "</td>\n";
558 }
559
560 $ret .= '</tr></table>';
561 return $ret;
562 }
563
564 /**
565 * Format a list of articles chunked by letter in a bullet list.
566 * @param $articles Array
567 * @param $articles_start_char Array
568 * @return String
569 * @private
570 */
571 static function shortList( $articles, $articles_start_char ) {
572 $r = '<h3>' . htmlspecialchars( $articles_start_char[0] ) . "</h3>\n";
573 $r .= '<ul><li>' . $articles[0] . '</li>';
574 for ( $index = 1; $index < count( $articles ); $index++ ) {
575 if ( $articles_start_char[$index] != $articles_start_char[$index - 1] ) {
576 $r .= "</ul><h3>" . htmlspecialchars( $articles_start_char[$index] ) . "</h3>\n<ul>";
577 }
578
579 $r .= "<li>{$articles[$index]}</li>";
580 }
581 $r .= '</ul>';
582 return $r;
583 }
584
585 /**
586 * Create paging links, as a helper method to getSectionPagingLinks().
587 *
588 * @param string $first The 'until' parameter for the generated URL
589 * @param string $last The 'from' parameter for the generated URL
590 * @param string $type A prefix for parameters, 'page' or 'subcat' or
591 * 'file'
592 * @return String HTML
593 */
594 private function pagingLinks( $first, $last, $type = '' ) {
595 $prevLink = $this->msg( 'prevn' )->numParams( $this->limit )->escaped();
596
597 if ( $first != '' ) {
598 $prevQuery = $this->query;
599 $prevQuery["{$type}until"] = $first;
600 unset( $prevQuery["{$type}from"] );
601 $prevLink = Linker::linkKnown(
602 $this->addFragmentToTitle( $this->title, $type ),
603 $prevLink,
604 array(),
605 $prevQuery
606 );
607 }
608
609 $nextLink = $this->msg( 'nextn' )->numParams( $this->limit )->escaped();
610
611 if ( $last != '' ) {
612 $lastQuery = $this->query;
613 $lastQuery["{$type}from"] = $last;
614 unset( $lastQuery["{$type}until"] );
615 $nextLink = Linker::linkKnown(
616 $this->addFragmentToTitle( $this->title, $type ),
617 $nextLink,
618 array(),
619 $lastQuery
620 );
621 }
622
623 return $this->msg( 'categoryviewer-pagedlinks' )->rawParams( $prevLink, $nextLink )->escaped();
624 }
625
626 /**
627 * Takes a title, and adds the fragment identifier that
628 * corresponds to the correct segment of the category.
629 *
630 * @param Title $title: The title (usually $this->title)
631 * @param string $section: Which section
632 * @throws MWException
633 * @return Title
634 */
635 private function addFragmentToTitle( $title, $section ) {
636 switch ( $section ) {
637 case 'page':
638 $fragment = 'mw-pages';
639 break;
640 case 'subcat':
641 $fragment = 'mw-subcategories';
642 break;
643 case 'file':
644 $fragment = 'mw-category-media';
645 break;
646 default:
647 throw new MWException( __METHOD__ .
648 " Invalid section $section." );
649 }
650
651 return Title::makeTitle( $title->getNamespace(),
652 $title->getDBkey(), $fragment );
653 }
654
655 /**
656 * What to do if the category table conflicts with the number of results
657 * returned? This function says what. Each type is considered independently
658 * of the other types.
659 *
660 * @param int $rescnt The number of items returned by our database query.
661 * @param int $dbcnt The number of items according to the category table.
662 * @param string $type 'subcat', 'article', or 'file'
663 * @return string: A message giving the number of items, to output to HTML.
664 */
665 private function getCountMessage( $rescnt, $dbcnt, $type ) {
666 // There are three cases:
667 // 1) The category table figure seems sane. It might be wrong, but
668 // we can't do anything about it if we don't recalculate it on ev-
669 // ery category view.
670 // 2) The category table figure isn't sane, like it's smaller than the
671 // number of actual results, *but* the number of results is less
672 // than $this->limit and there's no offset. In this case we still
673 // know the right figure.
674 // 3) We have no idea.
675
676 // Check if there's a "from" or "until" for anything
677
678 // This is a little ugly, but we seem to use different names
679 // for the paging types then for the messages.
680 if ( $type === 'article' ) {
681 $pagingType = 'page';
682 } else {
683 $pagingType = $type;
684 }
685
686 $fromOrUntil = false;
687 if ( ( isset( $this->from[$pagingType] ) && $this->from[$pagingType] !== null ) ||
688 ( isset( $this->until[$pagingType] ) && $this->until[$pagingType] !== null )
689 ) {
690 $fromOrUntil = true;
691 }
692
693 if ( $dbcnt == $rescnt ||
694 ( ( $rescnt == $this->limit || $fromOrUntil ) && $dbcnt > $rescnt )
695 ) {
696 // Case 1: seems sane.
697 $totalcnt = $dbcnt;
698 } elseif ( $rescnt < $this->limit && !$fromOrUntil ) {
699 // Case 2: not sane, but salvageable. Use the number of results.
700 // Since there are fewer than 200, we can also take this opportunity
701 // to refresh the incorrect category table entry -- which should be
702 // quick due to the small number of entries.
703 $totalcnt = $rescnt;
704 $this->cat->refreshCounts();
705 } else {
706 // Case 3: hopeless. Don't give a total count at all.
707 // Messages: category-subcat-count-limited, category-article-count-limited,
708 // category-file-count-limited
709 return $this->msg( "category-$type-count-limited" )->numParams( $rescnt )->parseAsBlock();
710 }
711 // Messages: category-subcat-count, category-article-count, category-file-count
712 return $this->msg( "category-$type-count" )->numParams( $rescnt, $totalcnt )->parseAsBlock();
713 }
714 }