MediaWiki  1.34.0
SpecialUncategorizedCategories.php
Go to the documentation of this file.
1 <?php
35  private $exceptionList = null;
36 
37  function __construct( $name = 'Uncategorizedcategories' ) {
38  parent::__construct( $name );
39  $this->requestedNamespace = NS_CATEGORY;
40  }
41 
48  private function getExceptionList() {
49  if ( $this->exceptionList === null ) {
50  $this->exceptionList = [];
51  $exList = $this->msg( 'uncategorized-categories-exceptionlist' )
52  ->inContentLanguage()->plain();
53  $proposedTitles = explode( "\n", $exList );
54  foreach ( $proposedTitles as $count => $titleStr ) {
55  if ( strpos( $titleStr, '*' ) !== 0 ) {
56  continue;
57  }
58  $titleStr = preg_replace( "/^\\*\\s*/", '', $titleStr );
59  $title = Title::newFromText( $titleStr, NS_CATEGORY );
60  if ( $title && $title->getNamespace() !== NS_CATEGORY ) {
61  $title = Title::makeTitleSafe( NS_CATEGORY, $titleStr );
62  }
63  if ( $title ) {
64  $this->exceptionList[] = $title->getDBkey();
65  }
66  }
67  }
68  return $this->exceptionList;
69  }
70 
71  public function getQueryInfo() {
72  $dbr = wfGetDB( DB_REPLICA );
73  $query = parent::getQueryInfo();
75  if ( $exceptionList ) {
76  $query['conds'][] = 'page_title not in ( ' . $dbr->makeList( $exceptionList ) . ' )';
77  }
78 
79  return $query;
80  }
81 
88  function formatResult( $skin, $result ) {
89  $title = Title::makeTitle( NS_CATEGORY, $result->title );
90  $text = $title->getText();
91 
92  return $this->getLinkRenderer()->makeKnownLink( $title, $text );
93  }
94 }
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:35
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:792
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:316
SpecialUncategorizedPages
A special page looking for page without any category.
Definition: SpecialUncategorizedPages.php:32
SpecialUncategorizedCategories\__construct
__construct( $name='Uncategorizedcategories')
Definition: SpecialUncategorizedCategories.php:37
SpecialUncategorizedCategories
A special page that lists uncategorized categories.
Definition: SpecialUncategorizedCategories.php:29
SpecialUncategorizedCategories\formatResult
formatResult( $skin, $result)
Formats the result.
Definition: SpecialUncategorizedCategories.php:88
$dbr
$dbr
Definition: testCompression.php:50
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:2575
$title
$title
Definition: testCompression.php:34
SpecialUncategorizedCategories\getExceptionList
getExceptionList()
Returns an array of category titles (usually without the namespace), which shouldn't be listed on thi...
Definition: SpecialUncategorizedCategories.php:48
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:586
DB_REPLICA
const DB_REPLICA
Definition: defines.php:25
NS_CATEGORY
const NS_CATEGORY
Definition: Defines.php:74
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:613
SpecialPage\getLinkRenderer
getLinkRenderer()
Definition: SpecialPage.php:904
SpecialUncategorizedCategories\getQueryInfo
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
Definition: SpecialUncategorizedCategories.php:71