tag setting rpc: use JSON

This commit is contained in:
Andrew Dolgov 2010-11-29 14:21:28 +03:00
parent 8eb592ec71
commit ddcbbea2de
2 changed files with 15 additions and 26 deletions

View File

@ -364,6 +364,7 @@
} }
if ($subop == "setArticleTags") { if ($subop == "setArticleTags") {
header("Content-Type: text/plain");
global $memcache; global $memcache;
@ -425,9 +426,8 @@
$tags_str = format_tags_string(get_article_tags($link, $id), $id); $tags_str = format_tags_string(get_article_tags($link, $id), $id);
print "<rpc-reply> print json_encode(array("tags_str" => array("id" => $id,
<tags-str id=\"$id\"><![CDATA[$tags_str]]></tags-str> "content" => $tags_str)));
</rpc-reply>";
return; return;
} }

View File

@ -1065,15 +1065,6 @@ function catchupSelection() {
} }
function editArticleTags(id) { function editArticleTags(id) {
/* displayDlg('editArticleTags', id,
function () {
$("tags_str").focus();
new Ajax.Autocompleter('tags_str', 'tags_choices',
"backend.php?op=rpc&subop=completeTags",
{ tokens: ',', paramName: "search" });
}); */
var query = "backend.php?op=dlg&id=editArticleTags&param=" + param_escape(id); var query = "backend.php?op=dlg&id=editArticleTags&param=" + param_escape(id);
if (dijit.byId("editTagsDlg")) if (dijit.byId("editTagsDlg"))
@ -1095,21 +1086,19 @@ function editArticleTags(id) {
notify(''); notify('');
dialog.hide(); dialog.hide();
if (transport.responseXML) { var data = JSON.parse(transport.responseText);
var tags_str = transport.responseXML.getElementsByTagName("tags-str")[0];
if (data) {
if (tags_str) { var tags_str = data.tags_str;
var id = tags_str.getAttribute("id"); var id = tags_str.id;
if (id) { var tags = $("ATSTR-" + id);
var tags = $("ATSTR-" + id);
if (tags) { if (tags) {
tags.innerHTML = tags_str.firstChild.nodeValue; tags.innerHTML = tags_str.content;
}
cache_invalidate(id);
}
} }
cache_invalidate(id);
} }
}}); }});