Index: trunk/phase3/RELEASE-NOTES-1.18 |
— | — | @@ -209,6 +209,7 @@ |
210 | 210 | * Introduced $wgVaryOnXFPForAPI which will cause the API to send |
211 | 211 | Vary: X-Forwarded-Proto headers. |
212 | 212 | * New maintenance script to refresh image metadata (maintenance/refreshImageMetadata.php) |
| 213 | +* (bug 30722) Add a new collation that sorts categories in ascii sort order. |
213 | 214 | |
214 | 215 | === Bug fixes in 1.18 === |
215 | 216 | * mw.util.getScript has been implemented (like wfScript in GlobalFunctions.php) |
Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -118,6 +118,7 @@ |
119 | 119 | 'HttpRequest' => 'includes/HttpFunctions.old.php', |
120 | 120 | 'IContextSource' => 'includes/RequestContext.php', |
121 | 121 | 'IcuCollation' => 'includes/Collation.php', |
| 122 | + 'IdentityCollation' => 'includes/Collation.php', |
122 | 123 | 'ImageGallery' => 'includes/ImageGallery.php', |
123 | 124 | 'ImageHistoryList' => 'includes/ImagePage.php', |
124 | 125 | 'ImageHistoryPseudoPager' => 'includes/ImagePage.php', |
Index: trunk/phase3/includes/Collation.php |
— | — | @@ -23,6 +23,8 @@ |
24 | 24 | switch( $collationName ) { |
25 | 25 | case 'uppercase': |
26 | 26 | return new UppercaseCollation; |
| 27 | + case 'identity': |
| 28 | + return new IdentityCollation; |
27 | 29 | case 'uca-default': |
28 | 30 | return new IcuCollation( 'root' ); |
29 | 31 | default: |
— | — | @@ -99,6 +101,30 @@ |
100 | 102 | } |
101 | 103 | } |
102 | 104 | |
| 105 | +/** |
| 106 | + * Collation class that's essentially a no-op. |
| 107 | + * |
| 108 | + * Does sorting based on binary value of the string. |
| 109 | + * Like how things were pre 1.17. |
| 110 | + */ |
| 111 | +class IdentityCollation extends Collation { |
| 112 | + |
| 113 | + function getSortKey( $string ) { |
| 114 | + return $string; |
| 115 | + } |
| 116 | + |
| 117 | + function getFirstLetter( $string ) { |
| 118 | + global $wgContLang; |
| 119 | + // Copied from UppercaseCollation. |
| 120 | + // I'm kind of unclear on when this could happen... |
| 121 | + if ( $string[0] == "\0" ) { |
| 122 | + $string = substr( $string, 1 ); |
| 123 | + } |
| 124 | + return $wgContLang->firstChar( $string ); |
| 125 | + } |
| 126 | +} |
| 127 | + |
| 128 | + |
103 | 129 | class IcuCollation extends Collation { |
104 | 130 | var $primaryCollator, $mainCollator, $locale; |
105 | 131 | var $firstLetterData; |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -4879,6 +4879,8 @@ |
4880 | 4880 | * |
4881 | 4881 | * - uppercase: Converts the category name to upper case, and sorts by that. |
4882 | 4882 | * |
| 4883 | + * - identity: Does no conversion. Sorts by binary value of the string. |
| 4884 | + * |
4883 | 4885 | * - uca-default: Provides access to the Unicode Collation Algorithm with |
4884 | 4886 | * the default element table. This is a compromise collation which sorts |
4885 | 4887 | * all languages in a mediocre way. However, it is better than "uppercase". |
— | — | @@ -4892,7 +4894,7 @@ |
4893 | 4895 | * the sort keys in the database. |
4894 | 4896 | * |
4895 | 4897 | * Extensions can define there own collations by subclassing Collation |
4896 | | - * and using the class name as the value of this variable. |
| 4898 | + * and using the Collation::factory hook. |
4897 | 4899 | */ |
4898 | 4900 | $wgCategoryCollation = 'uppercase'; |
4899 | 4901 | |