summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorAndrew Dolgov <fox@fakecake.org>2024-11-23 11:07:50 +0300
committerAndrew Dolgov <fox@fakecake.org>2024-11-23 11:07:50 +0300
commit31ca090c631fe16e76235d37c822957f291c4463 (patch)
tree4f3eeba074dec77357caed580e0bc28fc32ec2cd /classes
parentf28df34fece3185f66d2bb96d160328c6dba30e8 (diff)
get filter action descriptions on pref_filters class init instead of doing it all the time, use ORM in _get_action_name
Diffstat (limited to 'classes')
-rw-r--r--classes/Pref_Filters.php45
1 files changed, 25 insertions, 20 deletions
diff --git a/classes/Pref_Filters.php b/classes/Pref_Filters.php
index 065303130..2d8003629 100644
--- a/classes/Pref_Filters.php
+++ b/classes/Pref_Filters.php
@@ -10,6 +10,19 @@ class Pref_Filters extends Handler_Protected {
const PARAM_ACTIONS = [self::ACTION_TAG, self::ACTION_SCORE,
self::ACTION_LABEL, self::ACTION_PLUGIN, self::ACTION_REMOVE_TAG];
+ private $action_descriptions = [];
+
+ function before(string $method) : bool {
+
+ $descriptions = ORM::for_table("ttrss_filter_actions")->find_array();
+
+ foreach ($descriptions as $desc) {
+ $this->action_descriptions[$desc['id']] = $desc;
+ }
+
+ return parent::before($method);
+ }
+
function csrf_ignore(string $method): bool {
$csrf_ignored = array("index", "getfiltertree", "savefilterorder");
@@ -471,32 +484,24 @@ class Pref_Filters extends Handler_Protected {
return "";
}
- $sth = $this->pdo->prepare("SELECT description FROM
- ttrss_filter_actions WHERE id = ?");
- $sth->execute([(int)$action["action_id"]]);
-
- $title = "";
+ $title = $this->action_descriptions[$action['action_id']]['description'] ??
+ T_sprintf('Unknown action: %d', $action['action_id']);
- if ($row = $sth->fetch()) {
-
- $title = __($row["description"]);
+ if ($action["action_id"] == self::ACTION_PLUGIN) {
+ list ($pfclass, $pfaction) = explode(":", $action["action_param"]);
- if ($action["action_id"] == self::ACTION_PLUGIN) {
- list ($pfclass, $pfaction) = explode(":", $action["action_param"]);
-
- $filter_actions = PluginHost::getInstance()->get_filter_actions();
+ $filter_actions = PluginHost::getInstance()->get_filter_actions();
- foreach ($filter_actions as $fclass => $factions) {
- foreach ($factions as $faction) {
- if ($pfaction == $faction["action"] && $pfclass == $fclass) {
- $title .= ": " . $fclass . ": " . $faction["description"];
- break;
- }
+ foreach ($filter_actions as $fclass => $factions) {
+ foreach ($factions as $faction) {
+ if ($pfaction == $faction["action"] && $pfclass == $fclass) {
+ $title .= ": " . $fclass . ": " . $faction["description"];
+ break;
}
}
- } else if (in_array($action["action_id"], self::PARAM_ACTIONS)) {
- $title .= ": " . $action["action_param"];
}
+ } else if (in_array($action["action_id"], self::PARAM_ACTIONS)) {
+ $title .= ": " . $action["action_param"];
}
return $title;