aboutsummaryrefslogtreecommitdiff
path: root/lib/lib_rss.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2019-09-29 16:22:50 +0200
committerGravatar GitHub <noreply@github.com> 2019-09-29 16:22:50 +0200
commite3e5954394f4523850c78e80e496f1b916622677 (patch)
tree2e20d9091735e1da1de85e273e19635f58111e0f /lib/lib_rss.php
parentec4307c1a64a0f60648fdd7d0a2eb819bbf12965 (diff)
PDO refactoring for code simplification (#2522)
* PDO refactor * Automatic prefix when using the syntax `_tableName` * Uniformity: MySQL is now PDO::ATTR_EMULATE_PREPARES = false just like SQLite and PostgreSQL, with consequences such as only one statement per query * Use PDO methods exec(), query(), prepare() + execute() in a more efficient way * Remove auto-update SQL code for versions older than FreshRSS 1.5 (3 years old) * The name of the default category is set in PHP instead of in the DB (simplies SQL and allows changing the name according to the FreshRSS language) * Rename `->bd` to `->pdo` (less of a frenshism, and more informative) * Fix some requests, which were not compatible with MySQL prepared statements * Whitespace * Fix syntax for PostgreSQL sequences + MySQL install * Minor formatting * Fix lastInsertId for PostgreSQL * Use PHP 5.6+ const Take advantage of https://github.com/FreshRSS/FreshRSS/pull/2527 https://www.php.net/manual/en/migration56.new-features.php * A bit of forgotten PHP 5.6 simplification for cURL * Forgotten $s * Mini fix custom user config https://github.com/FreshRSS/FreshRSS/pull/2490/files#r326290346 * More work on install.php but not finished * install.php working * More cleaning of PDO in install * Even more simplification Take advantage of PDO->exec() to run multiple statements * Disallow changing the name of the default category https://github.com/FreshRSS/FreshRSS/pull/2522#discussion_r326967724
Diffstat (limited to 'lib/lib_rss.php')
-rw-r--r--lib/lib_rss.php11
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/lib_rss.php b/lib/lib_rss.php
index 1bba60c36..854126b54 100644
--- a/lib/lib_rss.php
+++ b/lib/lib_rss.php
@@ -535,17 +535,16 @@ function _i($icon, $url_only = false) {
}
-$SHORTCUT_KEYS = array( //No const for < PHP 5.6 compatibility
+const SHORTCUT_KEYS = [
'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) {
- global $SHORTCUT_KEYS;
$legacy = array(
'down' => 'ArrowDown', 'left' => 'ArrowLeft', 'page_down' => 'PageDown', 'page_up' => 'PageUp',
'right' => 'ArrowRight', 'up' => 'ArrowUp',
@@ -554,17 +553,17 @@ function validateShortcutList($shortcuts) {
$shortcuts_ok = array();
foreach ($shortcuts as $key => $value) {
- if (in_array($value, $SHORTCUT_KEYS)) {
+ 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);
+ $upper = array_map('strtoupper', SHORTCUT_KEYS);
}
$i = array_search(strtoupper($value), $upper);
if ($i !== false) {
- $shortcuts_ok[$key] = $SHORTCUT_KEYS[$i];
+ $shortcuts_ok[$key] = SHORTCUT_KEYS[$i];
}
}
}