diff options
-rw-r--r-- | classes/dlg.php | 37 | ||||
-rwxr-xr-x | classes/feeds.php | 2 | ||||
-rwxr-xr-x | classes/pref/feeds.php | 19 | ||||
-rw-r--r-- | js/CommonDialogs.js | 62 |
4 files changed, 71 insertions, 49 deletions
diff --git a/classes/dlg.php b/classes/dlg.php index 7c07cf4f1..93c1c4c51 100644 --- a/classes/dlg.php +++ b/classes/dlg.php @@ -128,41 +128,4 @@ class Dlg extends Handler_Protected { print "</footer>"; } - - function generatedFeed() { - - $this->params = explode(":", $this->param, 3); - $feed_id = $this->params[0]; - $is_cat = (bool) $this->params[1]; - - $key = Feeds::get_feed_access_key($feed_id, $is_cat); - - $url_path = htmlspecialchars($this->params[2]) . "&key=" . $key; - - $feed_title = Feeds::getFeedTitle($feed_id, $is_cat); - - print "<header>".T_sprintf("%s can be accessed via the following secret URL:", $feed_title)."</header>"; - - print "<section>"; - print "<div class='panel text-center'>"; - print "<a id='gen_feed_url' href='$url_path' target='_blank'>$url_path</a>"; - print "</div>"; - print "</section>"; - - print "<footer>"; - - print "<button dojoType='dijit.form.Button' style='float : left' class='alt-info' onclick='window.open(\"https://tt-rss.org/wiki/GeneratedFeeds\")'> - <i class='material-icons'>help</i> ".__("More info...")."</button>"; - - print "<button dojoType='dijit.form.Button' onclick=\"return CommonDialogs.genUrlChangeKey('$feed_id', '$is_cat')\">". - __('Generate new URL')."</button> "; - - print "<button dojoType='dijit.form.Button' onclick=\"return CommonDialogs.closeInfoBox()\">". - __('Close this window')."</button>"; - - print "</footer>"; - - //return; - } - } diff --git a/classes/feeds.php b/classes/feeds.php index bcfcbf894..e8c3bcf2c 100755 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -37,7 +37,7 @@ class Feeds extends Handler_Protected { $reply .= "<a href=\"#\" title=\"".__("Show as feed")."\" - onclick=\"App.displayDlg('".__("Show as feed")."','generatedFeed', '$feed_id:$is_cat:$rss_link')\"> + onclick='CommonDialogs.generatedFeed(\"$feed_id\", \"$is_cat\", \"$rss_link\")'> <i class='icon-syndicate material-icons'>rss_feed</i></a>"; $reply .= "<span id='feed_title'>"; diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index cb2e79853..55bdfae9f 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -1391,10 +1391,10 @@ class Pref_Feeds extends Handler_Protected { print "<h3>" . __('Published articles can be subscribed by anyone who knows the following URL:') . "</h3>"; - $rss_url = '-2::' . htmlspecialchars(get_self_url_prefix() . + $rss_url = htmlspecialchars(get_self_url_prefix() . "/public.php?op=rss&id=-2&view-mode=all_articles");; - print "<button dojoType='dijit.form.Button' class='alt-primary' onclick=\"return App.displayDlg('".__("Show as feed")."','generatedFeed', '$rss_url')\">". + print "<button dojoType='dijit.form.Button' class='alt-primary' onclick='CommonDialogs.generatedFeed('-2', false, \"$rss_url\")'>". __('Display URL')."</button> "; print "<button class=\"alt-danger\" dojoType=\"dijit.form.Button\" onclick=\"return Helpers.clearFeedAccessKeys()\">". @@ -1714,23 +1714,26 @@ class Pref_Feeds extends Handler_Protected { $this->update_feed_access_key('OPML:Publish', false, $_SESSION["uid"]); - $new_link = OPML::opml_publish_url(); - - print json_encode(["link" => $new_link]); + print json_encode(["link" => OPML::opml_publish_url()]); } function regenFeedKey() { $feed_id = clean($_REQUEST['id']); $is_cat = clean($_REQUEST['is_cat']); - $new_key = $this->update_feed_access_key($feed_id, $is_cat); + $new_key = $this->update_feed_access_key($feed_id, $is_cat, $_SESSION["uid"]); print json_encode(["link" => $new_key]); } + function getFeedKey() { + $feed_id = clean($_REQUEST['id']); + $is_cat = clean($_REQUEST['is_cat']); + + print json_encode(["link" => Feeds::get_feed_access_key($feed_id, $is_cat, $_SESSION["uid"])]); + } - private function update_feed_access_key($feed_id, $is_cat, $owner_uid = false) { - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; + private function update_feed_access_key($feed_id, $is_cat, $owner_uid) { // clear old value and generate new one $sth = $this->pdo->prepare("DELETE FROM ttrss_access_keys diff --git a/js/CommonDialogs.js b/js/CommonDialogs.js index 08a32de86..72c3653b3 100644 --- a/js/CommonDialogs.js +++ b/js/CommonDialogs.js @@ -370,7 +370,7 @@ const CommonDialogs = { dijit.byId("publicOPMLDlg").destroyRecursive(); const dialog = new dijit.Dialog({ - title: "Public OPML URL", + title: __("Public OPML URL"), id: 'publicOPMLDlg', style: "width: 600px", onCancel: function () { @@ -386,7 +386,7 @@ const CommonDialogs = { <header>${__("Your Public OPML URL is:")}</header> <section> <div class='panel text-center'> - <a id='pub_opml_url' href='$url_path' target='_blank'>${reply.link}</a> + <a id='pub_opml_url' href="${App.escapeHtml(reply.link)}" target='_blank'>${reply.link}</a> </div> </section> <footer class='text-center'> @@ -396,7 +396,63 @@ const CommonDialogs = { <button dojoType='dijit.form.Button' type='submit' class='alt-primary'> ${__('Close this window')} </button> - </footer> + </footer> + ` + }); + + dialog.show(); + + Notify.close(); + + } catch (e) { + this.Error.report(e); + } + }); + }, + generatedFeed: function(feed, is_cat, rss_url) { + + Notify.progress("Loading, please wait...", true); + + xhrJson("backend.php", {op: "pref-feeds", method: "getFeedKey", id: feed, is_cat: is_cat}, (reply) => { + try { + if (dijit.byId("genFeedDlg")) + dijit.byId("genFeedDlg").destroyRecursive(); + + const feed_title = Feeds.getName(feed, is_cat); + + const secret_url = rss_url + "&key=" + encodeURIComponent(reply.link); + + const dialog = new dijit.Dialog({ + title: __("Show as feed"), + id: 'genFeedDlg', + style: "width: 600px", + onCancel: function () { + return true; + }, + onExecute: function () { + return true; + }, + onClose: function () { + return true; + }, + content: ` + <header>${__("%s can be accessed via the following secret URL:").replace("%s", feed_title)}</header> + <section> + <div class='panel text-center'> + <a id='gen_feed_url' href="${App.escapeHtml(secret_url)}" target='_blank'>${secret_url}</a> + </div> + </section> + <footer> + <button dojoType='dijit.form.Button' style='float : left' class='alt-info' + onclick='window.open("https://tt-rss.org/wiki/GeneratedFeeds")'> + <i class='material-icons'>help</i> ${__("More info...")}</button> + <button dojoType='dijit.form.Button' onclick="return CommonDialogs.genUrlChangeKey('${feed}', '${is_cat}')"> + ${__('Generate new URL')} + </button> + <button dojoType='dijit.form.Button' class='alt-primary' type='submit'> + ${__('Close this window')} + </button> + </footer> ` }); |