MediaWiki 1.44.0
CategoryViewer.php
Go to the documentation of this file.
1<?php
23namespace MediaWiki\Category;
24
25use Collation;
28use InvalidArgumentException;
32use MediaWiki\Debug\DeprecationHelper;
33use MediaWiki\HookContainer\ProtectedHookAccessorTrait;
46
48 use ProtectedHookAccessorTrait;
49 use DeprecationHelper;
50
52 public $limit;
53
55 public $from;
56
58 public $until;
59
61 public $articles;
62
65
67 public $children;
68
71
74
77
80
82 public $nextPage;
83
85 protected $prevPage;
86
88 public $flip;
89
91 protected $page;
92
94 public $collation;
95
97 public $gallery;
98
100 private $cat;
101
103 private $query;
104
106 private $languageConverter;
107
108 private int $migrationStage;
109
119 public function __construct( PageIdentity $page, IContextSource $context, array $from = [],
120 array $until = [], array $query = []
121 ) {
122 $this->page = $page;
123
124 $this->deprecatePublicPropertyFallback(
125 'title',
126 '1.37',
127 function (): Title {
128 return Title::newFromPageIdentity( $this->page );
129 },
130 function ( PageIdentity $page ) {
131 $this->page = $page;
132 }
133 );
134
135 $this->setContext( $context );
136 $this->getOutput()->addModuleStyles( [
137 'mediawiki.action.styles',
138 ] );
139 $this->from = $from;
140 $this->until = $until;
141 $this->limit = $context->getConfig()->get( MainConfigNames::CategoryPagingLimit );
142 $this->migrationStage = $context->getConfig()->get( MainConfigNames::CategoryLinksSchemaMigrationStage );
143 $this->cat = Category::newFromTitle( $page );
144 $this->query = $query;
145 $this->collation = MediaWikiServices::getInstance()->getCollationFactory()->getCategoryCollation();
146 $this->languageConverter = MediaWikiServices::getInstance()
147 ->getLanguageConverterFactory()->getLanguageConverter();
148 unset( $this->query['title'] );
149 }
150
156 public function getHTML() {
157 $this->showGallery = $this->getConfig()->get( MainConfigNames::CategoryMagicGallery )
158 && !$this->getOutput()->getOutputFlag( ParserOutputFlags::NO_GALLERY );
159
160 $this->clearCategoryState();
161 $this->doCategoryQuery();
162 $this->finaliseCategoryState();
163
164 $r = $this->getSubcategorySection() .
165 $this->getPagesSection() .
166 $this->getImageSection();
167
168 if ( $r == '' ) {
169 // If there is no category content to display, only
170 // show the top part of the navigation links.
171 // @todo FIXME: Cannot be completely suppressed because it
172 // is unknown if 'until' or 'from' makes this
173 // give 0 results.
174 $r = $this->getCategoryTop();
175 } else {
176 $r = $this->getCategoryTop() .
177 $r .
178 $this->getCategoryBottom();
179 }
180
181 // Give a proper message if category is empty
182 if ( $r == '' ) {
183 $r = $this->msg( 'category-empty' )->parseAsBlock();
184 }
185
186 $lang = $this->getLanguage();
187 $attribs = [
188 'class' => 'mw-category-generated',
189 'lang' => $lang->getHtmlCode(),
190 'dir' => $lang->getDir()
191 ];
192 # put a div around the headings which are in the user language
193 $r = Html::rawElement( 'div', $attribs, $r );
194
195 return $r;
196 }
197
198 protected function clearCategoryState() {
199 $this->articles = [];
200 $this->articles_start_char = [];
201 $this->children = [];
202 $this->children_start_char = [];
203 if ( $this->showGallery ) {
204 // Note that null for mode is taken to mean use default.
205 $mode = $this->getRequest()->getVal( 'gallerymode', null );
206 try {
207 $this->gallery = ImageGalleryBase::factory( $mode, $this->getContext() );
208 } catch ( ImageGalleryClassNotFoundException $e ) {
209 // User specified something invalid, fallback to default.
210 $this->gallery = ImageGalleryBase::factory( false, $this->getContext() );
211 }
212
213 $this->gallery->setHideBadImages();
214 } else {
215 $this->imgsNoGallery = [];
216 $this->imgsNoGallery_start_char = [];
217 }
218 }
219
226 public function addSubcategoryObject( Category $cat, $sortkey, $pageLength ) {
227 $page = $cat->getPage();
228 if ( !$page ) {
229 return;
230 }
231
232 // Subcategory; strip the 'Category' namespace from the link text.
233 $pageRecord = MediaWikiServices::getInstance()->getPageStore()
234 ->getPageByReference( $page );
235 if ( !$pageRecord ) {
236 return;
237 }
238
239 $this->children[] = $this->generateLink(
240 'subcat',
241 $pageRecord,
242 $pageRecord->isRedirect(),
243 htmlspecialchars( str_replace( '_', ' ', $pageRecord->getDBkey() ) )
244 );
245
246 $this->children_start_char[] =
247 $this->getSubcategorySortChar( $page, $sortkey );
248 }
249
261 private function generateLink(
262 string $type, PageReference $page, bool $isRedirect, ?string $html = null
263 ): string {
264 $link = null;
265 $legacyTitle = MediaWikiServices::getInstance()->getTitleFactory()
266 ->newFromPageReference( $page );
267 // @phan-suppress-next-line PhanTypeMismatchArgument Type mismatch on pass-by-ref args
268 $this->getHookRunner()->onCategoryViewer__generateLink( $type, $legacyTitle, $html, $link );
269 if ( $link === null ) {
270 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
271 if ( $html !== null ) {
272 $html = new HtmlArmor( $html );
273 }
274 $link = $linkRenderer->makeLink( $page, $html );
275 }
276 if ( $isRedirect ) {
277 $link = Html::rawElement(
278 'span',
279 [ 'class' => 'redirect-in-category' ],
280 $link
281 );
282 }
283
284 return $link;
285 }
286
298 public function getSubcategorySortChar( PageIdentity $page, string $sortkey ): string {
299 $titleText = MediaWikiServices::getInstance()->getTitleFormatter()
300 ->getPrefixedText( $page );
301 if ( $titleText === $sortkey ) {
302 $word = $page->getDBkey();
303 } else {
304 $word = $sortkey;
305 }
306
307 $firstChar = $this->collation->getFirstLetter( $word );
308
309 return $this->languageConverter->convert( $firstChar );
310 }
311
319 public function addImage(
320 PageReference $page, string $sortkey, int $pageLength, bool $isRedirect = false
321 ): void {
322 $title = MediaWikiServices::getInstance()->getTitleFactory()
323 ->newFromPageReference( $page );
324 if ( $this->showGallery ) {
325 $flip = $this->flip['file'];
326 if ( $flip ) {
327 $this->gallery->insert( $title, '', '', '', [], ImageGalleryBase::LOADING_LAZY );
328 } else {
329 $this->gallery->add( $title, '', '', '', [], ImageGalleryBase::LOADING_LAZY );
330 }
331 } else {
332 $this->imgsNoGallery[] = $this->generateLink( 'image', $page, $isRedirect );
333
334 $this->imgsNoGallery_start_char[] =
335 $this->languageConverter->convert( $this->collation->getFirstLetter( $sortkey ) );
336 }
337 }
338
346 public function addPage(
347 PageReference $page,
348 string $sortkey,
349 int $pageLength,
350 bool $isRedirect = false
351 ): void {
352 $this->articles[] = $this->generateLink( 'page', $page, $isRedirect );
353
354 $this->articles_start_char[] =
355 $this->languageConverter->convert( $this->collation->getFirstLetter( $sortkey ) );
356 }
357
358 protected function finaliseCategoryState() {
359 if ( $this->flip['subcat'] ) {
360 $this->children = array_reverse( $this->children );
361 $this->children_start_char = array_reverse( $this->children_start_char );
362 }
363 if ( $this->flip['page'] ) {
364 $this->articles = array_reverse( $this->articles );
365 $this->articles_start_char = array_reverse( $this->articles_start_char );
366 }
367 if ( !$this->showGallery && $this->flip['file'] ) {
368 $this->imgsNoGallery = array_reverse( $this->imgsNoGallery );
369 $this->imgsNoGallery_start_char = array_reverse( $this->imgsNoGallery_start_char );
370 }
371 }
372
373 protected function doCategoryQuery() {
374 $dbr = MediaWikiServices::getInstance()->getConnectionProvider()->getReplicaDatabase();
375
376 $this->nextPage = [
377 'page' => null,
378 'subcat' => null,
379 'file' => null,
380 ];
381 $this->prevPage = [
382 'page' => null,
383 'subcat' => null,
384 'file' => null,
385 ];
386
387 $this->flip = [ 'page' => false, 'subcat' => false, 'file' => false ];
388
389 foreach ( [ 'page', 'subcat', 'file' ] as $type ) {
390 # Get the sortkeys for start/end, if applicable. Note that if
391 # the collation in the database differs from the one
392 # set in $wgCategoryCollation, pagination might go totally haywire.
393 $extraConds = [ 'cl_type' => $type ];
394 if ( isset( $this->from[$type] ) ) {
395 $extraConds[] = $dbr->expr(
396 'cl_sortkey',
397 '>=',
398 $this->collation->getSortKey( $this->from[$type] )
399 );
400 } elseif ( isset( $this->until[$type] ) ) {
401 $extraConds[] = $dbr->expr(
402 'cl_sortkey',
403 '<',
404 $this->collation->getSortKey( $this->until[$type] )
405 );
406 $this->flip[$type] = true;
407 }
408
409 $queryBuilder = $dbr->newSelectQueryBuilder();
410 $queryBuilder->select( array_merge(
411 LinkCache::getSelectFields(),
412 [
413 'cl_sortkey',
414 'cat_id',
415 'cat_title',
416 'cat_subcats',
417 'cat_pages',
418 'cat_files',
419 'cl_sortkey_prefix',
420 ]
421 ) )
422 ->from( 'page' )
423 ->andWhere( $extraConds );
424
425 if ( $this->flip[$type] ) {
426 $queryBuilder->orderBy( 'cl_sortkey', SelectQueryBuilder::SORT_DESC );
427 } else {
428 $queryBuilder->orderBy( 'cl_sortkey' );
429 }
430
431 $queryBuilder
432 ->join( 'categorylinks', null, [ 'cl_from = page_id' ] )
433 ->leftJoin( 'category', null, [
434 'cat_title = page_title',
435 'page_namespace' => NS_CATEGORY
436 ] )
437 ->limit( $this->limit + 1 );
438 if ( $this->migrationStage & SCHEMA_COMPAT_READ_OLD ) {
439 $queryBuilder->where( [ 'cl_to' => $this->page->getDBkey() ] )
440 ->field( 'cl_collation' )
441 ->useIndex( [ 'categorylinks' => 'cl_sortkey' ] );
442 } else {
443 $queryBuilder->join( 'linktarget', null, 'cl_target_id = lt_id' )
444 ->where( [ 'lt_title' => $this->page->getDBkey(), 'lt_namespace' => NS_CATEGORY ] );
445
446 $queryBuilder->join( 'collation', null, 'cl_collation_id = collation_id' )
447 ->field( 'collation_name', 'cl_collation' );
448
449 $queryBuilder->useIndex( [ 'categorylinks' => 'cl_sortkey_id' ] );
450 }
451
452 $res = $queryBuilder->caller( __METHOD__ )->fetchResultSet();
453
454 $this->getHookRunner()->onCategoryViewer__doCategoryQuery( $type, $res );
455 $linkCache = MediaWikiServices::getInstance()->getLinkCache();
456
457 $count = 0;
458 foreach ( $res as $row ) {
459 $title = Title::newFromRow( $row );
460 $linkCache->addGoodLinkObjFromRow( $title, $row );
461
462 if ( $row->cl_collation === '' ) {
463 // Hack to make sure that while updating from 1.16 schema
464 // and db is inconsistent, that the sky doesn't fall.
465 // See r83544. Could perhaps be removed in a couple decades...
466 $humanSortkey = $row->cl_sortkey;
467 } else {
468 $humanSortkey = $title->getCategorySortkey( $row->cl_sortkey_prefix );
469 }
470
471 if ( ++$count > $this->limit ) {
472 # We've reached the one extra which shows that there
473 # are additional pages to be had. Stop here...
474 $this->nextPage[$type] = $humanSortkey;
475 break;
476 }
477 if ( $count == $this->limit ) {
478 $this->prevPage[$type] = $humanSortkey;
479 }
480
481 if ( $title->getNamespace() === NS_CATEGORY ) {
482 $cat = Category::newFromRow( $row, $title );
483 $this->addSubcategoryObject( $cat, $humanSortkey, $row->page_len );
484 } elseif ( $title->getNamespace() === NS_FILE ) {
485 $this->addImage( $title, $humanSortkey, $row->page_len, $row->page_is_redirect );
486 } else {
487 $this->addPage( $title, $humanSortkey, $row->page_len, $row->page_is_redirect );
488 }
489 }
490 }
491 }
492
496 protected function getCategoryTop() {
497 $r = $this->getCategoryBottom();
498 return $r === ''
499 ? $r
500 : "<br style=\"clear:both;\"/>\n" . $r;
501 }
502
506 protected function getSubcategorySection() {
507 # Don't show subcategories section if there are none.
508 $r = '';
509 $rescnt = count( $this->children );
510 $dbcnt = $this->cat->getSubcatCount();
511 // This function should be called even if the result isn't used, it has side-effects
512 $countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'subcat' );
513
514 if ( $rescnt > 0 ) {
515 # Showing subcategories
516 $r .= Html::openElement( 'div', [ 'id' => 'mw-subcategories' ] ) . "\n";
517 $r .= Html::rawElement( 'h2', [], $this->msg( 'subcategories' )->parse() ) . "\n";
518 $r .= $countmsg;
519 $r .= $this->getSectionPagingLinks( 'subcat' );
520 $r .= $this->formatList( $this->children, $this->children_start_char );
521 $r .= $this->getSectionPagingLinks( 'subcat' );
522 $r .= "\n" . Html::closeElement( 'div' );
523 }
524 return $r;
525 }
526
530 protected function getPagesSection() {
531 $name = $this->getOutput()->getUnprefixedDisplayTitle();
532 # Don't show articles section if there are none.
533 $r = '';
534
535 # @todo FIXME: Here and in the other two sections: we don't need to bother
536 # with this rigmarole if the entire category contents fit on one page
537 # and have already been retrieved. We can just use $rescnt in that
538 # case and save a query and some logic.
539 $dbcnt = $this->cat->getPageCount( Category::COUNT_CONTENT_PAGES );
540 $rescnt = count( $this->articles );
541 // This function should be called even if the result isn't used, it has side-effects
542 $countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'article' );
543
544 if ( $rescnt > 0 ) {
545 $r .= Html::openElement( 'div', [ 'id' => 'mw-pages' ] ) . "\n";
546 $r .= Html::rawElement(
547 'h2',
548 [],
549 $this->msg( 'category_header' )->rawParams( $name )->parse()
550 ) . "\n";
551 $r .= $countmsg;
552 $r .= $this->getSectionPagingLinks( 'page' );
553 $r .= $this->formatList( $this->articles, $this->articles_start_char );
554 $r .= $this->getSectionPagingLinks( 'page' );
555 $r .= "\n" . Html::closeElement( 'div' );
556 }
557 return $r;
558 }
559
563 protected function getImageSection() {
564 $name = $this->getOutput()->getUnprefixedDisplayTitle();
565 $r = '';
566 $rescnt = $this->showGallery ?
567 $this->gallery->count() :
568 count( $this->imgsNoGallery ?? [] );
569 $dbcnt = $this->cat->getFileCount();
570 // This function should be called even if the result isn't used, it has side-effects
571 $countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'file' );
572
573 if ( $rescnt > 0 ) {
574 $r .= Html::openElement( 'div', [ 'id' => 'mw-category-media' ] ) . "\n";
575 $r .= Html::rawElement(
576 'h2',
577 [],
578 $this->msg( 'category-media-header' )->rawParams( $name )->parse()
579 ) . "\n";
580 $r .= $countmsg;
581 $r .= $this->getSectionPagingLinks( 'file' );
582 if ( $this->showGallery ) {
583 $r .= $this->gallery->toHTML();
584 } else {
585 $r .= $this->formatList( $this->imgsNoGallery, $this->imgsNoGallery_start_char );
586 }
587 $r .= $this->getSectionPagingLinks( 'file' );
588 $r .= "\n" . Html::closeElement( 'div' );
589 }
590 return $r;
591 }
592
600 private function getSectionPagingLinks( $type ) {
601 if ( isset( $this->until[$type] ) ) {
602 // The new value for the until parameter should be pointing to the first
603 // result displayed on the page which is the second last result retrieved
604 // from the database.The next link should have a from parameter pointing
605 // to the until parameter of the current page.
606 if ( $this->nextPage[$type] !== null ) {
607 return $this->pagingLinks(
608 $this->prevPage[$type] ?? '',
609 $this->until[$type],
610 $type
611 );
612 }
613
614 // If the nextPage variable is null, it means that we have reached the first page
615 // and therefore the previous link should be disabled.
616 return $this->pagingLinks(
617 '',
618 $this->until[$type],
619 $type
620 );
621 } elseif ( $this->nextPage[$type] !== null || isset( $this->from[$type] ) ) {
622 return $this->pagingLinks(
623 $this->from[$type] ?? '',
624 $this->nextPage[$type],
625 $type
626 );
627 }
628
629 return '';
630 }
631
635 protected function getCategoryBottom() {
636 return '';
637 }
638
649 private function formatList( $articles, $articles_start_char, $cutoff = 6 ) {
650 $list = '';
651 if ( count( $articles ) > $cutoff ) {
652 $list = self::columnList( $articles, $articles_start_char );
653 } elseif ( count( $articles ) > 0 ) {
654 // for short lists of articles in categories.
655 $list = self::shortList( $articles, $articles_start_char );
656 }
657
658 $pageLang = MediaWikiServices::getInstance()->getTitleFactory()
659 ->newFromPageIdentity( $this->page )
660 ->getPageLanguage();
661 $attribs = [ 'lang' => $pageLang->getHtmlCode(), 'dir' => $pageLang->getDir(),
662 'class' => 'mw-content-' . $pageLang->getDir() ];
663 $list = Html::rawElement( 'div', $attribs, $list );
664
665 return $list;
666 }
667
678 public static function columnList(
679 $articles,
680 $articles_start_char,
681 $cssClasses = 'mw-category mw-category-columns'
682 ) {
683 $columns = array_combine( $articles, $articles_start_char );
684
685 $ret = Html::openElement( 'div', [ 'class' => $cssClasses ] );
686
687 $colContents = [];
688
689 # Kind of like array_flip() here, but we keep duplicates in an
690 # array instead of dropping them.
691 foreach ( $columns as $article => $char ) {
692 $colContents[$char][] = $article;
693 }
694
695 foreach ( $colContents as $char => $articles ) {
696 # Change space to non-breaking space to keep headers aligned
697 $h3char = $char === ' ' ? "\u{00A0}" : htmlspecialchars( $char );
698
699 $ret .= Html::openElement( 'div', [ 'class' => 'mw-category-group' ] );
700 $ret .= Html::rawElement( 'h3', [], $h3char ) . "\n";
701 $ret .= Html::openElement( 'ul' );
702 $ret .= implode(
703 "\n",
704 array_map(
705 static function ( $article ) {
706 return Html::rawElement( 'li', [], $article );
707 },
708 $articles
709 )
710 );
711 $ret .= Html::closeElement( 'ul' ) . Html::closeElement( 'div' );
712
713 }
714
715 $ret .= Html::closeElement( 'div' );
716 return $ret;
717 }
718
727 public static function shortList( $articles, $articles_start_char ) {
728 return self::columnList( $articles, $articles_start_char, 'mw-category' );
729 }
730
740 private function pagingLinks( $first, $last, $type = '' ) {
741 $prevLink = $this->msg( 'prev-page' )->escaped();
742
743 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
744 if ( $first != '' ) {
745 $prevQuery = $this->query;
746 $prevQuery["{$type}until"] = $first;
747 unset( $prevQuery["{$type}from"] );
748 $prevLink = $linkRenderer->makeKnownLink(
749 $this->addFragmentToTitle( $this->page, $type ),
750 new HtmlArmor( $prevLink ),
751 [],
752 $prevQuery
753 );
754 }
755
756 $nextLink = $this->msg( 'next-page' )->escaped();
757
758 if ( $last != '' ) {
759 $lastQuery = $this->query;
760 $lastQuery["{$type}from"] = $last;
761 unset( $lastQuery["{$type}until"] );
762 $nextLink = $linkRenderer->makeKnownLink(
763 $this->addFragmentToTitle( $this->page, $type ),
764 new HtmlArmor( $nextLink ),
765 [],
766 $lastQuery
767 );
768 }
769
770 return $this->msg( 'categoryviewer-pagedlinks' )->rawParams( $prevLink, $nextLink )->escaped();
771 }
772
781 private function addFragmentToTitle( PageReference $page, string $section ): LinkTarget {
782 switch ( $section ) {
783 case 'page':
784 $fragment = 'mw-pages';
785 break;
786 case 'subcat':
787 $fragment = 'mw-subcategories';
788 break;
789 case 'file':
790 $fragment = 'mw-category-media';
791 break;
792 default:
793 throw new InvalidArgumentException( __METHOD__ .
794 " Invalid section $section." );
795 }
796
797 return new TitleValue( $page->getNamespace(),
798 $page->getDBkey(), $fragment );
799 }
800
811 private function getCountMessage( $rescnt, $dbcnt, $type ) {
812 // There are three cases:
813 // 1) The category table figure seems good. It might be wrong, but
814 // we can't do anything about it if we don't recalculate it on ev-
815 // ery category view.
816 // 2) The category table figure isn't good, like it's smaller than the
817 // number of actual results, *but* the number of results is less
818 // than $this->limit and there's no offset. In this case we still
819 // know the right figure.
820 // 3) We have no idea.
821
822 // Check if there's a "from" or "until" for anything
823
824 // This is a little ugly, but we seem to use different names
825 // for the paging types then for the messages.
826 if ( $type === 'article' ) {
827 $pagingType = 'page';
828 } else {
829 $pagingType = $type;
830 }
831
832 $fromOrUntil = false;
833 if ( isset( $this->from[$pagingType] ) || isset( $this->until[$pagingType] ) ) {
834 $fromOrUntil = true;
835 }
836
837 if ( $dbcnt == $rescnt ||
838 ( ( $rescnt == $this->limit || $fromOrUntil ) && $dbcnt > $rescnt )
839 ) {
840 // Case 1: seems good.
841 $totalcnt = $dbcnt;
842 } elseif ( $rescnt < $this->limit && !$fromOrUntil ) {
843 // Case 2: not good, but salvageable. Use the number of results.
844 $totalcnt = $rescnt;
845 } else {
846 // Case 3: hopeless. Don't give a total count at all.
847 // Messages: category-subcat-count-limited, category-article-count-limited,
848 // category-file-count-limited
849 return $this->msg( "category-$type-count-limited" )->numParams( $rescnt )->parseAsBlock();
850 }
851 // Messages: category-subcat-count, category-article-count, category-file-count
852 return $this->msg( "category-$type-count" )->numParams( $rescnt, $totalcnt )->parseAsBlock();
853 }
854}
const NS_FILE
Definition Defines.php:71
const SCHEMA_COMPAT_READ_OLD
Definition Defines.php:304
const NS_CATEGORY
Definition Defines.php:79
static factory( $mode=false, ?IContextSource $context=null)
Get a new image gallery.
Class for exceptions thrown by ImageGalleryBase::factory().
Cache for article titles (prefixed DB keys) and ids linked from one source.
Definition LinkCache.php:52
getHTML()
Format the category data list.
static columnList( $articles, $articles_start_char, $cssClasses='mw-category mw-category-columns')
Format a list of articles chunked by letter in a three-column list, ordered vertically.
static shortList( $articles, $articles_start_char)
Format a list of articles chunked by letter in a bullet list.
addImage(PageReference $page, string $sortkey, int $pageLength, bool $isRedirect=false)
Add a page in the image namespace.
getSubcategorySortChar(PageIdentity $page, string $sortkey)
Get the character to be used for sorting subcategories.
addSubcategoryObject(Category $cat, $sortkey, $pageLength)
Add a subcategory to the internal lists, using a Category object.
__construct(PageIdentity $page, IContextSource $context, array $from=[], array $until=[], array $query=[])
addPage(PageReference $page, string $sortkey, int $pageLength, bool $isRedirect=false)
Add a miscellaneous page.
Category objects are immutable, strictly speaking.
Definition Category.php:44
static newFromTitle(PageIdentity $page)
Factory function.
Definition Category.php:196
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
setContext(IContextSource $context)
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
getContext()
Get the base IContextSource object.
This class is a collection of static functions that serve two purposes:
Definition Html.php:57
A class containing constants representing the names of configuration variables.
const CategoryLinksSchemaMigrationStage
Name constant for the CategoryLinksSchemaMigrationStage setting, for use with Config::get()
const CategoryPagingLimit
Name constant for the CategoryPagingLimit setting, for use with Config::get()
const CategoryMagicGallery
Name constant for the CategoryMagicGallery setting, for use with Config::get()
Service locator for MediaWiki core services.
static getInstance()
Returns the global default instance of the top level service locator.
Represents the target of a wiki link.
Represents a title within MediaWiki.
Definition Title.php:78
Marks HTML that shouldn't be escaped.
Definition HtmlArmor.php:32
Build SELECT queries with a fluent interface.
Interface for objects which can provide a MediaWiki context on request.
getConfig()
Get the site configuration.
The shared interface for all language converters.
Represents the target of a wiki link.
Interface for objects (potentially) representing an editable wiki page.
Interface for objects (potentially) representing a page that can be viewable and linked to on a wiki.
getNamespace()
Returns the page's namespace number.
getDBkey()
Get the page title in DB key form.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...