even more hooks

This commit is contained in:
Andrew Dolgov 2021-02-08 21:28:09 +03:00
parent 6e57fd77af
commit 7eb860af61
1 changed files with 30 additions and 18 deletions

View File

@ -84,13 +84,17 @@ class Handler_Public extends Handler {
$line["content_preview"] = Sanitizer::sanitize(truncate_string(strip_tags($line["content"]), 100, '...')); $line["content_preview"] = Sanitizer::sanitize(truncate_string(strip_tags($line["content"]), 100, '...'));
$line["tags"] = Article::get_article_tags($line["id"], $owner_uid); $line["tags"] = Article::get_article_tags($line["id"], $owner_uid);
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_QUERY_HEADLINES,
$line = $p->hook_query_headlines($line); function ($result) use (&$line) {
} $line = $result;
},
$line);
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_EXPORT_FEED) as $p) { PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_ARTICLE_EXPORT_FEED,
$line = $p->hook_article_export_feed($line, $feed, $is_cat, $owner_uid); function ($result) use (&$line) {
} $line = $result;
},
$line, $feed, $is_cat, $owner_uid);
$tpl->setVariable('ARTICLE_ID', $tpl->setVariable('ARTICLE_ID',
htmlspecialchars($orig_guid ? $line['link'] : htmlspecialchars($orig_guid ? $line['link'] :
@ -182,13 +186,17 @@ class Handler_Public extends Handler {
$line["content_preview"] = Sanitizer::sanitize(truncate_string(strip_tags($line["content_preview"]), 100, '...')); $line["content_preview"] = Sanitizer::sanitize(truncate_string(strip_tags($line["content_preview"]), 100, '...'));
$line["tags"] = Article::get_article_tags($line["id"], $owner_uid); $line["tags"] = Article::get_article_tags($line["id"], $owner_uid);
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_QUERY_HEADLINES,
$line = $p->hook_query_headlines($line, 100); function ($result) use (&$line) {
} $line = $result;
},
$line);
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_EXPORT_FEED) as $p) { PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_ARTICLE_EXPORT_FEED,
$line = $p->hook_article_export_feed($line, $feed, $is_cat); function ($result) use (&$line) {
} $line = $result;
},
$line, $feed, $is_cat, $owner_uid);
$article = array(); $article = array();
@ -344,9 +352,11 @@ class Handler_Public extends Handler {
$line['hide_images'], $line['hide_images'],
$owner_uid, $line["site_url"], false, $line["id"]); $owner_uid, $line["site_url"], false, $line["id"]);
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE) as $p) { PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_RENDER_ARTICLE,
$line = $p->hook_render_article($line); function ($result) use (&$line) {
} $line = $result;
},
$line);
$line['content'] = DiskCache::rewriteUrls($line['content']); $line['content'] = DiskCache::rewriteUrls($line['content']);
@ -441,9 +451,11 @@ class Handler_Public extends Handler {
} }
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FORMAT_ARTICLE) as $p) { PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_FORMAT_ARTICLE,
$rv = $p->hook_format_article($rv, $line, true); function ($result) use (&$rv) {
} $rv = $result;
},
$rv, $line);
return $rv; return $rv;