1. Use param $ignoreOtherCond instead of $forTemplate and $ignoreSubmitCond in findVa...
authorPhilip Tzou <philip@users.mediawiki.org>
Mon, 2 Feb 2009 07:54:43 +0000 (07:54 +0000)
committerPhilip Tzou <philip@users.mediawiki.org>
Mon, 2 Feb 2009 07:54:43 +0000 (07:54 +0000)
2. Drop some duplicate categories produced by findVariantLink().

includes/LinksUpdate.php
includes/OutputPage.php
languages/Language.php
languages/LanguageConverter.php
languages/classes/LanguageKk.php
languages/classes/LanguageKu.php
languages/classes/LanguageSr.php

index 93c4d4b..d0abf2f 100644 (file)
@@ -470,7 +470,7 @@ class LinksUpdate {
                $arr = array();
                foreach ( $diffs as $name => $sortkey ) {
                        $nt = Title::makeTitleSafe( NS_CATEGORY, $name );
-                       $wgContLang->findVariantLink( $name, $nt, false, true );
+                       $wgContLang->findVariantLink( $name, $nt, true );
                        $arr[] = array(
                                'cl_from'    => $this->mId,
                                'cl_to'      => $name,
index f50d0fd..b1a0275 100644 (file)
@@ -408,8 +408,12 @@ class OutputPage {
                if ( wfRunHooks( 'OutputPageMakeCategoryLinks', array( &$this, $categories, &$this->mCategoryLinks ) ) ) {
                        $sk = $wgUser->getSkin();
                        foreach ( $categories as $category => $type ) {
+                               $origcategory = $category;
                                $title = Title::makeTitleSafe( NS_CATEGORY, $category );
-                               $wgContLang->findVariantLink( $category, $title );
+                               $wgContLang->findVariantLink( $category, $title, true );
+                               if ( $category != $origcategory )
+                                       if ( array_key_exists( $category, $categories ) )
+                                               continue;
                                $text = $wgContLang->convertHtml( $title->getText() );
                                $this->mCategoryLinks[$type][] = $sk->makeLinkObj( $title, $text );
                        }
index 454a1c1..97ac27c 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, $ignoreSubmitCond = false) {}
+       function findVariantLink(&$l, &$n, $ignoreOtherCond = false) {}
        function getExtraHashOptions() {return '';}
        function getParsedTitle() {return '';}
        function markNoConversion($text, $noParse=false) {return $text;}
@@ -2223,12 +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.
+        * @param boolean $ignoreOtherCond: to disable other conditions when
+        *      we need to transclude a template or update a category's link
         * @return null the input parameters may be modified upon return
         */
-       function findVariantLink( &$link, &$nt, $forTemplate = false, $ignoreSubmitCond = false ) {
-               $this->mConverter->findVariantLink( $link, $nt, $forTemplate, $ignoreSubmitCond );
+       function findVariantLink( &$link, &$nt, $ignoreOtherCond = false ) {
+               $this->mConverter->findVariantLink( $link, $nt, $ignoreOtherCond );
        }
 
        /**
index 2220a2e..698baec 100644 (file)
@@ -529,12 +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.
+        * @param boolean $ignoreOtherCond: to disable other conditions when
+        *      we need to transclude a template or update a category's link
         * @return null the input parameters may be modified upon return
         * @public
         */
-       function findVariantLink( &$link, &$nt, $forTemplate = false, $ignoreSubmitCond = false ) {
+       function findVariantLink( &$link, &$nt, $ignoreOtherCond = false ) {
                global $wgDisableLangConversion, $wgDisableTitleConversion, $wgRequest, $wgUser;
                $isredir = $wgRequest->getText( 'redirect', 'yes' );
                $action = $wgRequest->getText( 'action' );
@@ -544,9 +544,9 @@ class LanguageConverter {
 
                $ns=NS_MAIN;
 
-               if ( $disableLinkConversion || ( !$forTemplate && ( $isredir == 'no' || $action == 'edit'
-                       || (!$ignoreSubmitCond && $action == 'submit') || $linkconvert == 'no'
-                       || $wgUser->getOption('noconvertlink') == 1 ) ) ) { return;     }
+               if ( $disableLinkConversion || ( !$ignoreOtherCond && ( $isredir == 'no' || $action == 'edit'
+                       || $action == 'submit' || $linkconvert == 'no' || $wgUser->getOption('noconvertlink') == 1 ) ) )
+                       return;
 
                if(is_object($nt))
                        $ns = $nt->getNamespace();
index 2ba1c99..b358a70 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, $ignoreSubmitCond = false ) {
+       function findVariantLink( &$link, &$nt, $ignoreOtherCond = 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, $ignoreSubmitCond );
+               parent::findVariantLink( $link, $nt, $ignoreOtherCond );
                if( $this->getPreferredVariant()==$this->mMainLanguageCode )
                        $link=$oldlink;
        }
index 0b6603e..3b84a9b 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, $ignoreSubmitCond = false ) {
+       function findVariantLink( &$link, &$nt, $ignoreOtherCond = 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, $ignoreSubmitCond );
+               parent::findVariantLink( $link, $nt, $ignoreOtherCond );
                if( $this->getPreferredVariant() == $this->mMainLanguageCode )
                        $link=$oldlink;
        }
index 0ee894f..79a2ec2 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, $ignoreSubmitCond = false ) {
+       function findVariantLink( &$link, &$nt, $ignoreOtherCond = 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, $ignoreSubmitCond );
+               parent::findVariantLink( $link, $nt, $ignoreOtherCond );
                if($this->getPreferredVariant()==$this->mMainLanguageCode)
                        $link=$oldlink;
        }