MediaWiki  master
SpecialUncategorizedCategories.php
Go to the documentation of this file.
1 <?php
27 
39  private $exceptionList = null;
40 
47  public function __construct(
48  NamespaceInfo $namespaceInfo,
49  ILoadBalancer $loadBalancer,
50  LinkBatchFactory $linkBatchFactory,
51  LanguageConverterFactory $languageConverterFactory
52  ) {
53  parent::__construct(
54  $namespaceInfo,
55  $loadBalancer,
56  $linkBatchFactory,
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 $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();
94  $exceptionList = $this->getExceptionList();
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...
getDBLoadBalancer()
Definition: QueryPage.php:924
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
A special page that lists uncategorized categories.
formatResult( $skin, $result)
Formats the result.
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)
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:373
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:667
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:641
Create and track the database connections and transactions for a given database cluster.
const DB_REPLICA
Definition: defines.php:26