Factored out sortkey magic to allow CategoryTree to hook in nicely.
authorDaniel Kinzler <daniel@users.mediawiki.org>
Sat, 2 Sep 2006 11:45:30 +0000 (11:45 +0000)
committerDaniel Kinzler <daniel@users.mediawiki.org>
Sat, 2 Sep 2006 11:45:30 +0000 (11:45 +0000)
includes/CategoryPage.php

index a47017f..e55d297 100644 (file)
@@ -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 );
        }
 
        /**