category editor: properly initialize inline editors

This commit is contained in:
Andrew Dolgov 2009-01-20 17:48:38 +01:00
parent 62f7bf7181
commit 8f70815592
2 changed files with 54 additions and 21 deletions

View File

@ -934,10 +934,29 @@
$cat_title = db_escape_string(trim($_REQUEST["value"])); $cat_title = db_escape_string(trim($_REQUEST["value"]));
$cat_id = db_escape_string($_GET["cid"]); $cat_id = db_escape_string($_GET["cid"]);
$result = db_query($link, "UPDATE ttrss_feed_categories SET db_query($link, "BEGIN");
title = '$cat_title' WHERE id = '$cat_id' AND owner_uid = ".$_SESSION["uid"]);
print $_REQUEST["value"]; $result = db_query($link, "SELECT title FROM ttrss_feed_categories
WHERE id = '$cat_id' AND owner_uid = ".$_SESSION["uid"]);
if (db_num_rows($result) == 1) {
$old_title = db_fetch_result($result, 0, "title");
if ($cat_title != "") {
$result = db_query($link, "UPDATE ttrss_feed_categories SET
title = '$cat_title' WHERE id = '$cat_id' AND
owner_uid = ".$_SESSION["uid"]);
print $cat_title;
} else {
print $old_title;
}
} else {
print $_REQUEST["value"];
}
db_query($link, "COMMIT");
return; return;
@ -1370,8 +1389,14 @@
<option value=\"facDefault\" selected>".__('Actions...')."</option> <option value=\"facDefault\" selected>".__('Actions...')."</option>
<option disabled>--------</option> <option disabled>--------</option>
<option style=\"color : #5050aa\" disabled>".__('Selection:')."</option> <option style=\"color : #5050aa\" disabled>".__('Selection:')."</option>
<option value=\"facEdit\">&nbsp;&nbsp;".__('Edit')."</option> <option value=\"facEdit\">&nbsp;&nbsp;".__('Edit')."</option>";
<option value=\"facPurge\">&nbsp;&nbsp;".__('Manual purge')."</option>
if (FORCE_ARTICLE_PURGE == 0) {
print
"<option value=\"facPurge\">&nbsp;&nbsp;".__('Manual purge')."</option>";
}
print "
<option value=\"facClear\">&nbsp;&nbsp;".__('Clear feed data')."</option> <option value=\"facClear\">&nbsp;&nbsp;".__('Clear feed data')."</option>
<option value=\"facRescore\">&nbsp;&nbsp;".__('Rescore articles')."</option> <option value=\"facRescore\">&nbsp;&nbsp;".__('Rescore articles')."</option>
<option value=\"facUnsubscribe\">&nbsp;&nbsp;".__('Unsubscribe')."</option>"; <option value=\"facUnsubscribe\">&nbsp;&nbsp;".__('Unsubscribe')."</option>";

View File

@ -240,24 +240,32 @@ function changepass_callback() {
} }
} }
function init_cat_inline_editor() {
try {
if (document.getElementById("prefFeedCatList")) {
var elems = document.getElementById("prefFeedCatList").getElementsByTagName("SPAN");
for (var i = 0; i < elems.length; i++) {
if (elems[i].id && elems[i].id.match("FCATT-")) {
var cat_id = elems[i].id.replace("FCATT-", "");
new Ajax.InPlaceEditor(elems[i],
'backend.php?op=pref-feeds&subop=editCats&action=save&cid=' + cat_id);
}
}
}
} catch (e) {
exception_error("init_cat_inline_editor", e);
}
}
function infobox_feed_cat_callback() { function infobox_feed_cat_callback() {
if (xmlhttp.readyState == 4) { if (xmlhttp.readyState == 4) {
try { try {
infobox_callback(); infobox_callback();
init_cat_inline_editor();
if (document.getElementById("prefFeedCatList")) {
var elems = document.getElementById("prefFeedCatList").getElementsByTagName("SPAN");
for (var i = 0; i < elems.length; i++) {
if (elems[i].id && elems[i].id.match("FCATT-")) {
var cat_id = elems[i].id.replace("FCATT-", "");
new Ajax.InPlaceEditor(elems[i],
'backend.php?op=pref-feeds&subop=editCats&action=save&cid=' + cat_id);
}
}
}
} catch (e) { } catch (e) {
exception_error("infobox_feed_cat_callback", e); exception_error("infobox_feed_cat_callback", e);
@ -388,7 +396,7 @@ function addFeedCat() {
xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=add&cat=" + xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=add&cat=" +
param_escape(cat.value), true); param_escape(cat.value), true);
xmlhttp.onreadystatechange=infobox_callback; xmlhttp.onreadystatechange=infobox_feed_cat_callback;
xmlhttp.send(null); xmlhttp.send(null);
link.value = ""; link.value = "";
@ -763,7 +771,7 @@ function removeSelectedFeedCats() {
xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+ xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+
param_escape(sel_rows.toString()), true); param_escape(sel_rows.toString()), true);
xmlhttp.onreadystatechange=infobox_callback; xmlhttp.onreadystatechange=infobox_feed_cat_callback;
xmlhttp.send(null); xmlhttp.send(null);
} }