]> git.wh0rd.org Git - tt-rss.git/commitdiff
rpc/checkDate: use JSON; mark some XML methods
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 29 Nov 2010 13:09:28 +0000 (16:09 +0300)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 29 Nov 2010 13:09:28 +0000 (16:09 +0300)
functions.js
modules/backend-rpc.php

index f0364deb053aa86704faaf9714254b737855bcb5..5dcfe6f3a1a20acdd82252200512bed238a207b3 100644 (file)
@@ -607,19 +607,15 @@ function filterDlgCheckDate() {
                        parameters: query,
                        onComplete: function(transport) { 
 
-                               if (transport.responseXML) {
-                                       var result = transport.responseXML.getElementsByTagName("result")[0];
+                               var reply = JSON.parse(transport.responseText);
 
-                                       if (result && result.firstChild) {
-                                               if (result.firstChild.nodeValue == "1") {
-                                                       alert(__("Date syntax appears to be correct."));
-                                                       return;
-                                               }
-                                       }
+                               if (reply['result'] == true) {
+                                       alert(__("Date syntax appears to be correct."));
+                                       return;
+                               } else {
+                                       alert(__("Date syntax is incorrect."));
                                }
 
-                               alert(__("Date syntax is incorrect."));
-
                        } });
 
 
index 54c66df33b0b3b7506b0c9900ed9cba22bf1d9dc..3120fb7b3eba8bc2c333728432e9209fe163730b 100644 (file)
                }
 
                if ($subop == "setpref") {
-                       print "<rpc-reply>";
+                       header("Content-Type: text/plain");
 
                        $key = db_escape_string($_REQUEST["key"]);
                        $value = db_escape_string($_REQUEST["value"]);
 
                        set_pref($link, $key, $value);
 
-                       print "<param-set key=\"$key\" value=\"$value\"/>";
-
-                       print "</rpc-reply>";
-
+                       print json_encode(array("param" =>$key, "value" => $value));
                        return;
                }
 
                        return;
                }
 
-
+               // XML method
                if ($subop == "publ") {
                        $pub = $_REQUEST["pub"];
                        $id = db_escape_string($_REQUEST["id"]);
                        return;
                }
 
+               // XML method
                if ($subop == "sanityCheck") {
                        print "<rpc-reply>";
                        if (sanity_check($link)) {
                                print "]]></init-params>";
 
                                print_runtime_info($link);
-
-                               # assign client-passed params to session
-                               $_SESSION["client.userAgent"] = $_REQUEST["ua"];
-
                        }
                        print "</rpc-reply>";
 
                        return;
                }               
 
-               if ($subop == "globalPurge") {
+/*             if ($subop == "globalPurge") {
 
                        print "<rpc-reply>";
                        global_purge_old_posts($link, true);
                        print "</rpc-reply>";
 
                        return;
-               }
+               } */
 
                if ($subop == "setArticleTags") {
                        header("Content-Type: text/plain");
                        return;
                }
 
+               // XML method
                if ($subop == "regenOPMLKey") {
 
                        print "<rpc-reply>";
                        return;
                }
 
+               // XML method
                if ($subop == "logout") {
                        logout_user();
                        print_error_xml(6);
 
                } */
 
+               // XML method
                if ($subop == "getArticles") {
                        $ids = split(",", db_escape_string($_REQUEST["ids"]));
 
                        }
                        print "</rpc-reply>";
 
-                       return;
+                       return;         
                }
 
                if ($subop == "checkDate") {
+                       header("Content-Type: text/plain");
 
                        $date = db_escape_string($_REQUEST["date"]);
                        $date_parsed = strtotime($date);
 
-                       print "<rpc-reply>";
-
-                       if ($date_parsed) {
-                               print "<result>1</result>";
-                       } else {
-                               print "<result>0</result>";
-                       }
-
-                       print "</rpc-reply>";
-
+                       print json_encode(array("result" => (bool)$date_parsed));
                        return;
                }