mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-13 08:35:55 +00:00
rewrite some more hooks
This commit is contained in:
@@ -874,13 +874,17 @@ class Feeds extends Handler_Protected {
|
|||||||
if (is_array($search) && $search[0]) {
|
if (is_array($search) && $search[0]) {
|
||||||
$search_qpart = "";
|
$search_qpart = "";
|
||||||
|
|
||||||
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SEARCH) as $plugin) {
|
PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_SEARCH,
|
||||||
list($search_qpart, $search_words) = $plugin->hook_search($search[0]);
|
function ($result) use (&$search_qpart, &$search_words) {
|
||||||
break;
|
if (!empty($result)) {
|
||||||
}
|
list($search_qpart, $search_words) = $result;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
$search[0]);
|
||||||
|
|
||||||
// fall back in case of no plugins
|
// fall back in case of no plugins
|
||||||
if (!$search_qpart) {
|
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 {
|
} else {
|
||||||
@@ -1160,11 +1164,13 @@ class Feeds extends Handler_Protected {
|
|||||||
|
|
||||||
$contents = @UrlHelper::fetch($url, false, $auth_login, $auth_pass);
|
$contents = @UrlHelper::fetch($url, false, $auth_login, $auth_pass);
|
||||||
|
|
||||||
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SUBSCRIBE_FEED) as $plugin) {
|
PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_SUBSCRIBE_FEED,
|
||||||
$contents = $plugin->hook_subscribe_feed($contents, $url, $auth_login, $auth_pass);
|
function ($result) use (&$contents) {
|
||||||
}
|
$contents = $result;
|
||||||
|
},
|
||||||
|
$contents, $url, $auth_login, $auth_pass);
|
||||||
|
|
||||||
if (!$contents) {
|
if (empty($contents)) {
|
||||||
if (preg_match("/cloudflare\.com/", $fetch_last_error_content)) {
|
if (preg_match("/cloudflare\.com/", $fetch_last_error_content)) {
|
||||||
$fetch_last_error .= " (feed behind Cloudflare)";
|
$fetch_last_error .= " (feed behind Cloudflare)";
|
||||||
}
|
}
|
||||||
@@ -1473,10 +1479,14 @@ class Feeds extends Handler_Protected {
|
|||||||
if ($search) {
|
if ($search) {
|
||||||
$search_query_part = "";
|
$search_query_part = "";
|
||||||
|
|
||||||
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SEARCH) as $plugin) {
|
PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_SEARCH,
|
||||||
list($search_query_part, $search_words) = $plugin->hook_search($search);
|
function ($result) use (&$search_query_part, &$search_words) {
|
||||||
break;
|
if (!empty($result)) {
|
||||||
}
|
list($search_query_part, $search_words) = $result;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
$search);
|
||||||
|
|
||||||
// fall back in case of no plugins
|
// fall back in case of no plugins
|
||||||
if (!$search_query_part) {
|
if (!$search_query_part) {
|
||||||
@@ -2347,11 +2357,13 @@ class Feeds extends Handler_Protected {
|
|||||||
$query = "";
|
$query = "";
|
||||||
$skip_first_id = false;
|
$skip_first_id = false;
|
||||||
|
|
||||||
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_HEADLINES_CUSTOM_SORT_OVERRIDE) as $p) {
|
PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_HEADLINES_CUSTOM_SORT_OVERRIDE,
|
||||||
list ($query, $skip_first_id) = $p->hook_headlines_custom_sort_override($order);
|
function ($result) use (&$query, &$skip_first_id) {
|
||||||
|
list ($query, $skip_first_id) = $result;
|
||||||
|
},
|
||||||
|
$order);
|
||||||
|
|
||||||
if ($query) return [$query, $skip_first_id];
|
if ($query) return [$query, $skip_first_id];
|
||||||
}
|
|
||||||
|
|
||||||
switch ($order) {
|
switch ($order) {
|
||||||
case "title":
|
case "title":
|
||||||
|
|||||||
@@ -1586,12 +1586,9 @@ class Pref_Feeds extends Handler_Protected {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static function remove_feed($id, $owner_uid) {
|
static function remove_feed($id, $owner_uid) {
|
||||||
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_UNSUBSCRIBE_FEED) as $p) {
|
|
||||||
if (! $p->hook_unsubscribe_feed($id, $owner_uid)) {
|
if (PluginHost::getInstance()->run_hooks_until(PluginHost::HOOK_UNSUBSCRIBE_FEED, true, $id, $owner_uid))
|
||||||
user_error("Feed $id (owner: $owner_uid) not removed due to plugin error (HOOK_UNSUBSCRIBE_FEED).", E_USER_WARNING);
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$pdo = Db::pdo();
|
$pdo = Db::pdo();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user