r91434 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91433‎ | r91434 | r91435 >
Date:04:34, 5 July 2011
Author:bawolff
Status:deferred
Tags:
Comment:
Change extension to append the pagename to the sortkey if there is no "invisible" part.
Modified paths:
  • /trunk/extensions/CategorySortHeaders/CategorySortHeaders.php (modified) (history)
  • /trunk/extensions/CategorySortHeaders/CategorySortHeaders_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CategorySortHeaders/CategorySortHeaders_body.php
@@ -18,7 +18,7 @@
1919 // which gets turned into "^my header^foo\n<page name>"
2020 // which we turn into "M^my header^FOO\n<PAGE NAME>"
2121 function getSortKey( $string ) {
22 - global $wgContLang;
 22+ global $wgContLang, $wgCategorySortHeaderAppendPageNameToKey;
2323 // UppercaseCollation uses an EN lang object always instead of content lang.
2424 // I'm not sure why. To me it makes more sense to use $wgContLang.
2525 // There's minnor differences in some languages (like Turkish)
@@ -28,14 +28,27 @@
2929 if ( $matches[1] === '' ) $matches[1] = ' ';
3030 $part1 = $wgContLang->firstChar( $wgContLang->uc( $matches[1] ) );
3131 $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).
3338
 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+
3448 } else {
3549 // Ordinay sortkey, no header info.
3650 $part3 = $wgContLang->uc( $string );
3751 $part1 = $part2 = $wgContLang->firstChar( $part3 );
3852 }
39 -
4053 return $part1 . '^' . $part2 . '^' . $part3;
4154 }
4255
Index: trunk/extensions/CategorySortHeaders/CategorySortHeaders.php
@@ -57,4 +57,8 @@
5858
5959 $wgCategoryCollation = 'CustomHeaderCollation';
6060
 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
6164
 65+$wgCategorySortHeaderAppendPageNameToKey = true;

Status & tagging log