MediaWiki master
CategoryViewer.php
Go to the documentation of this file.
1<?php
9namespace MediaWiki\Category;
10
11use InvalidArgumentException;
15use MediaWiki\Debug\DeprecationHelper;
19use MediaWiki\HookContainer\ProtectedHookAccessorTrait;
34
36 use ProtectedHookAccessorTrait;
37 use DeprecationHelper;
38
39 public readonly int $limit;
41 public array $articles = [];
43 public array $articles_start_char = [];
45 public array $children = [];
47 public array $children_start_char = [];
48 public bool $showGallery;
50 public array $imgsNoGallery_start_char = [];
52 public array $imgsNoGallery = [];
54 public array $nextPage = [];
56 protected array $prevPage = [];
58 public array $flip = [];
59
60 public readonly Collation $collation;
62
64 private readonly Category $cat;
65
66 private readonly ILanguageConverter $languageConverter;
67
77 public function __construct(
78 protected PageIdentity $page,
79 IContextSource $context,
80 public readonly array $from = [],
81 public readonly array $until = [],
82 private array $query = [],
83 ) {
84 $this->deprecatePublicPropertyFallback(
85 'title',
86 '1.37',
87 fn (): Title => Title::newFromPageIdentity( $this->page ),
88 fn ( PageIdentity $page ) => $this->page = $page
89 );
90
91 $this->setContext( $context );
92 $this->getOutput()->addModuleStyles( [
93 'mediawiki.action.styles',
94 ] );
95 $this->limit = $context->getConfig()->get( MainConfigNames::CategoryPagingLimit );
96 $this->cat = Category::newFromTitle( $page );
97
99 $this->collation = $services->getCollationFactory()->getCategoryCollation();
100 $this->languageConverter = $services->getLanguageConverterFactory()->getLanguageConverter();
101
102 unset( $this->query['title'] );
103 }
104
110 public function getHTML() {
111 $this->showGallery = $this->getConfig()->get( MainConfigNames::CategoryMagicGallery )
112 && !$this->getOutput()->getOutputFlag( ParserOutputFlags::NO_GALLERY );
113
114 $this->clearCategoryState();
115 $this->doCategoryQuery();
116 $this->finaliseCategoryState();
117
118 $html = $this->getSubcategorySection() .
119 $this->getPagesSection() .
120 $this->getImageSection();
121
122 if ( $html === '' ) {
123 $html = $this->msg( 'category-empty' )->parseAsBlock();
124 }
125
126 # put a div around the headings which are in the user language
127 $lang = $this->getLanguage();
128 return Html::rawElement( 'div', [
129 'class' => 'mw-category-generated',
130 'lang' => $lang->getHtmlCode(),
131 'dir' => $lang->getDir()
132 ], $html );
133 }
134
135 protected function clearCategoryState() {
136 $this->articles = [];
137 $this->articles_start_char = [];
138 $this->children = [];
139 $this->children_start_char = [];
140 if ( $this->showGallery ) {
141 // Note that null for mode is taken to mean use default.
142 $mode = $this->getRequest()->getVal( 'gallerymode', null );
143 try {
144 $this->gallery = ImageGalleryBase::factory( $mode, $this->getContext() );
146 // User specified something invalid, fallback to default.
147 $this->gallery = ImageGalleryBase::factory( false, $this->getContext() );
148 }
149
150 $this->gallery->setHideBadImages();
151 } else {
152 $this->imgsNoGallery = [];
153 $this->imgsNoGallery_start_char = [];
154 }
155 }
156
163 public function addSubcategoryObject( Category $cat, string $sortkey, int $pageLength ): void {
164 $page = $cat->getPage();
165 if ( !$page ) {
166 return;
167 }
168
169 // Subcategory; strip the 'Category' namespace from the link text.
170 $pageRecord = MediaWikiServices::getInstance()->getPageStore()
171 ->getPageByReference( $page );
172 if ( !$pageRecord ) {
173 return;
174 }
175
176 $this->children[] = $this->generateLink(
177 'subcat',
178 $pageRecord,
179 $pageRecord->isRedirect(),
180 htmlspecialchars( str_replace( '_', ' ', $pageRecord->getDBkey() ) )
181 );
182
183 $this->children_start_char[] =
184 $this->languageConverter->convert( $this->collation->getFirstLetter( $sortkey ) );
185 }
186
198 private function generateLink(
199 string $type,
200 PageReference $page,
201 bool $isRedirect,
202 ?string $html = null
203 ): string {
204 $link = null;
205 $legacyTitle = MediaWikiServices::getInstance()->getTitleFactory()
206 ->newFromPageReference( $page );
207 // @phan-suppress-next-line PhanTypeMismatchArgument Type mismatch on pass-by-ref args
208 $this->getHookRunner()->onCategoryViewer__generateLink( $type, $legacyTitle, $html, $link );
209 if ( $link === null ) {
210 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
211 if ( $html !== null ) {
212 $html = new HtmlArmor( $html );
213 }
214 $link = $linkRenderer->makeLink( $page, $html );
215 }
216 if ( $isRedirect ) {
217 $link = Html::rawElement(
218 'span',
219 [ 'class' => 'redirect-in-category' ],
220 $link
221 );
222 }
223
224 return $link;
225 }
226
235 public function getSubcategorySortChar( PageIdentity $page, string $sortkey ): string {
236 wfDeprecated( __METHOD__, '1.45' );
237 $firstChar = $this->collation->getFirstLetter( $sortkey );
238
239 return $this->languageConverter->convert( $firstChar );
240 }
241
249 public function addImage(
250 PageReference $page,
251 string $sortkey,
252 int $pageLength,
253 bool $isRedirect = false
254 ): void {
255 $title = MediaWikiServices::getInstance()->getTitleFactory()
256 ->newFromPageReference( $page );
257 if ( $this->showGallery ) {
258 $flip = $this->flip['file'];
259 if ( $flip ) {
260 $this->gallery->insert( $title, '', '', '', [], ImageGalleryBase::LOADING_LAZY );
261 } else {
262 $this->gallery->add( $title, '', '', '', [], ImageGalleryBase::LOADING_LAZY );
263 }
264 } else {
265 $this->imgsNoGallery[] = $this->generateLink( 'image', $page, $isRedirect );
266
267 $this->imgsNoGallery_start_char[] =
268 $this->languageConverter->convert( $this->collation->getFirstLetter( $sortkey ) );
269 }
270 }
271
279 public function addPage(
280 PageReference $page,
281 string $sortkey,
282 int $pageLength,
283 bool $isRedirect = false
284 ): void {
285 $this->articles[] = $this->generateLink( 'page', $page, $isRedirect );
286
287 $this->articles_start_char[] =
288 $this->languageConverter->convert( $this->collation->getFirstLetter( $sortkey ) );
289 }
290
291 protected function finaliseCategoryState() {
292 if ( $this->flip['subcat'] ) {
293 $this->children = array_reverse( $this->children );
294 $this->children_start_char = array_reverse( $this->children_start_char );
295 }
296 if ( $this->flip['page'] ) {
297 $this->articles = array_reverse( $this->articles );
298 $this->articles_start_char = array_reverse( $this->articles_start_char );
299 }
300 if ( !$this->showGallery && $this->flip['file'] ) {
301 $this->imgsNoGallery = array_reverse( $this->imgsNoGallery );
302 $this->imgsNoGallery_start_char = array_reverse( $this->imgsNoGallery_start_char );
303 }
304 }
305
306 protected function doCategoryQuery() {
307 $connProvider = MediaWikiServices::getInstance()->getConnectionProvider();
308 $dbr = $connProvider->getReplicaDatabase();
309 $categoryLinksDbr = $connProvider->getReplicaDatabase( CategoryLinksTable::VIRTUAL_DOMAIN );
310
311 $this->nextPage = [
312 'page' => null,
313 'subcat' => null,
314 'file' => null,
315 ];
316 $this->prevPage = [
317 'page' => null,
318 'subcat' => null,
319 'file' => null,
320 ];
321
322 $this->flip = [ 'page' => false, 'subcat' => false, 'file' => false ];
323
324 foreach ( [ 'page', 'subcat', 'file' ] as $type ) {
325 # Get the sortkeys for start/end, if applicable. Note that if
326 # the collation in the database differs from the one
327 # set in $wgCategoryCollation, pagination might go totally haywire.
328 $extraConds = [ 'cl_type' => $type ];
329 if ( isset( $this->from[$type] ) ) {
330 $extraConds[] = $categoryLinksDbr->expr(
331 'cl_sortkey',
332 '>=',
333 // @phan-suppress-next-line PhanTypeMismatchArgumentNullable
334 $this->collation->getSortKey( $this->from[$type] )
335 );
336 } elseif ( isset( $this->until[$type] ) ) {
337 $extraConds[] = $categoryLinksDbr->expr(
338 'cl_sortkey',
339 '<',
340 // @phan-suppress-next-line PhanTypeMismatchArgumentNullable
341 $this->collation->getSortKey( $this->until[$type] )
342 );
343 $this->flip[$type] = true;
344 }
345
346 $queryBuilder = $categoryLinksDbr->newSelectQueryBuilder();
347 $queryBuilder->select( array_merge(
348 LinkCache::getSelectFields(),
349 [
350 'cl_sortkey',
351 'cl_sortkey_prefix',
352 'collation_name',
353 ]
354 ) )
355 ->from( 'page' )
356 ->andWhere( $extraConds );
357
358 if ( $this->flip[$type] ) {
359 $queryBuilder->orderBy( 'cl_sortkey', SelectQueryBuilder::SORT_DESC );
360 } else {
361 $queryBuilder->orderBy( 'cl_sortkey' );
362 }
363
364 $queryBuilder
365 ->join( 'categorylinks', null, [ 'cl_from = page_id' ] )
366 ->join( 'linktarget', null, 'cl_target_id = lt_id' )
367 ->straightJoin( 'collation', null, 'cl_collation_id = collation_id' )
368 ->where( [ 'lt_title' => $this->page->getDBkey(), 'lt_namespace' => NS_CATEGORY ] )
369 ->useIndex( [ 'categorylinks' => 'cl_sortkey_id' ] )
370 ->limit( $this->limit + 1 );
371
372 $res = $queryBuilder->caller( __METHOD__ )->fetchResultSet();
373
374 $categoryTitles = [];
375 $pageRows = [];
376
377 foreach ( $res as $row ) {
378 $pageRows[] = $row;
379 if ( (int)$row->page_namespace === NS_CATEGORY ) {
380 $categoryTitles[] = $row->page_title;
381 }
382 }
383
384 $categoryFields = [ 'cat_id', 'cat_title', 'cat_subcats', 'cat_pages', 'cat_files' ];
385
386 $categoryData = [];
387 if ( $categoryTitles !== [] ) {
388 $categoryRes = $dbr->newSelectQueryBuilder()
389 ->select( $categoryFields )
390 ->from( 'category' )
391 ->where( [ 'cat_title' => $categoryTitles ] )
392 ->caller( __METHOD__ )
393 ->fetchResultSet();
394
395 foreach ( $categoryRes as $catRow ) {
396 $categoryData[$catRow->cat_title] = $catRow;
397 }
398 }
399
400 foreach ( $pageRows as $row ) {
401 if ( (int)$row->page_namespace === NS_CATEGORY ) {
402 $catRow = $categoryData[$row->page_title] ?? null;
403 foreach ( $categoryFields as $field ) {
404 $row->$field = $catRow->$field ?? null;
405 }
406 }
407 }
408
409 // Convert modified pageRows back to result wrapper for hook
410 $res = new FakeResultWrapper( $pageRows );
411 $this->getHookRunner()->onCategoryViewer__doCategoryQuery( $type, $res );
412 $linkCache = MediaWikiServices::getInstance()->getLinkCache();
413
414 $count = 0;
415 foreach ( $pageRows as $row ) {
416 $title = Title::newFromRow( $row );
417 $linkCache->addGoodLinkObjFromRow( $title, $row );
418 $humanSortkey = $title->getCategorySortkey( $row->cl_sortkey_prefix );
419
420 if ( ++$count > $this->limit ) {
421 # We've reached the one extra which shows that there
422 # are additional pages to be had. Stop here...
423 $this->nextPage[$type] = $humanSortkey;
424 break;
425 }
426 if ( $count == $this->limit ) {
427 $this->prevPage[$type] = $humanSortkey;
428 }
429
430 if ( $title->getNamespace() === NS_CATEGORY ) {
431 $cat = Category::newFromRow( $row, $title );
432 $this->addSubcategoryObject( $cat, $humanSortkey, $row->page_len );
433 } elseif ( $title->getNamespace() === NS_FILE ) {
434 $this->addImage( $title, $humanSortkey, $row->page_len, $row->page_is_redirect );
435 } else {
436 $this->addPage( $title, $humanSortkey, $row->page_len, $row->page_is_redirect );
437 }
438 }
439 }
440 }
441
445 protected function getSubcategorySection() {
446 # Don't show subcategories section if there are none.
447 $html = '';
448 $localCount = count( $this->children );
449 $databaseCount = $this->cat->getSubcatCount();
450 // This function should be called even if the result isn't used, it has side-effects
451 $countMessage = $this->getCountMessage( $localCount, $databaseCount, 'subcat' );
452
453 if ( $localCount > 0 ) {
454 $html .= Html::openElement( 'div', [ 'id' => 'mw-subcategories' ] ) . "\n";
455 $html .= Html::rawElement( 'h2', [], $this->msg( 'subcategories' )->parse() ) . "\n";
456 $html .= $countMessage;
457 $html .= $this->getSectionPagingLinks( 'subcat' );
458 $html .= $this->formatList( $this->children, $this->children_start_char );
459 $html .= $this->getSectionPagingLinks( 'subcat' );
460 $html .= "\n" . Html::closeElement( 'div' );
461 }
462 return $html;
463 }
464
468 protected function getPagesSection() {
469 $name = $this->getOutput()->getUnprefixedDisplayTitle();
470 # Don't show articles section if there are none.
471 $html = '';
472
473 # @todo FIXME: Here and in the other two sections: we don't need to bother
474 # with this rigmarole if the entire category contents fit on one page
475 # and have already been retrieved. We can just use $rescnt in that
476 # case and save a query and some logic.
477 $databaseCount = $this->cat->getPageCount( Category::COUNT_CONTENT_PAGES );
478 $localCount = count( $this->articles );
479 // This function should be called even if the result isn't used, it has side-effects
480 $countMessage = $this->getCountMessage( $localCount, $databaseCount, 'page' );
481
482 if ( $localCount > 0 ) {
483 $html .= Html::openElement( 'div', [ 'id' => 'mw-pages' ] ) . "\n";
484 $html .= Html::rawElement(
485 'h2',
486 [],
487 $this->msg( 'category_header' )->rawParams( $name )->parse()
488 ) . "\n";
489 $html .= $countMessage;
490 $html .= $this->getSectionPagingLinks( 'page' );
491 $html .= $this->formatList( $this->articles, $this->articles_start_char );
492 $html .= $this->getSectionPagingLinks( 'page' );
493 $html .= "\n" . Html::closeElement( 'div' );
494 }
495 return $html;
496 }
497
501 protected function getImageSection() {
502 $name = $this->getOutput()->getUnprefixedDisplayTitle();
503 $html = '';
504 $localCount = $this->showGallery ?
505 $this->gallery->count() :
506 count( $this->imgsNoGallery );
507 $databaseCount = $this->cat->getFileCount();
508 // This function should be called even if the result isn't used, it has side-effects
509 $countMessage = $this->getCountMessage( $localCount, $databaseCount, 'file' );
510
511 if ( $localCount > 0 ) {
512 $html .= Html::openElement( 'div', [ 'id' => 'mw-category-media' ] ) . "\n";
513 $html .= Html::rawElement(
514 'h2',
515 [],
516 $this->msg( 'category-media-header' )->rawParams( $name )->parse()
517 ) . "\n";
518 $html .= $countMessage;
519 $html .= $this->getSectionPagingLinks( 'file' );
520 if ( $this->showGallery ) {
521 $html .= $this->gallery->toHTML();
522 } else {
523 $html .= $this->formatList( $this->imgsNoGallery, $this->imgsNoGallery_start_char );
524 }
525 $html .= $this->getSectionPagingLinks( 'file' );
526 $html .= "\n" . Html::closeElement( 'div' );
527 }
528 return $html;
529 }
530
538 private function getSectionPagingLinks( string $type ): string {
539 if ( isset( $this->until[$type] ) ) {
540 // The new value for the until parameter should be pointing to the first
541 // result displayed on the page which is the second last result retrieved
542 // from the database.The next link should have a from parameter pointing
543 // to the until parameter of the current page.
544 if ( $this->nextPage[$type] !== null ) {
545 return $this->pagingLinks(
546 $this->prevPage[$type] ?? '',
547 // @phan-suppress-next-line PhanTypeMismatchArgumentNullable
548 $this->until[$type],
549 $type
550 );
551 }
552
553 // If the nextPage variable is null, it means that we have reached the first page
554 // and therefore the previous link should be disabled.
555 return $this->pagingLinks(
556 '',
557 // @phan-suppress-next-line PhanTypeMismatchArgumentNullable
558 $this->until[$type],
559 $type
560 );
561 } elseif ( $this->nextPage[$type] !== null || isset( $this->from[$type] ) ) {
562 return $this->pagingLinks(
563 $this->from[$type] ?? '',
564 $this->nextPage[$type] ?? '',
565 $type
566 );
567 }
568
569 return '';
570 }
571
582 private function formatList( array $articles, array $articles_start_char, int $cutoff = 6 ): string {
583 $list = '';
584 if ( count( $articles ) > $cutoff ) {
585 $list = self::columnList( $articles, $articles_start_char );
586 } elseif ( count( $articles ) > 0 ) {
587 // for short lists of articles in categories.
588 $list = self::shortList( $articles, $articles_start_char );
589 }
590
591 $pageLang = MediaWikiServices::getInstance()->getTitleFactory()
592 ->newFromPageIdentity( $this->page )
593 ->getPageLanguage();
594 $attribs = [ 'lang' => $pageLang->getHtmlCode(), 'dir' => $pageLang->getDir(),
595 'class' => 'mw-content-' . $pageLang->getDir() ];
596 $list = Html::rawElement( 'div', $attribs, $list );
597
598 return $list;
599 }
600
611 public static function columnList(
612 $articles,
613 $articles_start_char,
614 $cssClasses = 'mw-category mw-category-columns'
615 ) {
616 $columns = array_combine( $articles, $articles_start_char );
617
618 $ret = Html::openElement( 'div', [ 'class' => $cssClasses ] );
619
620 $colContents = [];
621
622 # Kind of like array_flip() here, but we keep duplicates in an
623 # array instead of dropping them.
624 foreach ( $columns as $article => $char ) {
625 $colContents[$char][] = $article;
626 }
627
628 foreach ( $colContents as $char => $articles ) {
629 # Change space to non-breaking space to keep headers aligned
630 $h3char = $char === ' ' ? "\u{00A0}" : htmlspecialchars( $char );
631
632 $ret .= Html::openElement( 'div', [ 'class' => 'mw-category-group' ] );
633 $ret .= Html::rawElement( 'h3', [], $h3char ) . "\n";
634 $ret .= Html::openElement( 'ul' );
635 $ret .= implode(
636 "\n",
637 array_map(
638 static fn ( $article ) => Html::rawElement( 'li', [], $article ),
639 $articles
640 )
641 );
642 $ret .= Html::closeElement( 'ul' ) . Html::closeElement( 'div' );
643
644 }
645
646 $ret .= Html::closeElement( 'div' );
647 return $ret;
648 }
649
658 public static function shortList( $articles, $articles_start_char ) {
659 return self::columnList( $articles, $articles_start_char, 'mw-category' );
660 }
661
670 private function pagingLinks( string $first, string $last, string $type = '' ): string {
671 $prevLink = $this->msg( 'prev-page' )->escaped();
672
673 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
674 if ( $first != '' ) {
675 $prevQuery = $this->query;
676 $prevQuery["{$type}until"] = $first;
677 unset( $prevQuery["{$type}from"] );
678 $prevLink = $linkRenderer->makeKnownLink(
679 $this->addFragmentToTitle( $this->page, $type ),
680 new HtmlArmor( $prevLink ),
681 [],
682 $prevQuery
683 );
684 }
685
686 $nextLink = $this->msg( 'next-page' )->escaped();
687
688 if ( $last != '' ) {
689 $lastQuery = $this->query;
690 $lastQuery["{$type}from"] = $last;
691 unset( $lastQuery["{$type}until"] );
692 $nextLink = $linkRenderer->makeKnownLink(
693 $this->addFragmentToTitle( $this->page, $type ),
694 new HtmlArmor( $nextLink ),
695 [],
696 $lastQuery
697 );
698 }
699
700 return $this->msg( 'categoryviewer-pagedlinks' )->rawParams( $prevLink, $nextLink )->escaped();
701 }
702
711 private function addFragmentToTitle( PageReference $page, string $section ): LinkTarget {
712 $fragment = match ( $section ) {
713 'page' => 'mw-pages',
714 'subcat' => 'mw-subcategories',
715 'file' => 'mw-category-media',
716 default => throw new InvalidArgumentException( __METHOD__ . " Invalid section $section." )
717 };
718 return new TitleValue( $page->getNamespace(), $page->getDBkey(), $fragment );
719 }
720
731 private function getCountMessage( int $localCount, int $databaseCount, string $type ): string {
732 // There are three cases:
733 // 1) The category table figure seems good. It might be wrong, but
734 // we can't do anything about it if we don't recalculate it on ev-
735 // ery category view.
736 // 2) The category table figure isn't good, like it's smaller than the
737 // number of actual results, *but* the number of results is less
738 // than $this->limit and there's no offset. In this case we still
739 // know the right figure.
740 // 3) We have no idea.
741
742 // Check if there's a "from" or "until" for anything
743
744 // This is a little ugly, but we seem to use different names
745 // for the paging types then for the messages.
746 $msgType = $type === 'page' ? 'article' : $type;
747
748 $fromOrUntil = false;
749 if ( isset( $this->from[$type] ) || isset( $this->until[$type] ) ) {
750 $fromOrUntil = true;
751 }
752
753 if ( $databaseCount == $localCount ||
754 ( ( $localCount == $this->limit || $fromOrUntil ) && $databaseCount > $localCount )
755 ) {
756 // Case 1: seems good.
757 $totalCount = $databaseCount;
758 } elseif ( $localCount < $this->limit && !$fromOrUntil ) {
759 // Case 2: not good, but salvageable. Use the number of results.
760 $totalCount = $localCount;
761 } else {
762 // Case 3: hopeless. Don't give a total count at all.
763 // Messages: category-subcat-count-limited, category-article-count-limited,
764 // category-file-count-limited
765 return $this->msg( "category-$msgType-count-limited" )->numParams( $localCount )->parseAsBlock();
766 }
767 // Messages: category-subcat-count, category-article-count, category-file-count
768 return $this->msg( "category-$msgType-count" )->numParams( $localCount, $totalCount )->parseAsBlock();
769 }
770}
const NS_FILE
Definition Defines.php:57
const NS_CATEGORY
Definition Defines.php:65
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
if(!defined('MW_SETUP_CALLBACK'))
Definition WebStart.php:69
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.
array array< 'page'| 'subcat'| 'file', bool > $flip
Sorting order for each type.
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.
__construct(protected PageIdentity $page, IContextSource $context, public readonly array $from=[], public readonly array $until=[], private array $query=[],)
getSubcategorySortChar(PageIdentity $page, string $sortkey)
Get the character to be used for sorting subcategories.
array array< 'page'| 'subcat'| 'file',?string > $prevPage
addPage(PageReference $page, string $sortkey, int $pageLength, bool $isRedirect=false)
Add a miscellaneous page.
array array< 'page'| 'subcat'| 'file',?string > $nextPage
addSubcategoryObject(Category $cat, string $sortkey, int $pageLength)
Add a subcategory to the internal lists, using a Category object.
Category objects are immutable, strictly speaking.
Definition Category.php:29
static newFromTitle(PageIdentity $page)
Factory function.
Definition Category.php:171
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.
Class for exceptions thrown by ImageGalleryBase::factory().
static factory( $mode=false, ?IContextSource $context=null)
Get a new image gallery.
This class is a collection of static functions that serve two purposes:
Definition Html.php:44
A class containing constants representing the names of configuration variables.
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.
Page existence and metadata cache.
Definition LinkCache.php:54
Represents the target of a wiki link.
Represents a title within MediaWiki.
Definition Title.php:69
Marks HTML that shouldn't be escaped.
Definition HtmlArmor.php:18
Overloads the relevant methods of the real ResultWrapper so it doesn't go anywhere near an actual dat...
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.
msg( $key,... $params)