summaryrefslogtreecommitdiff
path: root/classes/feeds.php
diff options
context:
space:
mode:
Diffstat (limited to 'classes/feeds.php')
-rwxr-xr-xclasses/feeds.php82
1 files changed, 78 insertions, 4 deletions
diff --git a/classes/feeds.php b/classes/feeds.php
index 42673ca95..ea9158949 100755
--- a/classes/feeds.php
+++ b/classes/feeds.php
@@ -230,17 +230,43 @@ class Feeds extends Handler_Protected {
$line["feed_title"] = $line["feed_title"] ?? "";
+ $button_doc = new DOMDocument();
+
$line["buttons_left"] = "";
PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_ARTICLE_LEFT_BUTTON,
- function ($result) use (&$line) {
- $line["buttons_left"] .= $result;
+ function ($result, $plugin) use (&$line, &$button_doc) {
+ if ($result && $button_doc->loadXML($result)) {
+
+ /** @var DOMElement|null */
+ $child = $button_doc->firstChild;
+
+ if ($child) {
+ do {
+ $child->setAttribute('data-plugin-name', get_class($plugin));
+ } while ($child = $child->nextSibling);
+
+ $line["buttons_left"] .= $button_doc->saveXML($button_doc->firstChild);
+ }
+ }
},
$line);
$line["buttons"] = "";
PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_ARTICLE_BUTTON,
- function ($result) use (&$line) {
- $line["buttons"] .= $result;
+ function ($result, $plugin) use (&$line, &$button_doc) {
+ if ($result && $button_doc->loadXML($result)) {
+
+ /** @var DOMElement|null */
+ $child = $button_doc->firstChild;
+
+ if ($child) {
+ do {
+ $child->setAttribute('data-plugin-name', get_class($plugin));
+ } while ($child = $child->nextSibling);
+
+ $line["buttons"] .= $button_doc->saveXML($button_doc->firstChild);
+ }
+ }
},
$line);
@@ -587,6 +613,23 @@ class Feeds extends Handler_Protected {
]);
}
+ function opensite() {
+ $feed = ORM::for_table('ttrss_feeds')
+ ->find_one((int)$_REQUEST['feed_id']);
+
+ if ($feed) {
+ $site_url = UrlHelper::validate($feed->site_url);
+
+ if ($site_url) {
+ header("Location: $site_url");
+ return;
+ }
+ }
+
+ header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
+ print "Feed not found or has an empty site URL.";
+ }
+
function updatedebugger() {
header("Content-type: text/html");
@@ -996,6 +1039,13 @@ class Feeds extends Handler_Protected {
if (!$url) return ["code" => 2];
+ PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_PRE_SUBSCRIBE,
+ /** @phpstan-ignore-next-line */
+ function ($result) use (&$url, &$auth_login, &$auth_pass) {
+ // arguments are updated inside the hook (if needed)
+ },
+ $url, $auth_login, $auth_pass);
+
$contents = UrlHelper::fetch($url, false, $auth_login, $auth_pass);
PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_SUBSCRIBE_FEED,
@@ -1105,6 +1155,30 @@ class Feeds extends Handler_Protected {
}
}
+ /** $owner_uid defaults to $_SESSION['uid] */
+ static function _find_by_title(string $title, bool $cat = false, int $owner_uid = 0) {
+
+ $res = false;
+
+ if ($cat) {
+ $res = ORM::for_table('ttrss_feed_categories')
+ ->where('owner_uid', $owner_uid ? $owner_uid : $_SESSION['uid'])
+ ->where('title', $title)
+ ->find_one();
+ } else {
+ $res = ORM::for_table('ttrss_feeds')
+ ->where('owner_uid', $owner_uid ? $owner_uid : $_SESSION['uid'])
+ ->where('title', $title)
+ ->find_one();
+ }
+
+ if ($res) {
+ return $res->id;
+ } else {
+ return false;
+ }
+ }
+
static function _get_title($id, bool $cat = false) {
$pdo = Db::pdo();