|
|
@ -27,38 +27,34 @@ class NSFW extends Plugin {
|
|
|
|
$a_tags = array_map("trim", explode(",", $article["tag_cache"]));
|
|
|
|
$a_tags = array_map("trim", explode(",", $article["tag_cache"]));
|
|
|
|
|
|
|
|
|
|
|
|
if (count(array_intersect($tags, $a_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>
|
|
|
|
$article["content"] = "<div class='nswf wrapper'>".
|
|
|
|
<div class='nswf content' style='display : none'>".$article["content"]."</div></div>";
|
|
|
|
\Controls\button_tag(__("Not work safe (click to toggle)"), '', ['onclick' => 'Plugins.NSFW.toggle(this)']).
|
|
|
|
|
|
|
|
"<div class='nswf content' style='display : none'>".$article["content"]."</div>
|
|
|
|
|
|
|
|
</div>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return $article;
|
|
|
|
return $article;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function hook_render_article_cdm($article) {
|
|
|
|
function hook_render_article_cdm($article) {
|
|
|
|
$tags = array_map("trim", explode(",", $this->host->get($this, "tags")));
|
|
|
|
return $this->hook_render_article($article);
|
|
|
|
$a_tags = array_map("trim", explode(",", $article["tag_cache"]));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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>";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $article;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function hook_prefs_tab($args) {
|
|
|
|
function hook_prefs_tab($args) {
|
|
|
|
if ($args != "prefPrefs") return;
|
|
|
|
if ($args != "prefPrefs") return;
|
|
|
|
|
|
|
|
|
|
|
|
print "<div dojoType=\"dijit.layout.AccordionPane\"
|
|
|
|
|
|
|
|
title=\"<i class='material-icons'>extension</i> ".__("NSFW Plugin")."\">";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print "<br/>";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$tags = $this->host->get($this, "tags");
|
|
|
|
$tags = $this->host->get($this, "tags");
|
|
|
|
|
|
|
|
|
|
|
|
print "<form dojoType=\"dijit.form.Form\">";
|
|
|
|
?>
|
|
|
|
|
|
|
|
<div dojoType="dijit.layout.AccordionPane"
|
|
|
|
|
|
|
|
title="<i class='material-icons'>extension</i> <?= __("NSFW Plugin") ?>">
|
|
|
|
|
|
|
|
<form dojoType="dijit.form.Form">
|
|
|
|
|
|
|
|
|
|
|
|
print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">
|
|
|
|
<?= \Controls\hidden_tag("op", "pluginhandler") ?>
|
|
|
|
|
|
|
|
<?= \Controls\hidden_tag("method", "save") ?>
|
|
|
|
|
|
|
|
<?= \Controls\hidden_tag("plugin", "nsfw") ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script type="dojo/method" event="onSubmit" args="evt">
|
|
|
|
evt.preventDefault();
|
|
|
|
evt.preventDefault();
|
|
|
|
if (this.validate()) {
|
|
|
|
if (this.validate()) {
|
|
|
|
new Ajax.Request('backend.php', {
|
|
|
|
new Ajax.Request('backend.php', {
|
|
|
@ -67,34 +63,28 @@ class NSFW extends Plugin {
|
|
|
|
Notify.info(transport.responseText);
|
|
|
|
Notify.info(transport.responseText);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
//this.reset();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>";
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
print \Controls\hidden_tag("op", "pluginhandler");
|
|
|
|
|
|
|
|
print \Controls\hidden_tag("method", "save");
|
|
|
|
|
|
|
|
print \Controls\hidden_tag("plugin", "nsfw");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print "<table width=\"100%\" class=\"prefPrefsList\">";
|
|
|
|
<header><?= __("Tags to consider NSFW (comma-separated):") ?></header>
|
|
|
|
|
|
|
|
|
|
|
|
print "<tr><td width=\"40%\">".__("Tags to consider NSFW (comma-separated)")."</td>";
|
|
|
|
<fieldset>
|
|
|
|
print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" name=\"tags\" value=\"$tags\"></td></tr>";
|
|
|
|
<textarea dojoType='dijit.form.SimpleTextarea' rows='4'
|
|
|
|
|
|
|
|
style='width: 500px; font-size : 12px;'
|
|
|
|
|
|
|
|
name='tags'><?= $tags ?></textarea>
|
|
|
|
|
|
|
|
</fieldset>
|
|
|
|
|
|
|
|
|
|
|
|
print "</table>";
|
|
|
|
<hr/>
|
|
|
|
|
|
|
|
|
|
|
|
print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">".
|
|
|
|
<?= \Controls\submit_tag(__("Save")) ?>
|
|
|
|
__("Save")."</button>";
|
|
|
|
</form>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
print "</form>";
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
print "</div>"; #pane
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function save() {
|
|
|
|
function save() {
|
|
|
|
$tags = explode(",", $_POST["tags"]);
|
|
|
|
$tags = implode(", ",
|
|
|
|
$tags = array_map("trim", $tags);
|
|
|
|
FeedItem_Common::normalize_categories(explode(",", $_POST["tags"] ?? "")));
|
|
|
|
$tags = array_map("mb_strtolower", $tags);
|
|
|
|
|
|
|
|
$tags = join(", ", $tags);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->host->set($this, "tags", $tags);
|
|
|
|
$this->host->set($this, "tags", $tags);
|
|
|
|
|
|
|
|
|
|
|
|