From 481bd7610059cfa09282a03e1a9c8dbc213f4819 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 12 Feb 2021 21:51:32 +0300 Subject: pref helpers: move some methods to their own sections --- classes/pref/feeds.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'classes/pref/feeds.php') diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index 47e5689ec..ff9e69336 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -1394,7 +1394,7 @@ class Pref_Feeds extends Handler_Protected { print " - "; PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "prefFeedsPublishedGenerated"); -- cgit v1.2.3-54-g00ecf From 17413078a72e1298c6dc8953c40e8d83ce38c49c Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 13 Feb 2021 18:32:02 +0300 Subject: pref feeds: index cleanup, split into several methods, use tabs to maximize space for feed tree, persist feed tree state --- classes/pref/feeds.php | 333 +++++++++++++++++++++++++---------------------- classes/pref/filters.php | 6 - classes/pref/labels.php | 7 - js/PrefFeedTree.js | 37 +++++- plugins/share/init.php | 6 +- themes/compact.css | 15 +-- themes/compact_night.css | 15 +-- themes/light.css | 15 +-- themes/light/prefs.less | 14 +- themes/night.css | 15 +-- themes/night_blue.css | 15 +-- 11 files changed, 235 insertions(+), 243 deletions(-) (limited to 'classes/pref/feeds.php') diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index ff9e69336..d8495a59c 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -1197,12 +1197,7 @@ class Pref_Feeds extends Handler_Protected { $opml->opml_import($_SESSION["uid"]); } - function index() { - - print "
"; - print "
rss_feed ".__('Feeds')."\">"; - + private function index_feeds() { $sth = $this->pdo->prepare("SELECT COUNT(id) AS num_errors FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ?"); $sth->execute([$_SESSION['uid']]); @@ -1214,16 +1209,15 @@ class Pref_Feeds extends Handler_Protected { } if ($num_errors > 0) { - $error_button = ""; + $error_button = ""; } else { $error_button = ""; } - $inactive_button = ""; @@ -1235,175 +1229,202 @@ class Pref_Feeds extends Handler_Protected { $feed_search = $_SESSION["prefs_feed_search"] ?? ""; } - print '
'; - - print "
"; #toolbar - - print "
- - -
"; - - print "
". - "" . __('Select').""; - print "
"; - print "
".__('All')."
"; - print "
".__('None')."
"; - print "
"; - - print "
". - "" . __('Feeds').""; - print "
"; - print "
".__('Subscribe to feed')."
"; - print "
".__('Edit selected feeds')."
"; - print "
".__('Reset sort order')."
"; - print "
".__('Batch subscribe')."
"; - print "
" - .__('Unsubscribe')."
"; - print "
"; - - if (get_pref('ENABLE_FEED_CATS')) { - print "
". - "" . __('Categories').""; - print "
"; - print "
".__('Add category')."
"; - print "
".__('Reset sort order')."
"; - print "
".__('Remove selected')."
"; - print "
"; - - } - - print $error_button; - print $inactive_button; - - print "
"; # toolbar - - //print '
'; - print '
'; - - print "
- ". - __("Loading, please wait...")."
"; - - $auto_expand = $feed_search != "" ? "true" : "false"; - - print "
-
-
+ ?> + +
+
+
+ + +
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+ + +
+ +
+
+
+
+
+
+ + + +
+
+
+
+ +
+
+ +
" + persist="true" + model="feedModel" + openOnClick="false"> + + +
+
-
- - -
"; - -# print "
-# ".__('Hint: you can drag feeds and categories around.')." -#
"; + '; - print '
'; - - print "
"; # feeds pane + } - print "
"; + private function index_opml() { + ?> - print "

" . __("Using OPML you can export and import your feeds, filters, labels and Tiny Tiny RSS settings.") . "

"; +

- print_notice("Only main settings profile can be migrated using OPML."); + - print "
-
"; # pane - - print "
share ".__('Published & shared articles / Generated feeds')."\">"; - - print "

" . __('Published articles can be subscribed by anyone who knows the following URL:') . "

"; - + private function index_shared() { $rss_url = htmlspecialchars(get_self_url_prefix() . - "/public.php?op=rss&id=-2&view-mode=all_articles");; + "/public.php?op=rss&id=-2&view-mode=all_articles"); + ?> - print " - "; +

- PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "prefFeedsPublishedGenerated"); + - print "
"; #pane + - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, "prefFeeds"); + run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "prefFeedsPublishedGenerated"); + } - print "
"; #container + function index() { + ?> + +
+
+ index_feeds() ?> +
+ +
+ index_opml() ?> +
+ +
+ index_shared() ?> +
+ + run_hooks(PluginHost::HOOK_PREFS_TAB, "prefFeeds"); + $plugin_data = trim((string)ob_get_contents()); + ob_end_clean(); + ?> + + +
+ +
+ +
+
+ +
+
-
- -
@@ -758,9 +755,6 @@ class Pref_Filters extends Handler_Protected {
-
diff --git a/js/PrefFeedTree.js b/js/PrefFeedTree.js index e17b8744d..e0a2dd932 100644 --- a/js/PrefFeedTree.js +++ b/js/PrefFeedTree.js @@ -209,6 +209,13 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_b return false; }, + checkErrorFeeds: function() { + xhrJson("backend.php", {op: "pref-feeds", method: "feedsWithErrors"}, (reply) => { + if (reply.length > 0) { + Element.show(dijit.byId("pref_feeds_errors_btn").domNode); + } + }); + }, checkInactiveFeeds: function() { xhrJson("backend.php", {op: "pref-feeds", method: "inactivefeeds"}, (reply) => { if (reply.length > 0) { diff --git a/themes/compact.css b/themes/compact.css index f923b2ee1..36c5aec9f 100644 --- a/themes/compact.css +++ b/themes/compact.css @@ -1456,7 +1456,7 @@ body.ttrss_prefs #feedsTab { body.ttrss_prefs .dijitDialog #pref-profiles-list .dijitInlineEditBoxDisplayMode { padding: 0px; } -body.ttrss_prefs #errorButton { +body.ttrss_prefs #pref_feeds_errors_btn { color: red; } body.ttrss_prefs .user-css-editor { diff --git a/themes/compact_night.css b/themes/compact_night.css index e512e8176..e39b7020a 100644 --- a/themes/compact_night.css +++ b/themes/compact_night.css @@ -1456,7 +1456,7 @@ body.ttrss_prefs #feedsTab { body.ttrss_prefs .dijitDialog #pref-profiles-list .dijitInlineEditBoxDisplayMode { padding: 0px; } -body.ttrss_prefs #errorButton { +body.ttrss_prefs #pref_feeds_errors_btn { color: red; } body.ttrss_prefs .user-css-editor { diff --git a/themes/light.css b/themes/light.css index a19467c41..b6c487b66 100644 --- a/themes/light.css +++ b/themes/light.css @@ -1456,7 +1456,7 @@ body.ttrss_prefs #feedsTab { body.ttrss_prefs .dijitDialog #pref-profiles-list .dijitInlineEditBoxDisplayMode { padding: 0px; } -body.ttrss_prefs #errorButton { +body.ttrss_prefs #pref_feeds_errors_btn { color: red; } body.ttrss_prefs .user-css-editor { diff --git a/themes/light/prefs.less b/themes/light/prefs.less index 0206916ae..ec3006ce5 100644 --- a/themes/light/prefs.less +++ b/themes/light/prefs.less @@ -65,7 +65,7 @@ body.ttrss_prefs { padding : 0px; } - #errorButton { + #pref_feeds_errors_btn { color : red; } diff --git a/themes/night.css b/themes/night.css index e2bd50142..5941fd8e1 100644 --- a/themes/night.css +++ b/themes/night.css @@ -1457,7 +1457,7 @@ body.ttrss_prefs #feedsTab { body.ttrss_prefs .dijitDialog #pref-profiles-list .dijitInlineEditBoxDisplayMode { padding: 0px; } -body.ttrss_prefs #errorButton { +body.ttrss_prefs #pref_feeds_errors_btn { color: red; } body.ttrss_prefs .user-css-editor { diff --git a/themes/night_blue.css b/themes/night_blue.css index 93027e8be..99bb191a2 100644 --- a/themes/night_blue.css +++ b/themes/night_blue.css @@ -1457,7 +1457,7 @@ body.ttrss_prefs #feedsTab { body.ttrss_prefs .dijitDialog #pref-profiles-list .dijitInlineEditBoxDisplayMode { padding: 0px; } -body.ttrss_prefs #errorButton { +body.ttrss_prefs #pref_feeds_errors_btn { color: red; } body.ttrss_prefs .user-css-editor { -- cgit v1.2.3-54-g00ecf From 15fd23c374eb32c50733de1906065f552afbfbc4 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 14 Feb 2021 09:15:51 +0300 Subject: use shortcut echo syntax for php templates --- classes/feeds.php | 10 +++--- classes/handler/public.php | 44 +++++++++++------------ classes/pref/feeds.php | 74 +++++++++++++++++++------------------- classes/pref/filters.php | 20 +++++------ classes/pref/labels.php | 12 +++---- classes/pref/system.php | 42 +++++++++++----------- include/login_form.php | 34 +++++++++--------- index.php | 78 ++++++++++++++++++++--------------------- plugins/af_redditimgur/init.php | 4 +-- plugins/auth_internal/init.php | 18 +++++----- plugins/toggle_sidebar/init.php | 2 +- prefs.php | 28 +++++++-------- 12 files changed, 183 insertions(+), 183 deletions(-) (limited to 'classes/pref/feeds.php') diff --git a/classes/feeds.php b/classes/feeds.php index 031a671ae..e6bd1459d 100755 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -838,14 +838,14 @@ class Feeds extends Handler_Protected {
-

Feed Debugger: getFeedTitle($feed_id) ?>

+

Feed Debugger: getFeedTitle($feed_id) ?>

- + - +
- +
- +
diff --git a/classes/handler/public.php b/classes/handler/public.php index db8a924ad..481145606 100755 --- a/classes/handler/public.php +++ b/classes/handler/public.php @@ -519,7 +519,7 @@ class Handler_Public extends Handler { - <?php echo __("Share with Tiny Tiny RSS") ?> + <?= __("Share with Tiny Tiny RSS") ?>
- - + +
- - + +
- +
- +
- - - + + +
@@ -635,24 +635,24 @@ class Handler_Public extends Handler { -
+
- + " /> + required="1" value="" />
- + "/> + value=""/>

@@ -660,7 +660,7 @@ class Handler_Public extends Handler {
- +
@@ -781,7 +781,7 @@ class Handler_Public extends Handler { };
-

+

- +
- + Database Updater - +
-

+

diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index 72a8344ad..6b5df0289 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -1223,52 +1223,52 @@ class Pref_Feeds extends Handler_Protected {
+ value=""> +
- +
+ dojoType="dijit.MenuItem">
+ dojoType="dijit.MenuItem">
- +
+ dojoType="dijit.MenuItem">
+ dojoType="dijit.MenuItem">
+ dojoType="dijit.MenuItem">
+ dojoType="dijit.MenuItem">
-
+
- +
+ dojoType="dijit.MenuItem">
+ dojoType="dijit.MenuItem">
+ dojoType="dijit.MenuItem">
- - + +
" + autoExpand="" persist="true" model="feedModel" openOnClick="false"> @@ -1311,19 +1311,19 @@ class Pref_Feeds extends Handler_Protected { private function index_opml() { ?> -

+

-
+ + + + + diff --git a/classes/pref/labels.php b/classes/pref/labels.php index 22a2dddea..d182a0995 100644 --- a/classes/pref/labels.php +++ b/classes/pref/labels.php @@ -195,23 +195,23 @@ class Pref_Labels extends Handler_Protected {
- +
+ dojoType='dijit.MenuItem'>
+ dojoType='dijit.MenuItem'>
+ + + diff --git a/classes/pref/system.php b/classes/pref/system.php index 72e15e4f3..1adddf116 100644 --- a/classes/pref/system.php +++ b/classes/pref/system.php @@ -76,30 +76,30 @@ class Pref_System extends Handler_Protected {
- -
- + - - - - - + + + + + - + - - - + + + - + @@ -162,7 +162,7 @@ class Pref_System extends Handler_Protected { $page = (int) ($_REQUEST["page"] ?? 0); ?>
-
'> +
'> log_viewer($page, $severity); @@ -172,11 +172,11 @@ class Pref_System extends Handler_Protected { ?>
-
'> +
'> -
+
run_hooks(PluginHost::HOOK_PREFS_TAB, "prefSystem") ?> diff --git a/include/login_form.php b/include/login_form.php index aec305b13..aa6a72260 100755 --- a/include/login_form.php +++ b/include/login_form.php @@ -92,29 +92,29 @@
-

+

-
- +
- + " /> + required="1" value="" />
- + "/> + value=""/>
- +
- +
@@ -143,11 +143,11 @@ +
- +
@@ -155,11 +155,11 @@ +
- +
0) { ?> @@ -167,7 +167,7 @@ @@ -177,7 +177,7 @@
- +
@@ -185,7 +185,7 @@
diff --git a/index.php b/index.php index fa23570ff..8bfca1af2 100644 --- a/index.php +++ b/index.php @@ -47,7 +47,7 @@ } ?> @@ -68,7 +68,7 @@ @@ -50,7 +50,7 @@ - - - -
'; - - print ""; - - print "
"; - print "
"; - - print "
"; - print ""; - - print ""; - print "
"; - - print ""; + function subscribeToFeed() { + print json_encode([ + "cat_select" => format_feed_cat_select("cat", false, 'dojoType="fox.form.Select"') + ]); } function search() { @@ -1077,6 +1002,18 @@ class Feeds extends Handler_Protected { } } + function add() { + $feed = clean($_REQUEST['feed']); + $cat = clean($_REQUEST['cat']); + $need_auth = isset($_REQUEST['need_auth']); + $login = $need_auth ? clean($_REQUEST['login']) : ''; + $pass = $need_auth ? clean($_REQUEST['pass']) : ''; + + $rc = Feeds::subscribe_to_feed($feed, $cat, $login, $pass); + + print json_encode(array("result" => $rc)); + } + /** * @return array (code => Status code, message => error message if available) * diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index e225949f2..af3877159 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -1241,7 +1241,7 @@ class Pref_Feeds extends Handler_Protected {
-
diff --git a/classes/rpc.php b/classes/rpc.php index e0753a08e..2bbaf4135 100755 --- a/classes/rpc.php +++ b/classes/rpc.php @@ -80,18 +80,6 @@ class RPC extends Handler_Protected { } } - function addfeed() { - $feed = clean($_REQUEST['feed']); - $cat = clean($_REQUEST['cat']); - $need_auth = isset($_REQUEST['need_auth']); - $login = $need_auth ? clean($_REQUEST['login']) : ''; - $pass = $need_auth ? clean($_REQUEST['pass']) : ''; - - $rc = Feeds::subscribe_to_feed($feed, $cat, $login, $pass); - - print json_encode(array("result" => $rc)); - } - function togglepref() { $key = clean($_REQUEST["key"]); set_pref($key, !get_pref($key)); diff --git a/js/App.js b/js/App.js index 3a31438c5..5c2d7726c 100644 --- a/js/App.js +++ b/js/App.js @@ -838,7 +838,7 @@ const App = { if (this.is_prefs) { this.hotkey_actions["feed_subscribe"] = () => { - CommonDialogs.quickAddFeed(); + CommonDialogs.subscribeToFeed(); }; this.hotkey_actions["create_label"] = () => { @@ -994,7 +994,7 @@ const App = { Feeds.toggleUnread(); }; this.hotkey_actions["feed_subscribe"] = () => { - CommonDialogs.quickAddFeed(); + CommonDialogs.subscribeToFeed(); }; this.hotkey_actions["feed_debug_update"] = () => { if (!Feeds.activeIsCat() && parseInt(Feeds.getActive()) > 0) { @@ -1139,7 +1139,7 @@ const App = { Feeds.search(); break; case "qmcAddFeed": - CommonDialogs.quickAddFeed(); + CommonDialogs.subscribeToFeed(); break; case "qmcDigest": window.location.href = "backend.php?op=digest"; diff --git a/js/CommonDialogs.js b/js/CommonDialogs.js index 60c3e2a84..492467b7f 100644 --- a/js/CommonDialogs.js +++ b/js/CommonDialogs.js @@ -77,15 +77,93 @@ const CommonDialogs = { return false; }, - quickAddFeed: function() { - xhrPost("backend.php", - {op: "feeds", method: "quickAddFeed"}, - (transport) => { - + subscribeToFeed: function() { + xhrJson("backend.php", + {op: "feeds", method: "subscribeToFeed"}, + (reply) => { const dialog = new fox.SingleUseDialog({ - id: "feedAddDlg", title: __("Subscribe to Feed"), - content: transport.responseText, + content: ` +
+ + ${App.FormFields.hidden("op", "feeds")} + ${App.FormFields.hidden("method", "add")} + + + + + +
+
+
+ +
+ + ${App.getInitParam('enable_feed_cats') ? + ` +
+ + ${reply.cat_select} +
+ ` : ''} +
+ + + + + +
+ +
+ +
+ + +
+
+ `, show_error: function (msg) { const elem = $("fadd_error_message"); @@ -114,7 +192,7 @@ const CommonDialogs = { } catch (e) { Element.hide("feed_add_spinner"); alert(__("Failed to parse output. This can indicate server timeout and/or network issues. Backend output was logged to browser console.")); - console.log('quickAddFeed, backend returned:' + transport.responseText); + console.log('subscribeToFeed, backend returned:' + transport.responseText); return; } -- cgit v1.2.3-54-g00ecf From 020f062a76746a313fae9c82fbcf9b37fcc9d459 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 15 Feb 2021 15:43:07 +0300 Subject: feeds: unify naming --- classes/api.php | 20 +-- classes/counters.php | 14 +- classes/feeds.php | 152 ++++++++++----------- classes/handler/public.php | 12 +- classes/opml.php | 12 +- classes/pref/feeds.php | 24 ++-- classes/pref/filters.php | 12 +- classes/rpc.php | 2 +- classes/rssutils.php | 6 +- include/functions.php | 2 +- js/Feeds.js | 2 +- plugins/af_comics/filters/af_comics_gocomics.php | 2 +- .../filters/af_comics_gocomics_farside.php | 2 +- plugins/af_psql_trgm/init.php | 2 +- plugins/af_readability/init.php | 2 +- plugins/vf_shared/init.php | 2 +- 16 files changed, 134 insertions(+), 134 deletions(-) (limited to 'classes/pref/feeds.php') diff --git a/classes/api.php b/classes/api.php index 2531f0017..73e5c221a 100755 --- a/classes/api.php +++ b/classes/api.php @@ -96,7 +96,7 @@ class API extends Handler { if ($feed_id) { $this->wrap(self::STATUS_OK, array("unread" => getFeedUnread($feed_id, $is_cat))); } else { - $this->wrap(self::STATUS_OK, array("unread" => Feeds::getGlobalUnread())); + $this->wrap(self::STATUS_OK, array("unread" => Feeds::_get_global_unread())); } } @@ -147,7 +147,7 @@ class API extends Handler { $unread = getFeedUnread($line["id"], true); if ($enable_nested) - $unread += Feeds::getCategoryChildrenUnread($line["id"]); + $unread += Feeds::_get_cat_children_unread($line["id"]); if ($unread || !$unread_only) { array_push($cats, array("id" => (int) $line["id"], @@ -165,7 +165,7 @@ class API extends Handler { if ($unread || !$unread_only) { array_push($cats, array("id" => $cat_id, - "title" => Feeds::getCategoryTitle($cat_id), + "title" => Feeds::_get_cat_title($cat_id), "unread" => (int) $unread)); } } @@ -204,7 +204,7 @@ class API extends Handler { $_SESSION['hasSandbox'] = $has_sandbox; - list($override_order, $skip_first_id_check) = Feeds::order_to_override_query(clean($_REQUEST["order_by"] ?? null)); + list($override_order, $skip_first_id_check) = Feeds::_order_to_override_query(clean($_REQUEST["order_by"] ?? null)); /* do not rely on params below */ @@ -395,7 +395,7 @@ class API extends Handler { if (!in_array($mode, ["all", "1day", "1week", "2week"])) $mode = "all"; - Feeds::catchup_feed($feed_id, $is_cat, $_SESSION["uid"], $mode); + Feeds::_catchup($feed_id, $is_cat, $_SESSION["uid"], $mode); $this->wrap(self::STATUS_OK, array("status" => "OK")); } @@ -537,7 +537,7 @@ class API extends Handler { $unread = getFeedUnread($i); if ($unread || !$unread_only) { - $title = Feeds::getFeedTitle($i); + $title = Feeds::_get_title($i); $row = array( "id" => $i, @@ -562,7 +562,7 @@ class API extends Handler { while ($line = $sth->fetch()) { $unread = getFeedUnread($line["id"], true) + - Feeds::getCategoryChildrenUnread($line["id"]); + Feeds::_get_cat_children_unread($line["id"]); if ($unread || !$unread_only) { $row = array( @@ -610,7 +610,7 @@ class API extends Handler { $unread = getFeedUnread($line["id"]); - $has_icon = Feeds::feedHasIcon($line['id']); + $has_icon = Feeds::_has_icon($line['id']); if ($unread || !$unread_only) { @@ -676,7 +676,7 @@ class API extends Handler { "skip_first_id_check" => $skip_first_id_check ); - $qfh_ret = Feeds::queryFeedHeadlines($params); + $qfh_ret = Feeds::_get_headlines($params); $result = $qfh_ret[0]; $feed_title = $qfh_ret[1]; @@ -826,7 +826,7 @@ class API extends Handler { $password = clean($_REQUEST["password"]); if ($feed_url) { - $rc = Feeds::subscribe_to_feed($feed_url, $category_id, $login, $password); + $rc = Feeds::_subscribe($feed_url, $category_id, $login, $password); $this->wrap(self::STATUS_OK, array("status" => $rc)); } else { diff --git a/classes/counters.php b/classes/counters.php index 59605df18..29ced3d6c 100644 --- a/classes/counters.php +++ b/classes/counters.php @@ -25,8 +25,8 @@ class Counters { while ($line = $sth->fetch()) { list ($tmp_unread, $tmp_marked) = self::getCategoryChildrenCounters($line["id"], $owner_uid); - $unread += $tmp_unread + Feeds::getCategoryUnread($line["id"], $owner_uid); - $marked += $tmp_marked + Feeds::getCategoryMarked($line["id"], $owner_uid); + $unread += $tmp_unread + Feeds::_get_cat_unread($line["id"], $owner_uid); + $marked += $tmp_marked + Feeds::_get_cat_marked($line["id"], $owner_uid); } return [$unread, $marked]; @@ -38,7 +38,7 @@ class Counters { /* Labels category */ $cv = array("id" => -2, "kind" => "cat", - "counter" => Feeds::getCategoryUnread(-2)); + "counter" => Feeds::_get_cat_unread(-2)); array_push($ret, $cv); @@ -114,8 +114,8 @@ class Counters { $last_error = htmlspecialchars($line["last_error"]); $last_updated = TimeHelper::make_local_datetime($line['last_updated'], false); - if (Feeds::feedHasIcon($id)) { - $has_img = filemtime(Feeds::getIconFile($id)); + if (Feeds::_has_icon($id)) { + $has_img = filemtime(Feeds::_get_icon_file($id)); } else { $has_img = false; } @@ -149,7 +149,7 @@ class Counters { $ret = []; if ($global_unread == -1) { - $global_unread = Feeds::getGlobalUnread(); + $global_unread = Feeds::_get_global_unread(); } $cv = [ @@ -187,7 +187,7 @@ class Counters { $count = getFeedUnread($i); if ($i == 0 || $i == -1 || $i == -2) - $auxctr = Feeds::getFeedArticles($i, false); + $auxctr = Feeds::_get_counters($i, false); else $auxctr = 0; diff --git a/classes/feeds.php b/classes/feeds.php index 4cc76bd62..6bf176261 100755 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -16,13 +16,13 @@ class Feeds extends Handler_Protected { return array_search($method, $csrf_ignored) !== false; } - private function format_headlines_list($feed, $method, $view_mode, $limit, $cat_view, + private function _format_headlines_list($feed, $method, $view_mode, $limit, $cat_view, $offset, $override_order = false, $include_children = false, $check_first_id = false, $skip_first_id_check = false, $order_by = false) { $disable_cache = false; - $this->mark_timestamp("init"); + $this->_mark_timestamp("init"); $reply = []; $rgba_cache = []; @@ -41,7 +41,7 @@ class Feeds extends Handler_Protected { } if ($method_split[0] == "MarkAllReadGR") { - $this->catchup_feed($method_split[1], false); + $this->_catchup($method_split[1], false); } // FIXME: might break tag display? @@ -103,10 +103,10 @@ class Feeds extends Handler_Protected { "order_by" => $order_by ); - $qfh_ret = $this->queryFeedHeadlines($params); + $qfh_ret = $this->_get_headlines($params); } - $this->mark_timestamp("db query"); + $this->_mark_timestamp("db query"); $vfeed_group_enabled = get_pref("VFEED_GROUP_BY_FEED") && !(in_array($feed, self::NEVER_GROUP_FEEDS) && !$cat_view); @@ -157,13 +157,13 @@ class Feeds extends Handler_Protected { }, $feed, $cat_view, $qfh_ret); - $this->mark_timestamp("object header"); + $this->_mark_timestamp("object header"); $headlines_count = 0; if ($result instanceof PDOStatement) { while ($line = $result->fetch(PDO::FETCH_ASSOC)) { - $this->mark_timestamp("article start: " . $line["id"] . " " . $line["title"]); + $this->_mark_timestamp("article start: " . $line["id"] . " " . $line["title"]); ++$headlines_count; @@ -181,7 +181,7 @@ class Feeds extends Handler_Protected { $line, $max_excerpt_length); } - $this->mark_timestamp(" hook_query_headlines"); + $this->_mark_timestamp(" hook_query_headlines"); $id = $line["id"]; @@ -226,7 +226,7 @@ class Feeds extends Handler_Protected { array_push($topmost_article_ids, $id); } - $this->mark_timestamp(" labels"); + $this->_mark_timestamp(" labels"); $line["feed_title"] = $line["feed_title"] ?? ""; @@ -244,32 +244,32 @@ class Feeds extends Handler_Protected { }, $line); - $this->mark_timestamp(" pre-sanitize"); + $this->_mark_timestamp(" pre-sanitize"); $line["content"] = Sanitizer::sanitize($line["content"], $line['hide_images'], false, $line["site_url"], $highlight_words, $line["id"]); - $this->mark_timestamp(" sanitize"); + $this->_mark_timestamp(" sanitize"); PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_RENDER_ARTICLE_CDM, function ($result, $plugin) use (&$line) { $line = $result; - $this->mark_timestamp(" hook_render_cdm: " . get_class($plugin)); + $this->_mark_timestamp(" hook_render_cdm: " . get_class($plugin)); }, $line); - $this->mark_timestamp(" hook_render_cdm"); + $this->_mark_timestamp(" hook_render_cdm"); $line['content'] = DiskCache::rewriteUrls($line['content']); - $this->mark_timestamp(" disk_cache_rewrite"); + $this->_mark_timestamp(" disk_cache_rewrite"); if ($line['note']) $line['note'] = Article::format_article_note($id, $line['note']); else $line['note'] = ""; - $this->mark_timestamp(" note"); + $this->_mark_timestamp(" note"); if (!get_pref("CDM_EXPANDED")) { $line["cdm_excerpt"] = " @@ -281,14 +281,14 @@ class Feeds extends Handler_Protected { } } - $this->mark_timestamp(" pre-enclosures"); + $this->_mark_timestamp(" pre-enclosures"); $line["enclosures"] = Article::format_enclosures($id, $line["always_display_enclosures"], $line["content"], $line["hide_images"]); - $this->mark_timestamp(" enclosures"); + $this->_mark_timestamp(" enclosures"); $line["updated_long"] = TimeHelper::make_local_datetime($line["updated"],true); $line["updated"] = TimeHelper::make_local_datetime($line["updated"], false, false, false, true); @@ -296,7 +296,7 @@ class Feeds extends Handler_Protected { $line['imported'] = T_sprintf("Imported at %s", TimeHelper::make_local_datetime($line["date_entered"], false)); - $this->mark_timestamp(" local-datetime"); + $this->_mark_timestamp(" local-datetime"); if ($line["tag_cache"]) $tags = explode(",", $line["tag_cache"]); @@ -305,9 +305,9 @@ class Feeds extends Handler_Protected { $line["tags_str"] = Article::format_tags_string($tags); - $this->mark_timestamp(" tags"); + $this->_mark_timestamp(" tags"); - if (self::feedHasIcon($feed_id)) { + if (self::_has_icon($feed_id)) { $line['feed_icon'] = "\"\""; } else { $line['feed_icon'] = "rss_feed"; @@ -316,7 +316,7 @@ class Feeds extends Handler_Protected { //setting feed headline background color, needs to change text color based on dark/light $fav_color = $line['favicon_avg_color'] ?? false; - $this->mark_timestamp(" pre-color"); + $this->_mark_timestamp(" pre-color"); require_once "colors.php"; @@ -324,7 +324,7 @@ class Feeds extends Handler_Protected { if ($fav_color && $fav_color != 'fail') { $rgba_cache[$feed_id] = _color_unpack($fav_color); } else { - $rgba_cache[$feed_id] = _color_unpack($this->color_of($line['feed_title'])); + $rgba_cache[$feed_id] = _color_unpack($this->_color_of($line['feed_title'])); } } @@ -332,7 +332,7 @@ class Feeds extends Handler_Protected { $line['feed_bg_color'] = 'rgba(' . implode(",", $rgba_cache[$feed_id]) . ',0.3)'; } - $this->mark_timestamp(" color"); + $this->_mark_timestamp(" color"); /* we don't need those */ @@ -342,11 +342,11 @@ class Feeds extends Handler_Protected { array_push($reply['content'], $line); - $this->mark_timestamp("article end"); + $this->_mark_timestamp("article end"); } } - $this->mark_timestamp("end of articles"); + $this->_mark_timestamp("end of articles"); if (!$headlines_count) { @@ -408,7 +408,7 @@ class Feeds extends Handler_Protected { } } - $this->mark_timestamp("end"); + $this->_mark_timestamp("end"); return array($topmost_article_ids, $headlines_count, $feed, $disable_cache, $reply); } @@ -489,9 +489,9 @@ class Feeds extends Handler_Protected { $reply['headlines'] = []; - list($override_order, $skip_first_id_check) = self::order_to_override_query($order_by); + list($override_order, $skip_first_id_check) = self::_order_to_override_query($order_by); - $ret = $this->format_headlines_list($feed, $method, + $ret = $this->_format_headlines_list($feed, $method, $view_mode, $limit, $cat_view, $offset, $override_order, true, $check_first_id, $skip_first_id_check, $order_by); @@ -600,7 +600,7 @@ class Feeds extends Handler_Protected { print "
"; print "getFeedTitle($active_feed_id, $is_cat))."\" + placeHolder=\"".T_sprintf("Search %s...", $this->_get_title($active_feed_id, $is_cat))."\" name='query' type='search' value=''>"; print "
"; @@ -686,7 +686,7 @@ class Feeds extends Handler_Protected {
-

Feed Debugger: getFeedTitle($feed_id) ?>

+

Feed Debugger: _get_title($feed_id) ?>

@@ -731,7 +731,7 @@ class Feeds extends Handler_Protected { } - static function catchup_feed($feed, $cat_view, $owner_uid = false, $mode = 'all', $search = false) { + static function _catchup($feed, $cat_view, $owner_uid = false, $mode = 'all', $search = false) { if (!$owner_uid) $owner_uid = $_SESSION['uid']; @@ -751,7 +751,7 @@ class Feeds extends Handler_Protected { // fall back in case of no plugins if (empty($search_qpart)) { - list($search_qpart, $search_words) = self::search_to_sql($search[0], $search[1], $owner_uid); + list($search_qpart, $search_words) = self::_search_to_sql($search[0], $search[1], $owner_uid); } } else { $search_qpart = "true"; @@ -791,7 +791,7 @@ class Feeds extends Handler_Protected { if ($feed >= 0) { if ($feed > 0) { - $children = self::getChildCategories($feed, $owner_uid); + $children = self::_get_child_cats($feed, $owner_uid); array_push($children, $feed); $children = array_map("intval", $children); @@ -902,7 +902,7 @@ class Feeds extends Handler_Protected { } } - static function getFeedArticles($feed, $is_cat = false, $unread_only = false, + static function _get_counters($feed, $is_cat = false, $unread_only = false, $owner_uid = false) { $n_feed = (int) $feed; @@ -921,7 +921,7 @@ class Feeds extends Handler_Protected { $match_part = ""; if ($is_cat) { - return self::getCategoryUnread($n_feed, $owner_uid); + return self::_get_cat_unread($n_feed, $owner_uid); } else if ($n_feed == -6) { return 0; } else if ($feed != "0" && $n_feed == 0) { @@ -967,7 +967,7 @@ class Feeds extends Handler_Protected { $label_id = Labels::feed_to_label_id($feed); - return self::getLabelUnread($label_id, $owner_uid); + return self::_get_label_unread($label_id, $owner_uid); } if ($match_part) { @@ -1009,7 +1009,7 @@ class Feeds extends Handler_Protected { $login = $need_auth ? clean($_REQUEST['login']) : ''; $pass = $need_auth ? clean($_REQUEST['pass']) : ''; - $rc = Feeds::subscribe_to_feed($feed, $cat, $login, $pass); + $rc = Feeds::_subscribe($feed, $cat, $login, $pass); print json_encode(array("result" => $rc)); } @@ -1027,7 +1027,7 @@ class Feeds extends Handler_Protected { * 5 - Couldn't download the URL content. * 6 - Content is an invalid XML. */ - static function subscribe_to_feed($url, $cat_id = 0, + static function _subscribe($url, $cat_id = 0, $auth_login = '', $auth_pass = '') { global $fetch_last_error; @@ -1056,8 +1056,8 @@ class Feeds extends Handler_Protected { return array("code" => 5, "message" => $fetch_last_error); } - if (mb_strpos($fetch_last_content_type, "html") !== false && self::is_html($contents)) { - $feedUrls = self::get_feeds_from_html($url, $contents); + if (mb_strpos($fetch_last_content_type, "html") !== false && self::_is_html($contents)) { + $feedUrls = self::_get_feeds_from_html($url, $contents); if (count($feedUrls) == 0) { return array("code" => 3); @@ -1100,15 +1100,15 @@ class Feeds extends Handler_Protected { } } - static function getIconFile($feed_id) { + static function _get_icon_file($feed_id) { return ICONS_DIR . "/$feed_id.ico"; } - static function feedHasIcon($id) { + static function _has_icon($id) { return is_file(ICONS_DIR . "/$id.ico") && filesize(ICONS_DIR . "/$id.ico") > 0; } - static function getFeedIcon($id) { + static function _get_icon($id) { switch ($id) { case 0: return "archive"; @@ -1132,7 +1132,7 @@ class Feeds extends Handler_Protected { if ($id < LABEL_BASE_INDEX) { return "label"; } else { - $icon = self::getIconFile($id); + $icon = self::_get_icon_file($id); if ($icon && file_exists($icon)) { return ICONS_URL . "/" . basename($icon) . "?" . filemtime($icon); @@ -1144,11 +1144,11 @@ class Feeds extends Handler_Protected { return false; } - static function getFeedTitle($id, $cat = false) { + static function _get_title($id, $cat = false) { $pdo = Db::pdo(); if ($cat) { - return self::getCategoryTitle($id); + return self::_get_cat_title($id); } else if ($id == -1) { return __("Starred articles"); } else if ($id == -2) { @@ -1191,7 +1191,7 @@ class Feeds extends Handler_Protected { } // only real cats - static function getCategoryMarked($cat, $owner_uid = false) { + static function _get_cat_marked($cat, $owner_uid = false) { if (!$owner_uid) $owner_uid = $_SESSION["uid"]; @@ -1214,7 +1214,7 @@ class Feeds extends Handler_Protected { } } - static function getCategoryUnread($cat, $owner_uid = false) { + static function _get_cat_unread($cat, $owner_uid = false) { if (!$owner_uid) $owner_uid = $_SESSION["uid"]; @@ -1248,7 +1248,7 @@ class Feeds extends Handler_Protected { } // only accepts real cats (>= 0) - static function getCategoryChildrenUnread($cat, $owner_uid = false) { + static function _get_cat_children_unread($cat, $owner_uid = false) { if (!$owner_uid) $owner_uid = $_SESSION["uid"]; $pdo = Db::pdo(); @@ -1260,14 +1260,14 @@ class Feeds extends Handler_Protected { $unread = 0; while ($line = $sth->fetch()) { - $unread += self::getCategoryUnread($line["id"], $owner_uid); - $unread += self::getCategoryChildrenUnread($line["id"], $owner_uid); + $unread += self::_get_cat_unread($line["id"], $owner_uid); + $unread += self::_get_cat_children_unread($line["id"], $owner_uid); } return $unread; } - static function getGlobalUnread($user_id = false) { + static function _get_global_unread($user_id = false) { if (!$user_id) $user_id = $_SESSION["uid"]; @@ -1283,7 +1283,7 @@ class Feeds extends Handler_Protected { return $row["count"]; } - static function getCategoryTitle($cat_id) { + static function _get_cat_title($cat_id) { if ($cat_id == -1) { return __("Special"); @@ -1305,7 +1305,7 @@ class Feeds extends Handler_Protected { } } - static function getLabelUnread($label_id, $owner_uid = false) { + private static function _get_label_unread($label_id, $owner_uid = false) { if (!$owner_uid) $owner_uid = $_SESSION["uid"]; $pdo = Db::pdo(); @@ -1322,7 +1322,7 @@ class Feeds extends Handler_Protected { } } - static function queryFeedHeadlines($params) { + static function _get_headlines($params) { $pdo = Db::pdo(); @@ -1368,7 +1368,7 @@ class Feeds extends Handler_Protected { // fall back in case of no plugins if (!$search_query_part) { - list($search_query_part, $search_words) = self::search_to_sql($search, $search_language, $owner_uid); + list($search_query_part, $search_words) = self::_search_to_sql($search, $search_language, $owner_uid); } if (DB_TYPE == "pgsql") { @@ -1406,7 +1406,7 @@ class Feeds extends Handler_Protected { $unread = getFeedUnread($feed, $cat_view); if ($cat_view && $feed > 0 && $include_children) - $unread += self::getCategoryChildrenUnread($feed); + $unread += self::_get_cat_children_unread($feed); if ($unread > 0) { $view_query_part = " unread = true AND "; @@ -1450,7 +1450,7 @@ class Feeds extends Handler_Protected { if ($feed > 0) { if ($include_children) { # sub-cats - $subcats = self::getChildCategories($feed, $owner_uid); + $subcats = self::_get_child_cats($feed, $owner_uid); array_push($subcats, $feed); $subcats = array_map("intval", $subcats); @@ -1574,7 +1574,7 @@ class Feeds extends Handler_Protected { $feed_title = T_sprintf("Search results: %s", $search); } else { if ($cat_view) { - $feed_title = self::getCategoryTitle($feed); + $feed_title = self::_get_cat_title($feed); } else { if (is_numeric($feed) && $feed > 0) { $ssth = $pdo->prepare("SELECT title,site_url,last_error,last_updated @@ -1587,7 +1587,7 @@ class Feeds extends Handler_Protected { $last_error = $row["last_error"]; $last_updated = $row["last_updated"]; } else { - $feed_title = self::getFeedTitle($feed); + $feed_title = self::_get_title($feed); } } } @@ -1802,7 +1802,7 @@ class Feeds extends Handler_Protected { } - static function getParentCategories($cat, $owner_uid) { + static function _get_parent_cats($cat, $owner_uid) { $rv = array(); $pdo = Db::pdo(); @@ -1813,13 +1813,13 @@ class Feeds extends Handler_Protected { while ($line = $sth->fetch()) { array_push($rv, $line["parent_cat"]); - $rv = array_merge($rv, self::getParentCategories($line["parent_cat"], $owner_uid)); + $rv = array_merge($rv, self::_get_parent_cats($line["parent_cat"], $owner_uid)); } return $rv; } - static function getChildCategories($cat, $owner_uid) { + static function _get_child_cats($cat, $owner_uid) { $rv = array(); $pdo = Db::pdo(); @@ -1830,13 +1830,13 @@ class Feeds extends Handler_Protected { while ($line = $sth->fetch()) { array_push($rv, $line["id"]); - $rv = array_merge($rv, self::getChildCategories($line["id"], $owner_uid)); + $rv = array_merge($rv, self::_get_child_cats($line["id"], $owner_uid)); } return $rv; } - static function getFeedCategory($feed) { + static function _cat_of_feed($feed) { $pdo = Db::pdo(); $sth = $pdo->prepare("SELECT cat_id FROM ttrss_feeds @@ -1851,7 +1851,7 @@ class Feeds extends Handler_Protected { } - function color_of($name) { + private function _color_of($name) { $colormap = [ "#1cd7d7","#d91111","#1212d7","#8e16e5","#7b7b7b", "#39f110","#0bbea6","#ec0e0e","#1534f2","#b9e416", "#479af2","#f36b14","#10c7e9","#1e8fe7","#e22727" ]; @@ -1867,7 +1867,7 @@ class Feeds extends Handler_Protected { return $colormap[$sum]; } - static function get_feeds_from_html($url, $content) { + private static function _get_feeds_from_html($url, $content) { $url = UrlHelper::validate($url); $baseUrl = substr($url, 0, strrpos($url, '/') + 1); @@ -1895,11 +1895,11 @@ class Feeds extends Handler_Protected { return $feedUrls; } - static function is_html($content) { + static function _is_html($content) { return preg_match("/

".__('OPML Utility')."

"; - Feeds::add_feed_category("Imported feeds"); + Feeds::_add_cat("Imported feeds"); $this->opml_notice(__("Importing OPML...")); @@ -205,7 +205,7 @@ class OPML extends Handler_Protected { if (!$tmp_line["match_on"]) { if ($cat_filter && $tmp_line["cat_id"] || $tmp_line["feed_id"]) { - $tmp_line["feed"] = Feeds::getFeedTitle( + $tmp_line["feed"] = Feeds::_get_title( $cat_filter ? $tmp_line["cat_id"] : $tmp_line["feed_id"], $cat_filter); } else { @@ -218,13 +218,13 @@ class OPML extends Handler_Protected { if (strpos($feed_id, "CAT:") === 0) { $feed_id = (int)substr($feed_id, 4); if ($feed_id) { - array_push($match, [Feeds::getCategoryTitle($feed_id), true, false]); + array_push($match, [Feeds::_get_cat_title($feed_id), true, false]); } else { array_push($match, [0, true, true]); } } else { if ($feed_id) { - array_push($match, [Feeds::getFeedTitle((int)$feed_id), false, false]); + array_push($match, [Feeds::_get_title((int)$feed_id), false, false]); } else { array_push($match, [0, false, true]); } @@ -523,7 +523,7 @@ class OPML extends Handler_Protected { $order_id = (int) $root_node->attributes->getNamedItem('ttrssSortOrder')->nodeValue; if (!$order_id) $order_id = 0; - Feeds::add_feed_category($cat_title, $parent_id, $order_id); + Feeds::_add_cat($cat_title, $parent_id, $order_id); $cat_id = $this->get_feed_category($cat_title, $parent_id); } @@ -638,7 +638,7 @@ class OPML extends Handler_Protected { $url_path = get_self_url_prefix(); $url_path .= "/opml.php?op=publish&key=" . - Feeds::get_feed_access_key('OPML:Publish', false, $_SESSION["uid"]); + Feeds::_get_access_key('OPML:Publish', false, $_SESSION["uid"]); return $url_path; } diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index af3877159..edba71c5c 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -98,7 +98,7 @@ class Pref_Feeds extends Handler_Protected { $feed['checkbox'] = false; $feed['unread'] = -1; $feed['error'] = $feed_line['last_error']; - $feed['icon'] = Feeds::getFeedIcon($feed_line['id']); + $feed['icon'] = Feeds::_get_icon($feed_line['id']); $feed['param'] = TimeHelper::make_local_datetime( $feed_line['last_updated'], true); $feed['updates_disabled'] = (int)($feed_line['update_interval'] < 0); @@ -266,7 +266,7 @@ class Pref_Feeds extends Handler_Protected { $feed['name'] = $feed_line['title']; $feed['checkbox'] = false; $feed['error'] = $feed_line['last_error']; - $feed['icon'] = Feeds::getFeedIcon($feed_line['id']); + $feed['icon'] = Feeds::_get_icon($feed_line['id']); $feed['param'] = TimeHelper::make_local_datetime( $feed_line['last_updated'], true); $feed['unread'] = -1; @@ -301,7 +301,7 @@ class Pref_Feeds extends Handler_Protected { $feed['name'] = $feed_line['title']; $feed['checkbox'] = false; $feed['error'] = $feed_line['last_error']; - $feed['icon'] = Feeds::getFeedIcon($feed_line['id']); + $feed['icon'] = Feeds::_get_icon($feed_line['id']); $feed['param'] = TimeHelper::make_local_datetime( $feed_line['last_updated'], true); $feed['unread'] = -1; @@ -777,7 +777,7 @@ class Pref_Feeds extends Handler_Protected { /* Icon */ - print ""; + print ""; print " @@ -1189,7 +1189,7 @@ class Pref_Feeds extends Handler_Protected { function addCat() { $feed_cat = clean($_REQUEST["cat"]); - Feeds::add_feed_category($feed_cat); + Feeds::_add_cat($feed_cat); } function importOpml() { @@ -1420,9 +1420,9 @@ class Pref_Feeds extends Handler_Protected { $obj['id'] = 'CAT:' . $cat_id; $obj['items'] = array(); - $obj['name'] = Feeds::getCategoryTitle($cat_id); + $obj['name'] = Feeds::_get_cat_title($cat_id); $obj['type'] = 'category'; - $obj['unread'] = -1; //(int) Feeds::getCategoryUnread($cat_id); + $obj['unread'] = -1; //(int) Feeds::_get_cat_unread($cat_id); $obj['bare_id'] = $cat_id; return $obj; @@ -1433,7 +1433,7 @@ class Pref_Feeds extends Handler_Protected { $feed_id = (int) $feed_id; if (!$title) - $title = Feeds::getFeedTitle($feed_id, false); + $title = Feeds::_get_title($feed_id, false); if ($unread === false) $unread = getFeedUnread($feed_id, false); @@ -1444,7 +1444,7 @@ class Pref_Feeds extends Handler_Protected { $obj['type'] = 'feed'; $obj['error'] = $error; $obj['updated'] = $updated; - $obj['icon'] = Feeds::getFeedIcon($feed_id); + $obj['icon'] = Feeds::_get_icon($feed_id); $obj['bare_id'] = $feed_id; $obj['auxcounter'] = 0; @@ -1611,11 +1611,11 @@ class Pref_Feeds extends Handler_Protected { 'id' => $feed_id, 'is_cat' => (int)$is_cat, 'q' => $search, - 'key' => Feeds::get_feed_access_key($feed_id, $is_cat, $_SESSION["uid"]) + 'key' => Feeds::_get_access_key($feed_id, $is_cat, $_SESSION["uid"]) ]); print json_encode([ - "title" => Feeds::getFeedTitle($feed_id, $is_cat), + "title" => Feeds::_get_title($feed_id, $is_cat), "link" => $link ]); } @@ -1627,7 +1627,7 @@ class Pref_Feeds extends Handler_Protected { WHERE feed_id = ? AND is_cat = ? AND owner_uid = ?"); $sth->execute([$feed_id, bool_to_sql_bool($is_cat), $owner_uid]); - return Feeds::get_feed_access_key($feed_id, $is_cat, $owner_uid); + return Feeds::_get_access_key($feed_id, $is_cat, $owner_uid); } // Silent diff --git a/classes/pref/filters.php b/classes/pref/filters.php index 1c264f642..62bcb8f59 100755 --- a/classes/pref/filters.php +++ b/classes/pref/filters.php @@ -189,10 +189,10 @@ class Pref_Filters extends Handler_Protected { if (strpos($feed_id, "CAT:") === 0) { $feed_id = (int)substr($feed_id, 4); - array_push($feeds_fmt, Feeds::getCategoryTitle($feed_id)); + array_push($feeds_fmt, Feeds::_get_cat_title($feed_id)); } else { if ($feed_id) - array_push($feeds_fmt, Feeds::getFeedTitle((int)$feed_id)); + array_push($feeds_fmt, Feeds::_get_title((int)$feed_id)); else array_push($feeds_fmt, __("All feeds")); } @@ -203,9 +203,9 @@ class Pref_Filters extends Handler_Protected { } else { $where = $line["cat_filter"] ? - Feeds::getCategoryTitle($line["cat_id"]) : + Feeds::_get_cat_title($line["cat_id"]) : ($line["feed_id"] ? - Feeds::getFeedTitle($line["feed_id"]) : __("All feeds")); + Feeds::_get_title($line["feed_id"]) : __("All feeds")); } # $where = $line["cat_id"] . "/" . $line["feed_id"]; @@ -494,10 +494,10 @@ class Pref_Filters extends Handler_Protected { if (strpos($feed_id, "CAT:") === 0) { $feed_id = (int)substr($feed_id, 4); - array_push($feeds_fmt, Feeds::getCategoryTitle($feed_id)); + array_push($feeds_fmt, Feeds::_get_cat_title($feed_id)); } else { if ($feed_id) - array_push($feeds_fmt, Feeds::getFeedTitle((int)$feed_id)); + array_push($feeds_fmt, Feeds::_get_title((int)$feed_id)); else array_push($feeds_fmt, __("All feeds")); } diff --git a/classes/rpc.php b/classes/rpc.php index 2bbaf4135..206a93d60 100755 --- a/classes/rpc.php +++ b/classes/rpc.php @@ -219,7 +219,7 @@ class RPC extends Handler_Protected { $search_query = clean($_REQUEST['search_query']); $search_lang = clean($_REQUEST['search_lang']); - Feeds::catchup_feed($feed_id, $is_cat, false, $mode, [$search_query, $search_lang]); + Feeds::_catchup($feed_id, $is_cat, false, $mode, [$search_query, $search_lang]); // return counters here synchronously so that frontend can figure out next unread feed properly print json_encode(['counters' => Counters::getAllCounters()]); diff --git a/classes/rssutils.php b/classes/rssutils.php index 9dd7c4ab1..0e90d8fe4 100755 --- a/classes/rssutils.php +++ b/classes/rssutils.php @@ -1239,7 +1239,7 @@ class RSSUtils { Debug::log("purging feed...", Debug::$LOG_VERBOSE); - Feeds::purge_feed($feed, 0); + Feeds::_purge($feed, 0); $sth = $pdo->prepare("UPDATE ttrss_feeds SET last_updated = NOW(), @@ -1706,7 +1706,7 @@ class RSSUtils { $filters = array(); $feed_id = (int) $feed_id; - $cat_id = (int)Feeds::getFeedCategory($feed_id); + $cat_id = (int)Feeds::_cat_of_feed($feed_id); if ($cat_id == 0) $null_cat_qpart = "cat_id IS NULL OR"; @@ -1720,7 +1720,7 @@ class RSSUtils { $sth->execute([$owner_uid]); $check_cats = array_merge( - Feeds::getParentCategories($cat_id, $owner_uid), + Feeds::_get_parent_cats($cat_id, $owner_uid), [$cat_id]); $check_cats_str = join(",", $check_cats); diff --git a/include/functions.php b/include/functions.php index eaf7d8243..4557c0411 100644 --- a/include/functions.php +++ b/include/functions.php @@ -217,7 +217,7 @@ // @deprecated function getFeedUnread($feed, $is_cat = false) { - return Feeds::getFeedArticles($feed, $is_cat, true, $_SESSION["uid"]); + return Feeds::_get_counters($feed, $is_cat, true, $_SESSION["uid"]); } // @deprecated diff --git a/js/Feeds.js b/js/Feeds.js index 986936285..73f1bc338 100644 --- a/js/Feeds.js +++ b/js/Feeds.js @@ -501,7 +501,7 @@ const Feeds = { const tree = dijit.byId("feedTree"); if (tree && tree.model) - return tree.getFeedCategory(feed); + return tree._cat_of_feed(feed); } catch (e) { // diff --git a/plugins/af_comics/filters/af_comics_gocomics.php b/plugins/af_comics/filters/af_comics_gocomics.php index 949b7a235..6c5c7c0d3 100644 --- a/plugins/af_comics/filters/af_comics_gocomics.php +++ b/plugins/af_comics/filters/af_comics_gocomics.php @@ -11,7 +11,7 @@ class Af_Comics_Gocomics extends Af_ComicFilter { public function on_subscribe($url) { if (preg_match('#^https?://www\.gocomics\.com/([-a-z0-9]+)$#i', $url)) - return ''; // Get is_html() to return false. + return ''; // Get _is_html() to return false. else return false; } diff --git a/plugins/af_comics/filters/af_comics_gocomics_farside.php b/plugins/af_comics/filters/af_comics_gocomics_farside.php index 9663da8f9..89322209d 100644 --- a/plugins/af_comics/filters/af_comics_gocomics_farside.php +++ b/plugins/af_comics/filters/af_comics_gocomics_farside.php @@ -11,7 +11,7 @@ class Af_Comics_Gocomics_FarSide extends Af_ComicFilter { public function on_subscribe($url) { if (preg_match("#^https?://www\.thefarside\.com#", $url)) - return ''; // Get is_html() to return false. + return ''; // Get _is_html() to return false. else return false; } diff --git a/plugins/af_psql_trgm/init.php b/plugins/af_psql_trgm/init.php index 163b0ec38..47ff98fc2 100644 --- a/plugins/af_psql_trgm/init.php +++ b/plugins/af_psql_trgm/init.php @@ -209,7 +209,7 @@ class Af_Psql_Trgm extends Plugin { print "
  • " . "rss_feed " . - Feeds::getFeedTitle($f) . "
  • "; + Feeds::_get_title($f) . ""; } print ""; } diff --git a/plugins/af_readability/init.php b/plugins/af_readability/init.php index a76c98380..4d21a831c 100755 --- a/plugins/af_readability/init.php +++ b/plugins/af_readability/init.php @@ -122,7 +122,7 @@ class Af_Readability extends Plugin { print "
  • rss_feed ". - Feeds::getFeedTitle($f) . " " . ($is_append ? __("(append)") : "") . "
  • "; + Feeds::_get_title($f) . " " . ($is_append ? __("(append)") : "") . ""; } print ""; } diff --git a/plugins/vf_shared/init.php b/plugins/vf_shared/init.php index 8c38cbf32..1112f6f2f 100644 --- a/plugins/vf_shared/init.php +++ b/plugins/vf_shared/init.php @@ -60,7 +60,7 @@ class VF_Shared extends Plugin { "override_vfeed" => "ttrss_feeds.title AS feed_title," ); - $qfh_ret = Feeds::queryFeedHeadlines($params); + $qfh_ret = Feeds::_get_headlines($params); $qfh_ret[1] = __("Shared articles"); return $qfh_ret; -- cgit v1.2.3-54-g00ecf From 91285e3868fadcfb907cd57a90bb3e5c263c0979 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 15 Feb 2021 16:34:44 +0300 Subject: router: add additional logging for refused requests; reject requests for methods starting with _ --- backend.php | 12 ++++++++++++ classes/pref/feeds.php | 4 ++++ public.php | 10 +++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) (limited to 'classes/pref/feeds.php') diff --git a/backend.php b/backend.php index 030676dcb..e72d97ca4 100644 --- a/backend.php +++ b/backend.php @@ -30,6 +30,9 @@ require_once "db.php"; require_once "db-prefs.php"; + $op = (string)clean($op); + $method = (string)clean($method); + startup_gettext(); $script_started = microtime(true); @@ -92,6 +95,13 @@ if (class_exists($op) || $override) { + if (strpos($method, "_") === 0) { + user_error("Refusing to invoke method $method of handler $op which starts with underscore.", E_USER_WARNING); + header("Content-Type: text/json"); + print error_json(6); + return; + } + if ($override) { $handler = $override; } else { @@ -110,6 +120,7 @@ if ($reflection->getNumberOfRequiredParameters() == 0) { $handler->$method(); } else { + user_error("Refusing to invoke method $method of handler $op which has required parameters.", E_USER_WARNING); header("Content-Type: text/json"); print error_json(6); } @@ -126,6 +137,7 @@ return; } } else { + user_error("Refusing to invoke method $method of handler $op with invalid CSRF token.", E_USER_WARNING); header("Content-Type: text/json"); print error_json(6); return; diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index edba71c5c..4c865e9f0 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -109,6 +109,10 @@ class Pref_Feeds extends Handler_Protected { return $items; } + function _getfeedtree() { + print "OK"; + } + function getfeedtree() { print json_encode($this->makefeedtree()); } diff --git a/public.php b/public.php index 3e4a9e023..dcfc4056e 100644 --- a/public.php +++ b/public.php @@ -16,7 +16,7 @@ if (!init_plugins()) return; - $method = $_REQUEST["op"]; + $method = (string)clean($_REQUEST["op"]); $override = PluginHost::getInstance()->lookup_handler("public", $method); @@ -26,6 +26,13 @@ $handler = new Handler_Public($_REQUEST); } + if (strpos($method, "_") === 0) { + user_error("Refusing to invoke method $method which starts with underscore.", E_USER_WARNING); + header("Content-Type: text/json"); + print error_json(6); + return; + } + if (implements_interface($handler, "IHandler") && $handler->before($method)) { if ($method && method_exists($handler, $method)) { $reflection = new ReflectionMethod($handler, $method); @@ -33,6 +40,7 @@ if ($reflection->getNumberOfRequiredParameters() == 0) { $handler->$method(); } else { + user_error("Refusing to invoke method $method which has required parameters.", E_USER_WARNING); header("Content-Type: text/json"); print error_json(6); } -- cgit v1.2.3-54-g00ecf From bd3c38de849330b3ed28df05c1220c631c103628 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 15 Feb 2021 16:41:52 +0300 Subject: move bookmarklet-related subscribe_to_feed_url to bookmarklet plugin --- classes/pref/feeds.php | 6 ------ plugins/bookmarklets/init.php | 8 +++++++- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'classes/pref/feeds.php') diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index 4c865e9f0..cb6ff94fc 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -1655,10 +1655,4 @@ class Pref_Feeds extends Handler_Protected { return $c; } - static function subscribe_to_feed_url() { - $url_path = get_self_url_prefix() . - "/public.php?op=subscribe&feed_url=%s"; - return $url_path; - } - } diff --git a/plugins/bookmarklets/init.php b/plugins/bookmarklets/init.php index fa1bb8cf6..9e0f8f348 100644 --- a/plugins/bookmarklets/init.php +++ b/plugins/bookmarklets/init.php @@ -16,6 +16,12 @@ class Bookmarklets extends Plugin { $host->add_hook($host::HOOK_PREFS_TAB, $this); } + private function subscribe_to_feed_url() { + $url_path = get_self_url_prefix() . + "/public.php?op=subscribe&feed_url=%s"; + return $url_path; + } + function hook_prefs_tab($args) { if ($args == "prefFeeds") { @@ -24,7 +30,7 @@ class Bookmarklets extends Plugin { print "

    " . __("Drag the link below to your browser toolbar, open the feed you're interested in in your browser and click on the link to subscribe to it.") . "

    "; - $bm_subscribe_url = str_replace('%s', '', Pref_Feeds::subscribe_to_feed_url()); + $bm_subscribe_url = str_replace('%s', '', $this->subscribe_to_feed_url()); $confirm_str = str_replace("'", "\'", __('Subscribe to %s in Tiny Tiny RSS?')); -- cgit v1.2.3-54-g00ecf From 26d6b84a572b5cbd99acffc5ae727ea6d1be543a Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 16 Feb 2021 14:23:00 +0300 Subject: add namespaced controls with unified naming; deprecated old-style control shortcuts --- classes/feeds.php | 22 ++- classes/handler/public.php | 4 +- classes/pref/feeds.php | 27 ++-- classes/pref/filters.php | 21 +-- classes/pref/prefs.php | 41 +++-- classes/pref/system.php | 4 +- include/controls.php | 383 +++++++++++--------------------------------- include/controls_compat.php | 312 ++++++++++++++++++++++++++++++++++++ include/functions.php | 1 + include/login_form.php | 2 +- plugins/mail/init.php | 2 +- 11 files changed, 470 insertions(+), 349 deletions(-) create mode 100644 include/controls_compat.php (limited to 'classes/pref/feeds.php') 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 "
    "; print ""; - print_select("search_language", get_pref('DEFAULT_SEARCH_LANGUAGE'), Pref_Feeds::get_ts_languages(), - "dojoType='fox.form.Select' title=\"".__('Used for word stemming')."\""); + print \Controls\select_tag("search_language", get_pref('DEFAULT_SEARCH_LANGUAGE'), Pref_Feeds::get_ts_languages(), + "title=\"".__('Used for word stemming')."\""); print "
    "; } @@ -668,6 +668,15 @@ class Feeds extends Handler_Protected { display : none; } + - - + +
    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 {
    - __("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 .= ""; - if ($include_all_feeds) { - $is_selected = (in_array("0", $default_ids)) ? "selected=\"1\"" : ""; - print ""; - } - } + $pdo = \Db::pdo(); - if (get_pref('ENABLE_FEED_CATS')) { + if (!$root_id) $root_id = null; - 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]); - $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"); + $found = 0; - $sth->execute([":uid" => $_SESSION['uid'], ":root_id" => $root_id]); + while ($line = $sth->fetch()) { + ++$found; - while ($line = $sth->fetch()) { + if ($line["id"] == $default_id) { + $is_selected = "selected=\"1\""; + } else { + $is_selected = ""; + } - for ($i = 0; $i < $nest_level; $i++) - $line["title"] = " " . $line["title"]; + for ($i = 0; $i < $nest_level; $i++) + $line["title"] = " " . $line["title"]; - $is_selected = in_array("CAT:".$line["id"], $default_ids) ? "selected=\"1\"" : ""; + if ($line["title"]) + $ret .= sprintf("", + $line["id"], htmlspecialchars($line["title"])); - printf("", - $line["id"], htmlspecialchars($line["title"])); + if ($line["num_children"] > 0) + $ret .= select_feeds_cats($id, $default_id, $attributes, + $include_all_cats, $line["id"], $nest_level+1, $id); + } - if ($line["num_children"] > 0) - print_feed_multi_select($id, $default_ids, $attributes, - $include_all_feeds, $line["id"], $nest_level+1); + if (!$root_id) { + if ($include_all_cats) { + if ($found > 0) { + $ret .= ""; + } - $f_sth = $pdo->prepare("SELECT id,title FROM ttrss_feeds - WHERE cat_id = ? AND owner_uid = ? ORDER BY title"); + if ($default_id == 0) { + $is_selected = "selected=\"1\""; + } else { + $is_selected = ""; + } - $f_sth->execute([$line['id'], $_SESSION['uid']]); + $ret .= ""; + } + $ret .= ""; + } - while ($fline = $f_sth->fetch()) { - $is_selected = (in_array($fline["id"], $default_ids)) ? "selected=\"1\"" : ""; + return $ret; + } - $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 .= ""; - } - - 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 ""; - - -} 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 ""; +} + +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 ""; + } +} + +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 .= ""; + } + + 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 ""; + + +} 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 @@ - + diff --git a/plugins/mail/init.php b/plugins/mail/init.php index 829620ebc..b1263ece5 100644 --- a/plugins/mail/init.php +++ b/plugins/mail/init.php @@ -160,7 +160,7 @@ class Mail extends Plugin { style=\"width : 30em;\" name=\"destination\" id=\"emailArticleDlg_destination\">"; */ - print_select("destination", "", $addresslist, 'style="width: 30em" dojoType="dijit.form.ComboBox"'); + print \Controls\select_tag("destination", "", $addresslist, 'style="width: 30em" dojoType="dijit.form.ComboBox"'); /* print "
    "; */ -- cgit v1.2.3-54-g00ecf From 1f43d7916cda16e9680b9087bda1f52934e8f25b Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 16 Feb 2021 14:32:06 +0300 Subject: replace print_hidden with hidden_tag --- classes/pref/feeds.php | 12 ++++++------ classes/pref/filters.php | 10 +++++----- plugins/af_proxy_http/init.php | 6 +++--- plugins/af_psql_trgm/init.php | 6 +++--- plugins/af_readability/init.php | 6 +++--- plugins/af_redditimgur/init.php | 6 +++--- plugins/mail/init.php | 16 ++++++++-------- plugins/note/init.php | 8 ++++---- plugins/nsfw/init.php | 6 +++--- 9 files changed, 38 insertions(+), 38 deletions(-) (limited to 'classes/pref/feeds.php') diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index d97081293..d087d026d 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -524,9 +524,9 @@ class Pref_Feeds extends Handler_Protected { $title = htmlspecialchars($row["title"]); - print_hidden("id", "$feed_id"); - print_hidden("op", "pref-feeds"); - print_hidden("method", "editSave"); + print \Controls\hidden_tag("id", "$feed_id"); + print \Controls\hidden_tag("op", "pref-feeds"); + print \Controls\hidden_tag("method", "editSave"); print "
    ".__("Feed")."
    "; print "
    "; @@ -821,9 +821,9 @@ class Pref_Feeds extends Handler_Protected { print "

    "; - print_hidden("ids", "$feed_ids"); - print_hidden("op", "pref-feeds"); - print_hidden("method", "batchEditSave"); + print \Controls\hidden_tag("ids", "$feed_ids"); + print \Controls\hidden_tag("op", "pref-feeds"); + print \Controls\hidden_tag("method", "batchEditSave"); print "

    ".__("Feed")."
    "; print "
    "; diff --git a/classes/pref/filters.php b/classes/pref/filters.php index 23275a1d6..9b740753a 100755 --- a/classes/pref/filters.php +++ b/classes/pref/filters.php @@ -327,16 +327,16 @@ class Pref_Filters extends Handler_Protected { print ""; - print_hidden("op", "pref-filters"); + print \Controls\hidden_tag("op", "pref-filters"); if ($filter_id) { - print_hidden("id", "$filter_id"); - print_hidden("method", "editSave"); + print \Controls\hidden_tag("id", "$filter_id"); + print \Controls\hidden_tag("method", "editSave"); } else { - print_hidden("method", "add"); + print \Controls\hidden_tag("method", "add"); } - print_hidden("csrf_token", $_SESSION['csrf_token']); + print \Controls\hidden_tag("csrf_token", $_SESSION['csrf_token']); print "
    ".__("Caption")."
    diff --git a/plugins/af_proxy_http/init.php b/plugins/af_proxy_http/init.php index 3f26ca900..b82999281 100644 --- a/plugins/af_proxy_http/init.php +++ b/plugins/af_proxy_http/init.php @@ -218,9 +218,9 @@ class Af_Proxy_Http extends Plugin { } "; - print_hidden("op", "pluginhandler"); - print_hidden("method", "save"); - print_hidden("plugin", "af_proxy_http"); + print \Controls\hidden_tag("op", "pluginhandler"); + print \Controls\hidden_tag("method", "save"); + print \Controls\hidden_tag("plugin", "af_proxy_http"); $proxy_all = $this->host->get($this, "proxy_all"); print_checkbox("proxy_all", $proxy_all); diff --git a/plugins/af_psql_trgm/init.php b/plugins/af_psql_trgm/init.php index 47ff98fc2..715e63927 100644 --- a/plugins/af_psql_trgm/init.php +++ b/plugins/af_psql_trgm/init.php @@ -157,9 +157,9 @@ class Af_Psql_Trgm extends Plugin { } "; - print_hidden("op", "pluginhandler"); - print_hidden("method", "save"); - print_hidden("plugin", "af_psql_trgm"); + print \Controls\hidden_tag("op", "pluginhandler"); + print \Controls\hidden_tag("method", "save"); + print \Controls\hidden_tag("plugin", "af_psql_trgm"); print "

    " . __("Global settings") . "

    "; diff --git a/plugins/af_readability/init.php b/plugins/af_readability/init.php index 4d21a831c..435864c21 100755 --- a/plugins/af_readability/init.php +++ b/plugins/af_readability/init.php @@ -87,9 +87,9 @@ class Af_Readability extends Plugin { } "; - print_hidden("op", "pluginhandler"); - print_hidden("method", "save"); - print_hidden("plugin", "af_readability"); + print \Controls\hidden_tag("op", "pluginhandler"); + print \Controls\hidden_tag("method", "save"); + print \Controls\hidden_tag("plugin", "af_readability"); $enable_share_anything = $this->host->get($this, "enable_share_anything"); diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php index b9a2db68d..b9891ea03 100755 --- a/plugins/af_redditimgur/init.php +++ b/plugins/af_redditimgur/init.php @@ -58,9 +58,9 @@ class Af_RedditImgur extends Plugin { } "; - print_hidden("op", "pluginhandler"); - print_hidden("method", "save"); - print_hidden("plugin", "af_redditimgur"); + print \Controls\hidden_tag("op", "pluginhandler"); + print \Controls\hidden_tag("method", "save"); + print \Controls\hidden_tag("plugin", "af_redditimgur"); print "
    "; print "