mirror of
https://github.com/diocloid/LinkTitles.git
synced 2025-07-13 09:49:31 +02:00
Change nameSpace to all lowercase everywhere.
Makes it consistent with MW's spelling of the term.
This commit is contained in:
@ -34,14 +34,14 @@ class Targets {
|
||||
* potential target page titles.
|
||||
*
|
||||
* The subset of pages that may serve as target pages depends on the
|
||||
* name space of the source page. Therefore, if the $nameSpace differs from
|
||||
* name space of the source page. Therefore, if the $namespace differs from
|
||||
* the cached name space, the database is queried again.
|
||||
*
|
||||
* @param String $nameSpace The namespace of the current page.
|
||||
* @param String $namespace The namespace of the current page.
|
||||
* @param Config $config LinkTitles configuration.
|
||||
*/
|
||||
public static function default( \Title $title, Config $config ) {
|
||||
if ( ( self::$instance === null ) || ( self::$instance->nameSpace != $title->getNamespace() ) ) {
|
||||
if ( ( self::$instance === null ) || ( self::$instance->namespace != $title->getNamespace() ) ) {
|
||||
self::$instance = new Targets( $title, $config );
|
||||
}
|
||||
return self::$instance;
|
||||
@ -67,9 +67,9 @@ class Targets {
|
||||
|
||||
/**
|
||||
* Holds the name space (integer) for which the list of target pages was built.
|
||||
* @var Int $nameSpace
|
||||
* @var Int $namespace
|
||||
*/
|
||||
public $nameSpace;
|
||||
public $namespace;
|
||||
|
||||
private $config;
|
||||
|
||||
@ -79,7 +79,7 @@ class Targets {
|
||||
*/
|
||||
private function __construct( \Title $title, Config $config) {
|
||||
$this->config = $config;
|
||||
$this->nameSpace = $title->getNameSpace();
|
||||
$this->namespace = $title->getNamespace();
|
||||
$this->fetch();
|
||||
}
|
||||
|
||||
@ -101,18 +101,18 @@ class Targets {
|
||||
}
|
||||
|
||||
// Build our weight list. Make sure current namespace is first element
|
||||
$nameSpaces = array_diff( $this->config->nameSpaces, [ $this->nameSpace ] );
|
||||
array_unshift( $nameSpaces, $this->nameSpace );
|
||||
$namespaces = array_diff( $this->config->namespaces, [ $this->namespace ] );
|
||||
array_unshift( $namespaces, $this->namespace );
|
||||
|
||||
// No need for sanitiy check. we are sure that we have at least one element in the array
|
||||
$weightSelect = "CASE page_namespace ";
|
||||
$currentWeight = 0;
|
||||
foreach ($nameSpaces as &$nameSpaceValue) {
|
||||
foreach ($namespaces as &$namespaceValue) {
|
||||
$currentWeight = $currentWeight + 100;
|
||||
$weightSelect = $weightSelect . " WHEN " . $nameSpaceValue . " THEN " . $currentWeight . PHP_EOL;
|
||||
$weightSelect = $weightSelect . " WHEN " . $namespaceValue . " THEN " . $currentWeight . PHP_EOL;
|
||||
}
|
||||
$weightSelect = $weightSelect . " END ";
|
||||
$nameSpacesClause = '(' . implode( ', ', $nameSpaces ) . ')';
|
||||
$namespacesClause = '(' . implode( ', ', $namespaces ) . ')';
|
||||
|
||||
// Build an SQL query and fetch all page titles ordered by length from
|
||||
// shortest to longest. Only titles from 'normal' pages (namespace uid
|
||||
@ -125,7 +125,7 @@ class Targets {
|
||||
array( 'page_title', 'page_namespace' , "weight" => $weightSelect),
|
||||
array_filter(
|
||||
array(
|
||||
'page_namespace IN ' . $nameSpacesClause,
|
||||
'page_namespace IN ' . $namespacesClause,
|
||||
'CHAR_LENGTH(page_title) >= ' . $this->config->minimumTitleLength,
|
||||
$blackList,
|
||||
)
|
||||
@ -139,7 +139,7 @@ class Targets {
|
||||
array( 'page_title', 'page_namespace' , "weight" => $weightSelect ),
|
||||
array_filter(
|
||||
array(
|
||||
'page_namespace IN ' . $nameSpacesClause,
|
||||
'page_namespace IN ' . $namespacesClause,
|
||||
'LENGTH(page_title) >= ' . $this->config->minimumTitleLength,
|
||||
$blackList,
|
||||
)
|
||||
|
Reference in New Issue
Block a user