diff options
author | Andrew Dolgov <[email protected]> | 2021-02-24 21:56:52 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2021-02-24 21:56:52 +0300 |
commit | 93940d2a9f80d9e1dac49b5eb7db23230d31c5f6 (patch) | |
tree | 71016661f6017918d0934eb462bd9552018d557a /plugins/mail | |
parent | 8b022c2bfb356d7dddaf334bc931d6dec77086fb (diff) | |
parent | 1adacd057230aea4ede29dab510385bf01cf99a3 (diff) |
Merge branch 'master' of git.fakecake.org:fox/tt-rss into weblate-integration
Diffstat (limited to 'plugins/mail')
-rw-r--r-- | plugins/mail/init.php | 165 | ||||
-rw-r--r-- | plugins/mail/mail.js | 21 | ||||
-rw-r--r-- | plugins/mail/mail.png | bin | 641 -> 0 bytes |
3 files changed, 87 insertions, 99 deletions
diff --git a/plugins/mail/init.php b/plugins/mail/init.php index 40d147fc9..467f8294a 100644 --- a/plugins/mail/init.php +++ b/plugins/mail/init.php @@ -15,10 +15,15 @@ class Mail extends Plugin { $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); $host->add_hook($host::HOOK_PREFS_TAB, $this); + $host->add_hook($host::HOOK_HEADLINE_TOOLBAR_SELECT_MENU_ITEM, $this); } 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) { + return "<div dojoType='dijit.MenuItem' onclick='Plugins.Mail.send()'>".__('Forward by email')."</div>"; } function save() { @@ -32,42 +37,38 @@ class Mail extends Plugin { function hook_prefs_tab($args) { if ($args != "prefPrefs") return; - print "<div dojoType=\"dijit.layout.AccordionPane\" - title=\"<i class='material-icons'>mail</i> ".__('Mail plugin')."\">"; + $addresslist = $this->host->get($this, "addresslist"); - print "<p>" . __("You can set predefined email addressed here (comma-separated list):") . "</p>"; + ?> - print "<form dojoType=\"dijit.form.Form\">"; + <div dojoType="dijit.layout.AccordionPane" + title="<i class='material-icons'>mail</i> <?= __('Mail plugin') ?>"> - print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\"> - evt.preventDefault(); - if (this.validate()) { - console.log(dojo.objectToQuery(this.getValues())); - new Ajax.Request('backend.php', { - parameters: dojo.objectToQuery(this.getValues()), - onComplete: function(transport) { - Notify.info(transport.responseText); - } - }); - //this.reset(); - } - </script>"; + <form dojoType="dijit.form.Form"> + <?= \Controls\pluginhandler_tags($this, "save") ?> - print_hidden("op", "pluginhandler"); - print_hidden("method", "save"); - print_hidden("plugin", "mail"); + <script type="dojo/method" event="onSubmit" args="evt"> + evt.preventDefault(); + if (this.validate()) { + Notify.progress('Saving data...', true); + xhr.post("backend.php", this.getValues(), (reply) => { + Notify.info(reply); + }) + } + </script> - $addresslist = $this->host->get($this, "addresslist"); + <header><?= __("You can set predefined email addressed here (comma-separated list):") ?></header> - print "<textarea dojoType=\"dijit.form.SimpleTextarea\" style='font-size : 12px; width : 50%' rows=\"3\" - name='addresslist'>$addresslist</textarea>"; + <textarea dojoType="dijit.form.SimpleTextarea" style='font-size : 12px; width : 50%' rows="3" + name='addresslist'><?= $addresslist ?></textarea> - print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">". - __("Save")."</button>"; + <hr/> - print "</form>"; + <?= \Controls\submit_tag(__("Save")) ?> - print "</div>"; + </form> + </div> + <?php } function hook_article_button($line) { @@ -78,12 +79,9 @@ class Mail extends Plugin { function emailArticle() { - $ids = explode(",", $_REQUEST['param']); + $ids = explode(",", clean($_REQUEST['ids'])); $ids_qmarks = arr_qmarks($ids); - print_hidden("op", "pluginhandler"); - print_hidden("plugin", "mail"); - print_hidden("method", "sendEmail"); $sth = $this->pdo->prepare("SELECT email, full_name FROM ttrss_users WHERE id = ?"); @@ -100,9 +98,6 @@ class Mail extends Plugin { if (!$user_name) $user_name = $_SESSION['name']; - print_hidden("from_email", "$user_email"); - print_hidden("from_name", "$user_name"); - $tpl = new Templator(); $tpl->readTemplateFromFile("email_article_template.txt"); @@ -143,46 +138,56 @@ class Mail extends Plugin { $content = ""; $tpl->generateOutputToString($content); - print "<table width='100%'><tr><td>"; - $addresslist = explode(",", $this->host->get($this, "addresslist")); - print __('To:'); - - print "</td><td>"; - -/* print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"true\" - style=\"width : 30em;\" - name=\"destination\" id=\"emailArticleDlg_destination\">"; */ - - print_select("destination", "", $addresslist, 'style="width: 30em" dojoType="dijit.form.ComboBox"'); - -/* print "<div class=\"autocomplete\" id=\"emailArticleDlg_dst_choices\" - style=\"z-index: 30; display : none\"></div>"; */ - - print "</td></tr><tr><td>"; - - print __('Subject:'); - - print "</td><td>"; - - print "<input dojoType='dijit.form.ValidationTextBox' required='true' - style='width : 30em;' name='subject' value=\"$subject\" id='subject'>"; - - print "</td></tr>"; - - print "<tr><td colspan='2'><textarea dojoType='dijit.form.SimpleTextarea' - style='height : 200px; font-size : 12px; width : 98%' rows=\"20\" - name='content'>$content</textarea>"; - - print "</td></tr></table>"; - - print "<footer>"; - print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').execute()\">".__('Send e-mail')."</button> "; - print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').hide()\">".__('Cancel')."</button>"; - print "</footer>"; - - //return; + ?> + + <form dojoType='dijit.form.Form'> + + <?= \Controls\pluginhandler_tags($this, "sendemail") ?> + + <?= \Controls\hidden_tag("from_email", $user_email) ?> + <?= \Controls\hidden_tag("from_name", $user_name) ?> + + <script type='dojo/method' event='onSubmit' args='evt'> + evt.preventDefault(); + if (this.validate()) { + xhr.json("backend.php", this.getValues(), (reply) => { + if (reply && reply.error) + Notify.error(reply.error); + else + this.hide(); + }); + } + </script> + + <section> + <fieldset class='narrow'> + <label><?= __('To:') ?></label> + <?= \Controls\select_tag("destination", "", $addresslist, + ["style" => "width: 380px", "required" => 1, "dojoType" => "dijit.form.ComboBox"]) ?> + </fieldset> + </section> + + <section> + <fieldset class='narrow'> + <label><?= __('Subject:') ?></label> + <input dojoType='dijit.form.ValidationTextBox' required='true' + style='width : 380px' name='subject' value="<?= htmlspecialchars($subject) ?>" id='subject'> + </fieldset> + </section> + + <textarea dojoType='dijit.form.SimpleTextarea' + style='height : 200px; font-size : 12px; width : 98%' rows="20" + name='content'><?= $content ?></textarea> + + <footer> + <?= \Controls\submit_tag(__('Send email')) ?> + <?= \Controls\cancel_dialog_tag(__('Cancel')) ?> + </footer> + + </form> + <?php } function sendEmail() { @@ -223,20 +228,6 @@ class Mail extends Plugin { print json_encode($reply); } - /* function completeEmails() { - $search = $_REQUEST["search"]; - - print "<ul>"; - - foreach ($_SESSION['stored_emails'] as $email) { - if (strpos($email, $search) !== false) { - print "<li>$email</li>"; - } - } - - print "</ul>"; - } */ - function api_version() { return 2; } diff --git a/plugins/mail/mail.js b/plugins/mail/mail.js index 5ddc0dc41..d2bafe0e9 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, App, xhr, Notify, fox, __ */ Plugins.Mail = { send: function(id) { @@ -13,14 +13,11 @@ 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()) { - xhrJson("backend.php", this.attr('value'), (reply) => { + xhr.json("backend.php", this.attr('value'), (reply) => { if (reply) { const error = reply['error']; @@ -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" }); - }); */ + xhr.post("backend.php", App.getPhArgs("mail", "emailArticle", {ids: id}), (reply) => { + dialog.attr('content', reply); + }); + }); dialog.show(); }, diff --git a/plugins/mail/mail.png b/plugins/mail/mail.png Binary files differdeleted file mode 100644 index 7348aed77..000000000 --- a/plugins/mail/mail.png +++ /dev/null |