| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
namespace MediaWiki\Specials; |
| 22 |
|
| 23 |
use MediaWiki\Cache\LinkBatchFactory; |
| 24 |
use MediaWiki\Languages\LanguageConverterFactory; |
| 25 |
use MediaWiki\Title\NamespaceInfo; |
| 26 |
use MediaWiki\Title\Title; |
| 27 |
use Skin; |
| 28 |
use stdClass; |
| 29 |
use Wikimedia\Rdbms\IConnectionProvider; |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
class SpecialUncategorizedCategories extends SpecialUncategorizedPages { |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
private $exceptionList = null; |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
public function __construct( |
| 51 |
NamespaceInfo $namespaceInfo, |
| 52 |
IConnectionProvider $dbProvider, |
| 53 |
LinkBatchFactory $linkBatchFactory, |
| 54 |
LanguageConverterFactory $languageConverterFactory |
| 55 |
) { |
| 56 |
parent::__construct( |
| 57 |
$namespaceInfo, |
| 58 |
$dbProvider, |
| 59 |
$linkBatchFactory, |
| 60 |
$languageConverterFactory |
| 61 |
); |
| 62 |
$this->mName = 'Uncategorizedcategories'; |
| 63 |
$this->requestedNamespace = NS_CATEGORY; |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
private function getExceptionList() { |
| 73 |
if ( $this->exceptionList === null ) { |
| 74 |
$this->exceptionList = []; |
| 75 |
$exList = $this->msg( 'uncategorized-categories-exceptionlist' ) |
| 76 |
->inContentLanguage()->plain(); |
| 77 |
$proposedTitles = explode( "\n", $exList ); |
| 78 |
foreach ( $proposedTitles as $titleStr ) { |
| 79 |
if ( !str_starts_with( $titleStr, '*' ) ) { |
| 80 |
continue; |
| 81 |
} |
| 82 |
$titleStr = preg_replace( "/^\\*\\s*/", '', $titleStr ); |
| 83 |
$title = Title::newFromText( $titleStr, NS_CATEGORY ); |
| 84 |
if ( $title && $title->getNamespace() !== NS_CATEGORY ) { |
| 85 |
$title = Title::makeTitleSafe( NS_CATEGORY, $titleStr ); |
| 86 |
} |
| 87 |
if ( $title ) { |
| 88 |
$this->exceptionList[] = $title->getDBkey(); |
| 89 |
} |
| 90 |
} |
| 91 |
} |
| 92 |
return $this->exceptionList; |
| 93 |
} |
| 94 |
|
| 95 |
public function getQueryInfo() { |
| 96 |
$query = parent::getQueryInfo(); |
| 97 |
$exceptionList = $this->getExceptionList(); |
| 98 |
if ( $exceptionList ) { |
| 99 |
$dbr = $this->getDatabaseProvider()->getReplicaDatabase(); |
| 100 |
$query['conds'][] = $dbr->expr( 'page_title', '!=', $exceptionList ); |
| 101 |
} |
| 102 |
|
| 103 |
return $query; |
| 104 |
} |
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
public function formatResult( $skin, $result ) { |
| 113 |
$title = Title::makeTitle( NS_CATEGORY, $result->title ); |
| 114 |
$text = $title->getText(); |
| 115 |
|
| 116 |
return $this->getLinkRenderer()->makeKnownLink( $title, $text ); |
| 117 |
} |
| 118 |
} |
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
class_alias( SpecialUncategorizedCategories::class, 'SpecialUncategorizedCategories' ); |