]> git.wh0rd.org Git - tt-rss.git/commitdiff
implement article render hooks
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Sat, 23 Feb 2013 12:01:51 +0000 (16:01 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Sat, 23 Feb 2013 12:01:51 +0000 (16:01 +0400)
classes/feeds.php
classes/pluginhost.php
include/functions.php

index b257ca35ed7f52766f6c7137ae1bfa87fb0861ed..183edb401488148f392aaaae92cce91e771ddc2f 100644 (file)
@@ -494,6 +494,16 @@ class Feeds extends Handler_Protected {
 
                                } else {
 
+                                       $line["tags"] = get_article_tags($this->link, $id, $_SESSION["uid"], $line["tag_cache"]);
+                                       unset($line["tag_cache"]);
+
+                                       $line["content"] = sanitize($this->link, $line["content_preview"],
+                                                       false, false, $feed_site_url);
+
+                                       foreach ($pluginhost->get_hooks($pluginhost::HOOK_RENDER_ARTICLE_CDM) as $p) {
+                                               $line = $p->hook_render_article_cdm($line);
+                                       }
+
                                        if (get_pref($this->link, 'VFEED_GROUP_BY_FEED') && $line["feed_title"]) {
                                                if ($feed_id != $vgroup_last_feed) {
 
@@ -627,9 +637,6 @@ class Feeds extends Handler_Protected {
                                                $line["content_preview"] =& $line["cached_content"];
                                        }
 
-                                       $article_content = sanitize($this->link, $line["content_preview"],
-                                                       false, false, $feed_site_url);
-
                                        $reply['content'] .= "<div id=\"POSTNOTE-$id\">";
                                        if ($line['note']) {
                                                $reply['content'] .= format_article_note($id, $line['note']);
@@ -637,7 +644,7 @@ class Feeds extends Handler_Protected {
                                        $reply['content'] .= "</div>";
 
                                        $reply['content'] .= "<span id=\"CWRAP-$id\">";
-                                       $reply['content'] .= $article_content;
+                                       $reply['content'] .= $line["content"];
                                        $reply['content'] .= "</span>";
 
 /*                                     $tmp_result = db_query($this->link, "SELECT always_display_enclosures FROM
@@ -651,17 +658,13 @@ class Feeds extends Handler_Protected {
                                        $always_display_enclosures = sql_bool_to_bool($line["always_display_enclosures"]);
 
                                        $reply['content'] .= format_article_enclosures($this->link, $id, $always_display_enclosures,
-                                               $article_content);
+                                               $line["content"]);
 
                                        $reply['content'] .= "</div>";
 
                                        $reply['content'] .= "<div class=\"cdmFooter\">";
 
-                                       $tag_cache = $line["tag_cache"];
-
-                                       $tags_str = format_tags_string(
-                                               get_article_tags($this->link, $id, $_SESSION["uid"], $tag_cache),
-                                               $id);
+                                       $tags_str = format_tags_string($tags, $id);
 
                                        $reply['content'] .= "<img src='".theme_image($this->link,
                                                        'images/tag.png')."' alt='Tags' title='Tags'>
index a1ad7ef078ef5a8f48e81f173102c336205c7d7b..c6fcf6b577c431f2d6b0ef9d65ea2e617ade89f4 100644 (file)
@@ -17,6 +17,8 @@ class PluginHost {
        const HOOK_UPDATE_TASK = 7;
        const HOOK_AUTH_USER = 8;
        const HOOK_HOTKEY_MAP = 9;
+       const HOOK_RENDER_ARTICLE = 10;
+       const HOOK_RENDER_ARTICLE_CDM = 11;
 
        const KIND_ALL = 1;
        const KIND_SYSTEM = 2;
index b0ccba31392bf55ef12c2516c540f462b14d4ce9..a2b2c1c9ae6cfb5fa53a7894525cfb19bf2bed01 100644 (file)
 
                        $line = db_fetch_assoc($result);
 
-                       $feed_site_url = $line['site_url'];
+                       $tag_cache = $line["tag_cache"];
+
+                       $line["tags"] = get_article_tags($link, $id, $owner_uid, $line["tag_cache"]);
+                       unset($line["tag_cache"]);
+
+                       $line["content"] = sanitize($link, $line["content"], false, $owner_uid, $line["site_url"]);
+
+                       global $pluginhost;
+
+                       foreach ($pluginhost->get_hooks($pluginhost::HOOK_RENDER_ARTICLE) as $p) {
+                               $line = $p->hook_render_article($line);
+                       }
 
                        $num_comments = $line["num_comments"];
                        $entry_comments = "";
                                $rv['content'] .= "<div class='postTitle'>" . $line["title"] . "$entry_author</div>";
                        }
 
-                       $tag_cache = $line["tag_cache"];
-
-                       if (!$tag_cache)
-                               $tags = get_article_tags($link, $id, $owner_uid);
-                       else
-                               $tags = explode(",", $tag_cache);
-
-                       $tags_str = format_tags_string($tags, $id);
-                       $tags_str_full = join(", ", $tags);
+                       $tags_str = format_tags_string($line["tags"], $id);
+                       $tags_str_full = join(", ", $line["tags"]);
 
                        if (!$tags_str_full) $tags_str_full = __("no tags");
 
                                $line["content"] =& $line["cached_content"];
                        }
 
-                       $article_content = sanitize($link, $line["content"], false, $owner_uid,
-                               $feed_site_url);
-
-                       $rv['content'] .= $article_content;
+                       $rv['content'] .= $line["content"];
 
                        $rv['content'] .= format_article_enclosures($link, $id,
-                               $always_display_enclosures, $article_content);
+                               $always_display_enclosures, $line["content"]);
 
                        $rv['content'] .= "</div>";