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/note | |
parent | 8b022c2bfb356d7dddaf334bc931d6dec77086fb (diff) | |
parent | 1adacd057230aea4ede29dab510385bf01cf99a3 (diff) |
Merge branch 'master' of git.fakecake.org:fox/tt-rss into weblate-integration
Diffstat (limited to 'plugins/note')
-rw-r--r-- | plugins/note/init.php | 42 | ||||
-rw-r--r-- | plugins/note/note.js | 31 |
2 files changed, 35 insertions, 38 deletions
diff --git a/plugins/note/init.php b/plugins/note/init.php index 3c2ca0075..52f7be3eb 100644 --- a/plugins/note/init.php +++ b/plugins/note/init.php @@ -17,7 +17,7 @@ class Note extends Plugin { } function get_js() { - return file_get_contents(dirname(__FILE__) . "/note.js"); + return file_get_contents(__DIR__ . "/note.js"); } @@ -27,48 +27,42 @@ 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_hidden("id", "$param"); - print_hidden("op", "pluginhandler"); - print_hidden("method", "setNote"); - print_hidden("plugin", "note"); + print \Controls\hidden_tag("id", $id); + print \Controls\pluginhandler_tags($this, "setnote"); - print "<textarea dojoType='dijit.form.SimpleTextarea' + ?> + <textarea dojoType='dijit.form.SimpleTextarea' style='font-size : 12px; width : 98%; height: 100px;' - name='note'>$note</textarea>"; - + name='note'><?= $note ?></textarea> + <?php } - - print "<footer class='text-center'>"; - print "<button dojoType=\"dijit.form.Button\" - onclick=\"dijit.byId('editNoteDlg').execute()\">".__('Save')."</button> "; - print "<button dojoType=\"dijit.form.Button\" - onclick=\"dijit.byId('editNoteDlg').hide()\">".__('Cancel')."</button>"; - print "</footer>"; - + ?> + <footer class='text-center'> + <?= \Controls\submit_tag(__('Save')) ?> + <?= \Controls\cancel_dialog_tag(__('Cancel')) ?> + </footer> + <?php } function setNote() { - $id = $_REQUEST["id"]; - $note = trim(strip_tags($_REQUEST["note"])); + $id = (int)clean($_REQUEST["id"]); + $note = clean($_REQUEST["note"]); $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET note = ? WHERE ref_id = ? AND owner_uid = ?"); $sth->execute([$note, $id, $_SESSION['uid']]); - $formatted_note = Article::format_article_note($id, $note); - - print json_encode(array("note" => $formatted_note, - "raw_length" => mb_strlen($note))); + print json_encode(["id" => $id, "note" => $note]); } function api_version() { diff --git a/plugins/note/note.js b/plugins/note/note.js index ab2ed9208..a46acb355 100644 --- a/plugins/note/note.js +++ b/plugins/note/note.js @@ -1,36 +1,39 @@ -/* global Plugins, xhrJson, Notify, fox, __ */ +/* global dojo, Plugins, xhr, App, 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()) { Notify.progress("Saving article note...", true); - xhrJson("backend.php", this.attr('value'), (reply) => { + xhr.json("backend.php", this.attr('value'), (reply) => { Notify.close(); dialog.hide(); if (reply) { - const elem = $("POSTNOTE-" + id); - - if (elem) { - elem.innerHTML = reply.note; + App.findAll(`div[data-note-for="${reply.id}"]`).forEach((elem) => { + elem.querySelector(".body").innerHTML = reply.note; - if (reply.raw_length != 0) - Element.show(elem); + if (reply.note) + elem.show(); else - Element.hide(elem); - } + elem.hide(); + }); } }); } }, - href: query, + content: __("Loading, please wait...") + }); + + const tmph = dojo.connect(dialog, 'onShow', function () { + dojo.disconnect(tmph); + + xhr.post("backend.php", App.getPhArgs("note", "edit", {id: id}), (reply) => { + dialog.attr('content', reply); + }); }); dialog.show(); |