]> git.wh0rd.org - tt-rss.git/blob - plugins/nsfw/init.php
add nsfw plugin
[tt-rss.git] / plugins / nsfw / init.php
1 <?php
2 class NSFW extends Plugin {
3
4 private $link;
5 private $host;
6
7 function about() {
8 return array(1.0,
9 "Hide article content if tags contain \"nsfw\"",
10 "fox",
11 false);
12 }
13
14 function init($host) {
15 $this->link = $host->get_link();
16 $this->host = $host;
17
18 $host->add_hook($host::HOOK_RENDER_ARTICLE, $this);
19 $host->add_hook($host::HOOK_RENDER_ARTICLE_CDM, $this);
20
21 }
22
23 function get_js() {
24 return file_get_contents(dirname(__FILE__) . "/init.js");
25 }
26
27 function hook_render_article($article) {
28
29 if (array_search("nsfw", $article["tags"]) !== FALSE) {
30 $article["content"] = "<div class='nswf wrapper'><button onclick=\"nsfwShow(this)\">".__("Not work safe (click to toggle)")."</button>
31 <div class='nswf content' style='display : none'>".$article["content"]."</div></div>";
32 }
33
34 return $article;
35 }
36
37 function hook_render_article_cdm($article) {
38 if (array_search("nsfw", $article["tags"]) !== FALSE) {
39 $article["content"] = "<div class='nswf wrapper'><button onclick=\"nsfwShow(this)\">".__("Not work safe (click to toggle)")."</button>
40 <div class='nswf content' style='display : none'>".$article["content"]."</div></div>";
41 }
42
43 return $article;
44 }
45
46 }
47 ?>