From 4c3c5e493164b815cb6a75a15f3228b1e32f9050 Mon Sep 17 00:00:00 2001 From: c0nnex Date: Wed, 30 Sep 2015 01:50:19 +0200 Subject: [PATCH] Revert "Added Namespace support" This reverts commit a9840b77e8ea11c6fb2c16cfc37d8470995479f9. --- LinkTitles.body.php | 35 +++++++----------------- LinkTitles.php | 4 --- LinkTitles.phpproj | 66 --------------------------------------------- 3 files changed, 9 insertions(+), 96 deletions(-) delete mode 100644 LinkTitles.phpproj diff --git a/LinkTitles.body.php b/LinkTitles.body.php index 2713707..64744a4 100755 --- a/LinkTitles.body.php +++ b/LinkTitles.body.php @@ -108,7 +108,6 @@ global $wgLinkTitlesFirstOnly; global $wgLinkTitlesSmartMode; global $wgCapitalLinks; - global $wgLinkTitlesNamespaces; ( $wgLinkTitlesPreferShortTitles ) ? $sort_order = 'ASC' : $sort_order = 'DESC'; ( $wgLinkTitlesFirstOnly ) ? $limit = 1 : $limit = -1; @@ -122,23 +121,6 @@ '("' . implode( '", "',$wgLinkTitlesBlackList ) . '", "' . LinkTitles::$currentTitle->getDbKey() . '")' ); - $currentNamespace = $title->getNamespace(); - - // Build our weight list. Make sure current namespace is first element - $namespaces = array_unshift( array($currentNamespace), array_diff($wgLinkTitlesNamespaces, array($currentNamespace)) ); - - // 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 &$namspacevalue) { - $currentWeight = $currentWeight + 100; - $weightSelect = $weightSelect . " WHEN " . $namspacevalue . " THEN " . $currentWeight . PHP_EOL; - } - $weightSelect = $weightSelect . " END "; - - $namespacesClause = str_replace( '_', ' ', - '("' . 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 // = 0) are returned. Since the db may be sqlite, we need a try..catch @@ -147,20 +129,21 @@ try { $res = $dbr->select( 'page', - array( 'page_title', "page_namespace" , "weight" = > $weightSelect), - array( + 'page_title', + array( + 'page_namespace = 0', 'CHAR_LENGTH(page_title) >= ' . $wgLinkTitlesMinimumTitleLength, 'page_title NOT IN ' . $blackList, ), __METHOD__, - array( 'ORDER BY' => 'weight ASC, CHAR_LENGTH(page_title) ' . $sort_order ) + array( 'ORDER BY' => 'CHAR_LENGTH(page_title) ' . $sort_order ) ); } catch (Exception $e) { $res = $dbr->select( 'page', 'page_title', array( - 'page_namespace IN ' . $namespacesClause, + 'page_namespace = 0', 'LENGTH(page_title) >= ' . $wgLinkTitlesMinimumTitleLength, 'page_title NOT IN ' . $blackList, ), @@ -171,7 +154,7 @@ // Iterate through the page titles foreach( $res as $row ) { - LinkTitles::newTarget($row->page_namespace, $row->page_title ); + LinkTitles::newTarget( $row->page_title ); // split the page content by [[...]] groups // credits to inhan @ StackOverflow for suggesting preg_split @@ -266,7 +249,7 @@ // Build an anonymous callback function to be used in simple mode. private static function simpleModeCallback( array $matches ) { if ( LinkTitles::checkTargetPage() ) { - return '[[' . LinkTitles::$targetTitle . "|" . $matches[0] . ']]'; + return '[[' . $matches[0] . ']]'; } else { @@ -322,9 +305,9 @@ } /// Sets member variables for the current target page. - private static function newTarget($ns, $title ) { + private static function newTarget( $title ) { // @todo Make this wiki namespace aware. - LinkTitles::$targetTitle = Title::makeTitle( $ns, $title); + LinkTitles::$targetTitle = Title::makeTitle( NS_MAIN, $title); LinkTitles::$targetContent = null; } diff --git a/LinkTitles.php b/LinkTitles.php index e27504c..8746808 100755 --- a/LinkTitles.php +++ b/LinkTitles.php @@ -189,10 +189,6 @@ /// @ingroup config $wgLinkTitlesTimeLimit = 0.2; - /// Namespaces to search in weighted order. - /// Namespace of the page will always to highest weight, rest in given order - $wgLinkTitlesNamespaces = array(NS_USER); - /// @cond $wgExtensionCredits['parserhook'][] = array( 'path' => __FILE__, diff --git a/LinkTitles.phpproj b/LinkTitles.phpproj deleted file mode 100644 index 652932b..0000000 --- a/LinkTitles.phpproj +++ /dev/null @@ -1,66 +0,0 @@ - - - Debug - LinkTitles - {1c5e70d9-0077-48f3-9e7a-97e6e7967c2e} - LinkTitles - Library - {A0786B88-2ADB-4C21-ABE8-AA2D79766269} - - - true - - - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file