MediaWiki  master
SpecialUncategorizedCategories.php
Go to the documentation of this file.
1 <?php
27 
39  private $exceptionList = null;
40 
47  public function __construct(
51  LanguageConverterFactory $languageConverterFactory
52  ) {
53  parent::__construct(
57  $languageConverterFactory
58  );
59  $this->mName = 'Uncategorizedcategories';
60  $this->requestedNamespace = NS_CATEGORY;
61  }
62 
69  private function getExceptionList() {
70  if ( $this->exceptionList === null ) {
71  $this->exceptionList = [];
72  $exList = $this->msg( 'uncategorized-categories-exceptionlist' )
73  ->inContentLanguage()->plain();
74  $proposedTitles = explode( "\n", $exList );
75  foreach ( $proposedTitles as $count => $titleStr ) {
76  if ( strpos( $titleStr, '*' ) !== 0 ) {
77  continue;
78  }
79  $titleStr = preg_replace( "/^\\*\\s*/", '', $titleStr );
80  $title = Title::newFromText( $titleStr, NS_CATEGORY );
81  if ( $title && $title->getNamespace() !== NS_CATEGORY ) {
82  $title = Title::makeTitleSafe( NS_CATEGORY, $titleStr );
83  }
84  if ( $title ) {
85  $this->exceptionList[] = $title->getDBkey();
86  }
87  }
88  }
89  return $this->exceptionList;
90  }
91 
92  public function getQueryInfo() {
93  $query = parent::getQueryInfo();
95  if ( $exceptionList ) {
96  $dbr = $this->getDBLoadBalancer()->getConnectionRef( ILoadBalancer::DB_REPLICA );
97  $query['conds'][] = 'page_title not in ( ' . $dbr->makeList( $exceptionList ) . ' )';
98  }
99 
100  return $query;
101  }
102 
109  public function formatResult( $skin, $result ) {
110  $title = Title::makeTitle( NS_CATEGORY, $result->title );
111  $text = $title->getText();
112 
113  return $this->getLinkRenderer()->makeKnownLink( $title, $text );
114  }
115 }
SpecialUncategorizedCategories\$exceptionList
array $exceptionList
Holds a list of categories, which shouldn't be listed on this special page, even if it is uncategoriz...
Definition: SpecialUncategorizedCategories.php:39
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:912
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:383
QueryPage\getDBLoadBalancer
getDBLoadBalancer()
Definition: QueryPage.php:900
SpecialUncategorizedPages
A special page looking for page without any category.
Definition: SpecialUncategorizedPages.php:34
SpecialUncategorizedCategories
A special page that lists uncategorized categories.
Definition: SpecialUncategorizedCategories.php:33
SpecialUncategorizedPages\$namespaceInfo
NamespaceInfo $namespaceInfo
Definition: SpecialUncategorizedPages.php:39
MediaWiki\Languages\LanguageConverterFactory
An interface for creating language converters.
Definition: LanguageConverterFactory.php:46
SpecialUncategorizedCategories\formatResult
formatResult( $skin, $result)
Formats the result.
Definition: SpecialUncategorizedCategories.php:109
$dbr
$dbr
Definition: testCompression.php:54
SpecialUncategorizedCategories\__construct
__construct(NamespaceInfo $namespaceInfo, ILoadBalancer $loadBalancer, LinkBatchFactory $linkBatchFactory, LanguageConverterFactory $languageConverterFactory)
Definition: SpecialUncategorizedCategories.php:47
MediaWiki\Cache\LinkBatchFactory
Definition: LinkBatchFactory.php:39
$title
$title
Definition: testCompression.php:38
SpecialUncategorizedCategories\getExceptionList
getExceptionList()
Returns an array of category titles (usually without the namespace), which shouldn't be listed on thi...
Definition: SpecialUncategorizedCategories.php:69
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:651
DB_REPLICA
const DB_REPLICA
Definition: defines.php:25
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:677
QueryPage\$linkBatchFactory
LinkBatchFactory null $linkBatchFactory
Definition: QueryPage.php:74
SpecialPage\getLinkRenderer
getLinkRenderer()
Definition: SpecialPage.php:1028
SpecialUncategorizedCategories\getQueryInfo
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
Definition: SpecialUncategorizedCategories.php:92
NS_CATEGORY
const NS_CATEGORY
Definition: Defines.php:78
QueryPage\$loadBalancer
ILoadBalancer null $loadBalancer
Definition: QueryPage.php:71
NamespaceInfo
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
Definition: NamespaceInfo.php:35
Wikimedia\Rdbms\ILoadBalancer
Database cluster connection, tracking, load balancing, and transaction manager interface.
Definition: ILoadBalancer.php:81