MediaWiki master
SpecialUncategorizedCategories.php
Go to the documentation of this file.
1<?php
7namespace MediaWiki\Specials;
8
9use MediaWiki\Cache\LinkBatchFactory;
10use MediaWiki\Languages\LanguageConverterFactory;
14use stdClass;
16
28 private $exceptionList = null;
29
30 public function __construct(
31 NamespaceInfo $namespaceInfo,
32 IConnectionProvider $dbProvider,
33 LinkBatchFactory $linkBatchFactory,
34 LanguageConverterFactory $languageConverterFactory
35 ) {
36 parent::__construct(
37 $namespaceInfo,
38 $dbProvider,
39 $linkBatchFactory,
40 $languageConverterFactory
41 );
42 $this->mName = 'Uncategorizedcategories';
43 $this->requestedNamespace = NS_CATEGORY;
44 }
45
52 private function getExceptionList() {
53 if ( $this->exceptionList === null ) {
54 $this->exceptionList = [];
55 $exList = $this->msg( 'uncategorized-categories-exceptionlist' )
56 ->inContentLanguage()->plain();
57 $proposedTitles = explode( "\n", $exList );
58 foreach ( $proposedTitles as $titleStr ) {
59 if ( !str_starts_with( $titleStr, '*' ) ) {
60 continue;
61 }
62 $titleStr = preg_replace( "/^\\*\\s*/", '', $titleStr );
63 $title = Title::newFromText( $titleStr, NS_CATEGORY );
64 if ( $title && $title->getNamespace() !== NS_CATEGORY ) {
65 $title = Title::makeTitleSafe( NS_CATEGORY, $titleStr );
66 }
67 if ( $title ) {
68 $this->exceptionList[] = $title->getDBkey();
69 }
70 }
71 }
72 return $this->exceptionList;
73 }
74
76 public function getQueryInfo() {
77 $query = parent::getQueryInfo();
78 $exceptionList = $this->getExceptionList();
79 if ( $exceptionList ) {
80 $dbr = $this->getDatabaseProvider()->getReplicaDatabase();
81 $query['conds'][] = $dbr->expr( 'page_title', '!=', $exceptionList );
82 }
83
84 return $query;
85 }
86
93 public function formatResult( $skin, $result ) {
94 $title = Title::makeTitle( NS_CATEGORY, $result->title );
95 $text = $title->getText();
96
97 return $this->getLinkRenderer()->makeKnownLink( $title, $text );
98 }
99}
100
105class_alias( SpecialUncategorizedCategories::class, 'SpecialUncategorizedCategories' );
const NS_CATEGORY
Definition Defines.php:65
makeTitle( $linkId)
Convert a link ID to a Title.to override Title
The base class for all skins.
Definition Skin.php:52
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
__construct(NamespaceInfo $namespaceInfo, IConnectionProvider $dbProvider, LinkBatchFactory $linkBatchFactory, LanguageConverterFactory $languageConverterFactory)
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
Represents a title within MediaWiki.
Definition Title.php:69
Provide primary and replica IDatabase connections.