]> git.wh0rd.org - tt-rss.git/blobdiff - plugins/nsfw/init.php
oops, remove useless db_escape_string() in article class (and nsfw plugin)
[tt-rss.git] / plugins / nsfw / init.php
index 9aadde4dd05fe549f184d5db6e0032f8805a9815..6a1ae3c65a23958c6a167ed43bb43603daa0b8e8 100644 (file)
@@ -1,7 +1,5 @@
 <?php
 class NSFW extends Plugin {
-
-       private $link;
        private $host;
 
        function about() {
@@ -12,7 +10,6 @@ class NSFW extends Plugin {
        }
 
        function init($host) {
-               $this->link = $host->get_link();
                $this->host = $host;
 
                $host->add_hook($host::HOOK_RENDER_ARTICLE, $this);
@@ -26,9 +23,10 @@ class NSFW extends Plugin {
        }
 
        function hook_render_article($article) {
-               $tags = array_map("trim", explode(", ", $this->host->get($this, "tags")));
+               $tags = array_map("trim", explode(",", $this->host->get($this, "tags")));
+               $a_tags = array_map("trim", explode(",", $article["tag_cache"]));
 
-               if (count(array_intersect($tags, $article["tags"])) > 0) {
+               if (count(array_intersect($tags, $a_tags)) > 0) {
                        $article["content"] = "<div class='nswf wrapper'><button onclick=\"nsfwShow(this)\">".__("Not work safe (click to toggle)")."</button>
                                <div class='nswf content' style='display : none'>".$article["content"]."</div></div>";
                }
@@ -37,9 +35,10 @@ class NSFW extends Plugin {
        }
 
        function hook_render_article_cdm($article) {
-               $tags = array_map("trim", explode(", ", $this->host->get($this, "tags")));
+               $tags = array_map("trim", explode(",", $this->host->get($this, "tags")));
+               $a_tags = array_map("trim", explode(",", $article["tag_cache"]));
 
-               if (count(array_intersect($tags, $article["tags"])) > 0) {
+               if (count(array_intersect($tags, $a_tags)) > 0) {
                        $article["content"] = "<div class='nswf wrapper'><button onclick=\"nsfwShow(this)\">".__("Not work safe (click to toggle)")."</button>
                                <div class='nswf content' style='display : none'>".$article["content"]."</div></div>";
                }
@@ -71,9 +70,9 @@ class NSFW extends Plugin {
                        }
                        </script>";
 
-                       print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pluginhandler\">";
-                       print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"save\">";
-                       print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"plugin\" value=\"nsfw\">";
+                       print_hidden("op", "pluginhandler");
+                       print_hidden("method", "save");
+                       print_hidden("plugin", "nsfw");
 
                        print "<table width=\"100%\" class=\"prefPrefsList\">";
 
@@ -91,7 +90,7 @@ class NSFW extends Plugin {
        }
 
        function save() {
-               $tags = explode(",", db_escape_string($_POST["tags"]));
+               $tags = explode(",", $_POST["tags"]);
                $tags = array_map("trim", $tags);
                $tags = array_map("mb_strtolower", $tags);
                $tags = join(", ", $tags);
@@ -101,5 +100,8 @@ class NSFW extends Plugin {
                echo __("Configuration saved.");
        }
 
-}
-?>
+       function api_version() {
+               return 2;
+       }
+
+}
\ No newline at end of file