MediaWiki  1.30.0
CustomUppercaseCollation.php
Go to the documentation of this file.
1 <?php
40 
42  private $alphabet;
43 
45  private $puaSubset;
46 
53  public function __construct( array $alphabet, Language $lang ) {
54  // It'd be trivial to extend this past 64, you'd just
55  // need a bit of bit-fiddling. Doesn't seem necessary right
56  // now.
57  if ( count( $alphabet ) < 1 || count( $alphabet ) >= 64 ) {
58  throw new UnexpectedValueException( "Alphabet must be < 64 items" );
59  }
60  $this->alphabet = $alphabet;
61 
62  $this->puaSubset = [];
63  $len = count( $alphabet );
64  for ( $i = 0; $i < $len; $i++ ) {
65  $this->puaSubset[] = "\xF3\xB3\x80" . chr( $i + 128 );
66  }
67  parent::__construct( $lang );
68  }
69 
70  private function convertToPua( $string ) {
71  return str_replace( $this->alphabet, $this->puaSubset, $string );
72  }
73 
74  public function getSortKey( $string ) {
75  return $this->convertToPua( parent::getSortKey( $string ) );
76  }
77 
78  public function getFirstLetter( $string ) {
79  // In case a title has a PUA code in it, make it sort
80  // under the header for the character it would replace
81  // to avoid inconsistent behaviour. This class mostly
82  // assumes that people will not use PUA codes.
83  return parent::getFirstLetter(
84  str_replace( $this->puaSubset, $this->alphabet, $string )
85  );
86  }
87 }
captcha-old.count
count
Definition: captcha-old.py:249
CustomUppercaseCollation\$alphabet
$alphabet
Definition: CustomUppercaseCollation.php:42
CustomUppercaseCollation\convertToPua
convertToPua( $string)
Definition: CustomUppercaseCollation.php:70
CustomUppercaseCollation
Resort normal UTF-8 order by putting a bunch of stuff in PUA.
Definition: CustomUppercaseCollation.php:39
CustomUppercaseCollation\getFirstLetter
getFirstLetter( $string)
Given a string, return the logical "first letter" to be used for grouping on category pages and so on...
Definition: CustomUppercaseCollation.php:78
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
CustomUppercaseCollation\$puaSubset
$puaSubset
Definition: CustomUppercaseCollation.php:45
CustomUppercaseCollation\getSortKey
getSortKey( $string)
Given a string, convert it to a (hopefully short) key that can be used for efficient sorting.
Definition: CustomUppercaseCollation.php:74
NumericUppercaseCollation
Collation that orders text with numbers "naturally", so that 'Foo 1' < 'Foo 2' < 'Foo 12'.
Definition: NumericUppercaseCollation.php:35
CustomUppercaseCollation\__construct
__construct(array $alphabet, Language $lang)
Definition: CustomUppercaseCollation.php:53
UppercaseCollation\$lang
$lang
Definition: UppercaseCollation.php:25
Language
Internationalisation code.
Definition: Language.php:35
array
the array() calling protocol came about after MediaWiki 1.4rc1.