Browse Source

add HOOK_ENCLOSURE_ENTRY for af_zz_imgproxy

Andrew Dolgov 7 years ago
parent
commit
58210301e0
3 changed files with 14 additions and 0 deletions
  1. 1 0
      classes/pluginhost.php
  2. 4 0
      include/functions2.php
  3. 9 0
      plugins/af_zz_imgproxy/init.php

+ 1 - 0
classes/pluginhost.php

@@ -51,6 +51,7 @@ class PluginHost {
 	const HOOK_ARTICLE_FILTER_ACTION = 30;
 	const HOOK_ARTICLE_EXPORT_FEED = 31;
 	const HOOK_MAIN_TOOLBAR_BUTTON = 32;
+	const HOOK_ENCLOSURE_ENTRY = 33;
 
 	const KIND_ALL = 1;
 	const KIND_SYSTEM = 2;

+ 4 - 0
include/functions2.php

@@ -1944,6 +1944,10 @@
 
 			foreach ($result as $line) {
 
+				foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ENCLOSURE_ENTRY) as $plugin) {
+					$line = $plugin->hook_render_enclosure($line);
+				}
+				
 				$url = $line["content_url"];
 				$ctype = $line["content_type"];
 				$title = $line["title"];

+ 9 - 0
plugins/af_zz_imgproxy/init.php

@@ -18,10 +18,19 @@ class Af_Zz_ImgProxy extends Plugin {
 		$host->add_hook($host::HOOK_RENDER_ARTICLE, $this);
 		$host->add_hook($host::HOOK_RENDER_ARTICLE_CDM, $this);
 		$host->add_hook($host::HOOK_RENDER_ARTICLE_API, $this);
+		$host->add_hook($host::HOOK_ENCLOSURE_ENTRY, $this);
 
 		$host->add_hook($host::HOOK_PREFS_TAB, $this);
 	}
 
+	function hook_enclosure_entry($enc) {
+		$proxy_all = $this->host->get($this, "proxy_all");
+
+		$enc["url"] = $this->rewrite_url_if_needed($enc["url"], $proxy_all);
+
+		return $enc;
+	}
+
 	function hook_render_article($article) {
 		return $this->hook_render_article_cdm($article);
 	}