Full conversion support for category pages

This commit is contained in:
Zheng Zhu 2005-04-28 03:33:54 +00:00
parent b725d0748b
commit ff1e0c0581
5 changed files with 19 additions and 5 deletions

View file

@ -30,6 +30,7 @@ New exciting things! Need further work and testing...
* No longer using sorbs.net to check for open proxies by default.
* What was $wgDisableUploads is now $wgEnableUploads, and should be set to true if one wishes to enable uploads.
* Supplying a reason for a block is no longer mandatory
* Language conversion support for category pages
* ...and more!
Need to merge:

View file

@ -116,17 +116,19 @@ class CategoryPage extends Article {
if( $title->getNamespace() == NS_CATEGORY ) {
// Subcategory; strip the 'Category' namespace from the link text.
array_push( $children, $sk->makeKnownLinkObj( $title, $title->getText() ) );
array_push( $children, $sk->makeKnownLinkObj( $title, $wgContLang->convert( $title->getText() ) ) );
// If there's a link from Category:A to Category:B, the sortkey of the resulting
// entry in the categorylinks table is Category:A, not A, which it SHOULD be.
// Workaround: If sortkey == "Category:".$title, than use $title for sorting,
// else use sortkey...
$sortkey='';
if( $title->getPrefixedText() == $x->cl_sortkey ) {
array_push( $children_start_char, $wgContLang->firstChar( $x->page_title ) );
$sortkey=$wgContLang->firstChar( $x->page_title );
} else {
array_push( $children_start_char, $wgContLang->firstChar( $x->cl_sortkey ) ) ;
$sortkey=$wgContLang->firstChar( $x->cl_sortkey );
}
array_push( $children_start_char, $wgContLang->convert( $sortkey ) ) ;
} elseif( $wgCategoryMagicGallery && $title->getNamespace() == NS_IMAGE ) {
// Show thumbnails of categorized images, in a separate chunk
if( $flip ) {
@ -136,8 +138,8 @@ class CategoryPage extends Article {
}
} else {
// Page in this category
array_push( $articles, $sk->makeKnownLinkObj( $title ) ) ;
array_push( $articles_start_char, $wgContLang->firstChar( $x->cl_sortkey ) ) ;
array_push( $articles, $sk->makeKnownLinkObj( $title, $wgContLang->convert( $title->getText() ) ) ) ;
array_push( $articles_start_char, $wgContLang->convert( $wgContLang->firstChar( $x->cl_sortkey ) ) );
}
}
$dbr->freeResult( $res );

View file

@ -1357,6 +1357,7 @@ class Parser
} else {
$sortkey = $text;
}
$sortkey = $wgContLang->convertCategoryKey( $sortkey );
$wgLinkCache->addCategoryLinkObj( $nt, $sortkey );
$this->mOutput->addCategoryLink( $t );

View file

@ -1902,6 +1902,8 @@ class fakeConverter {
function getExtraHashOptions() {return '';}
function getParsedTitle() {return '';}
function markNoConversion($text) {return $text;}
function convertCategoryKey( $key ) {return $key; }
}
#--------------------------------------------------------------------------
@ -2532,6 +2534,10 @@ class Language {
return $this->mConverter->convert($text, $isTitle);
}
function convertCategoryKey( $key ) {
return $this->mConverter->convertCategoryKey( $key );
}
/**
* get the list of variants supported by this langauge
* see sample implementation in LanguageZh.php

View file

@ -31,6 +31,10 @@ class ZhConverter extends LanguageConverter {
function markNoConversion($text) {
return $text;
}
function convertCategoryKey( $key ) {
return $this->autoConvert( $key, 'zh-cn' );
}
}