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 }
const NS_CATEGORY
Definition: Defines.php:78
An interface for creating language converters.
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
LinkBatchFactory null $linkBatchFactory
Definition: QueryPage.php:75
getDBLoadBalancer()
Definition: QueryPage.php:903
ILoadBalancer null $loadBalancer
Definition: QueryPage.php:72
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
A special page that lists uncategorized categories.
formatResult( $skin, $result)
Formats the result.
array $exceptionList
Holds a list of categories, which shouldn't be listed on this special page, even if it is uncategoriz...
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
__construct(NamespaceInfo $namespaceInfo, ILoadBalancer $loadBalancer, LinkBatchFactory $linkBatchFactory, LanguageConverterFactory $languageConverterFactory)
getExceptionList()
Returns an array of category titles (usually without the namespace), which shouldn't be listed on thi...
A special page looking for page without any category.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:369
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:663
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:637
Database cluster connection, tracking, load balancing, and transaction manager interface.
const DB_REPLICA
Definition: defines.php:25