From 21891fe83f91241d2f4e0e5e21647cfe0e7456d1 Mon Sep 17 00:00:00 2001 From: Jens Frank Date: Thu, 10 Jun 2004 22:32:04 +0000 Subject: [PATCH] Fix sorting of subcategories without a sortkey. Use Category name as sortkey, not the first letter of Category. See comment for details. --- includes/Parser.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/includes/Parser.php b/includes/Parser.php index 15a272d082..71d537db2e 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -436,13 +436,23 @@ cl_sortkey" ; $res = wfQuery ( $sql, DB_READ ) ; while ( $x = wfFetchObject ( $res ) ) { - $t = $wgLang->getNsText ( $x->cur_namespace ) ; + $t = $ns = $wgLang->getNsText ( $x->cur_namespace ) ; if ( $t != '' ) $t .= ':' ; $t .= $x->cur_title ; if ( $x->cur_namespace == $cns ) { - array_push ( $children, $sk->makeKnownLink ( $t, str_replace( '_',' ',$x->cur_title) ) ) ; # Subcategory - array_push ( $children_start_char, $wgLang->firstChar( $x->cl_sortkey ) ) ; + $ctitle = str_replace( '_',' ',$x->cur_title ); + array_push ( $children, $sk->makeKnownLink ( $t, $ctitle ) ) ; # Subcategory + + // 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... + if ( ($ns.":".$ctitle) == $x->cl_sortkey ) { + array_push ( $children_start_char, $wgLang->firstChar( $x->cur_title ) ); + } else { + array_push ( $children_start_char, $wgLang->firstChar( $x->cl_sortkey ) ) ; + } } else { array_push ( $articles , $sk->makeLink ( $t ) ) ; # Page in this category array_push ( $articles_start_char, $wgLang->firstChar( $x->cl_sortkey ) ) ; @@ -458,7 +468,7 @@ cl_sortkey" ; # Showing subcategories $r .= '

' . wfMsg( 'subcategories' ) . "

\n" . wfMsg( 'subcategorycount', count( $children ) ); - if ( count ( $children ) > 20) { + if ( count ( $children ) > 6 ) { // divide list into three equal chunks $chunk = (int) (count ( $children ) / 3); -- 2.20.1