MediaWiki REL1_40
CustomUppercaseCollation Class Reference

Resort normal UTF-8 order by putting a bunch of stuff in PUA. More...

Inherits NumericUppercaseCollation.

Inherited by AbkhazUppercaseCollation, and BashkirUppercaseCollation.

Collaboration diagram for CustomUppercaseCollation:

Public Member Functions

 __construct (LanguageFactory $languageFactory, array $alphabet, $digitTransformLang)
 
 getFirstLetter ( $string)
 Given a string, return the logical "first letter" to be used for grouping on category pages and so on.
 
 getSortKey ( $string)
 Given a string, convert it to a (hopefully short) key that can be used for efficient sorting.
 
- Public Member Functions inherited from NumericUppercaseCollation
 __construct (LanguageFactory $languageFactory, $digitTransformLang)
 
- Public Member Functions inherited from UppercaseCollation
 __construct (LanguageFactory $languageFactory)
 
- Public Member Functions inherited from Collation
 getSortKeys ( $strings)
 Get multiple sort keys.
 

Detailed Description

Resort normal UTF-8 order by putting a bunch of stuff in PUA.

This takes a bunch of characters (The alphabet) that should, be together, and converts them all to private-use-area characters so that they are all sorted in the right order relative to each other.

This renumbers characters starting at U+F3000 (Chosen to avoid conflicts with other people using private use area)

This does not support fancy things like secondary differences, etc. (It supports digraphs, trigraphs etc. though.)

It is expected most people will subclass this and just override the constructor to hard-code an alphabet.

Definition at line 42 of file CustomUppercaseCollation.php.

Constructor & Destructor Documentation

◆ __construct()

CustomUppercaseCollation::__construct ( LanguageFactory $languageFactory,
array $alphabet,
$digitTransformLang )
Note
This assumes $alphabet does not contain U+F3000-U+F3FFF
Parameters
LanguageFactory$languageFactory
array$alphabetSorted array of uppercase characters.
string | Language$digitTransformLangWhat language for number sorting.

Definition at line 60 of file CustomUppercaseCollation.php.

References MediaWiki\Languages\LanguageFactory\getLanguage().

Member Function Documentation

◆ getFirstLetter()

CustomUppercaseCollation::getFirstLetter ( $string)

Given a string, return the logical "first letter" to be used for grouping on category pages and so on.

This has to be coordinated carefully with convertToSortkey(), or else the sorted list might jump back and forth between the same "initial letters" or other pathological behavior. For instance, if you just return the first character, but "a" sorts the same as "A" based on getSortKey(), then you might get a list like

== A ==

  • [[Aardvark]]

== a ==

  • [[antelope]]

== A ==

  • [[Ape]]

etc., assuming for the sake of argument that $wgCapitalLinks is false.

Since
1.16.3
Parameters
string$stringUTF-8 string
Returns
string UTF-8 string corresponding to the first letter of input

Reimplemented from NumericUppercaseCollation.

Definition at line 97 of file CustomUppercaseCollation.php.

References getSortKey().

◆ getSortKey()

CustomUppercaseCollation::getSortKey ( $string)

Given a string, convert it to a (hopefully short) key that can be used for efficient sorting.

A binary sort according to the sortkeys corresponds to a logical sort of the corresponding strings. Current code expects that a line feed character should sort before all others, but has no other particular expectations (and that one can be changed if necessary).

Since
1.16.3
Parameters
string$stringUTF-8 string
Returns
string Binary sortkey

Reimplemented from NumericUppercaseCollation.

Definition at line 93 of file CustomUppercaseCollation.php.

Referenced by getFirstLetter().


The documentation for this class was generated from the following file: