[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/inc/Utf8/ -> Sort.php (summary)

(no description)

File Size: 173 lines (6 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Sort:: (7 methods):
  getCollator()
  useIntl()
  strcmp()
  sort()
  ksort()
  asort()
  asortFN()


Class: Sort  - X-Ref

DokuWiki sort functions

When "intl" extension is available, all sorts are done using a collator.
Otherwise, primitive PHP functions are called.

The collator is created using the locale given in $conf['lang'].
It always uses case insensitive "natural" ordering in its collation.
The fallback solution uses the primitive PHP functions that return almost the same results
when the input is text with only [A-Za-z0-9] characters.

getCollator()   X-Ref
Initialization of a collator using $conf['lang'] as the locale.
The initialization is done only once.
The collation takes "natural ordering" into account, that is, "page 2" is before "page 10".

return: \Collator Returns a configured collator or null if the collator cannot be created.
author: Moisés Braga Ribeiro <moisesbr@gmail.com>

useIntl($use = true)   X-Ref
Enable or disable the use of the "intl" extension collator.
This is used for testing and should not be used in normal code.

param: bool $use
author: Andreas Gohr <andi@splitbrain.org>

strcmp($str1, $str2)   X-Ref
Drop-in replacement for strcmp(), strcasecmp(), strnatcmp() and strnatcasecmp().
It uses a collator-based comparison, or strnatcasecmp() as a fallback.

param: string $str1 The first string.
param: string $str2 The second string.
return: int Returns < 0 if $str1 is less than $str2; > 0 if $str1 is greater than $str2, and 0 if they are equal.
author: Moisés Braga Ribeiro <moisesbr@gmail.com>

sort(&$array)   X-Ref
Drop-in replacement for sort().
It uses a collator-based sort, or sort() with flags SORT_NATURAL and SORT_FLAG_CASE as a fallback.

param: array $array The input array.
return: bool Returns true on success or false on failure.
author: Moisés Braga Ribeiro <moisesbr@gmail.com>

ksort(&$array)   X-Ref
Drop-in replacement for ksort().
It uses a collator-based sort, or ksort() with flags SORT_NATURAL and SORT_FLAG_CASE as a fallback.

param: array $array The input array.
return: bool Returns true on success or false on failure.
author: Moisés Braga Ribeiro <moisesbr@gmail.com>

asort(&$array)   X-Ref
Drop-in replacement for asort(), natsort() and natcasesort().
It uses a collator-based sort, or asort() with flags SORT_NATURAL and SORT_FLAG_CASE as a fallback.

param: array $array The input array.
return: bool Returns true on success or false on failure.
author: Moisés Braga Ribeiro <moisesbr@gmail.com>

asortFN(&$array)   X-Ref
Drop-in replacement for asort(), natsort() and natcasesort() when the parameter is an array of filenames.
Filenames may not be equal to page names, depending on the setting in $conf['fnencode'],
so the correct behavior is to sort page names and reflect this sorting in the filename array.

param: array $array The input array.
return: bool Returns true on success or false on failure.
author: Moisés Braga Ribeiro <moisesbr@gmail.com>
author: Andreas Gohr <andi@splitbrain.org>