aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2019-04-02 00:08:51 +0200
committerGravatar GitHub <noreply@github.com> 2019-04-02 00:08:51 +0200
commitd9e246ecf763eb592f8246d4e9431a80599248e3 (patch)
tree9148f8b9989a9addfae605fdddb2e9102cf047f1 /lib
parent0853cab2c46e2a38ce2f820a882dc0805be85ab8 (diff)
Shortcuts legacy (#2320)
Fix https://github.com/FreshRSS/FreshRSS/issues/2316
Diffstat (limited to 'lib')
-rw-r--r--lib/lib_rss.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/lib_rss.php b/lib/lib_rss.php
index 3e0033a61..00b38254a 100644
--- a/lib/lib_rss.php
+++ b/lib/lib_rss.php
@@ -544,3 +544,39 @@ function base64url_decode($data) {
function _i($icon, $url_only = false) {
return FreshRSS_Themes::icon($icon, $url_only);
}
+
+
+const SHORTCUT_KEYS = array(
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
+ 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
+ 'F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'F10', 'F11', 'F12',
+ 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'ArrowUp', 'Backspace', 'Delete',
+ 'End', 'Enter', 'Escape', 'Home', 'Insert', 'PageDown', 'PageUp', 'Space', 'Tab',
+ );
+
+function validateShortcutList($shortcuts) {
+ $legacy = array(
+ 'down' => 'ArrowDown', 'left' => 'ArrowLeft', 'page_down' => 'PageDown', 'page_up' => 'PageUp',
+ 'right' => 'ArrowRight', 'up' => 'ArrowUp',
+ );
+ $upper = null;
+ $shortcuts_ok = array();
+
+ foreach ($shortcuts as $key => $value) {
+ if (in_array($value, SHORTCUT_KEYS)) {
+ $shortcuts_ok[$key] = $value;
+ } elseif (isset($legacy[$value])) {
+ $shortcuts_ok[$key] = $legacy[$value];
+ } else { //Case-insensitive search
+ if ($upper === null) {
+ $upper = array_map('strtoupper', SHORTCUT_KEYS);
+ }
+ $i = array_search(strtoupper($value), $upper);
+ if ($i !== false) {
+ $shortcuts_ok[$key] = SHORTCUT_KEYS[$i];
+ }
+ }
+ }
+ return $shortcuts_ok;
+}