".__('Filter Editor').""; print "
"; print "
"; print ""; print ""; print ""; $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 "
".__("Match")."
"; print "
"; print ""; print " " . __("on field") . " "; print_select_hash("filter_type", $filter_type, $filter_types); print "
"; print __("in") . " "; print_feed_select($link, "feed_id", $feed_id); print "
"; print "
".__("Perform Action")."
"; print "
"; print ""; $param_hidden = ($action_id == 4 || $action_id == 6) ? "" : "display : none"; print ""; print " " . __("with parameters:") . " "; print ""; print ""; print " "; // tiny layout hack print "
"; print "
".__("Options")."
"; print "
"; print "
"; if ($enabled) { $checked = "checked"; } else { $checked = ""; } print "
"; if ($inverse) { $checked = "checked"; } else { $checked = ""; } print " "; print "
"; print "
"; print "
"; $reg_exp = htmlspecialchars($reg_exp, ENT_QUOTES); // second escaping seems to be needed for javascript print "
"; print " "; print "
"; print " "; print ""; print "
"; return; } if ($subop == "editSave") { $reg_exp = db_escape_string(trim($_GET["reg_exp"])); $filter_type = db_escape_string(trim($_GET["filter_type"])); $filter_id = db_escape_string($_GET["id"]); $feed_id = db_escape_string($_GET["feed_id"]); $action_id = db_escape_string($_GET["action_id"]); $action_param = db_escape_string($_GET["action_param"]); $enabled = checkbox_to_sql_bool(db_escape_string($_GET["enabled"])); $inverse = checkbox_to_sql_bool(db_escape_string($_GET["inverse"])); if (!$feed_id) { $feed_id = 'NULL'; } else { $feed_id = sprintf("'%s'", db_escape_string($feed_id)); } $result = db_query($link, "UPDATE ttrss_filters SET reg_exp = '$reg_exp', feed_id = $feed_id, action_id = '$action_id', filter_type = '$filter_type', enabled = $enabled, inverse = $inverse, action_param = '$action_param' WHERE id = '$filter_id' AND owner_uid = " . $_SESSION["uid"]); if (db_affected_rows($link, $result) != 0) { print_notice(T_sprintf("Saved filter %s", htmlspecialchars($reg_exp))); } } if ($subop == "remove") { $ids = split(",", db_escape_string($_GET["ids"])); foreach ($ids as $id) { db_query($link, "DELETE FROM ttrss_filters WHERE id = '$id' AND owner_uid = ". $_SESSION["uid"]); } } if ($subop == "add") { $regexp = db_escape_string(trim($_GET["reg_exp"])); $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"]); $action_param = db_escape_string($_GET["action_param"]); $inverse = checkbox_to_sql_bool(db_escape_string($_GET["inverse"])); if (!$regexp) return; if (!$feed_id) { $feed_id = 'NULL'; } else { $feed_id = sprintf("'%s'", db_escape_string($feed_id)); } $result = db_query($link, "INSERT INTO ttrss_filters (reg_exp,filter_type,owner_uid,feed_id, action_id, action_param, inverse) VALUES ('$regexp', '$filter_type','".$_SESSION["uid"]."', $feed_id, '$action_id', '$action_param', $inverse)"); if (db_affected_rows($link, $result) != 0) { print T_sprintf("Created filter %s", htmlspecialchars($regexp)); } return; } if ($quiet) return; set_pref($link, "_PREFS_ACTIVE_TAB", "filterConfig"); $sort = db_escape_string($_GET["sort"]); if (!$sort || $sort == "undefined") { $sort = "reg_exp"; } // print "
PLACEHOLDER
"; $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"]; } $filter_search = db_escape_string($_GET["search"]); if (array_key_exists("search", $_GET)) { $_SESSION["prefs_filter_search"] = $filter_search; } else { $filter_search = $_SESSION["prefs_filter_search"]; } print "

"; print ""; print " "; print ""; if ($filter_search) { $filter_search = db_escape_string($filter_search); $filter_search_query = "( UPPER(ttrss_filter_actions.description) LIKE UPPER('%$filter_search%') OR UPPER(reg_exp) LIKE UPPER('%$filter_search%') OR UPPER(ttrss_feeds.title) LIKE UPPER('%$filter_search%') OR UPPER(ttrss_filter_types.description) LIKE UPPER('%$filter_search%')) AND"; } else { $filter_search_query = ""; } $result = db_query($link, "SELECT ttrss_filters.id AS id,reg_exp, ttrss_filter_types.name AS filter_type_name, ttrss_filter_types.description AS filter_type_descr, enabled, inverse, feed_id, ttrss_filter_actions.description AS action_description, ttrss_feeds.title AS feed_title, ttrss_filter_actions.name AS action_name, ttrss_filters.action_param AS action_param FROM ttrss_filter_types,ttrss_filter_actions,ttrss_filters LEFT JOIN ttrss_feeds ON (ttrss_filters.feed_id = ttrss_feeds.id) WHERE filter_type = ttrss_filter_types.id AND $filter_search_query ttrss_filter_actions.id = action_id AND ttrss_filters.owner_uid = ".$_SESSION["uid"]." ORDER by action_description, $sort"); if (db_num_rows($result) != 0) { print "

"; print ""; print ""; } print ""; $line["reg_exp"] = htmlspecialchars($line["reg_exp"]); if (!$line["feed_title"]) $line["feed_title"] = __("All feeds"); if (!$line["action_param"]) { $line["action_param"] = "—"; } else if ($line["action_name"] == "score") { $score_pic = get_score_pic($line["action_param"]); $score_pic = ""; $line["action_param"] = "$score_pic " . $line["action_param"]; } $line["feed_title"] = htmlspecialchars($line["feed_title"]); print ""; if (!$enabled) { $line["reg_exp"] = "" . $line["reg_exp"] . " " . __("(Disabled)").""; $line["feed_title"] = "" . $line["feed_title"] . ""; $line["filter_type_descr"] = "" . $line["filter_type_descr"] . ""; $line["action_description"] = "" . $line["action_description"] . ""; $line["action_param"] = "" . $line["action_param"] . ""; } $onclick = "onclick='editFilter($filter_id)' title='".__('Click to edit')."'"; print ""; print ""; $inverse_label = ""; if ($inverse) { $inverse_label = " ".__('(Inverse)').""; } print ""; print ""; print ""; ++$lnum; } print "
".__('Select:')." ".__('All').", ".__('None')." "; $lnum = 0; $cur_action_description = ""; while ($line = db_fetch_assoc($result)) { $class = ($lnum % 2) ? "even" : "odd"; $filter_id = $line["id"]; $edit_filter_id = $_GET["id"]; $enabled = sql_bool_to_bool($line["enabled"]); $inverse = sql_bool_to_bool($line["inverse"]); if ($subop == "edit" && $filter_id != $edit_filter_id) { $class .= "Grayed"; $this_row_id = ""; } else { $this_row_id = "id=\"FILRR-$filter_id\""; } $line["filter_type_descr"] = __($line["filter_type_descr"]); $line["action_description"] = __($line["action_description"]); if ($line["action_description"] != $cur_action_description) { $cur_action_description = $line["action_description"]; print "
$cur_action_description
  ".__('Filter expression')." ".__('Feed')." ".__('Match')." ".__('Params')."
" . $line["reg_exp"] . "" . $line["feed_title"] . "" . $line["filter_type_descr"] . "$inverse_label" . $line["action_param"] . "
"; print "

"; print " "; print "

"; } else { print "

"; if (!$filter_search) { print __('No filters defined.'); } else { print __('No matching filters found.'); } print "

"; } } ?>