]> git.wh0rd.org - tt-rss.git/commitdiff
Added HOOK_FORMAT_ENCLOSURES plugin hook.
authorDave Zaikos <myself@zaikos.com>
Mon, 12 May 2014 04:59:27 +0000 (00:59 -0400)
committerDave Zaikos <myself@zaikos.com>
Mon, 12 May 2014 04:59:27 +0000 (00:59 -0400)
Runs HTML and enclosures array through a plugin hook when rendering an article's enclosures in format_article_enclosures(). Allows plugins to override handling of how enclosures are presented by either filtering the array of enclosures, or generating the HTML to add to the article content.

classes/pluginhost.php
include/functions2.php

index 4582c314a856e747df333d6d64bbefced0521b5d..bd6afa81d5b41e012dcebb20ea06bac6f8df0953 100644 (file)
@@ -40,6 +40,7 @@ class PluginHost {
        const HOOK_QUERY_HEADLINES = 23;
        const HOOK_HOUSE_KEEPING = 24;
        const HOOK_SEARCH = 25;
+       const HOOK_FORMAT_ENCLOSURES = 26;
 
        const KIND_ALL = 1;
        const KIND_SYSTEM = 2;
index 959e7154deaf62e44df36907b7bbd7f6ccb28e54..cf1fba17cc39c9cb84dccf787aad9ad7e6125068 100644 (file)
                $result = get_article_enclosures($id);
                $rv = '';
 
-               if (count($result) > 0) {
+               foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FORMAT_ENCLOSURES) as $plugin) {
+                       $retval = $plugin->hook_format_enclosures($rv, $result, $id, $always_display_enclosures, $article_content, $hide_images);
+                       if (is_array($retval)) {
+                               $rv = $retval[0];
+                               $result = $retval[1];
+                       } else {
+                               $rv = $retval;
+                       }
+               }
 
+               if ($rv === '' && is_array($result)) {
                        $entries_html = array();
                        $entries = array();
                        $entries_inline = array();