reinstate HOOK_RENDER_ENCLOSURE

This commit is contained in:
Andrew Dolgov 2021-02-22 10:00:50 +03:00
parent 6f29ecbbb9
commit 33fff26869
4 changed files with 24 additions and 15 deletions

View File

@ -343,6 +343,7 @@ class Article extends Handler_Protected {
} }
$rv = [ $rv = [
'formatted' => '',
'entries' => [] 'entries' => []
]; ];
@ -358,12 +359,24 @@ class Article extends Handler_Protected {
// this is highly approximate // this is highly approximate
$enc["filename"] = basename($enc["content_url"]); $enc["filename"] = basename($enc["content_url"]);
PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_ENCLOSURE_ENTRY, $rendered_enc = "";
function ($result) use (&$enc) { PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_RENDER_ENCLOSURE,
$enc = $result; function ($result) use (&$rendered_enc) {
$rendered_enc = $result;
}, },
$enc, $id); $enc, $id, $rv);
array_push($rv['entries'], $enc);
if ($rendered_enc) {
$rv['formatted'] .= $rendered_enc;
} else {
PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_ENCLOSURE_ENTRY,
function ($result) use (&$enc) {
$enc = $result;
},
$enc, $id, $rv);
array_push($rv['entries'], $enc);
}
} }
return $rv; return $rv;

View File

@ -51,11 +51,11 @@ class PluginHost {
const HOOK_FORMAT_ENCLOSURES = "hook_format_enclosures"; // hook__format_enclosures($rv, $result, $id, $always_display_enclosures, $article_content, $hide_images) (byref) const HOOK_FORMAT_ENCLOSURES = "hook_format_enclosures"; // hook__format_enclosures($rv, $result, $id, $always_display_enclosures, $article_content, $hide_images) (byref)
const HOOK_SUBSCRIBE_FEED = "hook_subscribe_feed"; // hook_subscribe_feed($contents, $url, $auth_login, $auth_pass) (byref) const HOOK_SUBSCRIBE_FEED = "hook_subscribe_feed"; // hook_subscribe_feed($contents, $url, $auth_login, $auth_pass) (byref)
const HOOK_HEADLINES_BEFORE = "hook_headlines_before"; // hook_headlines_before($feed, $is_cat, $qfh_ret) const HOOK_HEADLINES_BEFORE = "hook_headlines_before"; // hook_headlines_before($feed, $is_cat, $qfh_ret)
const HOOK_RENDER_ENCLOSURE = "hook_render_enclosure"; // hook_render_enclosure($entry, $hide_images) const HOOK_RENDER_ENCLOSURE = "hook_render_enclosure"; // hook_render_enclosure($entry, $id, $rv)
const HOOK_ARTICLE_FILTER_ACTION = "hook_article_filter_action"; // hook_article_filter_action($article, $action) const HOOK_ARTICLE_FILTER_ACTION = "hook_article_filter_action"; // hook_article_filter_action($article, $action)
const HOOK_ARTICLE_EXPORT_FEED = "hook_article_export_feed"; // hook_article_export_feed($line, $feed, $is_cat, $owner_uid) (byref) const HOOK_ARTICLE_EXPORT_FEED = "hook_article_export_feed"; // hook_article_export_feed($line, $feed, $is_cat, $owner_uid) (byref)
const HOOK_MAIN_TOOLBAR_BUTTON = "hook_main_toolbar_button"; // hook_main_toolbar_button() const HOOK_MAIN_TOOLBAR_BUTTON = "hook_main_toolbar_button"; // hook_main_toolbar_button()
const HOOK_ENCLOSURE_ENTRY = "hook_enclosure_entry"; // hook_enclosure_entry($row, $id) (byref) const HOOK_ENCLOSURE_ENTRY = "hook_enclosure_entry"; // hook_enclosure_entry($entry, $id, $rv) (byref)
const HOOK_FORMAT_ARTICLE = "hook_format_article"; // hook_format_article($html, $row) const HOOK_FORMAT_ARTICLE = "hook_format_article"; // hook_format_article($html, $row)
const HOOK_FORMAT_ARTICLE_CDM = "hook_format_article_cdm"; /* RIP */ const HOOK_FORMAT_ARTICLE_CDM = "hook_format_article_cdm"; /* RIP */
const HOOK_FEED_BASIC_INFO = "hook_feed_basic_info"; // hook_feed_basic_info($basic_info, $fetch_url, $owner_uid, $feed_id, $auth_login, $auth_pass) (byref) const HOOK_FEED_BASIC_INFO = "hook_feed_basic_info"; // hook_feed_basic_info($basic_info, $fetch_url, $owner_uid, $feed_id, $auth_login, $auth_pass) (byref)

View File

@ -150,12 +150,8 @@ const Article = {
).join("")}</span>`; ).join("")}</span>`;
}, },
renderEnclosures: function (enclosures) { renderEnclosures: function (enclosures) {
// enclosure list was handled by backend (HOOK_FORMAT_ENCLOSURES)
if (enclosures.formatted)
return enclosures.formatted;
return ` return `
${enclosures.formatted}
${enclosures.can_inline ? ${enclosures.can_inline ?
`<div class='attachments-inline'> `<div class='attachments-inline'>
${enclosures.entries.map((enc) => { ${enclosures.entries.map((enc) => {

View File

@ -23,9 +23,9 @@ class Af_Youtube_Embed extends Plugin {
$matches = array(); $matches = array();
if (preg_match("/\/\/www\.youtube\.com\/v\/([\w-]+)/", $entry["url"], $matches) || if (preg_match("/\/\/www\.youtube\.com\/v\/([\w-]+)/", $entry["content_url"], $matches) ||
preg_match("/\/\/www\.youtube\.com\/watch?v=([\w-]+)/", $entry["url"], $matches) || preg_match("/\/\/www\.youtube\.com\/watch?v=([\w-]+)/", $entry["content_url"], $matches) ||
preg_match("/\/\/youtu.be\/([\w-]+)/", $entry["url"], $matches)) { preg_match("/\/\/youtu.be\/([\w-]+)/", $entry["content_url"], $matches)) {
$vid_id = $matches[1]; $vid_id = $matches[1];