From a2e688fcb2d463a5db700ebd013c783e3a8f4971 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 14 Feb 2021 22:17:13 +0300 Subject: render headline-specific toolbar on the client --- plugins/mailto/init.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'plugins/mailto/init.php') diff --git a/plugins/mailto/init.php b/plugins/mailto/init.php index 390984b71..3e24dcf29 100644 --- a/plugins/mailto/init.php +++ b/plugins/mailto/init.php @@ -12,6 +12,11 @@ class MailTo extends Plugin { $this->host = $host; $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); + $host->add_hook($host::HOOK_HEADLINE_TOOLBAR_SELECT_MENU_ITEM, $this); + } + + function hook_headline_toolbar_select_menu_item($feed_id, $is_cat) { + return "
".__('Forward by email')."
"; } function get_js() { -- cgit v1.2.3-54-g00ecf From 2b2833bb4fa6f958b89a83adea89d9e7c73daee7 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 17 Feb 2021 14:56:36 +0300 Subject: plugins: load dialogs via xhr instead of http --- plugins/af_redditimgur/init.php | 6 +++++- plugins/mail/init.php | 35 ++++++++--------------------------- plugins/mail/mail.js | 19 ++++++++----------- plugins/mailto/init.js | 17 ++++++++++++----- plugins/mailto/init.php | 6 +++--- plugins/note/init.php | 6 +++--- plugins/note/note.js | 15 ++++++++++----- 7 files changed, 49 insertions(+), 55 deletions(-) (limited to 'plugins/mailto/init.php') diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php index 1fa61953a..63a23cd36 100755 --- a/plugins/af_redditimgur/init.php +++ b/plugins/af_redditimgur/init.php @@ -647,7 +647,11 @@ class Af_RedditImgur extends Plugin { fieldset { border : 0; } label { display : inline-block; min-width : 120px; } -
+ + + + + ">
diff --git a/plugins/mail/init.php b/plugins/mail/init.php index c054196df..8a0d01aca 100644 --- a/plugins/mail/init.php +++ b/plugins/mail/init.php @@ -19,7 +19,7 @@ class Mail extends Plugin { } function get_js() { - return file_get_contents(dirname(__FILE__) . "/mail.js"); + return file_get_contents(__DIR__ . "/mail.js"); } function hook_headline_toolbar_select_menu_item($feed_id, $is_cat) { @@ -83,9 +83,11 @@ class Mail extends Plugin { function emailArticle() { - $ids = explode(",", $_REQUEST['param']); + $ids = explode(",", clean($_REQUEST['ids'])); $ids_qmarks = arr_qmarks($ids); + print ""; + print \Controls\hidden_tag("op", "pluginhandler"); print \Controls\hidden_tag("plugin", "mail"); print \Controls\hidden_tag("method", "sendEmail"); @@ -156,15 +158,8 @@ class Mail extends Plugin { print ""; -/* print ""; */ - print \Controls\select_tag("destination", "", $addresslist, - ["style" => "width: 30em", "dojoType" => "dijit.form.ComboBox"]); - -/* print "
"; */ + ["style" => "width: 30em", "required" => 1, "dojoType" => "dijit.form.ComboBox"]); print ""; @@ -184,11 +179,11 @@ class Mail extends Plugin { print ""; print "
"; - print " "; - print ""; + print \Controls\submit_tag(__('Send email')); + print \Controls\cancel_dialog_tag(__('Cancel')); print "
"; - //return; + print ""; } function sendEmail() { @@ -229,20 +224,6 @@ class Mail extends Plugin { print json_encode($reply); } - /* function completeEmails() { - $search = $_REQUEST["search"]; - - print "
    "; - - foreach ($_SESSION['stored_emails'] as $email) { - if (strpos($email, $search) !== false) { - print "
  • $email
  • "; - } - } - - print "
"; - } */ - function api_version() { return 2; } diff --git a/plugins/mail/mail.js b/plugins/mail/mail.js index 5ddc0dc41..4cdf6999d 100644 --- a/plugins/mail/mail.js +++ b/plugins/mail/mail.js @@ -1,4 +1,4 @@ -/* global Plugins, Headlines, xhrJson, Notify, fox, __ */ +/* global Plugins, Headlines, dojo, xhrPost, xhrJson, Notify, fox, __ */ Plugins.Mail = { send: function(id) { @@ -13,10 +13,7 @@ Plugins.Mail = { id = ids.toString(); } - const query = "backend.php?op=pluginhandler&plugin=mail&method=emailArticle¶m=" + encodeURIComponent(id); - const dialog = new fox.SingleUseDialog({ - id: "emailArticleDlg", title: __("Forward article by email"), execute: function () { if (this.validate()) { @@ -35,16 +32,16 @@ Plugins.Mail = { }); } }, - href: query + content: __("Loading, please wait...") }); - /* var tmph = dojo.connect(dialog, 'onLoad', function() { - dojo.disconnect(tmph); + const tmph = dojo.connect(dialog, 'onShow', function () { + dojo.disconnect(tmph); - new Ajax.Autocompleter('emailArticleDlg_destination', 'emailArticleDlg_dst_choices', - "backend.php?op=pluginhandler&plugin=mail&method=completeEmails", - { tokens: '', paramName: "search" }); - }); */ + xhrPost("backend.php", {op: "pluginhandler", plugin: "mail", method: "emailArticle", ids: id}, (transport) => { + dialog.attr('content', transport.responseText); + }); + }); dialog.show(); }, diff --git a/plugins/mailto/init.js b/plugins/mailto/init.js index ae68bf49b..4bf672a88 100644 --- a/plugins/mailto/init.js +++ b/plugins/mailto/init.js @@ -1,4 +1,4 @@ -/* global Plugins, Headlines, fox, __ */ +/* global Plugins, Headlines, xhrPost, dojo, fox, __ */ Plugins.Mailto = { send: function (id) { @@ -13,12 +13,19 @@ Plugins.Mailto = { id = ids.toString(); } - const query = "backend.php?op=pluginhandler&plugin=mailto&method=emailArticle¶m=" + encodeURIComponent(id); - const dialog = new fox.SingleUseDialog({ - id: "emailArticleDlg", title: __("Forward article by email"), - href: query}); + content: __("Loading, please wait...") + }); + + const tmph = dojo.connect(dialog, 'onShow', function () { + dojo.disconnect(tmph); + + xhrPost("backend.php", {op: "pluginhandler", plugin: "mailto", method: "emailArticle", ids: id}, (transport) => { + dialog.attr('content', transport.responseText); + }); + }); + dialog.show(); } diff --git a/plugins/mailto/init.php b/plugins/mailto/init.php index 3e24dcf29..4b858eae6 100644 --- a/plugins/mailto/init.php +++ b/plugins/mailto/init.php @@ -20,7 +20,7 @@ class MailTo extends Plugin { } function get_js() { - return file_get_contents(dirname(__FILE__) . "/init.js"); + return file_get_contents(__DIR__ . "/init.js"); } function hook_article_button($line) { @@ -31,7 +31,7 @@ class MailTo extends Plugin { function emailArticle() { - $ids = explode(",", $_REQUEST['param']); + $ids = explode(",", clean($_REQUEST['ids'])); $ids_qmarks = arr_qmarks($ids); $tpl = new Templator(); @@ -85,7 +85,7 @@ class MailTo extends Plugin { print "

"; print "

"; - print ""; + print \Controls\submit_tag(__('Close this dialog')); print "
"; //return; diff --git a/plugins/note/init.php b/plugins/note/init.php index 12c56f7ad..65e1f0eef 100644 --- a/plugins/note/init.php +++ b/plugins/note/init.php @@ -27,17 +27,17 @@ class Note extends Plugin { } function edit() { - $param = $_REQUEST['param']; + $id = clean($_REQUEST['id']); $sth = $this->pdo->prepare("SELECT note FROM ttrss_user_entries WHERE ref_id = ? AND owner_uid = ?"); - $sth->execute([$param, $_SESSION['uid']]); + $sth->execute([$id, $_SESSION['uid']]); if ($row = $sth->fetch()) { $note = $row['note']; - print \Controls\hidden_tag("id", "$param"); + print \Controls\hidden_tag("id", $id); print \Controls\hidden_tag("op", "pluginhandler"); print \Controls\hidden_tag("method", "setNote"); print \Controls\hidden_tag("plugin", "note"); diff --git a/plugins/note/note.js b/plugins/note/note.js index ab2ed9208..215058b21 100644 --- a/plugins/note/note.js +++ b/plugins/note/note.js @@ -1,11 +1,8 @@ -/* global Plugins, xhrJson, Notify, fox, __ */ +/* global dojo, xhrPost, Plugins, xhrJson, Notify, fox, __ */ Plugins.Note = { edit: function(id) { - const query = "backend.php?op=pluginhandler&plugin=note&method=edit¶m=" + encodeURIComponent(id); - const dialog = new fox.SingleUseDialog({ - id: "editNoteDlg", title: __("Edit article note"), execute: function () { if (this.validate()) { @@ -30,7 +27,15 @@ Plugins.Note = { }); } }, - href: query, + content: __("Loading, please wait...") + }); + + const tmph = dojo.connect(dialog, 'onShow', function () { + dojo.disconnect(tmph); + + xhrPost("backend.php", {op: "pluginhandler", plugin: "note", method: "edit", id: id}, (transport) => { + dialog.attr('content', transport.responseText); + }); }); dialog.show(); -- cgit v1.2.3-54-g00ecf From 2ac6508fe697ed5e95cc7bf73ffb9e2e0bf0d3fa Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 17 Feb 2021 15:53:00 +0300 Subject: mail, mailto: cleanup markup --- plugins/mail/init.php | 150 ++++++++++++++++++++++++++---------------------- plugins/mailto/init.js | 2 +- plugins/mailto/init.php | 33 +++++------ 3 files changed, 97 insertions(+), 88 deletions(-) (limited to 'plugins/mailto/init.php') diff --git a/plugins/mail/init.php b/plugins/mail/init.php index 8a0d01aca..bb576a4d9 100644 --- a/plugins/mail/init.php +++ b/plugins/mail/init.php @@ -37,42 +37,44 @@ class Mail extends Plugin { function hook_prefs_tab($args) { if ($args != "prefPrefs") return; - print "
mail ".__('Mail plugin')."\">"; - - print "

" . __("You can set predefined email addressed here (comma-separated list):") . "

"; - - print "
"; - - print ""; + - print \Controls\hidden_tag("op", "pluginhandler"); - print \Controls\hidden_tag("method", "save"); - print \Controls\hidden_tag("plugin", "mail"); +
- $addresslist = $this->host->get($this, "addresslist"); + - print ""; +
- print "

"; + - print "

"; + - print "
"; + + "; - - print \Controls\hidden_tag("op", "pluginhandler"); - print \Controls\hidden_tag("plugin", "mail"); - print \Controls\hidden_tag("method", "sendEmail"); $sth = $this->pdo->prepare("SELECT email, full_name FROM ttrss_users WHERE id = ?"); @@ -107,9 +104,6 @@ class Mail extends Plugin { if (!$user_name) $user_name = $_SESSION['name']; - print \Controls\hidden_tag("from_email", "$user_email"); - print \Controls\hidden_tag("from_name", "$user_name"); - $tpl = new Templator(); $tpl->readTemplateFromFile("email_article_template.txt"); @@ -150,40 +144,58 @@ class Mail extends Plugin { $content = ""; $tpl->generateOutputToString($content); - print ""; - - print "
"; - $addresslist = explode(",", $this->host->get($this, "addresslist")); - print __('To:'); - - print ""; - - print \Controls\select_tag("destination", "", $addresslist, - ["style" => "width: 30em", "required" => 1, "dojoType" => "dijit.form.ComboBox"]); - - print "
"; - - print __('Subject:'); - - print ""; - - print ""; - - print "
"; - - print "
"; - - print "
"; - print \Controls\submit_tag(__('Send email')); - print \Controls\cancel_dialog_tag(__('Cancel')); - print "
"; - - print ""; + ?> + +
+ + + + + + + + + + +
+
+ + "width: 380px", "required" => 1, "dojoType" => "dijit.form.ComboBox"]) ?> +
+
+ +
+
+ + +
+
+ + + +
+ + +
+ +
+ ".__('Forward by email').""; + return "
".__('Forward by email (mailto:)')."
"; } function get_js() { @@ -26,7 +26,7 @@ class MailTo extends Plugin { function hook_article_button($line) { return "mail_outline"; + title='".__('Forward by email (mailto:)')."'>mail_outline"; } function emailArticle() { @@ -42,7 +42,6 @@ class MailTo extends Plugin { //$tpl->setVariable('USER_EMAIL', $user_email, true); $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"], true); - $sth = $this->pdo->prepare("SELECT DISTINCT link, content, title FROM ttrss_user_entries, ttrss_entries WHERE id = ref_id AND id IN ($ids_qmarks) AND owner_uid = ?"); @@ -70,25 +69,23 @@ class MailTo extends Plugin { $content = ""; $tpl->generateOutputToString($content); - $mailto_link = htmlspecialchars("mailto:?subject=".rawurlencode($subject). - "&body=".rawurlencode($content)); - - print __("Clicking the following link to invoke your mail client:"); - - print ""; + $mailto_link = "mailto:?subject=".rawurlencode($subject)."&body=".rawurlencode($content); - print __("You should be able to edit the message before sending in your mail client."); + ?> - print "

"; +

+
+ + + +
+
- print "
"; - print \Controls\submit_tag(__('Close this dialog')); - print "
"; +
+ +
- //return; +