MediaWiki master
SpecialUncategorizedCategories.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\Specials;
22
27use Skin;
28use stdClass;
30
42 private $exceptionList = null;
43
50 public function __construct(
51 NamespaceInfo $namespaceInfo,
52 IConnectionProvider $dbProvider,
53 LinkBatchFactory $linkBatchFactory,
54 LanguageConverterFactory $languageConverterFactory
55 ) {
56 parent::__construct(
57 $namespaceInfo,
58 $dbProvider,
59 $linkBatchFactory,
60 $languageConverterFactory
61 );
62 $this->mName = 'Uncategorizedcategories';
63 $this->requestedNamespace = NS_CATEGORY;
64 }
65
72 private function getExceptionList() {
73 if ( $this->exceptionList === null ) {
74 $this->exceptionList = [];
75 $exList = $this->msg( 'uncategorized-categories-exceptionlist' )
76 ->inContentLanguage()->plain();
77 $proposedTitles = explode( "\n", $exList );
78 foreach ( $proposedTitles as $titleStr ) {
79 if ( !str_starts_with( $titleStr, '*' ) ) {
80 continue;
81 }
82 $titleStr = preg_replace( "/^\\*\\s*/", '', $titleStr );
83 $title = Title::newFromText( $titleStr, NS_CATEGORY );
84 if ( $title && $title->getNamespace() !== NS_CATEGORY ) {
85 $title = Title::makeTitleSafe( NS_CATEGORY, $titleStr );
86 }
87 if ( $title ) {
88 $this->exceptionList[] = $title->getDBkey();
89 }
90 }
91 }
92 return $this->exceptionList;
93 }
94
95 public function getQueryInfo() {
96 $query = parent::getQueryInfo();
97 $exceptionList = $this->getExceptionList();
98 if ( $exceptionList ) {
99 $dbr = $this->getDatabaseProvider()->getReplicaDatabase();
100 $query['conds'][] = $dbr->expr( 'page_title', '!=', $exceptionList );
101 }
102
103 return $query;
104 }
105
112 public function formatResult( $skin, $result ) {
113 $title = Title::makeTitle( NS_CATEGORY, $result->title );
114 $text = $title->getText();
115
116 return $this->getLinkRenderer()->makeKnownLink( $title, $text );
117 }
118}
119
124class_alias( SpecialUncategorizedCategories::class, 'SpecialUncategorizedCategories' );
const NS_CATEGORY
Definition Defines.php:79
An interface for creating language converters.
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:79
The base class for all skins.
Definition Skin.php:59
Provide primary and replica IDatabase connections.