MediaWiki  master
SpecialUncategorizedCategories.php
Go to the documentation of this file.
1 <?php
25 
37  private $exceptionList = null;
38 
40  private $loadBalancer;
41 
46  public function __construct(
49  ) {
50  parent::__construct( $namespaceInfo );
51  $this->mName = 'Uncategorizedcategories';
52  $this->requestedNamespace = NS_CATEGORY;
53  $this->loadBalancer = $loadBalancer;
54  }
55 
62  private function getExceptionList() {
63  if ( $this->exceptionList === null ) {
64  $this->exceptionList = [];
65  $exList = $this->msg( 'uncategorized-categories-exceptionlist' )
66  ->inContentLanguage()->plain();
67  $proposedTitles = explode( "\n", $exList );
68  foreach ( $proposedTitles as $count => $titleStr ) {
69  if ( strpos( $titleStr, '*' ) !== 0 ) {
70  continue;
71  }
72  $titleStr = preg_replace( "/^\\*\\s*/", '', $titleStr );
73  $title = Title::newFromText( $titleStr, NS_CATEGORY );
74  if ( $title && $title->getNamespace() !== NS_CATEGORY ) {
75  $title = Title::makeTitleSafe( NS_CATEGORY, $titleStr );
76  }
77  if ( $title ) {
78  $this->exceptionList[] = $title->getDBkey();
79  }
80  }
81  }
82  return $this->exceptionList;
83  }
84 
85  public function getQueryInfo() {
86  $query = parent::getQueryInfo();
88  if ( $exceptionList ) {
89  $dbr = $this->loadBalancer->getConnectionRef( ILoadBalancer::DB_REPLICA );
90  $query['conds'][] = 'page_title not in ( ' . $dbr->makeList( $exceptionList ) . ' )';
91  }
92 
93  return $query;
94  }
95 
102  public function formatResult( $skin, $result ) {
103  $title = Title::makeTitle( NS_CATEGORY, $result->title );
104  $text = $title->getText();
105 
106  return $this->getLinkRenderer()->makeKnownLink( $title, $text );
107  }
108 }
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:37
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:827
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:328
SpecialUncategorizedPages
A special page looking for page without any category.
Definition: SpecialUncategorizedPages.php:30
SpecialUncategorizedCategories\$loadBalancer
ILoadBalancer $loadBalancer
Definition: SpecialUncategorizedCategories.php:40
SpecialUncategorizedCategories
A special page that lists uncategorized categories.
Definition: SpecialUncategorizedCategories.php:31
SpecialUncategorizedPages\$namespaceInfo
NamespaceInfo $namespaceInfo
Definition: SpecialUncategorizedPages.php:35
SpecialUncategorizedCategories\formatResult
formatResult( $skin, $result)
Formats the result.
Definition: SpecialUncategorizedCategories.php:102
$dbr
$dbr
Definition: testCompression.php:54
$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:62
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:591
DB_REPLICA
const DB_REPLICA
Definition: defines.php:25
NS_CATEGORY
const NS_CATEGORY
Definition: Defines.php:83
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:617
SpecialPage\getLinkRenderer
getLinkRenderer()
Definition: SpecialPage.php:944
SpecialUncategorizedCategories\getQueryInfo
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
Definition: SpecialUncategorizedCategories.php:85
SpecialUncategorizedCategories\__construct
__construct(ILoadBalancer $loadBalancer, NamespaceInfo $namespaceInfo)
Definition: SpecialUncategorizedCategories.php:46
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