plugins: load dialogs via xhr instead of http
This commit is contained in:
parent
4632d6cf55
commit
2b2833bb4f
|
@ -647,7 +647,11 @@ class Af_RedditImgur extends Plugin {
|
||||||
fieldset { border : 0; }
|
fieldset { border : 0; }
|
||||||
label { display : inline-block; min-width : 120px; }
|
label { display : inline-block; min-width : 120px; }
|
||||||
</style>
|
</style>
|
||||||
<form action="backend.php?op=pluginhandler&method=testurl&plugin=af_redditimgur" method="post">
|
<form action="backend.php" method="post">
|
||||||
|
<input type="hidden" name="op" value="pluginhandler">
|
||||||
|
<input type="hidden" name="method" value="testurl">
|
||||||
|
<input type="hidden" name="plugin" value="af_redditimgur">
|
||||||
|
<input type="hidden" name="csrf_token" value="<?= $_SESSION["csrf_token"] ?>">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<label>URL:</label>
|
<label>URL:</label>
|
||||||
<input name="url" size="100" value="<?= htmlspecialchars($url) ?>"></input>
|
<input name="url" size="100" value="<?= htmlspecialchars($url) ?>"></input>
|
||||||
|
|
|
@ -19,7 +19,7 @@ class Mail extends Plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_js() {
|
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) {
|
function hook_headline_toolbar_select_menu_item($feed_id, $is_cat) {
|
||||||
|
@ -83,9 +83,11 @@ class Mail extends Plugin {
|
||||||
|
|
||||||
function emailArticle() {
|
function emailArticle() {
|
||||||
|
|
||||||
$ids = explode(",", $_REQUEST['param']);
|
$ids = explode(",", clean($_REQUEST['ids']));
|
||||||
$ids_qmarks = arr_qmarks($ids);
|
$ids_qmarks = arr_qmarks($ids);
|
||||||
|
|
||||||
|
print "<form onsubmit=\"return false\">";
|
||||||
|
|
||||||
print \Controls\hidden_tag("op", "pluginhandler");
|
print \Controls\hidden_tag("op", "pluginhandler");
|
||||||
print \Controls\hidden_tag("plugin", "mail");
|
print \Controls\hidden_tag("plugin", "mail");
|
||||||
print \Controls\hidden_tag("method", "sendEmail");
|
print \Controls\hidden_tag("method", "sendEmail");
|
||||||
|
@ -156,15 +158,8 @@ class Mail extends Plugin {
|
||||||
|
|
||||||
print "</td><td>";
|
print "</td><td>";
|
||||||
|
|
||||||
/* print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"true\"
|
|
||||||
style=\"width : 30em;\"
|
|
||||||
name=\"destination\" id=\"emailArticleDlg_destination\">"; */
|
|
||||||
|
|
||||||
print \Controls\select_tag("destination", "", $addresslist,
|
print \Controls\select_tag("destination", "", $addresslist,
|
||||||
["style" => "width: 30em", "dojoType" => "dijit.form.ComboBox"]);
|
["style" => "width: 30em", "required" => 1, "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 "</td></tr><tr><td>";
|
||||||
|
|
||||||
|
@ -184,11 +179,11 @@ class Mail extends Plugin {
|
||||||
print "</td></tr></table>";
|
print "</td></tr></table>";
|
||||||
|
|
||||||
print "<footer>";
|
print "<footer>";
|
||||||
print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').execute()\">".__('Send e-mail')."</button> ";
|
print \Controls\submit_tag(__('Send email'));
|
||||||
print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').hide()\">".__('Cancel')."</button>";
|
print \Controls\cancel_dialog_tag(__('Cancel'));
|
||||||
print "</footer>";
|
print "</footer>";
|
||||||
|
|
||||||
//return;
|
print "</form>";
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendEmail() {
|
function sendEmail() {
|
||||||
|
@ -229,20 +224,6 @@ class Mail extends Plugin {
|
||||||
print json_encode($reply);
|
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() {
|
function api_version() {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* global Plugins, Headlines, xhrJson, Notify, fox, __ */
|
/* global Plugins, Headlines, dojo, xhrPost, xhrJson, Notify, fox, __ */
|
||||||
|
|
||||||
Plugins.Mail = {
|
Plugins.Mail = {
|
||||||
send: function(id) {
|
send: function(id) {
|
||||||
|
@ -13,10 +13,7 @@ Plugins.Mail = {
|
||||||
id = ids.toString();
|
id = ids.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
const query = "backend.php?op=pluginhandler&plugin=mail&method=emailArticle¶m=" + encodeURIComponent(id);
|
|
||||||
|
|
||||||
const dialog = new fox.SingleUseDialog({
|
const dialog = new fox.SingleUseDialog({
|
||||||
id: "emailArticleDlg",
|
|
||||||
title: __("Forward article by email"),
|
title: __("Forward article by email"),
|
||||||
execute: function () {
|
execute: function () {
|
||||||
if (this.validate()) {
|
if (this.validate()) {
|
||||||
|
@ -35,16 +32,16 @@ Plugins.Mail = {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
href: query
|
content: __("Loading, please wait...")
|
||||||
});
|
});
|
||||||
|
|
||||||
/* var tmph = dojo.connect(dialog, 'onLoad', function() {
|
const tmph = dojo.connect(dialog, 'onShow', function () {
|
||||||
dojo.disconnect(tmph);
|
dojo.disconnect(tmph);
|
||||||
|
|
||||||
new Ajax.Autocompleter('emailArticleDlg_destination', 'emailArticleDlg_dst_choices',
|
xhrPost("backend.php", {op: "pluginhandler", plugin: "mail", method: "emailArticle", ids: id}, (transport) => {
|
||||||
"backend.php?op=pluginhandler&plugin=mail&method=completeEmails",
|
dialog.attr('content', transport.responseText);
|
||||||
{ tokens: '', paramName: "search" });
|
});
|
||||||
}); */
|
});
|
||||||
|
|
||||||
dialog.show();
|
dialog.show();
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* global Plugins, Headlines, fox, __ */
|
/* global Plugins, Headlines, xhrPost, dojo, fox, __ */
|
||||||
|
|
||||||
Plugins.Mailto = {
|
Plugins.Mailto = {
|
||||||
send: function (id) {
|
send: function (id) {
|
||||||
|
@ -13,12 +13,19 @@ Plugins.Mailto = {
|
||||||
id = ids.toString();
|
id = ids.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
const query = "backend.php?op=pluginhandler&plugin=mailto&method=emailArticle¶m=" + encodeURIComponent(id);
|
|
||||||
|
|
||||||
const dialog = new fox.SingleUseDialog({
|
const dialog = new fox.SingleUseDialog({
|
||||||
id: "emailArticleDlg",
|
|
||||||
title: __("Forward article by email"),
|
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();
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ class MailTo extends Plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_js() {
|
function get_js() {
|
||||||
return file_get_contents(dirname(__FILE__) . "/init.js");
|
return file_get_contents(__DIR__ . "/init.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
function hook_article_button($line) {
|
function hook_article_button($line) {
|
||||||
|
@ -31,7 +31,7 @@ class MailTo extends Plugin {
|
||||||
|
|
||||||
function emailArticle() {
|
function emailArticle() {
|
||||||
|
|
||||||
$ids = explode(",", $_REQUEST['param']);
|
$ids = explode(",", clean($_REQUEST['ids']));
|
||||||
$ids_qmarks = arr_qmarks($ids);
|
$ids_qmarks = arr_qmarks($ids);
|
||||||
|
|
||||||
$tpl = new Templator();
|
$tpl = new Templator();
|
||||||
|
@ -85,7 +85,7 @@ class MailTo extends Plugin {
|
||||||
print "<p>";
|
print "<p>";
|
||||||
|
|
||||||
print "<footer class='text-center'>";
|
print "<footer class='text-center'>";
|
||||||
print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').hide()\">".__('Close this dialog')."</button>";
|
print \Controls\submit_tag(__('Close this dialog'));
|
||||||
print "</footer>";
|
print "</footer>";
|
||||||
|
|
||||||
//return;
|
//return;
|
||||||
|
|
|
@ -27,17 +27,17 @@ class Note extends Plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
function edit() {
|
function edit() {
|
||||||
$param = $_REQUEST['param'];
|
$id = clean($_REQUEST['id']);
|
||||||
|
|
||||||
$sth = $this->pdo->prepare("SELECT note FROM ttrss_user_entries WHERE
|
$sth = $this->pdo->prepare("SELECT note FROM ttrss_user_entries WHERE
|
||||||
ref_id = ? AND owner_uid = ?");
|
ref_id = ? AND owner_uid = ?");
|
||||||
$sth->execute([$param, $_SESSION['uid']]);
|
$sth->execute([$id, $_SESSION['uid']]);
|
||||||
|
|
||||||
if ($row = $sth->fetch()) {
|
if ($row = $sth->fetch()) {
|
||||||
|
|
||||||
$note = $row['note'];
|
$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("op", "pluginhandler");
|
||||||
print \Controls\hidden_tag("method", "setNote");
|
print \Controls\hidden_tag("method", "setNote");
|
||||||
print \Controls\hidden_tag("plugin", "note");
|
print \Controls\hidden_tag("plugin", "note");
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
/* global Plugins, xhrJson, Notify, fox, __ */
|
/* global dojo, xhrPost, Plugins, xhrJson, Notify, fox, __ */
|
||||||
|
|
||||||
Plugins.Note = {
|
Plugins.Note = {
|
||||||
edit: function(id) {
|
edit: function(id) {
|
||||||
const query = "backend.php?op=pluginhandler&plugin=note&method=edit¶m=" + encodeURIComponent(id);
|
|
||||||
|
|
||||||
const dialog = new fox.SingleUseDialog({
|
const dialog = new fox.SingleUseDialog({
|
||||||
id: "editNoteDlg",
|
|
||||||
title: __("Edit article note"),
|
title: __("Edit article note"),
|
||||||
execute: function () {
|
execute: function () {
|
||||||
if (this.validate()) {
|
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();
|
dialog.show();
|
||||||
|
|
Loading…
Reference in New Issue