Index: trunk/extensions/CategorySortHeaders/CategorySortHeaders_body.php |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | // which gets turned into "^my header^foo\n<page name>" |
20 | 20 | // which we turn into "M^my header^FOO\n<PAGE NAME>" |
21 | 21 | function getSortKey( $string ) { |
22 | | - global $wgContLang; |
| 22 | + global $wgContLang, $wgCategorySortHeaderAppendPageNameToKey; |
23 | 23 | // UppercaseCollation uses an EN lang object always instead of content lang. |
24 | 24 | // I'm not sure why. To me it makes more sense to use $wgContLang. |
25 | 25 | // There's minnor differences in some languages (like Turkish) |
— | — | @@ -28,14 +28,27 @@ |
29 | 29 | if ( $matches[1] === '' ) $matches[1] = ' '; |
30 | 30 | $part1 = $wgContLang->firstChar( $wgContLang->uc( $matches[1] ) ); |
31 | 31 | $part2 = $matches[1]; |
32 | | - $part3 = $wgContLang->uc( $matches[2] ); |
| 32 | + $part3prefix = ''; |
| 33 | + if ( $wgCategorySortHeaderAppendPageNameToKey ) { |
| 34 | + // This is kind of ugly, and seems wrong |
| 35 | + // because it shouldn't be the collations |
| 36 | + // job to do this type of thing (but then |
| 37 | + // again it shouldn't be doing headers either). |
33 | 38 | |
| 39 | + // See Title::getCategorySortkey if you're |
| 40 | + // mystified by what this does. |
| 41 | + $trimmed = trim( $matches[2], "\n" ); |
| 42 | + if ( $trimmed !== $matches[2] ) { |
| 43 | + $part3prefix = $trimmed; |
| 44 | + } |
| 45 | + } |
| 46 | + $part3 = $wgContLang->uc( $part3prefix . $matches[2] ); |
| 47 | + |
34 | 48 | } else { |
35 | 49 | // Ordinay sortkey, no header info. |
36 | 50 | $part3 = $wgContLang->uc( $string ); |
37 | 51 | $part1 = $part2 = $wgContLang->firstChar( $part3 ); |
38 | 52 | } |
39 | | - |
40 | 53 | return $part1 . '^' . $part2 . '^' . $part3; |
41 | 54 | } |
42 | 55 | |
Index: trunk/extensions/CategorySortHeaders/CategorySortHeaders.php |
— | — | @@ -57,4 +57,8 @@ |
58 | 58 | |
59 | 59 | $wgCategoryCollation = 'CustomHeaderCollation'; |
60 | 60 | |
| 61 | +// Control if a sortkey of ^foo^ is considered just ^foo^ or ^foo^{{PAGENAME}}. |
| 62 | +// After changing this option, you should run the maintinance script (the --force is important) |
| 63 | +// php updateCollations.php --force |
61 | 64 | |
| 65 | +$wgCategorySortHeaderAppendPageNameToKey = true; |