feed editor: use client dialog
This commit is contained in:
parent
9586c72a17
commit
22fe9b54d2
|
@ -843,7 +843,7 @@ class API extends Handler {
|
||||||
$_REQUEST['force_show_empty'] = $include_empty;
|
$_REQUEST['force_show_empty'] = $include_empty;
|
||||||
|
|
||||||
$this->_wrap(self::STATUS_OK,
|
$this->_wrap(self::STATUS_OK,
|
||||||
array("categories" => $pf->makefeedtree()));
|
array("categories" => $pf->_makefeedtree()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// only works for labels or uncategorized for the time being
|
// only works for labels or uncategorized for the time being
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
class Pref_Feeds extends Handler_Protected {
|
class Pref_Feeds extends Handler_Protected {
|
||||||
function csrf_ignore($method) {
|
function csrf_ignore($method) {
|
||||||
$csrf_ignored = array("index", "getfeedtree", "savefeedorder", "uploadicon");
|
$csrf_ignored = array("index", "getfeedtree", "savefeedorder");
|
||||||
|
|
||||||
return array_search($method, $csrf_ignored) !== false;
|
return array_search($method, $csrf_ignored) !== false;
|
||||||
}
|
}
|
||||||
|
@ -109,15 +109,11 @@ class Pref_Feeds extends Handler_Protected {
|
||||||
return $items;
|
return $items;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _getfeedtree() {
|
|
||||||
print "OK";
|
|
||||||
}
|
|
||||||
|
|
||||||
function getfeedtree() {
|
function getfeedtree() {
|
||||||
print json_encode($this->makefeedtree());
|
print json_encode($this->_makefeedtree());
|
||||||
}
|
}
|
||||||
|
|
||||||
function makefeedtree() {
|
function _makefeedtree() {
|
||||||
|
|
||||||
if (clean($_REQUEST['mode'] ?? 0) != 2)
|
if (clean($_REQUEST['mode'] ?? 0) != 2)
|
||||||
$search = $_SESSION["prefs_feed_search"] ?? "";
|
$search = $_SESSION["prefs_feed_search"] ?? "";
|
||||||
|
@ -500,7 +496,7 @@ class Pref_Feeds extends Handler_Protected {
|
||||||
WHERE id = ?");
|
WHERE id = ?");
|
||||||
$sth->execute([$feed_id]);
|
$sth->execute([$feed_id]);
|
||||||
|
|
||||||
$rc = 0;
|
$rc = Feeds::_get_icon($feed_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -573,298 +569,6 @@ class Pref_Feeds extends Handler_Protected {
|
||||||
} else {
|
} else {
|
||||||
print json_encode(["error" => "FEED_NOT_FOUND"]);
|
print json_encode(["error" => "FEED_NOT_FOUND"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ($row = $sth->fetch()) {
|
|
||||||
print '<div dojoType="dijit.layout.TabContainer" style="height : 450px">
|
|
||||||
<div dojoType="dijit.layout.ContentPane" title="'.__('General').'">';
|
|
||||||
|
|
||||||
$title = htmlspecialchars($row["title"]);
|
|
||||||
|
|
||||||
print \Controls\hidden_tag("id", "$feed_id");
|
|
||||||
print \Controls\hidden_tag("op", "pref-feeds");
|
|
||||||
print \Controls\hidden_tag("method", "editSave");
|
|
||||||
|
|
||||||
print "<header>".__("Feed")."</header>";
|
|
||||||
print "<section>";
|
|
||||||
|
|
||||||
/* Title */
|
|
||||||
|
|
||||||
print "<fieldset>";
|
|
||||||
|
|
||||||
print "<input dojoType='dijit.form.ValidationTextBox' required='1'
|
|
||||||
placeHolder=\"".__("Feed Title")."\"
|
|
||||||
style='font-size : 16px; width: 500px' name='title' value=\"$title\">";
|
|
||||||
|
|
||||||
print "</fieldset>";
|
|
||||||
|
|
||||||
/* Feed URL */
|
|
||||||
|
|
||||||
$feed_url = htmlspecialchars($row["feed_url"]);
|
|
||||||
|
|
||||||
print "<fieldset>";
|
|
||||||
|
|
||||||
print "<label>" . __('URL:') . "</label> ";
|
|
||||||
print "<input dojoType='dijit.form.ValidationTextBox' required='1'
|
|
||||||
placeHolder=\"".__("Feed URL")."\"
|
|
||||||
regExp='^(http|https)://.*' style='width : 300px'
|
|
||||||
name='feed_url' value=\"$feed_url\">";
|
|
||||||
|
|
||||||
if (!empty($row["last_error"])) {
|
|
||||||
print " <i class=\"material-icons\"
|
|
||||||
title=\"".htmlspecialchars($row["last_error"])."\">error</i>";
|
|
||||||
}
|
|
||||||
|
|
||||||
print "</fieldset>";
|
|
||||||
|
|
||||||
/* Category */
|
|
||||||
|
|
||||||
if (get_pref('ENABLE_FEED_CATS')) {
|
|
||||||
print "<fieldset>";
|
|
||||||
|
|
||||||
print "<label>" . __('Place in category:') . "</label> ";
|
|
||||||
|
|
||||||
print \Controls\select_feeds_cats("cat_id", $row["cat_id"]);
|
|
||||||
|
|
||||||
print "</fieldset>";
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Site URL */
|
|
||||||
|
|
||||||
$site_url = htmlspecialchars($row["site_url"]);
|
|
||||||
|
|
||||||
print "<fieldset>";
|
|
||||||
|
|
||||||
print "<label>" . __('Site URL:') . "</label> ";
|
|
||||||
print "<input dojoType='dijit.form.ValidationTextBox' required='1'
|
|
||||||
placeHolder=\"".__("Site URL")."\"
|
|
||||||
regExp='^(http|https)://.*' style='width : 300px'
|
|
||||||
name='site_url' value=\"$site_url\">";
|
|
||||||
|
|
||||||
print "</fieldset>";
|
|
||||||
|
|
||||||
/* FTS Stemming Language */
|
|
||||||
|
|
||||||
if (DB_TYPE == "pgsql") {
|
|
||||||
$feed_language = $row["feed_language"];
|
|
||||||
|
|
||||||
if (!$feed_language)
|
|
||||||
$feed_language = get_pref('DEFAULT_SEARCH_LANGUAGE');
|
|
||||||
|
|
||||||
print "<fieldset>";
|
|
||||||
|
|
||||||
print "<label>" . __('Language:') . "</label> ";
|
|
||||||
print \Controls\select_tag("feed_language", $feed_language, $this::get_ts_languages());
|
|
||||||
|
|
||||||
print "</fieldset>";
|
|
||||||
}
|
|
||||||
|
|
||||||
print "</section>";
|
|
||||||
|
|
||||||
print "<header>".__("Update")."</header>";
|
|
||||||
print "<section>";
|
|
||||||
|
|
||||||
/* Update Interval */
|
|
||||||
|
|
||||||
$update_interval = $row["update_interval"];
|
|
||||||
|
|
||||||
print "<fieldset>";
|
|
||||||
|
|
||||||
print "<label>".__("Interval:")."</label> ";
|
|
||||||
|
|
||||||
$local_update_intervals = $update_intervals;
|
|
||||||
$local_update_intervals[0] .= sprintf(" (%s)", $update_intervals[get_pref("DEFAULT_UPDATE_INTERVAL")]);
|
|
||||||
|
|
||||||
print \Controls\select_hash("update_interval", $update_interval, $local_update_intervals);
|
|
||||||
|
|
||||||
print "</fieldset>";
|
|
||||||
|
|
||||||
/* Purge intl */
|
|
||||||
|
|
||||||
$purge_interval = $row["purge_interval"];
|
|
||||||
|
|
||||||
print "<fieldset>";
|
|
||||||
|
|
||||||
print "<label>" . __('Article purging:') . "</label> ";
|
|
||||||
|
|
||||||
if (FORCE_ARTICLE_PURGE == 0) {
|
|
||||||
$local_purge_intervals = $purge_intervals;
|
|
||||||
$default_purge_interval = get_pref("PURGE_OLD_DAYS");
|
|
||||||
|
|
||||||
if ($default_purge_interval > 0)
|
|
||||||
$local_purge_intervals[0] .= " " . T_nsprintf('(%d day)', '(%d days)', $default_purge_interval, $default_purge_interval);
|
|
||||||
else
|
|
||||||
$local_purge_intervals[0] .= " " . sprintf("(%s)", __("Disabled"));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
$purge_interval = FORCE_ARTICLE_PURGE;
|
|
||||||
$local_purge_intervals = [ T_nsprintf('%d day', '%d days', $purge_interval, $purge_interval) ];
|
|
||||||
}
|
|
||||||
|
|
||||||
print \Controls\select_hash("purge_interval",
|
|
||||||
$purge_interval,
|
|
||||||
$local_purge_intervals,
|
|
||||||
(FORCE_ARTICLE_PURGE == 0) ? [] : ["disabled" => 1]);
|
|
||||||
|
|
||||||
print "</fieldset>";
|
|
||||||
|
|
||||||
print "</section>";
|
|
||||||
|
|
||||||
$auth_login = htmlspecialchars($row["auth_login"]);
|
|
||||||
$auth_pass = htmlspecialchars($row["auth_pass"]);
|
|
||||||
|
|
||||||
$auth_enabled = $auth_login !== '' || $auth_pass !== '';
|
|
||||||
|
|
||||||
$auth_style = $auth_enabled ? '' : 'display: none';
|
|
||||||
print "<div id='feedEditDlg_loginContainer' style='$auth_style'>";
|
|
||||||
print "<header>".__("Authentication")."</header>";
|
|
||||||
print "<section>";
|
|
||||||
|
|
||||||
print "<fieldset>";
|
|
||||||
|
|
||||||
print "<input dojoType='dijit.form.TextBox'
|
|
||||||
placeHolder='".__("Login")."'
|
|
||||||
autocomplete='new-password'
|
|
||||||
name='auth_login' value=\"$auth_login\">";
|
|
||||||
|
|
||||||
print "</fieldset><fieldset>";
|
|
||||||
|
|
||||||
print "<input dojoType='dijit.form.TextBox' type='password' name='auth_pass'
|
|
||||||
autocomplete='new-password'
|
|
||||||
placeHolder='".__("Password")."'
|
|
||||||
value=\"$auth_pass\">";
|
|
||||||
|
|
||||||
print "</fieldset>";
|
|
||||||
|
|
||||||
print "</section></div>";
|
|
||||||
|
|
||||||
$auth_checked = $auth_enabled ? 'checked' : '';
|
|
||||||
print "<label class='checkbox'>
|
|
||||||
<input type='checkbox' $auth_checked name='need_auth' dojoType='dijit.form.CheckBox' id='feedEditDlg_loginCheck'
|
|
||||||
onclick='App.displayIfChecked(this, \"feedEditDlg_loginContainer\")'>
|
|
||||||
".__('This feed requires authentication.')."</label>";
|
|
||||||
|
|
||||||
print '</div><div dojoType="dijit.layout.ContentPane" title="'.__('Options').'">';
|
|
||||||
|
|
||||||
print "<section class='narrow'>";
|
|
||||||
|
|
||||||
$include_in_digest = $row["include_in_digest"];
|
|
||||||
|
|
||||||
if ($include_in_digest) {
|
|
||||||
$checked = "checked=\"1\"";
|
|
||||||
} else {
|
|
||||||
$checked = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
print "<fieldset class='narrow'>";
|
|
||||||
|
|
||||||
print "<label class='checkbox'><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"include_in_digest\"
|
|
||||||
name=\"include_in_digest\"
|
|
||||||
$checked> ".__('Include in e-mail digest')."</label>";
|
|
||||||
|
|
||||||
print "</fieldset>";
|
|
||||||
|
|
||||||
$always_display_enclosures = $row["always_display_enclosures"];
|
|
||||||
|
|
||||||
if ($always_display_enclosures) {
|
|
||||||
$checked = "checked";
|
|
||||||
} else {
|
|
||||||
$checked = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
print "<fieldset class='narrow'>";
|
|
||||||
|
|
||||||
print "<label class='checkbox'><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"always_display_enclosures\"
|
|
||||||
name=\"always_display_enclosures\"
|
|
||||||
$checked> ".__('Always display image attachments')."</label>";
|
|
||||||
|
|
||||||
print "</fieldset>";
|
|
||||||
|
|
||||||
$hide_images = $row["hide_images"];
|
|
||||||
|
|
||||||
if ($hide_images) {
|
|
||||||
$checked = "checked=\"1\"";
|
|
||||||
} else {
|
|
||||||
$checked = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
print "<fieldset class='narrow'>";
|
|
||||||
|
|
||||||
print "<label class='checkbox'><input dojoType='dijit.form.CheckBox' type='checkbox' id='hide_images'
|
|
||||||
name='hide_images' $checked> ".__('Do not embed media')."</label>";
|
|
||||||
|
|
||||||
print "</fieldset>";
|
|
||||||
|
|
||||||
$cache_images = $row["cache_images"];
|
|
||||||
|
|
||||||
if ($cache_images) {
|
|
||||||
$checked = "checked=\"1\"";
|
|
||||||
} else {
|
|
||||||
$checked = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
print "<fieldset class='narrow'>";
|
|
||||||
|
|
||||||
print "<label class='checkbox'><input dojoType='dijit.form.CheckBox' type='checkbox' id='cache_images'
|
|
||||||
name='cache_images' $checked> ". __('Cache media')."</label>";
|
|
||||||
|
|
||||||
print "</fieldset>";
|
|
||||||
|
|
||||||
$mark_unread_on_update = $row["mark_unread_on_update"];
|
|
||||||
|
|
||||||
if ($mark_unread_on_update) {
|
|
||||||
$checked = "checked";
|
|
||||||
} else {
|
|
||||||
$checked = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
print "<fieldset class='narrow'>";
|
|
||||||
|
|
||||||
print "<label class='checkbox'><input dojoType='dijit.form.CheckBox' type='checkbox' id='mark_unread_on_update'
|
|
||||||
name='mark_unread_on_update' $checked> ".__('Mark updated articles as unread')."</label>";
|
|
||||||
|
|
||||||
print "</fieldset>";
|
|
||||||
|
|
||||||
print '</div><div dojoType="dijit.layout.ContentPane" title="'.__('Icon').'">';
|
|
||||||
|
|
||||||
/* Icon */
|
|
||||||
|
|
||||||
print "<img class='feedIcon feed-editor-icon' src=\"".Feeds::_get_icon($feed_id)."\">";
|
|
||||||
|
|
||||||
print "<form onsubmit='return false;' id='feed_icon_upload_form'
|
|
||||||
enctype='multipart/form-data' method='POST'>
|
|
||||||
<label class='dijitButton'>".__("Choose file...")."
|
|
||||||
<input style='display: none' id='icon_file' size='10' name='icon_file' type='file'>
|
|
||||||
</label>
|
|
||||||
<input type='hidden' name='op' value='pref-feeds'>
|
|
||||||
<input type='hidden' name='csrf_token' value='".$_SESSION['csrf_token']."'>
|
|
||||||
<input type='hidden' name='feed_id' value='$feed_id'>
|
|
||||||
<input type='hidden' name='method' value='uploadicon'>
|
|
||||||
<button dojoType='dijit.form.Button' onclick=\"return CommonDialogs.uploadFeedIcon();\"
|
|
||||||
type='submit'>".__('Replace')."</button>
|
|
||||||
<button class='alt-danger' dojoType='dijit.form.Button' onclick=\"return CommonDialogs.removeFeedIcon($feed_id);\"
|
|
||||||
type='submit'>".__('Remove')."</button>
|
|
||||||
</form>";
|
|
||||||
|
|
||||||
print "</section>";
|
|
||||||
|
|
||||||
print '</div><div dojoType="dijit.layout.ContentPane" title="'.__('Plugins').'">';
|
|
||||||
|
|
||||||
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_EDIT_FEED, $feed_id);
|
|
||||||
|
|
||||||
print "</div></div>";
|
|
||||||
|
|
||||||
$title = htmlspecialchars($title, ENT_QUOTES);
|
|
||||||
|
|
||||||
print "<footer>
|
|
||||||
<button style='float : left' class='alt-danger' dojoType='dijit.form.Button'
|
|
||||||
onclick='App.dialogOf(this).unsubscribeFeed($feed_id, \"$title\")'>".
|
|
||||||
__('Unsubscribe')."</button>
|
|
||||||
<button dojoType='dijit.form.Button' class='alt-primary' onclick='return App.dialogOf(this).execute()' type='submit'>".__('Save')."</button>
|
|
||||||
<button dojoType='dijit.form.Button' onclick='App.dialogOf(this).hide()'>".__('Cancel')."</button>
|
|
||||||
</footer>";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function editfeeds() {
|
function editfeeds() {
|
||||||
|
@ -1036,7 +740,7 @@ class Pref_Feeds extends Handler_Protected {
|
||||||
return $this->editsaveops(false);
|
return $this->editsaveops(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function editsaveops($batch) {
|
private function editsaveops($batch) {
|
||||||
|
|
||||||
$feed_title = clean($_POST["title"]);
|
$feed_title = clean($_POST["title"]);
|
||||||
$feed_url = clean($_POST["feed_url"]);
|
$feed_url = clean($_POST["feed_url"]);
|
||||||
|
@ -1064,10 +768,6 @@ class Pref_Feeds extends Handler_Protected {
|
||||||
$feed_language = clean($_POST["feed_language"]);
|
$feed_language = clean($_POST["feed_language"]);
|
||||||
|
|
||||||
if (!$batch) {
|
if (!$batch) {
|
||||||
if (clean($_POST["need_auth"] ?? "") !== 'on') {
|
|
||||||
$auth_login = '';
|
|
||||||
$auth_pass = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
/* $sth = $this->pdo->prepare("SELECT feed_url FROM ttrss_feeds WHERE id = ?");
|
/* $sth = $this->pdo->prepare("SELECT feed_url FROM ttrss_feeds WHERE id = ?");
|
||||||
$sth->execute([$feed_id]);
|
$sth->execute([$feed_id]);
|
||||||
|
|
|
@ -11,72 +11,6 @@ const CommonDialogs = {
|
||||||
const dialog = dijit.byId("infoBox");
|
const dialog = dijit.byId("infoBox");
|
||||||
if (dialog) dialog.hide();
|
if (dialog) dialog.hide();
|
||||||
},
|
},
|
||||||
removeFeedIcon: function(id) {
|
|
||||||
if (confirm(__("Remove stored feed icon?"))) {
|
|
||||||
Notify.progress("Removing feed icon...", true);
|
|
||||||
|
|
||||||
const query = {op: "pref-feeds", method: "removeicon", feed_id: id};
|
|
||||||
|
|
||||||
xhr.post("backend.php", query, () => {
|
|
||||||
Notify.info("Feed icon removed.");
|
|
||||||
|
|
||||||
if (App.isPrefs())
|
|
||||||
dijit.byId("feedTree").reload();
|
|
||||||
else
|
|
||||||
Feeds.reload();
|
|
||||||
|
|
||||||
const icon = App.findAll(".feed-editor-icon")[0];
|
|
||||||
|
|
||||||
if (icon)
|
|
||||||
icon.src = icon.src.replace(/\?[0-9]+$/, "?" + new Date().getTime());
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
uploadFeedIcon: function() {
|
|
||||||
const file = App.byId("icon_file");
|
|
||||||
|
|
||||||
if (file.value.length == 0) {
|
|
||||||
alert(__("Please select an image file to upload."));
|
|
||||||
} else if (confirm(__("Upload new icon for this feed?"))) {
|
|
||||||
Notify.progress("Uploading, please wait...", true);
|
|
||||||
|
|
||||||
const xhr = new XMLHttpRequest();
|
|
||||||
|
|
||||||
xhr.open( 'POST', 'backend.php', true );
|
|
||||||
xhr.onload = function () {
|
|
||||||
switch (parseInt(this.responseText)) {
|
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
Notify.info("Upload complete.");
|
|
||||||
|
|
||||||
if (App.isPrefs())
|
|
||||||
dijit.byId("feedTree").reload();
|
|
||||||
else
|
|
||||||
Feeds.reload();
|
|
||||||
|
|
||||||
const icon = App.findAll(".feed-editor-icon")[0];
|
|
||||||
|
|
||||||
if (icon)
|
|
||||||
icon.src = icon.src.replace(/\?[0-9]+$/, "?" + new Date().getTime());
|
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
Notify.error("Upload failed: icon is too big.");
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
Notify.error("Upload failed.");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
xhr.send(new FormData(App.byId("feed_icon_upload_form")));
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
subscribeToFeed: function() {
|
subscribeToFeed: function() {
|
||||||
xhr.json("backend.php",
|
xhr.json("backend.php",
|
||||||
{op: "feeds", method: "subscribeToFeed"},
|
{op: "feeds", method: "subscribeToFeed"},
|
||||||
|
@ -407,6 +341,86 @@ const CommonDialogs = {
|
||||||
CommonDialogs.unsubscribeFeed(feed_id);
|
CommonDialogs.unsubscribeFeed(feed_id);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
uploadIcon: function(input) {
|
||||||
|
if (input.files.length != 0) {
|
||||||
|
const icon_file = input.files[0];
|
||||||
|
|
||||||
|
if (icon_file.type.indexOf("image/") == -1) {
|
||||||
|
alert(__("Please select an image file."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const fd = new FormData();
|
||||||
|
fd.append('icon_file', icon_file)
|
||||||
|
fd.append('feed_id', feed_id);
|
||||||
|
fd.append('op', 'pref-feeds');
|
||||||
|
fd.append('method', 'uploadIcon');
|
||||||
|
fd.append('csrf_token', App.getInitParam("csrf_token"));
|
||||||
|
|
||||||
|
const xhr = new XMLHttpRequest();
|
||||||
|
|
||||||
|
xhr.open( 'POST', 'backend.php', true );
|
||||||
|
xhr.onload = function () {
|
||||||
|
console.log(this.responseText);
|
||||||
|
|
||||||
|
// TODO: make a notice box within panel content
|
||||||
|
switch (parseInt(this.responseText)) {
|
||||||
|
case 1:
|
||||||
|
Notify.error("Upload failed: icon is too big.");
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
Notify.error("Upload failed.");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
Notify.info("Upload complete.");
|
||||||
|
|
||||||
|
if (App.isPrefs())
|
||||||
|
dijit.byId("feedTree").reload();
|
||||||
|
else
|
||||||
|
Feeds.reload();
|
||||||
|
|
||||||
|
const icon = dialog.domNode.querySelector(".feedIcon");
|
||||||
|
|
||||||
|
if (icon) {
|
||||||
|
icon.src = this.responseText;
|
||||||
|
icon.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
input.value = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
xhr.send(fd);
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
removeIcon: function(id) {
|
||||||
|
if (confirm(__("Remove stored feed icon?"))) {
|
||||||
|
Notify.progress("Removing feed icon...", true);
|
||||||
|
|
||||||
|
const query = {op: "pref-feeds", method: "removeicon", feed_id: id};
|
||||||
|
|
||||||
|
xhr.post("backend.php", query, () => {
|
||||||
|
Notify.info("Feed icon removed.");
|
||||||
|
|
||||||
|
if (App.isPrefs())
|
||||||
|
dijit.byId("feedTree").reload();
|
||||||
|
else
|
||||||
|
Feeds.reload();
|
||||||
|
|
||||||
|
const icon = dialog.domNode.querySelector(".feedIcon");
|
||||||
|
|
||||||
|
if (icon) {
|
||||||
|
icon.src = "";
|
||||||
|
icon.hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
},
|
||||||
execute: function () {
|
execute: function () {
|
||||||
if (this.validate()) {
|
if (this.validate()) {
|
||||||
Notify.progress("Saving data...", true);
|
Notify.progress("Saving data...", true);
|
||||||
|
@ -437,205 +451,136 @@ const CommonDialogs = {
|
||||||
// for unsub prompt
|
// for unsub prompt
|
||||||
dialog.feed_title = feed.title;
|
dialog.feed_title = feed.title;
|
||||||
|
|
||||||
|
// options tab
|
||||||
|
const options = {
|
||||||
|
include_in_digest: [ feed.include_in_digest, __('Include in e-mail digest') ],
|
||||||
|
always_display_enclosures: [ feed.always_display_enclosures, __('Always display image attachments') ],
|
||||||
|
hide_images: [ feed.hide_images, __('Do not embed media') ],
|
||||||
|
cache_images: [ feed.cache_images, __('Cache media') ],
|
||||||
|
mark_unread_on_update: [ feed.mark_unread_on_update, __('Mark updated articles as unread') ]
|
||||||
|
};
|
||||||
|
|
||||||
dialog.attr('content',
|
dialog.attr('content',
|
||||||
`
|
`
|
||||||
<div dojoType="dijit.layout.TabContainer" style="height : 450px">
|
<form onsubmit="return false">
|
||||||
<div dojoType="dijit.layout.ContentPane" title="${__('General')}">
|
<div dojoType="dijit.layout.TabContainer" style="height : 450px">
|
||||||
|
<div dojoType="dijit.layout.ContentPane" title="${__('General')}">
|
||||||
|
|
||||||
${App.FormFields.hidden_tag("id", feed_id)}
|
${App.FormFields.hidden_tag("id", feed_id)}
|
||||||
${App.FormFields.hidden_tag("op", "pref-feeds")}
|
${App.FormFields.hidden_tag("op", "pref-feeds")}
|
||||||
${App.FormFields.hidden_tag("method", "editSave")}
|
${App.FormFields.hidden_tag("method", "editSave")}
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<input dojoType='dijit.form.ValidationTextBox' required='1'
|
<input dojoType='dijit.form.ValidationTextBox' required='1'
|
||||||
placeHolder="${__("Feed Title")}"
|
placeHolder="${__("Feed Title")}"
|
||||||
style='font-size : 16px; width: 500px' name='title' value="${App.escapeHtml(feed.title)}">
|
style='font-size : 16px; width: 500px' name='title' value="${App.escapeHtml(feed.title)}">
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<label>${__('URL:')}</label>
|
<label>${__('URL:')}</label>
|
||||||
<input dojoType='dijit.form.ValidationTextBox' required='1'
|
<input dojoType='dijit.form.ValidationTextBox' required='1'
|
||||||
placeHolder="${__("Feed URL")}"
|
placeHolder="${__("Feed URL")}"
|
||||||
regExp='^(http|https)://.*' style='width : 300px'
|
regExp='^(http|https)://.*' style='width : 300px'
|
||||||
name='feed_url' value="${App.escapeHtml(feed.feed_url)}">
|
name='feed_url' value="${App.escapeHtml(feed.feed_url)}">
|
||||||
|
|
||||||
${feed.last_error ?
|
${feed.last_error ?
|
||||||
`<i class="material-icons"
|
`<i class="material-icons"
|
||||||
title="${App.escapeHtml(feed.last_error)}">error</i>
|
title="${App.escapeHtml(feed.last_error)}">error</i>
|
||||||
|
` : ""}
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
${reply.cats.enabled ?
|
||||||
|
`
|
||||||
|
<fieldset>
|
||||||
|
<label>${__('Place in category:')}</label>
|
||||||
|
${reply.cats.select}
|
||||||
|
</fieldset>
|
||||||
` : ""}
|
` : ""}
|
||||||
</fieldset>
|
|
||||||
|
|
||||||
${reply.cats.enabled ?
|
|
||||||
`
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<label>${__('Place in category:')}</label>
|
<label>${__('Site URL:')}</label>
|
||||||
${reply.cats.select}
|
<input dojoType='dijit.form.ValidationTextBox' required='1'
|
||||||
|
placeHolder="${__("Site URL")}"
|
||||||
|
regExp='^(http|https)://.*' style='width : 300px'
|
||||||
|
name='site_url' value="${App.escapeHtml(feed.site_url)}">
|
||||||
</fieldset>
|
</fieldset>
|
||||||
` : ""}
|
|
||||||
|
|
||||||
<fieldset>
|
${reply.lang.enabled ?
|
||||||
<label>${__('Site URL:')}</label>
|
`
|
||||||
<input dojoType='dijit.form.ValidationTextBox' required='1'
|
<fieldset>
|
||||||
placeHolder="${__("Site URL")}"
|
<label>${__('Language:')}</label>
|
||||||
regExp='^(http|https)://.*' style='width : 300px'
|
${App.FormFields.select_tag("feed_language",
|
||||||
name='site_url' value="${App.escapeHtml(feed.site_url)}">
|
feed.feed_language ? feed.feed_language : reply.lang.default,
|
||||||
</fieldset>
|
reply.lang.all)}
|
||||||
|
</fieldset>
|
||||||
|
` : ""}
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
|
||||||
${reply.lang.enabled ?
|
|
||||||
`
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<label>${__('Language:')}</label>
|
<label>${__("Update interval:")}</label>
|
||||||
${App.FormFields.select_tag("feed_language", feed.feed_language, reply.lang.all)}
|
${App.FormFields.select_hash("update_interval", feed.update_interval, reply.intervals.update)}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
` : ""}
|
<fieldset>
|
||||||
|
<label>${__('Article purging:')}</label>
|
||||||
|
|
||||||
<hr/>
|
${App.FormFields.select_hash("purge_interval",
|
||||||
|
feed.purge_interval,
|
||||||
|
reply.intervals.purge,
|
||||||
|
reply.force_purge ? {disabled: 1} : {})}
|
||||||
|
|
||||||
<fieldset>
|
</fieldset>
|
||||||
<label>${__("Update interval:")}</label>
|
</section>
|
||||||
${App.FormFields.select_hash("update_interval", feed.update_interval, reply.intervals.update)}
|
</div>
|
||||||
</fieldset>
|
<div dojoType="dijit.layout.ContentPane" title="${__('Authentication')}">
|
||||||
<fieldset>
|
<section>
|
||||||
<label>${__('Article purging:')}</label>
|
<fieldset>
|
||||||
|
<label>${__("Login:")}</label>
|
||||||
|
<input dojoType='dijit.form.TextBox'
|
||||||
|
autocomplete='new-password'
|
||||||
|
name='auth_login' value="${App.escapeHtml(feed.auth_login)}">
|
||||||
|
</fieldset>
|
||||||
|
<fieldset>
|
||||||
|
<label>${__("Password:")}</label>
|
||||||
|
<input dojoType='dijit.form.TextBox' type='password' name='auth_pass'
|
||||||
|
autocomplete='new-password'
|
||||||
|
value="${App.escapeHtml(feed.auth_pass)}">
|
||||||
|
</fieldset>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
<div dojoType="dijit.layout.ContentPane" title="${__('Options')}">
|
||||||
|
<section class="narrow">
|
||||||
|
${Object.keys(options).map((name) =>
|
||||||
|
`
|
||||||
|
<fieldset class='narrow'>
|
||||||
|
<label class="checkbox">
|
||||||
|
${App.FormFields.checkbox_tag(name, options[name][0])}
|
||||||
|
${options[name][1]}
|
||||||
|
</label>
|
||||||
|
</fieldset>
|
||||||
|
`).join("")}
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
<div dojoType="dijit.layout.ContentPane" title="${__('Icon')}">
|
||||||
|
<div><img class='feedIcon' style="${feed.icon ? "" : "display : none"}" src="${feed.icon ? App.escapeHtml(feed.icon) : ""}"></div>
|
||||||
|
|
||||||
${App.FormFields.select_hash("purge_interval",
|
<label class="dijitButton">${__("Upload new icon...")}
|
||||||
feed.purge_interval,
|
<input style="display: none" type="file" onchange="App.dialogOf(this).uploadIcon(this)">
|
||||||
reply.intervals.purge,
|
|
||||||
reply.force_purge ? {disabled: 1} : {})}
|
|
||||||
|
|
||||||
</fieldset>
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
<div dojoType="dijit.layout.ContentPane" title="${__('Authentication')}">
|
|
||||||
<section>
|
|
||||||
<fieldset>
|
|
||||||
<label>${__("Login:")}</label>
|
|
||||||
<input dojoType='dijit.form.TextBox'
|
|
||||||
autocomplete='new-password'
|
|
||||||
name='auth_login' value="${App.escapeHtml(feed.auth_login)}">
|
|
||||||
</fieldset>
|
|
||||||
<fieldset>
|
|
||||||
<label>${__("Password:")}</label>
|
|
||||||
<input dojoType='dijit.form.TextBox' type='password' name='auth_pass'
|
|
||||||
autocomplete='new-password'
|
|
||||||
value="${App.escapeHtml(feed.auth_pass)}">
|
|
||||||
</fieldset>
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
<div dojoType="dijit.layout.ContentPane" title="'.__('Options').'">
|
|
||||||
|
|
||||||
<section class='narrow'>
|
|
||||||
|
|
||||||
$include_in_digest = $row["include_in_digest"];
|
|
||||||
|
|
||||||
if ($include_in_digest) {
|
|
||||||
$checked = "checked="1"
|
|
||||||
} else {
|
|
||||||
$checked = "
|
|
||||||
}
|
|
||||||
|
|
||||||
<fieldset class='narrow'>
|
|
||||||
|
|
||||||
<label class='checkbox'><input dojoType="dijit.form.CheckBox" type="checkbox" id="include_in_digest"
|
|
||||||
name="include_in_digest"
|
|
||||||
$checked> ".__('Include in e-mail digest')."</label>
|
|
||||||
|
|
||||||
</fieldset>
|
|
||||||
|
|
||||||
$always_display_enclosures = $row["always_display_enclosures"];
|
|
||||||
|
|
||||||
if ($always_display_enclosures) {
|
|
||||||
$checked = "checked
|
|
||||||
} else {
|
|
||||||
$checked = "
|
|
||||||
}
|
|
||||||
|
|
||||||
<fieldset class='narrow'>
|
|
||||||
|
|
||||||
<label class='checkbox'><input dojoType="dijit.form.CheckBox" type="checkbox" id="always_display_enclosures"
|
|
||||||
name="always_display_enclosures"
|
|
||||||
$checked> ".__('Always display image attachments')."</label>
|
|
||||||
|
|
||||||
</fieldset>
|
|
||||||
|
|
||||||
$hide_images = $row["hide_images"];
|
|
||||||
|
|
||||||
if ($hide_images) {
|
|
||||||
$checked = "checked="1"
|
|
||||||
} else {
|
|
||||||
$checked = "
|
|
||||||
}
|
|
||||||
|
|
||||||
<fieldset class='narrow'>
|
|
||||||
|
|
||||||
<label class='checkbox'><input dojoType='dijit.form.CheckBox' type='checkbox' id='hide_images'
|
|
||||||
name='hide_images' $checked> ".__('Do not embed media')."</label>
|
|
||||||
|
|
||||||
</fieldset>
|
|
||||||
|
|
||||||
$cache_images = $row["cache_images"];
|
|
||||||
|
|
||||||
if ($cache_images) {
|
|
||||||
$checked = "checked="1"
|
|
||||||
} else {
|
|
||||||
$checked = "
|
|
||||||
}
|
|
||||||
|
|
||||||
<fieldset class='narrow'>
|
|
||||||
|
|
||||||
<label class='checkbox'><input dojoType='dijit.form.CheckBox' type='checkbox' id='cache_images'
|
|
||||||
name='cache_images' $checked> ". __('Cache media')."</label>
|
|
||||||
|
|
||||||
</fieldset>
|
|
||||||
|
|
||||||
$mark_unread_on_update = $row["mark_unread_on_update"];
|
|
||||||
|
|
||||||
if ($mark_unread_on_update) {
|
|
||||||
$checked = "checked
|
|
||||||
} else {
|
|
||||||
$checked = "
|
|
||||||
}
|
|
||||||
|
|
||||||
<fieldset class='narrow'>
|
|
||||||
|
|
||||||
<label class='checkbox'><input dojoType='dijit.form.CheckBox' type='checkbox' id='mark_unread_on_update'
|
|
||||||
name='mark_unread_on_update' $checked> ".__('Mark updated articles as unread')."</label>
|
|
||||||
|
|
||||||
</fieldset>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div dojoType="dijit.layout.ContentPane" title="${__('Icon')}">
|
|
||||||
|
|
||||||
<img class='feedIcon feed-editor-icon' src="${feed.icon ? App.escapeHtml(feed.icon) : ""}">
|
|
||||||
|
|
||||||
<form onsubmit="return false" id="feed_icon_upload_form" enctype="multipart/form-data" method="post">
|
|
||||||
<label class="dijitButton">${__("Choose file...")}
|
|
||||||
<input style="display: none" id="icon_file" size="10" name="icon_file" type="file">
|
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
${App.FormFields.hidden_tag("op", "pref-feeds")}
|
${App.FormFields.submit_tag(__("Remove"), {class: "alt-danger", onclick: "App.dialogOf(this).removeIcon("+feed_id+")"})}
|
||||||
${App.FormFields.hidden_tag("feed_id", feed_id)}
|
</div>
|
||||||
${App.FormFields.hidden_tag("method", "uploadIcon")}
|
<div dojoType="dijit.layout.ContentPane" title="${__('Plugins')}">
|
||||||
${App.FormFields.hidden_tag("csrf_token", App.getInitParam("csrf_token"))}
|
${reply.plugin_data}
|
||||||
|
</div>
|
||||||
${App.FormFields.submit_tag(__("Replace"), {onclick: "return CommonDialogs.uploadFeedIcon()"})}
|
|
||||||
${App.FormFields.submit_tag(__("Remove"), {class: "alt-danger", onclick: "return CommonDialogs.removeFeedIcon("+feed_id+")"})}
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
|
<footer>
|
||||||
<div dojoType="dijit.layout.ContentPane" title="${__('Plugins')}">
|
${App.FormFields.button_tag(__("Unsubscribe"), "", {class: "pull-left alt-danger", onclick: "App.dialogOf(this).unsubscribe()"})}
|
||||||
${reply.plugin_data}
|
${App.FormFields.submit_tag(__("Save"), {onclick: "App.dialogOf(this).execute()"})}
|
||||||
</div>
|
${App.FormFields.cancel_dialog_tag(__("Cancel"))}
|
||||||
|
</footer>
|
||||||
</div>
|
</form>
|
||||||
|
|
||||||
<footer>
|
|
||||||
${App.FormFields.button_tag(__("Unsubscribe"), "", {class: "pull-left alt-danger", onclick: "App.dialogOf(this).unsubscribe()"})}
|
|
||||||
${App.FormFields.submit_tag(__("Save"), {onclick: "return App.dialogOf(this).execute()"})}
|
|
||||||
${App.FormFields.cancel_dialog_tag(__("Cancel"))}
|
|
||||||
</footer>
|
|
||||||
`);
|
`);
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue