From 6b71e5e1c1c1b7c8e5fa4822d80213461a77866c Mon Sep 17 00:00:00 2001 From: Daniel Kinzler Date: Sat, 2 Sep 2006 11:45:30 +0000 Subject: [PATCH] Factored out sortkey magic to allow CategoryTree to hook in nicely. --- includes/CategoryPage.php | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/includes/CategoryPage.php b/includes/CategoryPage.php index a47017ff4c..e55d29768e 100644 --- a/includes/CategoryPage.php +++ b/includes/CategoryPage.php @@ -116,16 +116,26 @@ class CategoryViewer { $this->children[] = $this->getSkin()->makeKnownLinkObj( $title, $wgContLang->convertHtml( $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... + $this->children_start_char[] = $this->getSubcategorySortChar( $title, $sortkey ); + } + + /** + * Get the character to be used for sorting subcategories. + * 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... + */ + function getSubcategorySortChar( $title, $sortkey ) { + global $wgContLang; + if( $title->getPrefixedText() == $sortkey ) { $firstChar = $wgContLang->firstChar( $title->getDBkey() ); } else { $firstChar = $wgContLang->firstChar( $sortkey ); } - $this->children_start_char[] = $wgContLang->convert( $firstChar ); + + return $wgContLang->convert( $firstChar ); } /** -- 2.20.1