update external subscribe dialog

This commit is contained in:
Andrew Dolgov 2019-02-20 12:32:52 +03:00
parent 205a75dfb9
commit d9e20f8b16
1 changed files with 92 additions and 72 deletions

View File

@ -737,92 +737,112 @@ class Handler_Public extends Handler {
$feed_url = trim(clean($_REQUEST["feed_url"])); $feed_url = trim(clean($_REQUEST["feed_url"]));
header('Content-Type: text/html; charset=utf-8'); header('Content-Type: text/html; charset=utf-8');
print "<html> ?>
<head> <html>
<title>Tiny Tiny RSS</title>"; <head>
print stylesheet_tag("css/default.css"); <title>Tiny Tiny RSS</title>
<?php
echo stylesheet_tag("css/default.css");
echo javascript_tag("lib/prototype.js");
echo javascript_tag("lib/dojo/dojo.js");
echo javascript_tag("lib/dojo/tt-rss-layer.js");
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="shortcut icon" type="image/png" href="images/favicon.png">
<link rel="icon" type="image/png" sizes="72x72" href="images/favicon-72px.png">
</head>
<body class='flat ttrss_utility'>
<script type="text/javascript">
require(['dojo/parser', "dojo/ready", 'dijit/form/Button','dijit/form/CheckBox', 'dijit/form/Form',
'dijit/form/Select','dijit/form/TextBox','dijit/form/ValidationTextBox'],function(parser, ready){
ready(function() {
parser.parse();
});
});
</script>
<div class="container">
<h1><?php echo __("Subscribe to feed...") ?></h1>
<div class='content'>
<?php
print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/> if (!$feed_url) {
<link rel=\"shortcut icon\" type=\"image/png\" href=\"images/favicon.png\"> print_error("No feed to subscribe to.");
<link rel=\"icon\" type=\"image/png\" sizes=\"72x72\" href=\"images/favicon-72px.png\"> } else {
</head> $rc = Feeds::subscribe_to_feed($feed_url);
<body class='claro ttrss_utility'> $feed_urls = false;
<div class=\"container\">
<h1>".__("Subscribe to feed...")."</h1><div class='content'>";
$rc = Feeds::subscribe_to_feed($feed_url); switch ($rc['code']) {
case 0:
switch ($rc['code']) { print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url));
case 0: break;
print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url)); case 1:
break; print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url));
case 1: break;
print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url)); case 2:
break; print_error(T_sprintf("Could not subscribe to <b>%s</b>.", $feed_url));
case 2: break;
print_error(T_sprintf("Could not subscribe to <b>%s</b>.", $feed_url)); case 3:
break; print_error(T_sprintf("No feeds found in <b>%s</b>.", $feed_url));
case 3: break;
print_error(T_sprintf("No feeds found in <b>%s</b>.", $feed_url)); case 4:
break; $feed_urls = $rc["feeds"];
case 4: break;
print_notice(__("Multiple feed URLs found.")); case 5:
$feed_urls = $rc["feeds"]; print_error(T_sprintf("Could not subscribe to <b>%s</b>.<br>Can't download the Feed URL.", $feed_url));
break; break;
case 5:
print_error(T_sprintf("Could not subscribe to <b>%s</b>.<br>Can't download the Feed URL.", $feed_url));
break;
}
if ($feed_urls) {
print "<form action=\"public.php\">";
print "<input type=\"hidden\" name=\"op\" value=\"subscribe\">";
print "<select name=\"feed_url\">";
foreach ($feed_urls as $url => $name) {
$url = htmlspecialchars($url);
$name = htmlspecialchars($name);
print "<option value=\"$url\">$name</option>";
} }
print "<input type=\"submit\" value=\"".__("Subscribe to selected feed"). if ($feed_urls) {
"\">";
print "</form>"; print "<form action='public.php'>";
} print "<input type='hidden' name='op' value='subscribe'>";
$tp_uri = get_self_url_prefix() . "/prefs.php"; print "<fieldset>";
$tt_uri = get_self_url_prefix(); print "<label style='display : inline'>" . __("Multiple feed URLs found:") . "</label>";
print "<select name='feed_url' dojoType='dijit.form.Select'>";
if ($rc['code'] <= 2){ foreach ($feed_urls as $url => $name) {
$sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE $url = htmlspecialchars($url);
$name = htmlspecialchars($name);
print "<option value=\"$url\">$name</option>";
}
print "</select>";
print "<button class='alt-primary' dojoType='dijit.form.Button' type='submit'>".__("Subscribe to selected feed")."</button>";
print "</fieldset>";
print "</form>";
}
$tp_uri = get_self_url_prefix() . "/prefs.php";
if ($rc['code'] <= 2){
$sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE
feed_url = ? AND owner_uid = ?"); feed_url = ? AND owner_uid = ?");
$sth->execute([$feed_url, $_SESSION['uid']]); $sth->execute([$feed_url, $_SESSION['uid']]);
$row = $sth->fetch(); $row = $sth->fetch();
$feed_id = $row["id"]; $feed_id = $row["id"];
} else { } else {
$feed_id = 0; $feed_id = 0;
} }
print "<p>"; print "<p>";
if ($feed_id) { if ($feed_id) {
print "<form method=\"GET\" style='display: inline' print "<form method='GET' style='float : left' action=\"$tp_uri\">
action=\"$tp_uri\"> <input type='hidden' name='tab' value='feedConfig'>
<input type=\"hidden\" name=\"tab\" value=\"feedConfig\"> <input type='hidden' name='method' value='editfeed'>
<input type=\"hidden\" name=\"method\" value=\"editfeed\"> <input type='hidden' name='methodparam' value='$feed_id'>
<input type=\"hidden\" name=\"methodparam\" value=\"$feed_id\"> <button dojoType='dijit.form.Button' class='alt-info' type='submit'>".__("Edit subscription options")."</button>
<input type=\"submit\" value=\"".__("Edit subscription options")."\">
</form>"; </form>";
}
} }
print "<form style='display: inline' method=\"GET\" action=\"$tt_uri\"> print "<form method='get' action='index.php'>
<input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\"> <button type='submit' dojoType='dijit.form.Button'>".__("Return to Tiny Tiny RSS")."</button>
</form></p>"; </form>";
print "</div></div></body></html>"; print "</div></div></body></html>";