summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--classes/Config.php4
-rw-r--r--classes/OPML.php8
-rw-r--r--classes/Pref_Filters.php213
-rw-r--r--include/errorhandler.php8
-rw-r--r--include/functions.php6
-rw-r--r--js/CommonFilters.js4
-rw-r--r--themes/compact.css6
-rw-r--r--themes/compact_night.css6
-rw-r--r--themes/light-high-contrast.css6
-rw-r--r--themes/light.css6
-rw-r--r--themes/light/defines.less2
-rw-r--r--themes/light/dijit_basic.less1
-rw-r--r--themes/light/prefs.less4
-rw-r--r--themes/light/tt-rss.less2
-rw-r--r--themes/night.css6
-rw-r--r--themes/night_blue.css6
16 files changed, 160 insertions, 128 deletions
diff --git a/classes/Config.php b/classes/Config.php
index 9235e2c45..ba6689214 100644
--- a/classes/Config.php
+++ b/classes/Config.php
@@ -534,8 +534,8 @@ class Config {
array_push($errors, "Please don't run this script as root.");
}
- if (version_compare(PHP_VERSION, '7.4.0', '<')) {
- array_push($errors, "PHP version 7.4.0 or newer required. You're using " . PHP_VERSION . ".");
+ if (version_compare(PHP_VERSION, '8.0.0', '<')) {
+ array_push($errors, "PHP version 8.0.0 or newer required. You're using " . PHP_VERSION . ".");
}
if (!class_exists("UConverter")) {
diff --git a/classes/OPML.php b/classes/OPML.php
index fce614a17..722312be6 100644
--- a/classes/OPML.php
+++ b/classes/OPML.php
@@ -647,16 +647,8 @@ class OPML extends Handler_Protected {
$doc = new DOMDocument();
- if (version_compare(PHP_VERSION, '8.0.0', '<')) {
- libxml_disable_entity_loader(false);
- }
-
$loaded = $doc->load($tmp_file);
- if (version_compare(PHP_VERSION, '8.0.0', '<')) {
- libxml_disable_entity_loader(true);
- }
-
// only remove temporary i.e. HTTP uploaded files
if (!$filename)
unlink($tmp_file);
diff --git a/classes/Pref_Filters.php b/classes/Pref_Filters.php
index 46cf6c30c..3a51a011b 100644
--- a/classes/Pref_Filters.php
+++ b/classes/Pref_Filters.php
@@ -10,6 +10,22 @@ 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];
+ const MAX_ACTIONS_TO_DISPLAY = 3;
+
+ /** @var array<int,array<mixed>> $action_descriptions */
+ 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");
@@ -174,60 +190,49 @@ class Pref_Filters extends Handler_Protected {
}
private function _get_rules_list(int $filter_id): string {
- $sth = $this->pdo->prepare("SELECT reg_exp,
- inverse,
- match_on,
- feed_id,
- cat_id,
- cat_filter,
- ttrss_filter_types.description AS field
- FROM
- ttrss_filters2_rules, ttrss_filter_types
- WHERE
- filter_id = ? AND filter_type = ttrss_filter_types.id
- ORDER BY reg_exp");
- $sth->execute([$filter_id]);
+ $rules = ORM::for_table('ttrss_filters2_rules')
+ ->table_alias('r')
+ ->join('ttrss_filter_types', ['r.filter_type', '=', 't.id'], 't')
+ ->where('filter_id', $filter_id)
+ ->select_many(['r.*', 'field' => 't.description'])
+ ->find_many();
$rv = "";
- while ($line = $sth->fetch()) {
-
- if ($line["match_on"]) {
- $feeds = json_decode($line["match_on"], true);
- $feeds_fmt = [];
-
- foreach ($feeds as $feed_id) {
+ foreach ($rules as $rule) {
+ if ($rule->match_on) {
+ $feeds = json_decode($rule->match_on, true);
+ $feeds_fmt = [];
- if (strpos($feed_id, "CAT:") === 0) {
- $feed_id = (int)substr($feed_id, 4);
- array_push($feeds_fmt, Feeds::_get_cat_title($feed_id));
- } else {
- if ($feed_id)
- array_push($feeds_fmt, Feeds::_get_title((int)$feed_id));
- else
- array_push($feeds_fmt, __("All feeds"));
- }
- }
+ foreach ($feeds as $feed_id) {
- $where = implode(", ", $feeds_fmt);
-
- } else {
+ if (strpos($feed_id, "CAT:") === 0) {
+ $feed_id = (int)substr($feed_id, 4);
+ array_push($feeds_fmt, Feeds::_get_cat_title($feed_id));
+ } else {
+ if ($feed_id)
+ array_push($feeds_fmt, Feeds::_get_title((int)$feed_id));
+ else
+ array_push($feeds_fmt, __("All feeds"));
+ }
+ }
- $where = $line["cat_filter"] ?
- Feeds::_get_cat_title($line["cat_id"] ?? 0) :
- ($line["feed_id"] ?
- Feeds::_get_title($line["feed_id"]) : __("All feeds"));
- }
+ $where = implode(", ", $feeds_fmt);
-# $where = $line["cat_id"] . "/" . $line["feed_id"];
+ } else {
+ $where = $rule->cat_filter ?
+ Feeds::_get_cat_title($rule->cat_id ?? 0) :
+ ($rule->feed_id ?
+ Feeds::_get_title($rule->feed_id) : __("All feeds"));
+ }
- $inverse = $line["inverse"] ? "inverse" : "";
+ $inverse_class = $rule->inverse ? "inverse" : "";
- $rv .= "<li class='$inverse'>" . T_sprintf("%s on %s in %s %s",
- htmlspecialchars($line["reg_exp"]),
- $line["field"],
+ $rv .= "<li class='$inverse_class'>" . T_sprintf("%s on %s in %s %s",
+ htmlspecialchars($rule->reg_exp),
+ $rule->field,
$where,
- $line["inverse"] ? __("(inverse)") : "") . "</li>";
+ $rule->inverse ? __("(inverse)") : "") . "</li>";
}
return $rv;
@@ -464,39 +469,31 @@ class Pref_Filters extends Handler_Protected {
}
/**
- * @param array<string, mixed>|null $action
+ * @param array<string,mixed>|ArrayAccess<string, mixed>|null $action
*/
- private function _get_action_name(?array $action = null): string {
+ private function _get_action_name(array|ArrayAccess|null $action = null): string {
if (!$action) {
return "";
}
- $sth = $this->pdo->prepare("SELECT description FROM
- ttrss_filter_actions WHERE id = ?");
- $sth->execute([(int)$action["action_id"]]);
+ $title = __($this->action_descriptions[$action['action_id']]['description']) ??
+ T_sprintf('Unknown action: %d', $action['action_id']);
- $title = "";
+ if ($action["action_id"] == self::ACTION_PLUGIN) {
+ list ($pfclass, $pfaction) = explode(":", $action["action_param"]);
- if ($row = $sth->fetch()) {
-
- $title = __($row["description"]);
-
- 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;
@@ -723,45 +720,63 @@ class Pref_Filters extends Handler_Protected {
*/
private function _get_name(int $id): array {
- $sth = $this->pdo->prepare(
- "SELECT title,match_any_rule,f.inverse AS inverse,COUNT(DISTINCT r.id) AS num_rules,COUNT(DISTINCT a.id) AS num_actions
- FROM ttrss_filters2 AS f LEFT JOIN ttrss_filters2_rules AS r
- ON (r.filter_id = f.id)
- LEFT JOIN ttrss_filters2_actions AS a
- ON (a.filter_id = f.id) WHERE f.id = ? GROUP BY f.title, f.match_any_rule, f.inverse");
- $sth->execute([$id]);
-
- if ($row = $sth->fetch()) {
-
- $title = $row["title"];
- $num_rules = $row["num_rules"];
- $num_actions = $row["num_actions"];
- $match_any_rule = $row["match_any_rule"];
- $inverse = $row["inverse"];
-
- if (!$title) $title = __("[No caption]");
-
- $title = sprintf(_ngettext("%s (%d rule)", "%s (%d rules)", (int) $num_rules), $title, $num_rules);
-
- $sth = $this->pdo->prepare("SELECT * FROM ttrss_filters2_actions
- WHERE filter_id = ? ORDER BY id LIMIT 1");
- $sth->execute([$id]);
-
- $actions = "";
+ $filter = ORM::for_table("ttrss_filters2")
+ ->table_alias('f')
+ ->select('f.title')
+ ->select('f.match_any_rule')
+ ->select('f.inverse')
+ ->select_expr('COUNT(DISTINCT r.id)', 'num_rules')
+ ->select_expr('COUNT(DISTINCT a.id)', 'num_actions')
+ ->left_outer_join('ttrss_filters2_rules', ['r.filter_id', '=', 'f.id'], 'r')
+ ->left_outer_join('ttrss_filters2_actions', ['a.filter_id', '=', 'f.id'], 'a')
+ ->where('f.id', $id)
+ ->group_by_expr('f.title, f.match_any_rule, f.inverse')
+ ->find_one();
+
+ if ($filter) {
+ $title_summary = [
+ sprintf(
+ _ngettext("%s (%d rule)", "%s (%d rules)", (int) $filter->num_rules),
+ ($filter->title ? $filter->title : __("[No caption]")),
+ $filter->num_rules)];
+
+ if ($filter->match_any_rule) array_push($title_summary, __("matches any rule"));
+ if ($filter->inverse) array_push($title_summary, __("inverse"));
+
+ $actions = ORM::for_table("ttrss_filters2_actions")
+ ->where("filter_id", $id)
+ ->order_by_asc('id')
+ ->find_many();
+
+ /** @var array<string> $actions_summary */
+ $actions_summary = [];
+ $cumulative_score = 0;
+
+ // we're going to show a summary adjustment so we skip individual score action descriptions here
+ foreach ($actions as $action) {
+ if ($action->action_id == self::ACTION_SCORE) {
+ $cumulative_score += (int) $action->action_param;
+ continue;
+ }
- if ($line = $sth->fetch()) {
- $actions = $this->_get_action_name($line);
+ array_push($actions_summary, self::_get_action_name($action));
+ }
- $num_actions -= 1;
+ // inject a fake action description using cumulative filter score
+ if ($cumulative_score != 0) {
+ array_unshift($actions_summary,
+ self::_get_action_name(["action_id" => self::ACTION_SCORE, "action_param" => $cumulative_score]));
}
- if ($match_any_rule) $title .= " (" . __("matches any rule") . ")";
- if ($inverse) $title .= " (" . __("inverse") . ")";
+ if (count($actions_summary) > self::MAX_ACTIONS_TO_DISPLAY) {
+ $actions_not_shown = count($actions_summary) - self::MAX_ACTIONS_TO_DISPLAY;
+ $actions_summary = array_slice($actions_summary, 0, self::MAX_ACTIONS_TO_DISPLAY);
- if ($num_actions > 0)
- $actions = sprintf(_ngettext("%s (+%d action)", "%s (+%d actions)", (int) $num_actions), $actions, $num_actions);
+ array_push($actions_summary,
+ "<em class='text-muted'>" . sprintf(_ngettext("(+%d action)", "(+%d actions)", $actions_not_shown), $actions_not_shown)) . "</em>";
+ }
- return [$title, $actions];
+ return [implode(", ", $title_summary), implode("<br/>", $actions_summary)];
}
return [];
diff --git a/include/errorhandler.php b/include/errorhandler.php
index 4f773bc19..c155c9989 100644
--- a/include/errorhandler.php
+++ b/include/errorhandler.php
@@ -41,12 +41,8 @@ function format_backtrace(array $trace): string {
}
function ttrss_error_handler(int $errno, string $errstr, string $file, int $line): bool {
- // return true in order to avoid default error handling by PHP
- if (version_compare(PHP_VERSION, '8.0.0', '<')) {
- if (error_reporting() == 0 || !$errno) return true;
- } else {
- if (!(error_reporting() & $errno)) return true;
- }
+ // return true in order to avoid default error handling by PHP
+ if (!(error_reporting() & $errno)) return true;
$file = substr(str_replace(dirname(__DIR__), "", $file), 1);
diff --git a/include/functions.php b/include/functions.php
index c77b68828..9fb98c60b 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -5,10 +5,6 @@
/** @deprecated by Config::SCHEMA_VERSION */
define('SCHEMA_VERSION', Config::SCHEMA_VERSION);
- if (version_compare(PHP_VERSION, '8.0.0', '<')) {
- libxml_disable_entity_loader(true);
- }
-
libxml_use_internal_errors(true);
// separate test because this is included before sanity checks
@@ -147,7 +143,7 @@
}
}
- if (!empty($_SESSION["uid"]) && get_schema_version() >= 120) {
+ if (!empty($_SESSION["uid"]) && Config::get_schema_version() >= 120) {
$pref_locale = Prefs::get(Prefs::USER_LANGUAGE, $_SESSION["uid"], $_SESSION["profile"] ?? null);
if (!empty($pref_locale) && $pref_locale != 'auto') {
diff --git a/js/CommonFilters.js b/js/CommonFilters.js
index 8be9e2613..6a85bf86c 100644
--- a/js/CommonFilters.js
+++ b/js/CommonFilters.js
@@ -324,7 +324,9 @@ const Filters = {
</form>
`);
- dijit.byId("filterDlg_actionSelect").attr('value', action.action_id);
+ const actionSelect = dijit.byId("filterDlg_actionSelect").attr('value', action.action_id);
+
+ edit_action_dialog.toggleParam(actionSelect);
/*xhr.post("backend.php", {op: 'Pref_Filters', method: 'newaction', action: actionStr}, (reply) => {
edit_action_dialog.attr('content', reply);
diff --git a/themes/compact.css b/themes/compact.css
index b0330b885..3ee5a4a90 100644
--- a/themes/compact.css
+++ b/themes/compact.css
@@ -1151,7 +1151,7 @@ body.ttrss_utility .text-warning {
}
body.ttrss_main .text-muted,
body.ttrss_utility .text-muted {
- color: #555;
+ color: #888888;
}
body.ttrss_main .text-small,
body.ttrss_utility .text-small,
@@ -1510,6 +1510,9 @@ body.ttrss_prefs h4 {
font-weight: 600;
color: #555;
}
+body.ttrss_prefs .text-muted {
+ color: #888888;
+}
body.ttrss_prefs .dijitContentPane > h1:first-of-type,
body.ttrss_prefs .dijitContentPane > h2:first-of-type,
body.ttrss_prefs .dijitContentPane > h3:first-of-type {
@@ -1964,6 +1967,7 @@ body.ttrss_utility.share_popup .content {
.flat .dijitTree .labelParam {
float: right;
margin-right: 16px;
+ text-align: right;
}
.flat .dijitTree .dijitTreeRow.filterDisabled {
opacity: 0.5;
diff --git a/themes/compact_night.css b/themes/compact_night.css
index 12b94dc85..c62554e29 100644
--- a/themes/compact_night.css
+++ b/themes/compact_night.css
@@ -1151,7 +1151,7 @@ body.ttrss_utility .text-warning {
}
body.ttrss_main .text-muted,
body.ttrss_utility .text-muted {
- color: #ccc;
+ color: #999999;
}
body.ttrss_main .text-small,
body.ttrss_utility .text-small,
@@ -1510,6 +1510,9 @@ body.ttrss_prefs h4 {
font-weight: 600;
color: #ccc;
}
+body.ttrss_prefs .text-muted {
+ color: #999999;
+}
body.ttrss_prefs .dijitContentPane > h1:first-of-type,
body.ttrss_prefs .dijitContentPane > h2:first-of-type,
body.ttrss_prefs .dijitContentPane > h3:first-of-type {
@@ -1866,6 +1869,7 @@ body.ttrss_prefs[hide-filter-rules="true"] ul.filterRules {
.flat .dijitTree .labelParam {
float: right;
margin-right: 16px;
+ text-align: right;
}
.flat .dijitTree .dijitTreeRow.filterDisabled {
opacity: 0.5;
diff --git a/themes/light-high-contrast.css b/themes/light-high-contrast.css
index 217d10eac..830b57f72 100644
--- a/themes/light-high-contrast.css
+++ b/themes/light-high-contrast.css
@@ -1151,7 +1151,7 @@ body.ttrss_utility .text-warning {
}
body.ttrss_main .text-muted,
body.ttrss_utility .text-muted {
- color: black;
+ color: #333333;
}
body.ttrss_main .text-small,
body.ttrss_utility .text-small,
@@ -1510,6 +1510,9 @@ body.ttrss_prefs h4 {
font-weight: 600;
color: black;
}
+body.ttrss_prefs .text-muted {
+ color: #333333;
+}
body.ttrss_prefs .dijitContentPane > h1:first-of-type,
body.ttrss_prefs .dijitContentPane > h2:first-of-type,
body.ttrss_prefs .dijitContentPane > h3:first-of-type {
@@ -1964,6 +1967,7 @@ body.ttrss_utility.share_popup .content {
.flat .dijitTree .labelParam {
float: right;
margin-right: 16px;
+ text-align: right;
}
.flat .dijitTree .dijitTreeRow.filterDisabled {
opacity: 0.5;
diff --git a/themes/light.css b/themes/light.css
index e7aa0c11e..33d137423 100644
--- a/themes/light.css
+++ b/themes/light.css
@@ -1151,7 +1151,7 @@ body.ttrss_utility .text-warning {
}
body.ttrss_main .text-muted,
body.ttrss_utility .text-muted {
- color: #555;
+ color: #888888;
}
body.ttrss_main .text-small,
body.ttrss_utility .text-small,
@@ -1510,6 +1510,9 @@ body.ttrss_prefs h4 {
font-weight: 600;
color: #555;
}
+body.ttrss_prefs .text-muted {
+ color: #888888;
+}
body.ttrss_prefs .dijitContentPane > h1:first-of-type,
body.ttrss_prefs .dijitContentPane > h2:first-of-type,
body.ttrss_prefs .dijitContentPane > h3:first-of-type {
@@ -1964,6 +1967,7 @@ body.ttrss_utility.share_popup .content {
.flat .dijitTree .labelParam {
float: right;
margin-right: 16px;
+ text-align: right;
}
.flat .dijitTree .dijitTreeRow.filterDisabled {
opacity: 0.5;
diff --git a/themes/light/defines.less b/themes/light/defines.less
index 08896b4f1..37d1beadf 100644
--- a/themes/light/defines.less
+++ b/themes/light/defines.less
@@ -28,6 +28,8 @@
@breakpoint-lg: 992px;
@breakpoint-xl: 1200px;
+@fg-text-muted: lighten(@default-text, 20%);
+
@embed-responsive-padding: 56.25%; // Use 56.25% for 16:9 aspect ratio, 75% for 4:3.
body.ttrss_main,
diff --git a/themes/light/dijit_basic.less b/themes/light/dijit_basic.less
index f29461530..fcdde88eb 100644
--- a/themes/light/dijit_basic.less
+++ b/themes/light/dijit_basic.less
@@ -151,6 +151,7 @@
.labelParam {
float: right;
margin-right: 16px;
+ text-align: right;
}
.dijitTreeRow.filterDisabled {
diff --git a/themes/light/prefs.less b/themes/light/prefs.less
index e13358956..849855796 100644
--- a/themes/light/prefs.less
+++ b/themes/light/prefs.less
@@ -9,6 +9,10 @@ body.ttrss_prefs {
color : @default-text;
}
+ .text-muted {
+ color : @fg-text-muted;
+ }
+
.dijitContentPane {
> h1:first-of-type,
> h2:first-of-type,
diff --git a/themes/light/tt-rss.less b/themes/light/tt-rss.less
index 3896665c8..bb6ef9ef8 100644
--- a/themes/light/tt-rss.less
+++ b/themes/light/tt-rss.less
@@ -1348,7 +1348,7 @@ body.ttrss_main, body.ttrss_utility {
}
.text-muted {
- color : @default-text;
+ color : @fg-text-muted;
}
.text-small, .small {
diff --git a/themes/night.css b/themes/night.css
index 33a239af0..81a1b444b 100644
--- a/themes/night.css
+++ b/themes/night.css
@@ -1152,7 +1152,7 @@ body.ttrss_utility .text-warning {
}
body.ttrss_main .text-muted,
body.ttrss_utility .text-muted {
- color: #ccc;
+ color: #999999;
}
body.ttrss_main .text-small,
body.ttrss_utility .text-small,
@@ -1511,6 +1511,9 @@ body.ttrss_prefs h4 {
font-weight: 600;
color: #ccc;
}
+body.ttrss_prefs .text-muted {
+ color: #999999;
+}
body.ttrss_prefs .dijitContentPane > h1:first-of-type,
body.ttrss_prefs .dijitContentPane > h2:first-of-type,
body.ttrss_prefs .dijitContentPane > h3:first-of-type {
@@ -1867,6 +1870,7 @@ body.ttrss_prefs[hide-filter-rules="true"] ul.filterRules {
.flat .dijitTree .labelParam {
float: right;
margin-right: 16px;
+ text-align: right;
}
.flat .dijitTree .dijitTreeRow.filterDisabled {
opacity: 0.5;
diff --git a/themes/night_blue.css b/themes/night_blue.css
index 6676426ef..16de963a3 100644
--- a/themes/night_blue.css
+++ b/themes/night_blue.css
@@ -1152,7 +1152,7 @@ body.ttrss_utility .text-warning {
}
body.ttrss_main .text-muted,
body.ttrss_utility .text-muted {
- color: #ccc;
+ color: #999999;
}
body.ttrss_main .text-small,
body.ttrss_utility .text-small,
@@ -1511,6 +1511,9 @@ body.ttrss_prefs h4 {
font-weight: 600;
color: #ccc;
}
+body.ttrss_prefs .text-muted {
+ color: #999999;
+}
body.ttrss_prefs .dijitContentPane > h1:first-of-type,
body.ttrss_prefs .dijitContentPane > h2:first-of-type,
body.ttrss_prefs .dijitContentPane > h3:first-of-type {
@@ -1867,6 +1870,7 @@ body.ttrss_prefs[hide-filter-rules="true"] ul.filterRules {
.flat .dijitTree .labelParam {
float: right;
margin-right: 16px;
+ text-align: right;
}
.flat .dijitTree .dijitTreeRow.filterDisabled {
opacity: 0.5;