From 0fc783e2b350b8ac6ff275fd9b201674cbcf2c16 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 16 Feb 2021 22:07:37 +0300 Subject: [PATCH] cleanup markup in some plugins, make nsfw generate dijit widgets --- include/controls.php | 4 +++ plugins/note/init.php | 21 ++++++----- plugins/nsfw/init.js | 13 ++++--- plugins/nsfw/init.php | 82 +++++++++++++++++++----------------------- plugins/share/init.php | 52 ++++++++++++--------------- 5 files changed, 82 insertions(+), 90 deletions(-) diff --git a/include/controls.php b/include/controls.php index 78ff75572..4c60d94f3 100755 --- a/include/controls.php +++ b/include/controls.php @@ -19,6 +19,10 @@ return button_tag($value, "submit", array_merge(["class" => "alt-primary"], $attributes)); } + function cancel_dialog_tag(string $value, array $attributes = []) { + return button_tag($value, "", array_merge(["onclick" => "App.dialogOf(this).hide()"], $attributes)); + } + function select_tag(string $name, $value, array $values, array $attributes = [], string $id = "") { $attributes_str = attributes_to_string($attributes); $dojo_type = strpos($attributes_str, "dojoType") === false ? "dojoType='fox.form.Select'" : ""; diff --git a/plugins/note/init.php b/plugins/note/init.php index 0634d4c57..12c56f7ad 100644 --- a/plugins/note/init.php +++ b/plugins/note/init.php @@ -42,19 +42,18 @@ class Note extends Plugin { print \Controls\hidden_tag("method", "setNote"); print \Controls\hidden_tag("plugin", "note"); - print ""; - + name='note'> + "; - print " "; - print ""; - print ""; - + ?> + + 0) { - $article["content"] = "
-
"; + $article["content"] = "
". + \Controls\button_tag(__("Not work safe (click to toggle)"), '', ['onclick' => 'Plugins.NSFW.toggle(this)']). + " +
"; } return $article; } function hook_render_article_cdm($article) { - $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"] = "
-
"; - } - - return $article; + return $this->hook_render_article($article); } function hook_prefs_tab($args) { if ($args != "prefPrefs") return; - print "
extension ".__("NSFW Plugin")."\">"; - - print "
"; - $tags = $this->host->get($this, "tags"); - print "
"; + ?> +
"> + - print ""; + - print \Controls\hidden_tag("op", "pluginhandler"); - print \Controls\hidden_tag("method", "save"); - print \Controls\hidden_tag("plugin", "nsfw"); +
- print ""; +
+ +
- print ""; - print ""; +
- print "
".__("Tags to consider NSFW (comma-separated)")."
"; - - print "

"; - - print "

"; - - print "
"; #pane + + +
+ host->set($this, "tags", $tags); diff --git a/plugins/share/init.php b/plugins/share/init.php index 42923ed8a..846e1f39c 100644 --- a/plugins/share/init.php +++ b/plugins/share/init.php @@ -41,14 +41,14 @@ class Share extends Plugin { function hook_prefs_tab_section($id) { if ($id == "prefFeedsPublishedGenerated") { + ?> +
- print "
"; - - print "

" . __("You can disable all articles shared by unique URLs here.") . "

"; - - print " "; +

+ + execute([$uuid, $param, $_SESSION['uid']]); } - print "
" . __("You can share this article by the following unique URL:") . "
"; + $url_path = htmlspecialchars(get_self_url_prefix() . "/public.php?op=share&key=$uuid"); - $url_path = get_self_url_prefix(); - $url_path .= "/public.php?op=share&key=$uuid"; + ?> - print "
+
+ + +
- $url_path +
-
"; - - /* if (!label_find_id(__('Shared'), $_SESSION["uid"])) - label_create(__('Shared'), $_SESSION["uid"]); - - label_add_article($ref_id, __('Shared'), $_SESSION['uid']); */ +
+ "; - - print ""; - - print ""; - - print ""; - - print ""; + ?> + +