diff --git a/includes/Config.php b/includes/Config.php index e8738c5..f2f2b93 100644 --- a/includes/Config.php +++ b/includes/Config.php @@ -70,9 +70,9 @@ class Config { /** * Array of those name spaces (integer constants) whose pages may be linked. - * @var Array $nameSpaces + * @var Array $namespaces */ - public $nameSpaces; + public $namespaces; /** * Indicates whether to add a link to the first occurrence of a page title @@ -186,7 +186,7 @@ class Config { $this->preferShortTitles = $wgLinkTitlesPreferShortTitles; $this->minimumTitleLength = $wgLinkTitlesMinimumTitleLength; $this->blackList = $wgLinkTitlesBlackList; - $this->nameSpaces = $wgLinkTitlesNamespaces; + $this->namespaces = $wgLinkTitlesNamespaces; $this->firstOnly = $wgLinkTitlesFirstOnly; $this->smartMode = $wgLinkTitlesSmartMode; $this->capitalLinks = $wgCapitalLinks; // MediaWiki global variable diff --git a/includes/Extension.php b/includes/Extension.php index 80c380a..ced7bbf 100644 --- a/includes/Extension.php +++ b/includes/Extension.php @@ -39,7 +39,7 @@ class Extension { // Only process if page is in one of our namespaces we want to link // Fixes ugly autolinking of sidebar pages - if ( in_array( $title->getNamespace(), $config->nameSpaces )) { + if ( in_array( $title->getNamespace(), $config->namespaces )) { $text = $content->getContentHandler()->serializeContent( $content ); if ( !\MagicWord::get( 'MAG_LINKTITLES_NOAUTOLINKS' )->match( $text ) ) { $linker = new Linker( $config ); @@ -65,7 +65,7 @@ class Extension { // If the page contains the magic word '__NOAUTOLINKS__', do not parse it. // Only process if page is in one of our namespaces we want to link if ( !\MagicWord::get( 'MAG_LINKTITLES_NOAUTOLINKS' )->match( $text ) && - in_array( $title->getNamespace(), $config->nameSpaces ) ) { + in_array( $title->getNamespace(), $config->namespaces ) ) { $linker = new Linker( $config ); $text = $linker->linkContent( $title, $text ); } diff --git a/includes/Special.php b/includes/Special.php index d316a9b..b302a3a 100644 --- a/includes/Special.php +++ b/includes/Special.php @@ -97,7 +97,7 @@ class Special extends \SpecialPage { */ private function process( \WebRequest &$request, \OutputPage &$output) { // get our Namespaces - $namespacesClause = str_replace( '_', ' ','(' . implode( ', ',$this->config->nameSpaces ) . ')' ); + $namespacesClause = str_replace( '_', ' ','(' . implode( ', ',$this->config->namespaces ) . ')' ); // Start the stopwatch $startTime = microtime( true ); diff --git a/includes/Target.php b/includes/Target.php index 034e60b..02dae8c 100644 --- a/includes/Target.php +++ b/includes/Target.php @@ -69,12 +69,12 @@ class Target { * * The parameters may be taken from database rows, for example. * - * @param Int $nameSpace Name space of the target page + * @param Int $namespace Name space of the target page * @param String &$title Title of the target page */ - public function __construct( $nameSpace, $title, Config &$config ) { - // print "\n>>>nameSpace=$nameSpace;title=$title<<<\n"; - $this->title = \Title::makeTitleSafe( $nameSpace, $title ); + public function __construct( $namespace, $title, Config &$config ) { + // print "\n>>>namespace=$namespace;title=$title<<<\n"; + $this->title = \Title::makeTitleSafe( $namespace, $title ); $this->titleValue = $this->title->getTitleValue(); $this->config = $config; diff --git a/includes/Targets.php b/includes/Targets.php index 305fade..a2d56c3 100644 --- a/includes/Targets.php +++ b/includes/Targets.php @@ -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, ) diff --git a/linktitles-cli.php b/linktitles-cli.php index 04a1887..535589f 100755 --- a/linktitles-cli.php +++ b/linktitles-cli.php @@ -155,12 +155,12 @@ class Cli extends \Maintenance { // Retrieve page names from the database. $dbr = $this->getDB( DB_SLAVE ); - $nameSpacesClause = str_replace( '_', ' ','(' . implode( ', ', $config->nameSpaces ) . ')' ); + $namespacesClause = str_replace( '_', ' ','(' . implode( ', ', $config->namespaces ) . ')' ); $res = $dbr->select( 'page', array( 'page_title', 'page_namespace' ), array( - 'page_namespace IN ' . $nameSpacesClause, + 'page_namespace IN ' . $namespacesClause, ), __METHOD__, array(