diff options
Diffstat (limited to 'application')
-rw-r--r-- | application/Router.php | 12 | ||||
-rw-r--r-- | application/Utils.php | 31 |
2 files changed, 43 insertions, 0 deletions
diff --git a/application/Router.php b/application/Router.php index c9a51912..4df0387c 100644 --- a/application/Router.php +++ b/application/Router.php | |||
@@ -13,6 +13,8 @@ class Router | |||
13 | 13 | ||
14 | public static $PAGE_TAGCLOUD = 'tagcloud'; | 14 | public static $PAGE_TAGCLOUD = 'tagcloud'; |
15 | 15 | ||
16 | public static $PAGE_TAGLIST = 'taglist'; | ||
17 | |||
16 | public static $PAGE_DAILY = 'daily'; | 18 | public static $PAGE_DAILY = 'daily'; |
17 | 19 | ||
18 | public static $PAGE_FEED_ATOM = 'atom'; | 20 | public static $PAGE_FEED_ATOM = 'atom'; |
@@ -45,6 +47,8 @@ class Router | |||
45 | 47 | ||
46 | public static $PAGE_SAVE_PLUGINSADMIN = 'save_pluginadmin'; | 48 | public static $PAGE_SAVE_PLUGINSADMIN = 'save_pluginadmin'; |
47 | 49 | ||
50 | public static $GET_TOKEN = 'token'; | ||
51 | |||
48 | /** | 52 | /** |
49 | * Reproducing renderPage() if hell, to avoid regression. | 53 | * Reproducing renderPage() if hell, to avoid regression. |
50 | * | 54 | * |
@@ -77,6 +81,10 @@ class Router | |||
77 | return self::$PAGE_TAGCLOUD; | 81 | return self::$PAGE_TAGCLOUD; |
78 | } | 82 | } |
79 | 83 | ||
84 | if (startsWith($query, 'do='. self::$PAGE_TAGLIST)) { | ||
85 | return self::$PAGE_TAGLIST; | ||
86 | } | ||
87 | |||
80 | if (startsWith($query, 'do='. self::$PAGE_OPENSEARCH)) { | 88 | if (startsWith($query, 'do='. self::$PAGE_OPENSEARCH)) { |
81 | return self::$PAGE_OPENSEARCH; | 89 | return self::$PAGE_OPENSEARCH; |
82 | } | 90 | } |
@@ -142,6 +150,10 @@ class Router | |||
142 | return self::$PAGE_SAVE_PLUGINSADMIN; | 150 | return self::$PAGE_SAVE_PLUGINSADMIN; |
143 | } | 151 | } |
144 | 152 | ||
153 | if (startsWith($query, 'do='. self::$GET_TOKEN)) { | ||
154 | return self::$GET_TOKEN; | ||
155 | } | ||
156 | |||
145 | return self::$PAGE_LINKLIST; | 157 | return self::$PAGE_LINKLIST; |
146 | } | 158 | } |
147 | } | 159 | } |
diff --git a/application/Utils.php b/application/Utils.php index ab463af9..9d0ebc5e 100644 --- a/application/Utils.php +++ b/application/Utils.php | |||
@@ -435,3 +435,34 @@ function get_max_upload_size($limitPost, $limitUpload, $format = true) | |||
435 | $maxsize = min($size1, $size2); | 435 | $maxsize = min($size1, $size2); |
436 | return $format ? human_bytes($maxsize) : $maxsize; | 436 | return $format ? human_bytes($maxsize) : $maxsize; |
437 | } | 437 | } |
438 | |||
439 | /** | ||
440 | * Sort the given array alphabetically using php-intl if available. | ||
441 | * Case sensitive. | ||
442 | * | ||
443 | * Note: doesn't support multidimensional arrays | ||
444 | * | ||
445 | * @param array $data Input array, passed by reference | ||
446 | * @param bool $reverse Reverse sort if set to true | ||
447 | * @param bool $byKeys Sort the array by keys if set to true, by value otherwise. | ||
448 | */ | ||
449 | function alphabetical_sort(&$data, $reverse = false, $byKeys = false) | ||
450 | { | ||
451 | $callback = function($a, $b) use ($reverse) { | ||
452 | // Collator is part of PHP intl. | ||
453 | if (class_exists('Collator')) { | ||
454 | $collator = new Collator(setlocale(LC_COLLATE, 0)); | ||
455 | if (!intl_is_failure(intl_get_error_code())) { | ||
456 | return $collator->compare($a, $b) * ($reverse ? -1 : 1); | ||
457 | } | ||
458 | } | ||
459 | |||
460 | return strcasecmp($a, $b) * ($reverse ? -1 : 1); | ||
461 | }; | ||
462 | |||
463 | if ($byKeys) { | ||
464 | uksort($data, $callback); | ||
465 | } else { | ||
466 | usort($data, $callback); | ||
467 | } | ||
468 | } | ||