batch subscribe: use client dialog
This commit is contained in:
parent
c36b2adf84
commit
103d30ad3f
|
@ -1557,52 +1557,10 @@ class Pref_Feeds extends Handler_Protected {
|
||||||
}
|
}
|
||||||
|
|
||||||
function batchSubscribe() {
|
function batchSubscribe() {
|
||||||
print "<form onsubmit='return false'>";
|
print json_encode([
|
||||||
|
"enable_cats" => (int)get_pref('ENABLE_FEED_CATS'),
|
||||||
print_hidden("op", "pref-feeds");
|
"cat_select" => format_feed_cat_select("cat", false, 'dojoType="fox.form.Select"')
|
||||||
print_hidden("method", "batchaddfeeds");
|
]);
|
||||||
|
|
||||||
print "<header class='horizontal'>".__("One valid feed per line (no detection is done)")."</header>";
|
|
||||||
print "<section>";
|
|
||||||
|
|
||||||
print "<textarea
|
|
||||||
style='font-size : 12px; width : 98%; height: 200px;'
|
|
||||||
dojoType='fox.form.ValidationTextArea' required='1' name='feeds'></textarea>";
|
|
||||||
|
|
||||||
if (get_pref('ENABLE_FEED_CATS')) {
|
|
||||||
print "<fieldset>";
|
|
||||||
print "<label>" . __('Place in category:') . "</label> ";
|
|
||||||
print_feed_cat_select("cat", false, 'dojoType="fox.form.Select"');
|
|
||||||
print "</fieldset>";
|
|
||||||
}
|
|
||||||
|
|
||||||
print "</section>";
|
|
||||||
|
|
||||||
print "<div id='feedDlg_loginContainer' style='display : none'>";
|
|
||||||
|
|
||||||
print "<header>" . __("Authentication") . "</header>";
|
|
||||||
print "<section>";
|
|
||||||
|
|
||||||
print "<input dojoType='dijit.form.TextBox' name='login' placeHolder=\"".__("Login")."\">
|
|
||||||
<input placeHolder=\"".__("Password")."\" dojoType=\"dijit.form.TextBox\" type='password'
|
|
||||||
autocomplete='new-password' name='pass''></div>";
|
|
||||||
|
|
||||||
print "</section>";
|
|
||||||
print "</div>";
|
|
||||||
|
|
||||||
print "<fieldset class='narrow'>
|
|
||||||
<label class='checkbox'><input type='checkbox' name='need_auth' dojoType='dijit.form.CheckBox'
|
|
||||||
onclick='App.displayIfChecked(this, \"feedDlg_loginContainer\")'> ".
|
|
||||||
__('Feeds require authentication.')."</label></div>";
|
|
||||||
print "</fieldset>";
|
|
||||||
|
|
||||||
print "<footer>
|
|
||||||
<button dojoType='dijit.form.Button' onclick='App.dialogOf(this).execute()' type='submit' class='alt-primary'>".
|
|
||||||
__('Subscribe')."</button>
|
|
||||||
<button dojoType='dijit.form.Button' onclick='App.dialogOf(this).hide()'>".__('Cancel')."</button>
|
|
||||||
</footer>";
|
|
||||||
|
|
||||||
print "</form>";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function batchAddFeeds() {
|
function batchAddFeeds() {
|
||||||
|
|
|
@ -181,11 +181,19 @@ function print_feed_multi_select($id, $default_ids = [],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function print_feed_cat_select($id, $default_id,
|
function print_feed_cat_select($id, $default_id, $attributes, $include_all_cats = true,
|
||||||
$attributes, $include_all_cats = true, $root_id = null, $nest_level = 0) {
|
$root_id = null, $nest_level = 0) {
|
||||||
|
|
||||||
|
print format_feed_cat_select($id, $default_id, $attributes, $include_all_cats, $root_id, $nest_level);
|
||||||
|
}
|
||||||
|
|
||||||
|
function format_feed_cat_select($id, $default_id, $attributes, $include_all_cats = true,
|
||||||
|
$root_id = null, $nest_level = 0) {
|
||||||
|
|
||||||
|
$ret = "";
|
||||||
|
|
||||||
if (!$root_id) {
|
if (!$root_id) {
|
||||||
print "<select id=\"$id\" name=\"$id\" default=\"$default_id\" $attributes>";
|
$ret .= "<select id=\"$id\" name=\"$id\" default=\"$default_id\" $attributes>";
|
||||||
}
|
}
|
||||||
|
|
||||||
$pdo = Db::pdo();
|
$pdo = Db::pdo();
|
||||||
|
@ -215,18 +223,18 @@ function print_feed_cat_select($id, $default_id,
|
||||||
$line["title"] = " " . $line["title"];
|
$line["title"] = " " . $line["title"];
|
||||||
|
|
||||||
if ($line["title"])
|
if ($line["title"])
|
||||||
printf("<option $is_selected value='%d'>%s</option>",
|
$ret .= sprintf("<option $is_selected value='%d'>%s</option>",
|
||||||
$line["id"], htmlspecialchars($line["title"]));
|
$line["id"], htmlspecialchars($line["title"]));
|
||||||
|
|
||||||
if ($line["num_children"] > 0)
|
if ($line["num_children"] > 0)
|
||||||
print_feed_cat_select($id, $default_id, $attributes,
|
$ret .= format_feed_cat_select($id, $default_id, $attributes,
|
||||||
$include_all_cats, $line["id"], $nest_level+1);
|
$include_all_cats, $line["id"], $nest_level+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$root_id) {
|
if (!$root_id) {
|
||||||
if ($include_all_cats) {
|
if ($include_all_cats) {
|
||||||
if ($found > 0) {
|
if ($found > 0) {
|
||||||
print "<option disabled=\"1\">―――――――――――――――</option>";
|
$ret .= "<option disabled=\"1\">―――――――――――――――</option>";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($default_id == 0) {
|
if ($default_id == 0) {
|
||||||
|
@ -235,10 +243,12 @@ function print_feed_cat_select($id, $default_id,
|
||||||
$is_selected = "";
|
$is_selected = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
print "<option $is_selected value=\"0\">".__('Uncategorized')."</option>";
|
$ret .= "<option $is_selected value=\"0\">".__('Uncategorized')."</option>";
|
||||||
}
|
}
|
||||||
print "</select>";
|
$ret .= "</select>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
function stylesheet_tag($filename, $id = false) {
|
function stylesheet_tag($filename, $id = false) {
|
||||||
|
|
|
@ -378,6 +378,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_b
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
batchSubscribe: function() {
|
batchSubscribe: function() {
|
||||||
|
xhrJson("backend.php", {op: 'pref-feeds', method: 'batchSubscribe'}, (reply) => {
|
||||||
const dialog = new fox.SingleUseDialog({
|
const dialog = new fox.SingleUseDialog({
|
||||||
id: "batchSubDlg",
|
id: "batchSubDlg",
|
||||||
title: __("Batch subscribe"),
|
title: __("Batch subscribe"),
|
||||||
|
@ -395,18 +396,59 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_b
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
content: __("Loading, please wait...")
|
content: `
|
||||||
});
|
<form onsubmit='return false'>
|
||||||
|
${App.FormFields.hidden("op", "pref-feeds")}
|
||||||
|
${App.FormFields.hidden("method", "batchaddfeeds")}
|
||||||
|
|
||||||
const tmph = dojo.connect(dialog, 'onShow', function () {
|
<header class='horizontal'>
|
||||||
dojo.disconnect(tmph);
|
${__("One valid feed per line (no detection is done)")}
|
||||||
|
</header>
|
||||||
|
|
||||||
xhrPost("backend.php", {op: 'pref-feeds', method: 'batchSubscribe'}, (transport) => {
|
<section>
|
||||||
dialog.attr('content', transport.responseText);
|
<textarea style='font-size : 12px; width : 98%; height: 200px;'
|
||||||
})
|
dojoType='fox.form.ValidationTextArea' required='1' name='feeds'></textarea>
|
||||||
|
|
||||||
|
${reply.enable_cats ?
|
||||||
|
`<fieldset>
|
||||||
|
<label>${__('Place in category:')}</label>
|
||||||
|
${reply.cat_select}
|
||||||
|
</fieldset>
|
||||||
|
` : ''
|
||||||
|
}
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div id='feedDlg_loginContainer' style='display : none'>
|
||||||
|
<header>${__("Authentication")}</header>
|
||||||
|
<section>
|
||||||
|
<input dojoType='dijit.form.TextBox' name='login' placeHolder="${__("Login")}">
|
||||||
|
<input placeHolder="${__("Password")}" dojoType="dijit.form.TextBox" type='password'
|
||||||
|
autocomplete='new-password' name='pass'></div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<fieldset class='narrow'>
|
||||||
|
<label class='checkbox'><input type='checkbox' name='need_auth' dojoType='dijit.form.CheckBox'
|
||||||
|
onclick='App.displayIfChecked(this, "feedDlg_loginContainer")'>
|
||||||
|
${__('Feeds require authentication.')}
|
||||||
|
</label>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
<button dojoType='dijit.form.Button' onclick='App.dialogOf(this).execute()' type='submit' class='alt-primary'>
|
||||||
|
${__('Subscribe')}
|
||||||
|
</button>
|
||||||
|
<button dojoType='dijit.form.Button' onclick='App.dialogOf(this).hide()'>
|
||||||
|
${__('Cancel')}
|
||||||
|
</button>
|
||||||
|
</footer>
|
||||||
|
</form>
|
||||||
|
`
|
||||||
});
|
});
|
||||||
|
|
||||||
dialog.show();
|
dialog.show();
|
||||||
|
|
||||||
|
});
|
||||||
},
|
},
|
||||||
showInactiveFeeds: function() {
|
showInactiveFeeds: function() {
|
||||||
xhrJson("backend.php", {op: 'pref-feeds', method: 'inactivefeeds'}, function (reply) {
|
xhrJson("backend.php", {op: 'pref-feeds', method: 'inactivefeeds'}, function (reply) {
|
||||||
|
|
Loading…
Reference in New Issue