MediaWiki  REL1_20
IcuCollation Class Reference
Inheritance diagram for IcuCollation:
Collaboration diagram for IcuCollation:

List of all members.

Public Member Functions

 __construct ($locale)
 findLowerBound ($valueCallback, $valueCount, $comparisonCallback, $target)
 Do a binary search, and return the index of the largest item that sorts less than or equal to the target value.
 getFirstLetter ($string)
 Given a string, return the logical "first letter" to be used for grouping on category pages and so on.
 getFirstLetterCount ()
 getFirstLetterData ()
 getLetterByIndex ($index)
 getPrimarySortKey ($string)
 getSortKey ($string)
 Given a string, convert it to a (hopefully short) key that can be used for efficient sorting.
 getSortKeyByLetterIndex ($index)

Static Public Member Functions

static isCjk ($codepoint)

Public Attributes

 $firstLetterData
 $locale
 $mainCollator
 $primaryCollator
const RECORD_LENGTH = 14

Static Public Attributes

static $cjkBlocks
 Unified CJK blocks.

Detailed Description

Definition at line 148 of file Collation.php.


Constructor & Destructor Documentation

Definition at line 181 of file Collation.php.

References $locale.


Member Function Documentation

IcuCollation::findLowerBound ( valueCallback,
valueCount,
comparisonCallback,
target 
)

Do a binary search, and return the index of the largest item that sorts less than or equal to the target value.

Parameters:
$valueCallbackarray A function to call to get the value with a given array index.
$valueCountint The number of items accessible via $valueCallback, indexed from 0 to $valueCount - 1
$comparisonCallbackarray A callback to compare two values, returning -1, 0 or 1 in the style of strcmp().
$targetstring The target value to find.
Returns:
int|bool The item index of the lower bound, or false if the target value sorts before all items.

Definition at line 337 of file Collation.php.

Referenced by getFirstLetter().

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.

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

Reimplemented from Collation.

Definition at line 213 of file Collation.php.

References findLowerBound(), getFirstLetterCount(), getLetterByIndex(), getPrimarySortKey(), and utf8ToCodepoint().

Definition at line 315 of file Collation.php.

References getFirstLetterData().

Referenced by getFirstLetter().

Definition at line 301 of file Collation.php.

References getFirstLetterData().

Referenced by getFirstLetter().

Definition at line 206 of file Collation.php.

References wfRestoreWarnings(), and wfSuppressWarnings().

Referenced by getFirstLetter(), and getFirstLetterData().

IcuCollation::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).

Parameters:
string$stringUTF-8 string
Returns:
string Binary sortkey

Reimplemented from Collation.

Definition at line 196 of file Collation.php.

References wfRestoreWarnings(), and wfSuppressWarnings().

Definition at line 308 of file Collation.php.

References getFirstLetterData().

static IcuCollation::isCjk ( codepoint) [static]

Definition at line 362 of file Collation.php.

Referenced by GenerateCollationData\charCallback().


Member Data Documentation

IcuCollation::$cjkBlocks [static]
Initial value:
 array(
                array( 0x2E80, 0x2EFF ), 
                array( 0x2F00, 0x2FDF ), 
                array( 0x2FF0, 0x2FFF ), 
                array( 0x3000, 0x303F ), 
                array( 0x31C0, 0x31EF ), 
                array( 0x3200, 0x32FF ), 
                array( 0x3300, 0x33FF ), 
                array( 0x3400, 0x4DBF ), 
                array( 0x4E00, 0x9FFF ), 
                array( 0xF900, 0xFAFF ), 
                array( 0xFE30, 0xFE4F ), 
                array( 0x20000, 0x2A6DF ), 
                array( 0x2A700, 0x2B73F ), 
                array( 0x2B740, 0x2B81F ), 
                array( 0x2F800, 0x2FA1F ), 
        )

Unified CJK blocks.

The same definition of a CJK block must be used for both Collation and generateCollationData.php. These blocks are omitted from the first letter data, as an optimisation measure and because the default UCA table is pretty useless for sorting Chinese text anyway. Japanese and Korean blocks are not included here, because they are smaller and more useful.

Definition at line 161 of file Collation.php.

IcuCollation::$firstLetterData

Definition at line 150 of file Collation.php.

IcuCollation::$locale

Definition at line 149 of file Collation.php.

Referenced by __construct().

IcuCollation::$mainCollator

Definition at line 149 of file Collation.php.

IcuCollation::$primaryCollator

Definition at line 149 of file Collation.php.

Definition at line 179 of file Collation.php.


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