MediaWiki REL1_35
SpecialUncategorizedCategories.php
Go to the documentation of this file.
1<?php
35 private $exceptionList = null;
36
37 public 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 }
69 }
70
71 public function getQueryInfo() {
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 public 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.
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( $name='Uncategorizedcategories')
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.
const NS_CATEGORY
Definition Defines.php:84
const DB_REPLICA
Definition defines.php:25