From 205ef1ba8b771dd8ac7760d113d328c29ddb62b7 Mon Sep 17 00:00:00 2001 From: Philip Tzou Date: Mon, 2 Feb 2009 07:54:43 +0000 Subject: [PATCH] 1. Use param $ignoreOtherCond instead of $forTemplate and $ignoreSubmitCond in findVariantLink(). 2. Drop some duplicate categories produced by findVariantLink(). --- includes/LinksUpdate.php | 2 +- includes/OutputPage.php | 6 +++++- languages/Language.php | 10 +++++----- languages/LanguageConverter.php | 12 ++++++------ languages/classes/LanguageKk.php | 4 ++-- languages/classes/LanguageKu.php | 4 ++-- languages/classes/LanguageSr.php | 4 ++-- 7 files changed, 23 insertions(+), 19 deletions(-) diff --git a/includes/LinksUpdate.php b/includes/LinksUpdate.php index 93c4d4b021..d0abf2f735 100644 --- a/includes/LinksUpdate.php +++ b/includes/LinksUpdate.php @@ -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, diff --git a/includes/OutputPage.php b/includes/OutputPage.php index f50d0fdebb..b1a027570e 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -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 ); } diff --git a/languages/Language.php b/languages/Language.php index 454a1c1e3c..97ac27cb41 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, $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 ); } /** diff --git a/languages/LanguageConverter.php b/languages/LanguageConverter.php index 2220a2e3a7..698baec11e 100644 --- a/languages/LanguageConverter.php +++ b/languages/LanguageConverter.php @@ -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(); diff --git a/languages/classes/LanguageKk.php b/languages/classes/LanguageKk.php index 2ba1c99ec3..b358a7094e 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, $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; } diff --git a/languages/classes/LanguageKu.php b/languages/classes/LanguageKu.php index 0b6603eb78..3b84a9b3a1 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, $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; } diff --git a/languages/classes/LanguageSr.php b/languages/classes/LanguageSr.php index 0ee894f53f..79a2ec2521 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, $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; } -- 2.20.1