To find an available category name during update table 'categorylinks'. Just act...
authorPhilip Tzou <philip@users.mediawiki.org>
Mon, 2 Feb 2009 06:53:49 +0000 (06:53 +0000)
committerPhilip Tzou <philip@users.mediawiki.org>
Mon, 2 Feb 2009 06:53:49 +0000 (06:53 +0000)
includes/LinksUpdate.php
languages/Language.php
languages/LanguageConverter.php
languages/classes/LanguageKk.php
languages/classes/LanguageKu.php
languages/classes/LanguageSr.php

index 13f35b5..93c4d4b 100644 (file)
@@ -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,
index 164057a..454a1c1 100644 (file)
@@ -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);
        }
index 32edfa7..2220a2e 100644 (file)
@@ -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;
                        }
                }
index 73f0a1f..2ba1c99 100644 (file)
@@ -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;
        }
index 3137c7e..0b6603e 100644 (file)
@@ -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;
        }
index cac82ce..0ee894f 100644 (file)
@@ -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;
        }