MediaWiki  master
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 }
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
getExceptionList()
Returns an array of category titles (usually without the namespace), which shouldn&#39;t be listed on thi...
formatResult( $skin, $result)
Formats the result.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
const NS_CATEGORY
Definition: Defines.php:74
A special page looking for page without any category.
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:612
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:586
array $exceptionList
Holds a list of categories, which shouldn&#39;t be listed on this special page, even if it is uncategoriz...
const DB_REPLICA
Definition: defines.php:25
A special page that lists uncategorized categories.
__construct( $name='Uncategorizedcategories')
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:319