mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-13 22:45:56 +00:00
rpc/addfeed: use JSON
This commit is contained in:
22
functions.js
22
functions.js
@@ -865,15 +865,10 @@ function quickAddFeed() {
|
|||||||
parameters: dojo.objectToQuery(this.attr('value')),
|
parameters: dojo.objectToQuery(this.attr('value')),
|
||||||
onComplete: function(transport) {
|
onComplete: function(transport) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
var reply = JSON.parse(transport.responseText);
|
||||||
|
|
||||||
if (!transport.responseXML) {
|
var rc = parseInt(reply['result']);
|
||||||
console.log(transport.responseText);
|
|
||||||
alert(__("Server error while trying to subscribe to specified feed."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var result = transport.responseXML.getElementsByTagName('result')[0];
|
|
||||||
var rc = parseInt(result.getAttribute('code'));
|
|
||||||
|
|
||||||
notify('');
|
notify('');
|
||||||
|
|
||||||
@@ -899,16 +894,11 @@ function quickAddFeed() {
|
|||||||
parameters: 'op=rpc&subop=extractfeedurls&url=' + param_escape(feed_url),
|
parameters: 'op=rpc&subop=extractfeedurls&url=' + param_escape(feed_url),
|
||||||
onComplete: function(transport, dialog, feed_url) {
|
onComplete: function(transport, dialog, feed_url) {
|
||||||
|
|
||||||
if (!transport.responseXML) {
|
|
||||||
console.log(transport.responseText);
|
|
||||||
alert(__("Server error while trying to query feed URLs."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
notify('');
|
notify('');
|
||||||
|
|
||||||
var result = transport.responseXML.getElementsByTagName('urls')[0];
|
var reply = JSON.parse(transport.responseText);
|
||||||
var feeds = JSON.parse(result.firstChild.nodeValue);
|
|
||||||
|
var feeds = reply['urls'];
|
||||||
|
|
||||||
console.log(transport.responseText);
|
console.log(transport.responseText);
|
||||||
|
|
||||||
|
|||||||
@@ -88,8 +88,6 @@
|
|||||||
if ($subop == "remarchive") {
|
if ($subop == "remarchive") {
|
||||||
$ids = split(",", db_escape_string($_REQUEST["ids"]));
|
$ids = split(",", db_escape_string($_REQUEST["ids"]));
|
||||||
|
|
||||||
print "<rpc-reply>";
|
|
||||||
|
|
||||||
foreach ($ids as $id) {
|
foreach ($ids as $id) {
|
||||||
$result = db_query($link, "DELETE FROM ttrss_archived_feeds WHERE
|
$result = db_query($link, "DELETE FROM ttrss_archived_feeds WHERE
|
||||||
(SELECT COUNT(*) FROM ttrss_user_entries
|
(SELECT COUNT(*) FROM ttrss_user_entries
|
||||||
@@ -97,17 +95,13 @@
|
|||||||
id = '$id' AND owner_uid = ".$_SESSION["uid"]);
|
id = '$id' AND owner_uid = ".$_SESSION["uid"]);
|
||||||
|
|
||||||
$rc = db_affected_rows($link, $result);
|
$rc = db_affected_rows($link, $result);
|
||||||
|
|
||||||
print "<feed id='$id' rc='$rc'/>";
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
print "</rpc-reply>";
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($subop == "addfeed") {
|
if ($subop == "addfeed") {
|
||||||
|
header("Content-Type: text/plain");
|
||||||
|
|
||||||
$feed = db_escape_string($_REQUEST['feed']);
|
$feed = db_escape_string($_REQUEST['feed']);
|
||||||
$cat = db_escape_string($_REQUEST['cat']);
|
$cat = db_escape_string($_REQUEST['cat']);
|
||||||
@@ -116,21 +110,18 @@
|
|||||||
|
|
||||||
$rc = subscribe_to_feed($link, $feed, $cat, $login, $pass);
|
$rc = subscribe_to_feed($link, $feed, $cat, $login, $pass);
|
||||||
|
|
||||||
print "<rpc-reply>";
|
print json_encode(array("result" => $rc));
|
||||||
print "<result code='$rc'/>";
|
|
||||||
print "</rpc-reply>";
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($subop == "extractfeedurls") {
|
if ($subop == "extractfeedurls") {
|
||||||
print "<rpc-reply>";
|
header("Content-Type: text/plain");
|
||||||
|
|
||||||
$urls = get_feeds_from_html($_REQUEST['url']);
|
$urls = get_feeds_from_html($_REQUEST['url']);
|
||||||
print "<urls><![CDATA[" . json_encode($urls) . "]]></urls>";
|
|
||||||
|
|
||||||
print "</rpc-reply>";
|
print json_encode(array("urls" => $urls));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user