X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=plugins%2Fnsfw%2Finit.php;h=6a1ae3c65a23958c6a167ed43bb43603daa0b8e8;hb=ed1262d55a01a6ffbefe01eb3b5fc22d33dfad24;hp=fd274eadae59764430caa4abd253595ca68ae2c3;hpb=1b9f9925cfc501828335efa17ae70fd0ac907d2c;p=tt-rss.git
diff --git a/plugins/nsfw/init.php b/plugins/nsfw/init.php
index fd274ead..6a1ae3c6 100644
--- a/plugins/nsfw/init.php
+++ b/plugins/nsfw/init.php
@@ -1,22 +1,20 @@
link = $host->get_link();
$this->host = $host;
$host->add_hook($host::HOOK_RENDER_ARTICLE, $this);
$host->add_hook($host::HOOK_RENDER_ARTICLE_CDM, $this);
+ $host->add_hook($host::HOOK_PREFS_TAB, $this);
}
@@ -25,8 +23,10 @@ class NSFW extends Plugin {
}
function hook_render_article($article) {
+ $tags = array_map("trim", explode(",", $this->host->get($this, "tags")));
+ $a_tags = array_map("trim", explode(",", $article["tag_cache"]));
- if (array_search("nsfw", $article["tags"]) !== FALSE) {
+ if (count(array_intersect($tags, $a_tags)) > 0) {
$article["content"] = "
".$article["content"]."
";
}
@@ -35,7 +35,10 @@ class NSFW extends Plugin {
}
function hook_render_article_cdm($article) {
- if (array_search("nsfw", $article["tags"]) !== FALSE) {
+ $tags = array_map("trim", explode(",", $this->host->get($this, "tags")));
+ $a_tags = array_map("trim", explode(",", $article["tag_cache"]));
+
+ if (count(array_intersect($tags, $a_tags)) > 0) {
$article["content"] = "
".$article["content"]."
";
}
@@ -43,5 +46,62 @@ class NSFW extends Plugin {
return $article;
}
-}
-?>
+ function hook_prefs_tab($args) {
+ if ($args != "prefPrefs") return;
+
+ print "";
+
+ print "
";
+
+ $tags = $this->host->get($this, "tags");
+
+ print "
";
+
+ print "
"; #pane
+ }
+
+ function save() {
+ $tags = explode(",", $_POST["tags"]);
+ $tags = array_map("trim", $tags);
+ $tags = array_map("mb_strtolower", $tags);
+ $tags = join(", ", $tags);
+
+ $this->host->set($this, "tags", $tags);
+
+ echo __("Configuration saved.");
+ }
+
+ function api_version() {
+ return 2;
+ }
+
+}
\ No newline at end of file