diff options
author | Andrew Dolgov <[email protected]> | 2006-05-22 04:54:51 +0100 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2006-05-22 04:54:51 +0100 |
commit | 071644795cdaf97601ba96d9c89b7910b49ab617 (patch) | |
tree | 5d2bc6c681e247aaf61ca7febf1fd07c92ae02e5 | |
parent | eb4311d00fde9f38c2ee1d9b95a4baee6fed3b39 (diff) |
filter editor uses prototype
-rw-r--r-- | backend.php | 169 | ||||
-rw-r--r-- | functions.php | 4 | ||||
-rw-r--r-- | prefs.js | 43 |
3 files changed, 110 insertions, 106 deletions
diff --git a/backend.php b/backend.php index 941c789a5..a3ba821d1 100644 --- a/backend.php +++ b/backend.php @@ -2094,6 +2094,90 @@ $subop = $_GET["subop"]; $quiet = $_GET["quiet"]; + if ($subop == "edit") { + + $filter_id = db_escape_string($_GET["id"]); + + $result = db_query($link, + "SELECT * FROM ttrss_filters WHERE id = '$filter_id'"); + + $reg_exp = htmlspecialchars(db_unescape_string(db_fetch_result($result, 0, "reg_exp"))); + $filter_type = db_fetch_result($result, 0, "filter_type"); + $feed_id = db_fetch_result($result, 0, "feed_id"); + $action_id = db_fetch_result($result, 0, "action_id"); + + print "<div id=\"infoBoxTitle\">Filter editor</div>"; + print "<div class=\"infoBoxContents\">"; + + print "<form id=\"filter_edit_form\">"; + + print "<input type=\"hidden\" name=\"op\" value=\"pref-filters\">"; + print "<input type=\"hidden\" name=\"id\" value=\"$filter_id\">"; + print "<input type=\"hidden\" name=\"subop\" value=\"editSave\">"; + +// print "<div class=\"notice\"><b>Note:</b> filter will only apply to new articles.</div>"; + + $result = db_query($link, "SELECT id,description + FROM ttrss_filter_types ORDER BY description"); + + $filter_types = array(); + + while ($line = db_fetch_assoc($result)) { + //array_push($filter_types, $line["description"]); + $filter_types[$line["id"]] = $line["description"]; + } + + print "<table width='100%'>"; + + print "<tr><td>Match:</td> + <td><input onkeypress=\"return filterCR(event)\" + onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\" + name=\"reg_exp\" size=\"30\" value=\"$reg_exp\"> "; + + print_select_hash("filter_type", $filter_type, $filter_types); + + print "</td></tr>"; + print "<tr><td>Feed:</td><td>"; + + print_feed_select($link, "feed_id", $feed_id); + + print "</td></tr>"; + + print "<tr><td>Action:</td>"; + + print "<td><select name=\"action_id\">"; + + $result = db_query($link, "SELECT id,description FROM ttrss_filter_actions + ORDER BY name"); + + while ($line = db_fetch_assoc($result)) { + $is_sel = ($line["id"] == $action_id) ? "selected" : ""; + printf("<option value='%d' $is_sel>%s</option>", $line["id"], $line["description"]); + } + + print "</select>"; + + print "</td></tr></table>"; + + print "</form>"; + + print "<div align='right'>"; + + print "<input type=\"submit\" + id=\"infobox_submit\" + class=\"button\" onclick=\"filterEditSave()\" + value=\"Save\"> "; + + print "<input class=\"button\" + type=\"submit\" onclick=\"filterEditCancel()\" + value=\"Cancel\">"; + + print "</div>"; + + return; + } + + if ($subop == "editSave") { $reg_exp = db_escape_string(trim($_GET["reg_exp"])); @@ -2134,7 +2218,7 @@ if (!WEB_DEMO_MODE) { $regexp = db_escape_string(trim($_GET["reg_exp"])); - $match_id = db_escape_string(trim($_GET["match_id"])); + $filter_type = db_escape_string(trim($_GET["filter_type"])); $feed_id = db_escape_string($_GET["feed_id"]); $action_id = db_escape_string($_GET["action_id"]); @@ -2148,7 +2232,7 @@ "INSERT INTO ttrss_filters (reg_exp,filter_type,owner_uid,feed_id, action_id) VALUES - ('$regexp', '$match_id','".$_SESSION["uid"]."', + ('$regexp', '$filter_type','".$_SESSION["uid"]."', $feed_id, '$action_id')"); } } @@ -2226,81 +2310,26 @@ print "<tr class=\"$class\" $this_row_id>"; - $line["regexp"] = htmlspecialchars($line["reg_exp"]); + $line["reg_exp"] = htmlspecialchars(db_unescape_string($line["reg_exp"])); if (!$line["feed_title"]) $line["feed_title"] = "All feeds"; - - if (!$edit_filter_id || $subop != "edit") { - print "<td align='center'><input onclick='toggleSelectPrefRow(this, \"filter\");' + $line["feed_title"] = htmlspecialchars(db_unescape_string($line["feed_title"])); + + print "<td align='center'><input onclick='toggleSelectPrefRow(this, \"filter\");' type=\"checkbox\" id=\"FICHK-".$line["id"]."\"></td>"; - print "<td><a href=\"javascript:editFilter($filter_id);\">" . - $line["reg_exp"] . "</td>"; + print "<td><a href=\"javascript:editFilter($filter_id);\">" . + $line["reg_exp"] . "</td>"; - print "<td><a href=\"javascript:editFilter($filter_id);\">" . - $line["feed_title"] . "</td>"; + print "<td><a href=\"javascript:editFilter($filter_id);\">" . + $line["feed_title"] . "</td>"; - print "<td><a href=\"javascript:editFilter($filter_id);\">" . - $line["filter_type_descr"] . "</td>"; + print "<td><a href=\"javascript:editFilter($filter_id);\">" . + $line["filter_type_descr"] . "</td>"; - print "<td><a href=\"javascript:editFilter($filter_id);\">" . - $line["action_description"] . "</td>"; - - } else if ($filter_id != $edit_filter_id) { - - if (!$line["description"]) $line["description"] = "[No description]"; - - print "<td align='center'><input disabled=\"true\" type=\"checkbox\" - id=\"FICHK-".$line["id"]."\"></td>"; - - print "<td>".$line["reg_exp"]."</td>"; - print "<td>".$line["feed_title"]."</td>"; - print "<td>".$line["filter_type_descr"]."</td>"; - print "<td>".$line["action_description"]."</td>"; - - } else { - - print "<td align='center'><input disabled=\"true\" type=\"checkbox\" checked>"; - - print "<input type=\"hidden\" name=\"id\" value=\"$filter_id\">"; - print "<input type=\"hidden\" name=\"op\" value=\"pref-filters\">"; - print "<input type=\"hidden\" name=\"subop\" value=\"editSave\">"; - - print "</td>"; - - print "<td><input onkeypress=\"return filterCR(event)\" - class=\"iedit\" name=\"reg_exp\" value=\"".$line["reg_exp"]."\"></td>"; - - print "<td>"; - print_feed_select($link, "feed_id", $line["feed_id"], "class=\"iedit\""); - print "</td>"; - - print "<td>"; - print_select_hash("filter_type", $line["filter_type"], $filter_types, - "class=\"iedit\""); - print "</td>"; - - print "<td>"; - print "<select name=\"action_id\" class=\"iedit\">"; - - $tmp_result = db_query($link, "SELECT id,description FROM ttrss_filter_actions - ORDER BY description"); - - while ($tmp_line = db_fetch_assoc($tmp_result)) { - if ($tmp_line["description"] == $line["action_description"]) { - $is_selected = "selected"; - } else { - $is_selected = ""; - } - printf("<option $is_selected value='%d'>%s</option>", - $tmp_line["id"], $tmp_line["description"]); - } - - print "</select></td>"; - - print "</td>"; - } + print "<td><a href=\"javascript:editFilter($filter_id);\">" . + $line["action_description"] . "</td>"; print "</tr>"; @@ -2766,7 +2795,7 @@ onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\" name=\"reg_exp\" size=\"30\"> "; - print_select_hash("match_id", 1, $filter_types); + print_select_hash("filter_type", 1, $filter_types); print "</td></tr>"; print "<tr><td>Feed:</td><td>"; diff --git a/functions.php b/functions.php index 73ef85774..0c1a959a7 100644 --- a/functions.php +++ b/functions.php @@ -1601,7 +1601,7 @@ $is_selected = ""; } printf("<option $is_selected value='%d'>%s</option>", - $line["id"], db_unescape_string($line["title"])); + $line["id"], htmlspecialchars(db_unescape_string($line["title"]))); } print "</select>"; @@ -1630,7 +1630,7 @@ $is_selected = ""; } printf("<option $is_selected value='%d'>%s</option>", - $line["id"], $line["title"]); + $line["id"], htmlspecialchars(db_unescape_string($line["title"]))); } print "</select>"; @@ -1,7 +1,6 @@ var xmlhttp = false; var active_feed_cat = false; -var active_filter = false; var active_label = false; var active_tab = false; var feed_to_expand = false; @@ -54,22 +53,7 @@ function feedlist_callback() { function filterlist_callback() { var container = document.getElementById('prefContent'); if (xmlhttp.readyState == 4) { - container.innerHTML=xmlhttp.responseText; - - if (active_filter) { - var row = document.getElementById("FILRR-" + active_filter); - if (row) { - if (!row.className.match("Selected")) { - row.className = row.className + "Selected"; - } - } - var checkbox = document.getElementById("FICHK-" + active_filter); - - if (checkbox) { - checkbox.checked = true; - } - } notify(""); } } @@ -354,13 +338,12 @@ function editFilter(id) { return } - active_filter = id; + selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false); + selectTableRowById('FILRR-'+id, 'FICHK-'+id, true); - xmlhttp.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + - param_escape(id), true); - xmlhttp.onreadystatechange=filterlist_callback; + xmlhttp.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id), true); + xmlhttp.onreadystatechange=infobox_callback; xmlhttp.send(null); - } function editFeed(feed) { @@ -713,7 +696,6 @@ function userEditCancel() { } selectPrefRows('user', false); // cleanup feed selection - closeInfoBox(); } @@ -723,15 +705,9 @@ function filterEditCancel() { printLockingError(); return } - - active_filter = false; - -// notify("Operation cancelled."); - - xmlhttp.open("GET", "backend.php?op=pref-filters", true); - xmlhttp.onreadystatechange=filterlist_callback; - xmlhttp.send(null); - + + selectPrefRows('filter', false); // cleanup feed selection + closeInfoBox(); } function labelEditSave() { @@ -809,10 +785,10 @@ function filterEditSave() { notify("Saving filter..."); - active_filter = false; - var query = Form.serialize("filter_edit_form"); + closeInfoBox(); + xmlhttp.open("GET", "backend.php?" + query, true); xmlhttp.onreadystatechange=filterlist_callback; xmlhttp.send(null); @@ -1137,7 +1113,6 @@ function selectTab(id, noupdate) { // clean up all current selections, just in case active_feed_cat = false; - active_filter = false; active_label = false; if (id == "feedConfig") { |