From 986a52106766e7497322951c2bf3a3cbd0b42bf9 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sat, 25 Mar 2017 15:54:18 +0100 Subject: Add an endpoint to refresh the token Useful for AJAX requests which burns the token --- application/Router.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'application') diff --git a/application/Router.php b/application/Router.php index c9a51912..f6896b1c 100644 --- a/application/Router.php +++ b/application/Router.php @@ -45,6 +45,8 @@ class Router public static $PAGE_SAVE_PLUGINSADMIN = 'save_pluginadmin'; + public static $GET_TOKEN = 'token'; + /** * Reproducing renderPage() if hell, to avoid regression. * @@ -142,6 +144,10 @@ class Router return self::$PAGE_SAVE_PLUGINSADMIN; } + if (startsWith($query, 'do='. self::$GET_TOKEN)) { + return self::$GET_TOKEN; + } + return self::$PAGE_LINKLIST; } } -- cgit v1.2.3 From aa4797ba3679b847adc895e2f817ac058779a171 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sat, 25 Mar 2017 15:59:01 +0100 Subject: Adds a taglist view with edit/delete buttons * The tag list can be sort alphabetically or by most used tag * Edit/Delete are perform using AJAX, or fallback to 'do=changetag' page * New features aren't backported to vintage theme --- application/Router.php | 6 ++++++ application/Utils.php | 31 +++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) (limited to 'application') diff --git a/application/Router.php b/application/Router.php index f6896b1c..4df0387c 100644 --- a/application/Router.php +++ b/application/Router.php @@ -13,6 +13,8 @@ class Router public static $PAGE_TAGCLOUD = 'tagcloud'; + public static $PAGE_TAGLIST = 'taglist'; + public static $PAGE_DAILY = 'daily'; public static $PAGE_FEED_ATOM = 'atom'; @@ -79,6 +81,10 @@ class Router return self::$PAGE_TAGCLOUD; } + if (startsWith($query, 'do='. self::$PAGE_TAGLIST)) { + return self::$PAGE_TAGLIST; + } + if (startsWith($query, 'do='. self::$PAGE_OPENSEARCH)) { return self::$PAGE_OPENSEARCH; } 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) $maxsize = min($size1, $size2); return $format ? human_bytes($maxsize) : $maxsize; } + +/** + * Sort the given array alphabetically using php-intl if available. + * Case sensitive. + * + * Note: doesn't support multidimensional arrays + * + * @param array $data Input array, passed by reference + * @param bool $reverse Reverse sort if set to true + * @param bool $byKeys Sort the array by keys if set to true, by value otherwise. + */ +function alphabetical_sort(&$data, $reverse = false, $byKeys = false) +{ + $callback = function($a, $b) use ($reverse) { + // Collator is part of PHP intl. + if (class_exists('Collator')) { + $collator = new Collator(setlocale(LC_COLLATE, 0)); + if (!intl_is_failure(intl_get_error_code())) { + return $collator->compare($a, $b) * ($reverse ? -1 : 1); + } + } + + return strcasecmp($a, $b) * ($reverse ? -1 : 1); + }; + + if ($byKeys) { + uksort($data, $callback); + } else { + usort($data, $callback); + } +} -- cgit v1.2.3