rework feed category edit box

This commit is contained in:
Andrew Dolgov 2007-08-20 08:29:39 +01:00
parent 768858f1e3
commit 11f083e73b
2 changed files with 47 additions and 67 deletions

View File

@ -519,22 +519,27 @@
if ($subop == "editCats") {
print "<div id=\"infoBoxTitle\">".__('Category editor')."</div>";
print "<div class=\"infoBoxContents\">";
$action = $_REQUEST["action"];
if ($action == "save") {
$cat_title = db_escape_string(trim($_GET["title"]));
$cat_id = db_escape_string($_GET["id"]);
$cat_title = db_escape_string(trim($_REQUEST["value"]));
$cat_id = db_escape_string($_GET["cid"]);
$result = db_query($link, "UPDATE ttrss_feed_categories SET
title = '$cat_title' WHERE id = '$cat_id' AND owner_uid = ".$_SESSION["uid"]);
print $_REQUEST["value"];
return;
}
print "<div id=\"infoBoxTitle\">".__('Category editor')."</div>";
print "<div class=\"infoBoxContents\">";
if ($action == "add") {
if (!WEB_DEMO_MODE) {
@ -626,10 +631,6 @@
print "<table width=\"100%\" class=\"prefFeedCatList\"
cellspacing=\"0\" id=\"prefFeedCatList\">";
/* print "<tr class=\"title\">
<td width=\"5%\">&nbsp;</td><td width=\"80%\">Title</td>
</tr>"; */
$lnum = 0;
while ($line = db_fetch_assoc($result)) {
@ -637,54 +638,18 @@
$class = ($lnum % 2) ? "even" : "odd";
$cat_id = $line["id"];
$edit_cat_id = $_GET["id"];
if ($action == "edit" && $cat_id == $edit_cat_id) {
$class .= "Selected";
$this_row_id = "";
} else if ($action == "edit" && $cat_id != $edit_cat_id) {
$class .= "Grayed";
$this_row_id = "";
} else {
$this_row_id = "id=\"FCATR-$cat_id\"";
}
print "<tr class=\"$class\" $this_row_id>";
$edit_title = htmlspecialchars($line["title"]);
if (!$edit_cat_id || $action != "edit") {
print "<td width='5%' align='center'><input
onclick='toggleSelectPrefRow(this, \"fcat\");'
type=\"checkbox\" id=\"FCCHK-".$line["id"]."\"></td>";
type=\"checkbox\" id=\"FCCHK-$cat_id\"></td>";
print "<td><a href=\"javascript:editFeedCat($cat_id);\">" .
$edit_title . "</a></td>";
} else if ($cat_id != $edit_cat_id) {
print "<td width='5%' align='center'><input disabled=\"true\" type=\"checkbox\"
id=\"FRCHK-".$line["id"]."\"></td>";
print "<td>$edit_title</td>";
} else {
print "<td width='5%' align='center'><input disabled=\"true\" type=\"checkbox\" checked>";
print "<input type=\"hidden\" name=\"id\" value=\"$cat_id\">";
print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">";
print "<input type=\"hidden\" name=\"subop\" value=\"editCats\">";
print "<input type=\"hidden\" name=\"action\" value=\"save\">";
print "</td>";
print "<td><input onkeypress=\"return filterCR(event, feedCatEditSave)\"
name=\"title\" size=\"40\" value=\"$edit_title\"></td>";
}
print "<td><span id=\"FCATT-$cat_id\">" .
$edit_title . "</span></td>";
print "</tr>";
@ -707,19 +672,9 @@
print "<div id=\"catOpToolbar\">";
if ($action == "edit") {
print "<input type=\"submit\" class=\"button\"
onclick=\"return feedCatEditSave()\" value=\"".__('Save')."\">
<input type=\"submit\" class=\"button\"
onclick=\"return feedCatEditCancel()\" value=\"".__('Cancel')."\">";
} else {
print "
<input type=\"submit\" class=\"button\" disabled=\"true\"
onclick=\"return editSelectedFeedCat()\" value=\"".__('Edit')."\">
<input type=\"submit\" class=\"button\" disabled=\"true\"
onclick=\"return removeSelectedFeedCats()\" value=\"".__('Remove')."\">";
}
print "</div>";

View File

@ -207,6 +207,31 @@ function changepass_callback() {
}
}
function infobox_feed_cat_callback() {
if (xmlhttp.readyState == 4) {
try {
infobox_callback();
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("infobox_feed_cat_callback", e);
}
}
}
function updateFeedList(sort_key) {
if (!xmlhttp_ready(xmlhttp)) {
@ -1615,7 +1640,7 @@ function editFeedCats() {
}
xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
xmlhttp.onreadystatechange=infobox_callback;
xmlhttp.onreadystatechange=infobox_feed_cat_callback;
xmlhttp.send(null);
}