MediaWiki REL1_35
UppercaseCollation.php
Go to the documentation of this file.
1<?php
24
26
27 private $lang;
28
29 public function __construct() {
30 // Get a language object so that we can use the generic UTF-8 uppercase
31 // function there
32 $this->lang = MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage( 'en' );
33 }
34
35 public function getSortKey( $string ) {
36 return $this->lang->uc( $string );
37 }
38
39 public function getFirstLetter( $string ) {
40 if ( $string[0] == "\0" ) {
41 $string = substr( $string, 1 );
42 }
43 return $this->lang->ucfirst( $this->lang->firstChar( $string ) );
44 }
45
46}
MediaWikiServices is the service locator for the application scope of MediaWiki.
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.