2. Drop some duplicate categories produced by findVariantLink().
$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,
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 );
}
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;}
*
* @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 );
}
/**
*
* @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' );
$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();
* 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();
}
$oldlink=$link;
- parent::findVariantLink( $link, $nt, $forTemplate, $ignoreSubmitCond );
+ parent::findVariantLink( $link, $nt, $ignoreOtherCond );
if( $this->getPreferredVariant()==$this->mMainLanguageCode )
$link=$oldlink;
}
* 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();
}
$oldlink=$link;
- parent::findVariantLink( $link, $nt, $forTemplate, $ignoreSubmitCond );
+ parent::findVariantLink( $link, $nt, $ignoreOtherCond );
if( $this->getPreferredVariant() == $this->mMainLanguageCode )
$link=$oldlink;
}
* 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();
}
$oldlink=$link;
- parent::findVariantLink( $link, $nt, $forTemplate, $ignoreSubmitCond );
+ parent::findVariantLink( $link, $nt, $ignoreOtherCond );
if($this->getPreferredVariant()==$this->mMainLanguageCode)
$link=$oldlink;
}