MediaWiki master
SpecialUncategorizedCategories.php
Go to the documentation of this file.
1<?php
24namespace MediaWiki\Specials;
25
30use Skin;
31use stdClass;
33
45 private $exceptionList = null;
46
53 public function __construct(
54 NamespaceInfo $namespaceInfo,
55 IConnectionProvider $dbProvider,
56 LinkBatchFactory $linkBatchFactory,
57 LanguageConverterFactory $languageConverterFactory
58 ) {
59 parent::__construct(
60 $namespaceInfo,
61 $dbProvider,
62 $linkBatchFactory,
63 $languageConverterFactory
64 );
65 $this->mName = 'Uncategorizedcategories';
66 $this->requestedNamespace = NS_CATEGORY;
67 }
68
75 private function getExceptionList() {
76 if ( $this->exceptionList === null ) {
77 $this->exceptionList = [];
78 $exList = $this->msg( 'uncategorized-categories-exceptionlist' )
79 ->inContentLanguage()->plain();
80 $proposedTitles = explode( "\n", $exList );
81 foreach ( $proposedTitles as $titleStr ) {
82 if ( !str_starts_with( $titleStr, '*' ) ) {
83 continue;
84 }
85 $titleStr = preg_replace( "/^\\*\\s*/", '', $titleStr );
86 $title = Title::newFromText( $titleStr, NS_CATEGORY );
87 if ( $title && $title->getNamespace() !== NS_CATEGORY ) {
88 $title = Title::makeTitleSafe( NS_CATEGORY, $titleStr );
89 }
90 if ( $title ) {
91 $this->exceptionList[] = $title->getDBkey();
92 }
93 }
94 }
95 return $this->exceptionList;
96 }
97
98 public function getQueryInfo() {
99 $query = parent::getQueryInfo();
100 $exceptionList = $this->getExceptionList();
101 if ( $exceptionList ) {
102 $dbr = $this->getDatabaseProvider()->getReplicaDatabase();
103 $query['conds'][] = $dbr->expr( 'page_title', '!=', $exceptionList );
104 }
105
106 return $query;
107 }
108
115 public function formatResult( $skin, $result ) {
116 $title = Title::makeTitle( NS_CATEGORY, $result->title );
117 $text = $title->getText();
118
119 return $this->getLinkRenderer()->makeKnownLink( $title, $text );
120 }
121}
122
127class_alias( SpecialUncategorizedCategories::class, 'SpecialUncategorizedCategories' );
const NS_CATEGORY
Definition Defines.php:78
An interface for creating language converters.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
A special page that lists uncategorized categories.
__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...
A special page looking for page without any category.
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
The base class for all skins.
Definition Skin.php:58
Provide primary and replica IDatabase connections.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...