From a31dceccc994722b4778fafac1847dfd410540a5 Mon Sep 17 00:00:00 2001 From: Philip Tzou Date: Mon, 2 Feb 2009 06:53:49 +0000 Subject: [PATCH] To find an available category name during update table 'categorylinks'. Just act on the language which enabled LanguageConverter. --- includes/LinksUpdate.php | 3 +++ languages/Language.php | 9 +++++---- languages/LanguageConverter.php | 11 ++++++----- languages/classes/LanguageKk.php | 4 ++-- languages/classes/LanguageKu.php | 4 ++-- languages/classes/LanguageSr.php | 4 ++-- 6 files changed, 20 insertions(+), 15 deletions(-) diff --git a/includes/LinksUpdate.php b/includes/LinksUpdate.php index 13f35b5a45..93c4d4b021 100644 --- a/includes/LinksUpdate.php +++ b/includes/LinksUpdate.php @@ -465,9 +465,12 @@ class LinksUpdate { * @private */ function getCategoryInsertions( $existing = array() ) { + global $wgContLang; $diffs = array_diff_assoc( $this->mCategories, $existing ); $arr = array(); foreach ( $diffs as $name => $sortkey ) { + $nt = Title::makeTitleSafe( NS_CATEGORY, $name ); + $wgContLang->findVariantLink( $name, $nt, false, true ); $arr[] = array( 'cl_from' => $this->mId, 'cl_to' => $name, diff --git a/languages/Language.php b/languages/Language.php index 164057a357..454a1c1e3c 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -39,7 +39,7 @@ class FakeConverter { function parserConvert($t, $p) {return $t;} function getVariants() { return array( $this->mLang->getCode() ); } function getPreferredVariant() {return $this->mLang->getCode(); } - function findVariantLink(&$l, &$n, $forTemplate = false) {} + function findVariantLink(&$l, &$n, $forTemplate = false, $ignoreSubmitCond = false) {} function getExtraHashOptions() {return '';} function getParsedTitle() {return '';} function markNoConversion($text, $noParse=false) {return $text;} @@ -2223,10 +2223,12 @@ class Language { * * @param $link String: the name of the link * @param $nt Mixed: the title object of the link + * @param boolean $ignoreSubmitCond: to disable the submit condition if + * we need to find a category's variant link when database update. * @return null the input parameters may be modified upon return */ - function findVariantLink( &$link, &$nt, $forTemplate = false ) { - $this->mConverter->findVariantLink($link, $nt, $forTemplate ); + function findVariantLink( &$link, &$nt, $forTemplate = false, $ignoreSubmitCond = false ) { + $this->mConverter->findVariantLink( $link, $nt, $forTemplate, $ignoreSubmitCond ); } /** @@ -2234,7 +2236,6 @@ class Language { * into an array of all possible variants of the text: * 'variant' => text in that variant */ - function convertLinkToAllVariants($text){ return $this->mConverter->convertLinkToAllVariants($text); } diff --git a/languages/LanguageConverter.php b/languages/LanguageConverter.php index 32edfa78de..2220a2e3a7 100644 --- a/languages/LanguageConverter.php +++ b/languages/LanguageConverter.php @@ -529,10 +529,12 @@ class LanguageConverter { * * @param string $link the name of the link * @param mixed $nt the title object of the link + * @param boolean $ignoreSubmitCond: to disable the submit condition if + * we need to find a category's variant link when database update. * @return null the input parameters may be modified upon return * @public */ - function findVariantLink( &$link, &$nt, $forTemplate = false ) { + function findVariantLink( &$link, &$nt, $forTemplate = false, $ignoreSubmitCond = false ) { global $wgDisableLangConversion, $wgDisableTitleConversion, $wgRequest, $wgUser; $isredir = $wgRequest->getText( 'redirect', 'yes' ); $action = $wgRequest->getText( 'action' ); @@ -543,9 +545,8 @@ class LanguageConverter { $ns=NS_MAIN; if ( $disableLinkConversion || ( !$forTemplate && ( $isredir == 'no' || $action == 'edit' - || $action == 'submit' || $linkconvert == 'no' || $wgUser->getOption('noconvertlink') == 1 ) ) ) { - return; - } + || (!$ignoreSubmitCond && $action == 'submit') || $linkconvert == 'no' + || $wgUser->getOption('noconvertlink') == 1 ) ) ) { return; } if(is_object($nt)) $ns = $nt->getNamespace(); @@ -572,7 +573,7 @@ class LanguageConverter { foreach( $titles as $varnt ) { if( $varnt->getArticleID() > 0 ) { $nt = $varnt; - $link = $v; + $link = $varnt->getText(); break; } } diff --git a/languages/classes/LanguageKk.php b/languages/classes/LanguageKk.php index 73f0a1f944..2ba1c99ec3 100644 --- a/languages/classes/LanguageKk.php +++ b/languages/classes/LanguageKk.php @@ -225,7 +225,7 @@ class KkConverter extends LanguageConverter { * names as they were * - do not try to find variants for usernames */ - function findVariantLink( &$link, &$nt, $forTemplate = false ) { + function findVariantLink( &$link, &$nt, $forTemplate = false, $ignoreSubmitCond = false ) { // check for user namespace if(is_object($nt)){ $ns = $nt->getNamespace(); @@ -234,7 +234,7 @@ class KkConverter extends LanguageConverter { } $oldlink=$link; - parent::findVariantLink( $link, $nt, $forTemplate ); + parent::findVariantLink( $link, $nt, $forTemplate, $ignoreSubmitCond ); if( $this->getPreferredVariant()==$this->mMainLanguageCode ) $link=$oldlink; } diff --git a/languages/classes/LanguageKu.php b/languages/classes/LanguageKu.php index 3137c7e865..0b6603eb78 100644 --- a/languages/classes/LanguageKu.php +++ b/languages/classes/LanguageKu.php @@ -148,7 +148,7 @@ class KuConverter extends LanguageConverter { * names as they were * - do not try to find variants for usernames */ - function findVariantLink( &$link, &$nt, $forTemplate = false ) { + function findVariantLink( &$link, &$nt, $forTemplate = false, $ignoreSubmitCond = false ) { // check for user namespace if(is_object($nt)){ $ns = $nt->getNamespace(); @@ -157,7 +157,7 @@ class KuConverter extends LanguageConverter { } $oldlink=$link; - parent::findVariantLink( $link, $nt, $forTemplate ); + parent::findVariantLink( $link, $nt, $forTemplate, $ignoreSubmitCond ); if( $this->getPreferredVariant() == $this->mMainLanguageCode ) $link=$oldlink; } diff --git a/languages/classes/LanguageSr.php b/languages/classes/LanguageSr.php index cac82ce7f9..0ee894f53f 100644 --- a/languages/classes/LanguageSr.php +++ b/languages/classes/LanguageSr.php @@ -92,7 +92,7 @@ class SrConverter extends LanguageConverter { * names as they were * - do not try to find variants for usernames */ - function findVariantLink( &$link, &$nt, $forTemplate = false ) { + function findVariantLink( &$link, &$nt, $forTemplate = false, $ignoreSubmitCond = false ) { // check for user namespace if(is_object($nt)){ $ns = $nt->getNamespace(); @@ -101,7 +101,7 @@ class SrConverter extends LanguageConverter { } $oldlink=$link; - parent::findVariantLink( $link, $nt, $forTemplate ); + parent::findVariantLink( $link, $nt, $forTemplate, $ignoreSubmitCond ); if($this->getPreferredVariant()==$this->mMainLanguageCode) $link=$oldlink; } -- 2.20.1