diff --git a/classes/feeds.php b/classes/feeds.php
index f3ce1e48b..aa1f889e0 100755
--- a/classes/feeds.php
+++ b/classes/feeds.php
@@ -583,7 +583,7 @@ class Feeds extends Handler_Protected {
function subscribeToFeed() {
print json_encode([
- "cat_select" => format_feed_cat_select("cat", false, 'dojoType="fox.form.Select"')
+ "cat_select" => \Controls\select_feeds_cats("cat")
]);
}
@@ -607,8 +607,8 @@ class Feeds extends Handler_Protected {
if (DB_TYPE == "pgsql") {
print "
diff --git a/classes/pref/system.php b/classes/pref/system.php
index f0a5f7b7f..d3b733364 100644
--- a/classes/pref/system.php
+++ b/classes/pref/system.php
@@ -90,12 +90,12 @@ class Pref_System extends Handler_Administrative {
= __("Severity:") ?>
- __("Errors"),
E_USER_WARNING => __("Warnings"),
E_USER_NOTICE => __("Everything")
- ], 'dojoType="fox.form.Select" onchange="Helpers.EventLog.refresh()"') ?>
+ ], 'onchange="Helpers.EventLog.refresh()"', "severity") ?>
diff --git a/include/controls.php b/include/controls.php
index f706931db..34a4af1f2 100755
--- a/include/controls.php
+++ b/include/controls.php
@@ -1,326 +1,133 @@
";
- foreach ($values as $v) {
- if ($v == $default)
- $sel = "selected=\"1\"";
- else
- $sel = "";
+ $rv = "
";
-}
+ $rv .= "
";
+ }
-function print_select_hash($id, $default, $values, $attributes = "", $name = "") {
- if (!$name) $name = $id;
+ $rv .= "";
- print "
";
-}
+ $values = [];
-function format_hidden($name, $value) {
- return "
";
-}
+ while ($row = $sth->fetch()) {
+ array_push($values, $row["caption"]);
+ }
-function print_hidden($name, $value) {
- print format_hidden($name, $value);
-}
+ return select_tag($name, $value, $values, $attributes, $id);
+ }
-function format_checkbox($id, $checked, $value = "", $attributes = "") {
- $checked_str = $checked ? "checked" : "";
- $value_str = $value ? "value=\"$value\"" : "";
+ function select_hash(string $name, $value, array $values, string $attributes = "", string $id = "") {
+ $dojo_type = strpos($attributes, "dojoType") === false ? "dojoType='fox.form.Select'" : "";
- return "
";
-}
+ $rv = "
";
- if ($v == $default)
- $sel = "checked";
- else
- $sel = "";
+ return $rv;
+ }
- if ($v == $true_is) {
- $sel .= " value=\"1\"";
- } else {
- $sel .= " value=\"0\"";
- }
+ function hidden_tag(string $name, string $value) {
+ return "
";
+ }
- print "
$v ";
+ function checkbox_tag(string $name, bool $checked, string $value = "", string $attributes = "", string $id = "") {
+ $is_checked = $checked ? "checked" : "";
+ $value_str = $value ? "value=\"".htmlspecialchars($value)."\"" : "";
- }
-}
+ return "
";
+ }
-function print_feed_multi_select($id, $default_ids = [],
- $attributes = "", $include_all_feeds = true,
- $root_id = null, $nest_level = 0) {
+ function select_feeds_cats(string $name, int $default_id = null, string $attributes = "",
+ bool $include_all_cats = true, string $root_id = null, int $nest_level = 0, string $id = "") {
- $pdo = Db::pdo();
+ $ret = "";
- print_r(in_array("CAT:6",$default_ids));
+ if (!$root_id) {
+ $ret .= "
";
- }
-}
-
-function print_feed_cat_select($id, $default_id, $attributes, $include_all_cats = true,
- $root_id = null, $nest_level = 0) {
-
- print format_feed_cat_select($id, $default_id, $attributes, $include_all_cats, $root_id, $nest_level);
-}
-
-function format_feed_cat_select($id, $default_id, $attributes, $include_all_cats = true,
- $root_id = null, $nest_level = 0) {
-
- $ret = "";
-
- if (!$root_id) {
- $ret .= "
";
- }
-
- $pdo = Db::pdo();
-
- if (!$root_id) $root_id = null;
-
- $sth = $pdo->prepare("SELECT id,title,
- (SELECT COUNT(id) FROM ttrss_feed_categories AS c2 WHERE
- c2.parent_cat = ttrss_feed_categories.id) AS num_children
- FROM ttrss_feed_categories
- WHERE owner_uid = :uid AND
- (parent_cat = :root_id OR (:root_id IS NULL AND parent_cat IS NULL)) ORDER BY title");
- $sth->execute([":uid" => $_SESSION['uid'], ":root_id" => $root_id]);
-
- $found = 0;
-
- while ($line = $sth->fetch()) {
- ++$found;
-
- if ($line["id"] == $default_id) {
- $is_selected = "selected=\"1\"";
- } else {
- $is_selected = "";
- }
-
- for ($i = 0; $i < $nest_level; $i++)
- $line["title"] = " " . $line["title"];
-
- if ($line["title"])
- $ret .= sprintf("",
- $line["id"], htmlspecialchars($line["title"]));
-
- if ($line["num_children"] > 0)
- $ret .= format_feed_cat_select($id, $default_id, $attributes,
- $include_all_cats, $line["id"], $nest_level+1);
- }
-
- if (!$root_id) {
- if ($include_all_cats) {
- if ($found > 0) {
- $ret .= "";
- }
-
- if ($default_id == 0) {
- $is_selected = "selected=\"1\"";
- } else {
- $is_selected = "";
- }
-
- $ret .= "";
- }
- $ret .= "";
- }
-
- return $ret;
-}
-
-function stylesheet_tag($filename, $id = false) {
- $timestamp = filemtime($filename);
-
- $id_part = $id ? "id=\"$id\"" : "";
-
- return "
\n";
-}
-
-function javascript_tag($filename) {
- $query = "";
-
- if (!(strpos($filename, "?") === false)) {
- $query = substr($filename, strpos($filename, "?")+1);
- $filename = substr($filename, 0, strpos($filename, "?"));
- }
-
- $timestamp = filemtime($filename);
-
- if ($query) $timestamp .= "&$query";
-
- return "\n";
-}
-
-function format_warning($msg, $id = "") {
- return "
$msg
";
-}
-
-function format_notice($msg, $id = "") {
- return "
$msg
";
-}
-
-function format_error($msg, $id = "") {
- return "
$msg
";
-}
-
-function print_notice($msg) {
- return print format_notice($msg);
-}
-
-function print_warning($msg) {
- return print format_warning($msg);
-}
-
-function print_error($msg) {
- return print format_error($msg);
-}
-
-function print_label_select($name, $value, $attributes = "") {
-
- $pdo = Db::pdo();
-
- $sth = $pdo->prepare("SELECT caption FROM ttrss_labels2
- WHERE owner_uid = ? ORDER BY caption");
- $sth->execute([$_SESSION['uid']]);
-
- print "
";
-
- while ($line = $sth->fetch()) {
-
- $issel = ($line["caption"] == $value) ? "selected=\"1\"" : "";
-
- print "";
-
- }
-
-# print "";
-
- print "";
-
-
-}
diff --git a/include/controls_compat.php b/include/controls_compat.php
new file mode 100644
index 000000000..3d2779b08
--- /dev/null
+++ b/include/controls_compat.php
@@ -0,0 +1,312 @@
+";
+ foreach ($values as $v) {
+ if ($v == $default)
+ $sel = "selected=\"1\"";
+ else
+ $sel = "";
+
+ $v = trim($v);
+
+ print "
";
+ }
+ print "";
+}
+
+function print_select_hash($id, $default, $values, $attributes = "", $name = "") {
+ if (!$name) $name = $id;
+
+ print "
";
+ foreach (array_keys($values) as $v) {
+ if ($v == $default)
+ $sel = 'selected="selected"';
+ else
+ $sel = "";
+
+ $v = trim($v);
+
+ print "";
+ }
+
+ print "";
+}
+
+function format_hidden($name, $value) {
+ return "
";
+}
+
+function print_hidden($name, $value) {
+ print format_hidden($name, $value);
+}
+
+function format_checkbox($id, $checked, $value = "", $attributes = "") {
+ $checked_str = $checked ? "checked" : "";
+ $value_str = $value ? "value=\"$value\"" : "";
+
+ return "
";
+}
+
+function print_checkbox($id, $checked, $value = "", $attributes = "") {
+ print format_checkbox($id, $checked, $value, $attributes);
+}
+
+function format_button($type, $value, $attributes = "") {
+ return "
";
+}
+
+function print_button($type, $value, $attributes = "") {
+ print format_button($type, $value, $attributes);
+}
+
+function print_feed_multi_select($id, $default_ids = [],
+ $attributes = "", $include_all_feeds = true,
+ $root_id = null, $nest_level = 0) {
+
+ $pdo = Db::pdo();
+
+ print_r(in_array("CAT:6",$default_ids));
+
+ if (!$root_id) {
+ print "
";
+ if ($include_all_feeds) {
+ $is_selected = (in_array("0", $default_ids)) ? "selected=\"1\"" : "";
+ print "";
+ }
+ }
+
+ if (get_pref('ENABLE_FEED_CATS')) {
+
+ if (!$root_id) $root_id = null;
+
+ $sth = $pdo->prepare("SELECT id,title,
+ (SELECT COUNT(id) FROM ttrss_feed_categories AS c2 WHERE
+ c2.parent_cat = ttrss_feed_categories.id) AS num_children
+ FROM ttrss_feed_categories
+ WHERE owner_uid = :uid AND
+ (parent_cat = :root_id OR (:root_id IS NULL AND parent_cat IS NULL)) ORDER BY title");
+
+ $sth->execute([":uid" => $_SESSION['uid'], ":root_id" => $root_id]);
+
+ while ($line = $sth->fetch()) {
+
+ for ($i = 0; $i < $nest_level; $i++)
+ $line["title"] = " " . $line["title"];
+
+ $is_selected = in_array("CAT:".$line["id"], $default_ids) ? "selected=\"1\"" : "";
+
+ printf("",
+ $line["id"], htmlspecialchars($line["title"]));
+
+ if ($line["num_children"] > 0)
+ print_feed_multi_select($id, $default_ids, $attributes,
+ $include_all_feeds, $line["id"], $nest_level+1);
+
+ $f_sth = $pdo->prepare("SELECT id,title FROM ttrss_feeds
+ WHERE cat_id = ? AND owner_uid = ? ORDER BY title");
+
+ $f_sth->execute([$line['id'], $_SESSION['uid']]);
+
+ while ($fline = $f_sth->fetch()) {
+ $is_selected = (in_array($fline["id"], $default_ids)) ? "selected=\"1\"" : "";
+
+ $fline["title"] = " " . $fline["title"];
+
+ for ($i = 0; $i < $nest_level; $i++)
+ $fline["title"] = " " . $fline["title"];
+
+ printf("",
+ $fline["id"], htmlspecialchars($fline["title"]));
+ }
+ }
+
+ if (!$root_id) {
+ $is_selected = in_array("CAT:0", $default_ids) ? "selected=\"1\"" : "";
+
+ printf("",
+ __("Uncategorized"));
+
+ $f_sth = $pdo->prepare("SELECT id,title FROM ttrss_feeds
+ WHERE cat_id IS NULL AND owner_uid = ? ORDER BY title");
+ $f_sth->execute([$_SESSION['uid']]);
+
+ while ($fline = $f_sth->fetch()) {
+ $is_selected = in_array($fline["id"], $default_ids) ? "selected=\"1\"" : "";
+
+ $fline["title"] = " " . $fline["title"];
+
+ for ($i = 0; $i < $nest_level; $i++)
+ $fline["title"] = " " . $fline["title"];
+
+ printf("",
+ $fline["id"], htmlspecialchars($fline["title"]));
+ }
+ }
+
+ } else {
+ $sth = $pdo->prepare("SELECT id,title FROM ttrss_feeds
+ WHERE owner_uid = ? ORDER BY title");
+ $sth->execute([$_SESSION['uid']]);
+
+ while ($line = $sth->fetch()) {
+
+ $is_selected = (in_array($line["id"], $default_ids)) ? "selected=\"1\"" : "";
+
+ printf("",
+ $line["id"], htmlspecialchars($line["title"]));
+ }
+ }
+
+ if (!$root_id) {
+ print "";
+ }
+}
+
+function print_feed_cat_select($id, $default_id, $attributes, $include_all_cats = true,
+ $root_id = null, $nest_level = 0) {
+
+ print format_feed_cat_select($id, $default_id, $attributes, $include_all_cats, $root_id, $nest_level);
+}
+
+function format_feed_cat_select($id, $default_id, $attributes, $include_all_cats = true,
+ $root_id = null, $nest_level = 0) {
+
+ $ret = "";
+
+ if (!$root_id) {
+ $ret .= "
";
+ }
+
+ $pdo = Db::pdo();
+
+ if (!$root_id) $root_id = null;
+
+ $sth = $pdo->prepare("SELECT id,title,
+ (SELECT COUNT(id) FROM ttrss_feed_categories AS c2 WHERE
+ c2.parent_cat = ttrss_feed_categories.id) AS num_children
+ FROM ttrss_feed_categories
+ WHERE owner_uid = :uid AND
+ (parent_cat = :root_id OR (:root_id IS NULL AND parent_cat IS NULL)) ORDER BY title");
+ $sth->execute([":uid" => $_SESSION['uid'], ":root_id" => $root_id]);
+
+ $found = 0;
+
+ while ($line = $sth->fetch()) {
+ ++$found;
+
+ if ($line["id"] == $default_id) {
+ $is_selected = "selected=\"1\"";
+ } else {
+ $is_selected = "";
+ }
+
+ for ($i = 0; $i < $nest_level; $i++)
+ $line["title"] = " " . $line["title"];
+
+ if ($line["title"])
+ $ret .= sprintf("",
+ $line["id"], htmlspecialchars($line["title"]));
+
+ if ($line["num_children"] > 0)
+ $ret .= format_feed_cat_select($id, $default_id, $attributes,
+ $include_all_cats, $line["id"], $nest_level+1);
+ }
+
+ if (!$root_id) {
+ if ($include_all_cats) {
+ if ($found > 0) {
+ $ret .= "";
+ }
+
+ if ($default_id == 0) {
+ $is_selected = "selected=\"1\"";
+ } else {
+ $is_selected = "";
+ }
+
+ $ret .= "";
+ }
+ $ret .= "";
+ }
+
+ return $ret;
+}
+
+function stylesheet_tag($filename, $id = false) {
+ $timestamp = filemtime($filename);
+
+ $id_part = $id ? "id=\"$id\"" : "";
+
+ return "
\n";
+}
+
+function javascript_tag($filename) {
+ $query = "";
+
+ if (!(strpos($filename, "?") === false)) {
+ $query = substr($filename, strpos($filename, "?")+1);
+ $filename = substr($filename, 0, strpos($filename, "?"));
+ }
+
+ $timestamp = filemtime($filename);
+
+ if ($query) $timestamp .= "&$query";
+
+ return "\n";
+}
+
+function format_warning($msg, $id = "") {
+ return "
$msg
";
+}
+
+function format_notice($msg, $id = "") {
+ return "
$msg
";
+}
+
+function format_error($msg, $id = "") {
+ return "
$msg
";
+}
+
+function print_notice($msg) {
+ return print format_notice($msg);
+}
+
+function print_warning($msg) {
+ return print format_warning($msg);
+}
+
+function print_error($msg) {
+ return print format_error($msg);
+}
+
+function print_label_select($name, $value, $attributes = "") {
+
+ $pdo = Db::pdo();
+
+ $sth = $pdo->prepare("SELECT caption FROM ttrss_labels2
+ WHERE owner_uid = ? ORDER BY caption");
+ $sth->execute([$_SESSION['uid']]);
+
+ print "
";
+
+ while ($line = $sth->fetch()) {
+
+ $issel = ($line["caption"] == $value) ? "selected=\"1\"" : "";
+
+ print "";
+
+ }
+
+# print "";
+
+ print "";
+
+
+}
diff --git a/include/functions.php b/include/functions.php
index 4557c0411..174ef39f0 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -203,6 +203,7 @@
require_once 'db-prefs.php';
require_once 'controls.php';
+ require_once 'controls_compat.php';
define('SELF_USER_AGENT', 'Tiny Tiny RSS/' . get_version() . ' (http://tt-rss.org/)');
ini_set('user_agent', SELF_USER_AGENT);
diff --git a/include/login_form.php b/include/login_form.php
index aa6a72260..798efa624 100755
--- a/include/login_form.php
+++ b/include/login_form.php
@@ -97,7 +97,7 @@