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