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