2006-10-01 10:05:20 +00:00
|
|
|
<?php
|
|
|
|
function module_pref_filters($link) {
|
2009-12-29 15:49:27 +00:00
|
|
|
$subop = $_REQUEST["subop"];
|
|
|
|
$quiet = $_REQUEST["quiet"];
|
2006-10-01 10:05:20 +00:00
|
|
|
|
|
|
|
if ($subop == "edit") {
|
|
|
|
|
2009-12-29 15:49:27 +00:00
|
|
|
$filter_id = db_escape_string($_REQUEST["id"]);
|
2006-10-01 10:05:20 +00:00
|
|
|
|
2010-11-14 20:46:49 +00:00
|
|
|
header("Content-Type: text/xml");
|
|
|
|
print "<dlg id=\"$subop\">";
|
|
|
|
print "<title>".__('Filter Editor')."</title>";
|
|
|
|
print "<content><![CDATA[";
|
|
|
|
|
2006-10-01 10:05:20 +00:00
|
|
|
$result = db_query($link,
|
|
|
|
"SELECT * FROM ttrss_filters WHERE id = '$filter_id' AND owner_uid = " . $_SESSION["uid"]);
|
|
|
|
|
2007-05-19 14:09:16 +00:00
|
|
|
$reg_exp = htmlspecialchars(db_fetch_result($result, 0, "reg_exp"));
|
2006-10-01 10:05:20 +00:00
|
|
|
$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");
|
2006-12-08 07:21:44 +00:00
|
|
|
$action_param = db_fetch_result($result, 0, "action_param");
|
2008-12-13 13:49:19 +00:00
|
|
|
$filter_param = db_fetch_result($result, 0, "filter_param");
|
2006-10-01 10:05:20 +00:00
|
|
|
|
|
|
|
$enabled = sql_bool_to_bool(db_fetch_result($result, 0, "enabled"));
|
2007-01-30 16:23:35 +00:00
|
|
|
$inverse = sql_bool_to_bool(db_fetch_result($result, 0, "inverse"));
|
2006-10-01 10:05:20 +00:00
|
|
|
|
2007-03-02 20:58:29 +00:00
|
|
|
print "<form id=\"filter_edit_form\" onsubmit='return false'>";
|
2006-10-01 10:05:20 +00:00
|
|
|
|
|
|
|
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\">";
|
|
|
|
|
|
|
|
$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"]);
|
2007-08-10 16:16:43 +00:00
|
|
|
$filter_types[$line["id"]] = __($line["description"]);
|
2006-10-01 10:05:20 +00:00
|
|
|
}
|
|
|
|
|
2008-08-06 06:47:56 +00:00
|
|
|
print "<div class=\"dlgSec\">".__("Match")."</div>";
|
|
|
|
|
|
|
|
print "<div class=\"dlgSecCont\">";
|
|
|
|
|
2008-12-13 12:35:26 +00:00
|
|
|
if ($filter_type != 5) {
|
2009-01-11 08:50:16 +00:00
|
|
|
$date_ops_invisible = 'style="display : none"';
|
2008-12-13 12:35:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
print "<span id=\"filter_dlg_date_mod_box\" $date_ops_invisible>";
|
|
|
|
print __("Date") . " ";
|
2008-12-13 13:49:19 +00:00
|
|
|
|
|
|
|
$filter_params = array(
|
|
|
|
"before" => __("before"),
|
|
|
|
"after" => __("after"));
|
|
|
|
|
|
|
|
print_select_hash("filter_date_modifier", $filter_param,
|
|
|
|
$filter_params);
|
|
|
|
|
|
|
|
print " </span>";
|
2008-12-13 12:35:26 +00:00
|
|
|
|
2008-08-06 06:47:56 +00:00
|
|
|
print "<input onkeypress=\"return filterCR(event, filterEditSave)\"
|
|
|
|
name=\"reg_exp\" size=\"30\" value=\"$reg_exp\">";
|
|
|
|
|
2008-12-13 12:35:26 +00:00
|
|
|
print "<span id=\"filter_dlg_date_chk_box\" $date_ops_invisible>";
|
2010-11-11 20:33:52 +00:00
|
|
|
print " <button onclick=\"return filterDlgCheckDate()\">".
|
|
|
|
__('Check it')."</button>";
|
2008-12-13 12:35:26 +00:00
|
|
|
print "</span>";
|
|
|
|
|
|
|
|
print "<br/> " . __("on field") . " ";
|
|
|
|
print_select_hash("filter_type", $filter_type, $filter_types,
|
|
|
|
'onchange="filterDlgCheckType(this)"');
|
2008-08-06 06:47:56 +00:00
|
|
|
|
|
|
|
print "<br/>";
|
|
|
|
|
|
|
|
print __("in") . " ";
|
|
|
|
print_feed_select($link, "feed_id", $feed_id);
|
|
|
|
|
|
|
|
print "</div>";
|
|
|
|
|
2008-08-06 07:51:28 +00:00
|
|
|
print "<div class=\"dlgSec\">".__("Perform Action")."</div>";
|
2008-08-06 06:47:56 +00:00
|
|
|
|
|
|
|
print "<div class=\"dlgSecCont\">";
|
|
|
|
|
|
|
|
print "<select name=\"action_id\"
|
|
|
|
onchange=\"filterDlgCheckAction(this)\">";
|
|
|
|
|
|
|
|
$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>";
|
|
|
|
|
2009-01-18 08:28:42 +00:00
|
|
|
$param_hidden = ($action_id == 4 || $action_id == 6 || $action_id == 7) ? "" : "display : none";
|
2008-08-06 06:47:56 +00:00
|
|
|
|
2008-08-07 03:17:24 +00:00
|
|
|
print "<span id=\"filter_dlg_param_box\" style=\"$param_hidden\">";
|
|
|
|
print " " . __("with parameters:") . " ";
|
2009-01-18 08:28:42 +00:00
|
|
|
|
|
|
|
$param_int_hidden = ($action_id != 7) ? "" : "display : none";
|
|
|
|
|
|
|
|
print "<input size=\"20\" style=\"$param_int_hidden\"
|
2008-08-11 15:31:39 +00:00
|
|
|
onkeypress=\"return filterCR(event, filterEditSave)\"
|
2008-08-07 03:17:24 +00:00
|
|
|
name=\"action_param\" value=\"$action_param\">";
|
2009-01-18 08:28:42 +00:00
|
|
|
|
|
|
|
$param_int_hidden = ($action_id == 7) ? "" : "display : none";
|
|
|
|
|
|
|
|
print_label_select($link, "action_param_label", $action_param,
|
|
|
|
$param_int_hidden);
|
|
|
|
|
2008-08-07 03:17:24 +00:00
|
|
|
print "</span>";
|
2008-08-06 06:47:56 +00:00
|
|
|
|
2008-08-07 03:17:24 +00:00
|
|
|
print " "; // tiny layout hack
|
2008-08-06 06:47:56 +00:00
|
|
|
|
|
|
|
print "</div>";
|
|
|
|
|
|
|
|
print "<div class=\"dlgSec\">".__("Options")."</div>";
|
|
|
|
print "<div class=\"dlgSecCont\">";
|
|
|
|
|
2008-08-06 07:51:28 +00:00
|
|
|
print "<div style=\"line-height : 100%\">";
|
|
|
|
|
2008-08-06 06:47:56 +00:00
|
|
|
if ($enabled) {
|
|
|
|
$checked = "checked";
|
|
|
|
} else {
|
|
|
|
$checked = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
print "<input type=\"checkbox\" name=\"enabled\" id=\"enabled\" $checked>
|
|
|
|
<label for=\"enabled\">".__('Enabled')."</label><br/>";
|
|
|
|
|
|
|
|
if ($inverse) {
|
|
|
|
$checked = "checked";
|
|
|
|
} else {
|
|
|
|
$checked = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
print "<input type=\"checkbox\" name=\"inverse\" id=\"inverse\" $checked>
|
|
|
|
<label for=\"inverse\">".__('Inverse match')."</label>";
|
|
|
|
|
|
|
|
print "</div>";
|
2008-08-06 07:51:28 +00:00
|
|
|
print "</div>";
|
2008-08-06 06:47:56 +00:00
|
|
|
|
|
|
|
print "<div class=\"dlgButtons\">";
|
2006-10-01 10:05:20 +00:00
|
|
|
|
2008-11-17 05:49:06 +00:00
|
|
|
$reg_exp = htmlspecialchars($reg_exp, ENT_QUOTES); // second escaping seems to be needed for javascript
|
2008-08-07 03:17:24 +00:00
|
|
|
|
|
|
|
print "<div style=\"float : left\">";
|
2010-01-12 12:56:29 +00:00
|
|
|
print "<button onclick='return removeFilter($filter_id, \"$reg_exp\")'>".
|
|
|
|
__('Remove')."</button>";
|
2008-08-07 03:17:24 +00:00
|
|
|
print "</div>";
|
|
|
|
|
2010-01-12 12:56:29 +00:00
|
|
|
print "<button onclick=\"return filterEditSave()\">".
|
|
|
|
__('Save')."</button> ";
|
2006-10-01 10:05:20 +00:00
|
|
|
|
2010-01-12 12:56:29 +00:00
|
|
|
print "<button onclick=\"return filterEditCancel()\">".
|
|
|
|
__('Cancel')."</button>";
|
2006-10-01 10:05:20 +00:00
|
|
|
|
2010-11-14 20:46:49 +00:00
|
|
|
print "]]></content></dlg>";
|
2006-10-01 10:05:20 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($subop == "editSave") {
|
|
|
|
|
2010-01-20 09:29:28 +00:00
|
|
|
global $memcache;
|
|
|
|
|
|
|
|
if ($memcache) $memcache->flush();
|
|
|
|
|
2009-12-29 15:49:27 +00:00
|
|
|
$reg_exp = db_escape_string(trim($_REQUEST["reg_exp"]));
|
|
|
|
$filter_type = db_escape_string(trim($_REQUEST["filter_type"]));
|
|
|
|
$filter_id = db_escape_string($_REQUEST["id"]);
|
|
|
|
$feed_id = db_escape_string($_REQUEST["feed_id"]);
|
|
|
|
$action_id = db_escape_string($_REQUEST["action_id"]);
|
|
|
|
$action_param = db_escape_string($_REQUEST["action_param"]);
|
|
|
|
$action_param_label = db_escape_string($_REQUEST["action_param_label"]);
|
|
|
|
$enabled = checkbox_to_sql_bool(db_escape_string($_REQUEST["enabled"]));
|
|
|
|
$inverse = checkbox_to_sql_bool(db_escape_string($_REQUEST["inverse"]));
|
2006-10-01 10:05:20 +00:00
|
|
|
|
2008-12-13 13:49:19 +00:00
|
|
|
# for the time being, no other filters use params anyway...
|
2009-12-29 15:49:27 +00:00
|
|
|
$filter_param = db_escape_string($_REQUEST["filter_date_modifier"]);
|
2008-12-13 13:49:19 +00:00
|
|
|
|
2006-10-01 10:05:20 +00:00
|
|
|
if (!$feed_id) {
|
|
|
|
$feed_id = 'NULL';
|
|
|
|
} else {
|
|
|
|
$feed_id = sprintf("'%s'", db_escape_string($feed_id));
|
|
|
|
}
|
2009-01-18 08:28:42 +00:00
|
|
|
|
|
|
|
/* When processing 'assign label' filters, action_param_label dropbox
|
|
|
|
* overrides action_param */
|
|
|
|
|
|
|
|
if ($action_id == 7) {
|
|
|
|
$action_param = $action_param_label;
|
|
|
|
}
|
|
|
|
|
2006-10-01 10:05:20 +00:00
|
|
|
$result = db_query($link, "UPDATE ttrss_filters SET
|
|
|
|
reg_exp = '$reg_exp',
|
|
|
|
feed_id = $feed_id,
|
|
|
|
action_id = '$action_id',
|
|
|
|
filter_type = '$filter_type',
|
2006-12-08 07:21:44 +00:00
|
|
|
enabled = $enabled,
|
2007-01-30 16:23:35 +00:00
|
|
|
inverse = $inverse,
|
2008-12-13 13:49:19 +00:00
|
|
|
action_param = '$action_param',
|
|
|
|
filter_param = '$filter_param'
|
2007-03-05 12:50:46 +00:00
|
|
|
WHERE id = '$filter_id' AND owner_uid = " . $_SESSION["uid"]);
|
2006-10-01 10:05:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($subop == "remove") {
|
2010-01-28 15:52:46 +00:00
|
|
|
|
|
|
|
if ($memcache) $memcache->flush();
|
2006-10-01 10:05:20 +00:00
|
|
|
|
2009-12-29 15:49:27 +00:00
|
|
|
$ids = split(",", db_escape_string($_REQUEST["ids"]));
|
2006-10-01 10:05:20 +00:00
|
|
|
|
2007-03-05 12:50:46 +00:00
|
|
|
foreach ($ids as $id) {
|
|
|
|
db_query($link, "DELETE FROM ttrss_filters WHERE id = '$id' AND owner_uid = ". $_SESSION["uid"]);
|
2006-10-01 10:05:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($subop == "add") {
|
2010-01-28 15:52:46 +00:00
|
|
|
|
|
|
|
if ($memcache) $memcache->flush();
|
|
|
|
|
2009-12-29 15:49:27 +00:00
|
|
|
$regexp = db_escape_string(trim($_REQUEST["reg_exp"]));
|
|
|
|
$filter_type = db_escape_string(trim($_REQUEST["filter_type"]));
|
|
|
|
$feed_id = db_escape_string($_REQUEST["feed_id"]);
|
|
|
|
$action_id = db_escape_string($_REQUEST["action_id"]);
|
|
|
|
$action_param = db_escape_string($_REQUEST["action_param"]);
|
|
|
|
$action_param_label = db_escape_string($_REQUEST["action_param_label"]);
|
|
|
|
$inverse = checkbox_to_sql_bool(db_escape_string($_REQUEST["inverse"]));
|
2007-03-05 12:50:46 +00:00
|
|
|
|
2008-12-13 13:49:19 +00:00
|
|
|
# for the time being, no other filters use params anyway...
|
2009-12-29 15:49:27 +00:00
|
|
|
$filter_param = db_escape_string($_REQUEST["filter_date_modifier"]);
|
2008-12-13 13:49:19 +00:00
|
|
|
|
2007-03-05 12:50:46 +00:00
|
|
|
if (!$regexp) return;
|
|
|
|
|
|
|
|
if (!$feed_id) {
|
|
|
|
$feed_id = 'NULL';
|
|
|
|
} else {
|
|
|
|
$feed_id = sprintf("'%s'", db_escape_string($feed_id));
|
|
|
|
}
|
|
|
|
|
2009-01-18 10:04:54 +00:00
|
|
|
/* When processing 'assign label' filters, action_param_label dropbox
|
|
|
|
* overrides action_param */
|
|
|
|
|
|
|
|
if ($action_id == 7) {
|
|
|
|
$action_param = $action_param_label;
|
|
|
|
}
|
|
|
|
|
2007-03-05 12:50:46 +00:00
|
|
|
$result = db_query($link,
|
|
|
|
"INSERT INTO ttrss_filters (reg_exp,filter_type,owner_uid,feed_id,
|
2008-12-13 12:22:16 +00:00
|
|
|
action_id, action_param, inverse, filter_param)
|
2007-03-05 12:50:46 +00:00
|
|
|
VALUES
|
|
|
|
('$regexp', '$filter_type','".$_SESSION["uid"]."',
|
2008-12-13 12:22:16 +00:00
|
|
|
$feed_id, '$action_id', '$action_param', $inverse, '$filter_param')");
|
2007-03-05 12:50:46 +00:00
|
|
|
|
2007-03-05 13:45:34 +00:00
|
|
|
if (db_affected_rows($link, $result) != 0) {
|
|
|
|
print T_sprintf("Created filter <b>%s</b>", htmlspecialchars($regexp));
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
2006-10-01 10:05:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($quiet) return;
|
|
|
|
|
2007-05-04 03:26:20 +00:00
|
|
|
set_pref($link, "_PREFS_ACTIVE_TAB", "filterConfig");
|
|
|
|
|
2009-12-29 15:49:27 +00:00
|
|
|
$sort = db_escape_string($_REQUEST["sort"]);
|
2006-10-01 10:05:20 +00:00
|
|
|
|
|
|
|
if (!$sort || $sort == "undefined") {
|
|
|
|
$sort = "reg_exp";
|
|
|
|
}
|
|
|
|
|
|
|
|
$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"];
|
|
|
|
}
|
|
|
|
|
2008-05-17 02:52:46 +00:00
|
|
|
|
2009-12-29 15:49:27 +00:00
|
|
|
$filter_search = db_escape_string($_REQUEST["search"]);
|
2008-05-17 02:52:46 +00:00
|
|
|
|
2009-12-29 15:49:27 +00:00
|
|
|
if (array_key_exists("search", $_REQUEST)) {
|
2008-05-17 02:52:46 +00:00
|
|
|
$_SESSION["prefs_filter_search"] = $filter_search;
|
|
|
|
} else {
|
|
|
|
$filter_search = $_SESSION["prefs_filter_search"];
|
|
|
|
}
|
2010-11-17 11:49:06 +00:00
|
|
|
|
|
|
|
print "<div id=\"pref-filter-wrap\" dojoType=\"dijit.layout.BorderContainer\" gutters=\"false\">";
|
|
|
|
print "<div id=\"pref-filter-header\" dojoType=\"dijit.layout.ContentPane\" region=\"top\">";
|
|
|
|
print "<div id=\"pref-filter-toolbar\" dojoType=\"dijit.Toolbar\">";
|
2008-05-17 02:52:46 +00:00
|
|
|
|
2010-11-17 11:49:06 +00:00
|
|
|
print "<div style='float : right; padding-right : 4px;'>
|
2010-11-17 18:13:41 +00:00
|
|
|
<input dojoType=\"dijit.form.TextBox\" id=\"filter_search\" size=\"20\" type=\"search\"
|
2008-05-17 03:11:51 +00:00
|
|
|
onfocus=\"javascript:disableHotkeys();\"
|
|
|
|
onblur=\"javascript:enableHotkeys();\"
|
2008-05-17 02:52:46 +00:00
|
|
|
onchange=\"javascript:updateFilterList()\" value=\"$filter_search\">
|
2010-11-17 18:13:41 +00:00
|
|
|
<button dojoType=\"dijit.form.Button\" onclick=\"javascript:updateFilterList()\">".__('Search')."</button>
|
2010-01-12 12:56:29 +00:00
|
|
|
</div>";
|
2008-05-17 02:52:46 +00:00
|
|
|
|
2010-11-17 18:39:51 +00:00
|
|
|
print "<div dojoType=\"dijit.form.DropDownButton\">".
|
|
|
|
"<span>" . __('Select')."</span>";
|
|
|
|
print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
|
|
|
|
print "<div onclick=\"selectTableRows('prefFilterList', 'all')\"
|
|
|
|
dojoType=\"dijit.MenuItem\">".__('All')."</div>";
|
|
|
|
print "<div onclick=\"selectTableRows('prefFilterList', 'none')\"
|
|
|
|
dojoType=\"dijit.MenuItem\">".__('None')."</div>";
|
|
|
|
print "</div></div>";
|
|
|
|
|
2010-11-17 18:13:41 +00:00
|
|
|
print "<button dojoType=\"dijit.form.Button\" onclick=\"return quickAddFilter()\">".
|
|
|
|
__('Create filter')."</button dojoType=\"dijit.form.Button\"> ";
|
2007-03-02 19:16:45 +00:00
|
|
|
|
2010-11-17 18:13:41 +00:00
|
|
|
print "<button dojoType=\"dijit.form.Button\" onclick=\"return editSelectedFilter()\">".
|
|
|
|
__('Edit')."</button dojoType=\"dijit.form.Button\"> ";
|
2006-10-01 10:05:20 +00:00
|
|
|
|
2010-11-17 18:13:41 +00:00
|
|
|
print "<button dojoType=\"dijit.form.Button\" onclick=\"return removeSelectedFilters()\">".
|
|
|
|
__('Remove')."</button dojoType=\"dijit.form.Button\"> ";
|
2010-01-11 15:43:53 +00:00
|
|
|
|
2010-11-10 08:49:31 +00:00
|
|
|
if (defined('_ENABLE_FEED_DEBUGGING')) {
|
2010-11-17 18:13:41 +00:00
|
|
|
print "<button dojoType=\"dijit.form.Button\" onclick=\"rescore_all_feeds()\">".
|
|
|
|
__('Rescore articles')."</button dojoType=\"dijit.form.Button\"> ";
|
2010-11-10 08:49:31 +00:00
|
|
|
}
|
2008-05-04 04:46:14 +00:00
|
|
|
|
2010-11-17 11:49:06 +00:00
|
|
|
print "</div>"; # toolbar
|
|
|
|
print "</div>"; # toolbar-frame
|
|
|
|
print "<div id=\"pref-filter-content\" dojoType=\"dijit.layout.ContentPane\" region=\"center\">";
|
|
|
|
|
2008-05-17 02:52:46 +00:00
|
|
|
if ($filter_search) {
|
2009-10-07 11:12:21 +00:00
|
|
|
$filter_search = split(' ', db_escape_string($filter_search));
|
|
|
|
|
|
|
|
$tokens = array();
|
|
|
|
|
|
|
|
foreach ($filter_search as $token) {
|
|
|
|
$token = trim($token);
|
|
|
|
|
|
|
|
array_push($tokens, "(
|
|
|
|
UPPER(ttrss_filter_actions.description) LIKE UPPER('%$token%') OR
|
|
|
|
UPPER(reg_exp) LIKE UPPER('%$token%') OR
|
|
|
|
UPPER(action_param) LIKE UPPER('%$token%') OR
|
|
|
|
UPPER(ttrss_feeds.title) LIKE UPPER('%$token%') OR
|
|
|
|
UPPER(ttrss_filter_types.description) LIKE UPPER('%$token%'))");
|
|
|
|
}
|
|
|
|
|
|
|
|
$filter_search_query = "(" . join($tokens, " AND ") . ") AND ";
|
|
|
|
|
2008-05-17 02:52:46 +00:00
|
|
|
} else {
|
|
|
|
$filter_search_query = "";
|
|
|
|
}
|
|
|
|
|
2006-10-01 10:05:20 +00:00
|
|
|
$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,
|
2007-01-30 16:23:35 +00:00
|
|
|
inverse,
|
2006-10-01 10:05:20 +00:00
|
|
|
feed_id,
|
2008-12-16 07:21:35 +00:00
|
|
|
filter_param,
|
2008-12-13 14:02:19 +00:00
|
|
|
filter_type,
|
2006-10-01 10:05:20 +00:00
|
|
|
ttrss_filter_actions.description AS action_description,
|
2008-04-30 07:20:33 +00:00
|
|
|
ttrss_feeds.title AS feed_title,
|
|
|
|
ttrss_filter_actions.name AS action_name,
|
|
|
|
ttrss_filters.action_param AS action_param
|
2006-10-01 10:05:20 +00:00
|
|
|
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
|
2008-05-17 02:52:46 +00:00
|
|
|
$filter_search_query
|
2006-10-01 10:05:20 +00:00
|
|
|
ttrss_filter_actions.id = action_id AND
|
|
|
|
ttrss_filters.owner_uid = ".$_SESSION["uid"]."
|
2008-04-30 16:39:39 +00:00
|
|
|
ORDER by action_description, $sort");
|
2006-10-01 10:05:20 +00:00
|
|
|
|
|
|
|
if (db_num_rows($result) != 0) {
|
|
|
|
|
|
|
|
print "<p><table width=\"100%\" cellspacing=\"0\" class=\"prefFilterList\"
|
|
|
|
id=\"prefFilterList\">";
|
|
|
|
|
|
|
|
print "<tr><td class=\"selectPrompt\" colspan=\"8\">
|
2007-05-14 07:56:49 +00:00
|
|
|
".__('Select:')."
|
2010-11-12 10:52:53 +00:00
|
|
|
<a href=\"#\" onclick=\"selectTableRows('prefFilterList', 'all')\">".__('All')."</a>,
|
|
|
|
<a href=\"#\" onclick=\"selectTableRows('prefFilterList', 'none')\">".__('None')."</a>
|
2006-10-01 10:05:20 +00:00
|
|
|
</td</tr>";
|
|
|
|
|
|
|
|
$lnum = 0;
|
2008-04-30 16:39:39 +00:00
|
|
|
|
|
|
|
$cur_action_description = "";
|
|
|
|
|
2006-10-01 10:05:20 +00:00
|
|
|
while ($line = db_fetch_assoc($result)) {
|
|
|
|
|
|
|
|
$filter_id = $line["id"];
|
2009-12-29 15:49:27 +00:00
|
|
|
$edit_filter_id = $_REQUEST["id"];
|
2006-10-01 10:05:20 +00:00
|
|
|
|
|
|
|
$enabled = sql_bool_to_bool($line["enabled"]);
|
2007-01-30 16:23:35 +00:00
|
|
|
$inverse = sql_bool_to_bool($line["inverse"]);
|
|
|
|
|
2010-01-14 16:36:52 +00:00
|
|
|
$this_row_id = "id=\"FILRR-$filter_id\"";
|
2008-04-30 16:39:39 +00:00
|
|
|
|
|
|
|
$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 "<tr><td class='filterEditCat' colspan='6'>$cur_action_description</td></tr>";
|
|
|
|
|
|
|
|
print "<tr class=\"title\">
|
|
|
|
<td align='center' width=\"5%\"> </td>
|
2010-11-11 15:59:21 +00:00
|
|
|
<td width=\"20%\"><a href=\"#\" onclick=\"updateFilterList('reg_exp')\">".__('Match')."</a></td>
|
|
|
|
<td width=\"\"><a href=\"#\" onclick=\"updateFilterList('feed_title')\">".__('Feed')."</a></td>
|
|
|
|
<td width=\"20%\"><a href=\"#\" onclick=\"updateFilterList('filter_type')\">".__('Field')."</a></td>
|
|
|
|
<td width=\"20%\"><a href=\"#\" onclick=\"updateFilterList('action_param')\">".__('Params')."</a></td>";
|
2008-04-30 16:39:39 +00:00
|
|
|
|
2010-01-14 16:36:52 +00:00
|
|
|
$lnum = 0;
|
2008-04-30 16:39:39 +00:00
|
|
|
}
|
|
|
|
|
2010-01-14 16:36:52 +00:00
|
|
|
$class = ($lnum % 2) ? "even" : "odd";
|
|
|
|
|
2006-10-01 10:05:20 +00:00
|
|
|
print "<tr class=\"$class\" $this_row_id>";
|
|
|
|
|
2007-05-19 14:09:16 +00:00
|
|
|
$line["reg_exp"] = htmlspecialchars($line["reg_exp"]);
|
2006-10-01 10:05:20 +00:00
|
|
|
|
2007-03-05 11:02:18 +00:00
|
|
|
if (!$line["feed_title"]) $line["feed_title"] = __("All feeds");
|
2008-05-04 04:19:19 +00:00
|
|
|
|
2010-11-11 20:23:29 +00:00
|
|
|
if (array_search($line["action_name"],
|
|
|
|
array("score", "tag", "label")) === false) {
|
|
|
|
|
|
|
|
$line["action_param"] = false;
|
|
|
|
}
|
|
|
|
|
2008-05-04 04:19:19 +00:00
|
|
|
if (!$line["action_param"]) {
|
2008-12-13 12:42:58 +00:00
|
|
|
$line["action_param"] = "—";
|
2008-05-04 04:19:19 +00:00
|
|
|
} else if ($line["action_name"] == "score") {
|
|
|
|
|
2010-01-14 20:09:23 +00:00
|
|
|
$score_pic = theme_image($link,
|
|
|
|
"images/" . get_score_pic($line["action_param"]));
|
2008-05-04 04:19:19 +00:00
|
|
|
|
2010-01-14 20:09:23 +00:00
|
|
|
$score_pic = "<img class='hlScorePic' src=\"$score_pic\">";
|
2008-05-04 04:19:19 +00:00
|
|
|
|
|
|
|
$line["action_param"] = "$score_pic " . $line["action_param"];
|
|
|
|
|
|
|
|
}
|
2006-10-01 10:05:20 +00:00
|
|
|
|
2007-05-19 14:09:16 +00:00
|
|
|
$line["feed_title"] = htmlspecialchars($line["feed_title"]);
|
2006-10-01 10:05:20 +00:00
|
|
|
|
2010-11-11 15:59:21 +00:00
|
|
|
print "<td align='center'><input onclick='toggleSelectRow(this);'
|
2006-10-01 10:05:20 +00:00
|
|
|
type=\"checkbox\" id=\"FICHK-".$line["id"]."\"></td>";
|
|
|
|
|
2008-12-16 07:21:35 +00:00
|
|
|
$filter_params = array(
|
|
|
|
"before" => __("before"),
|
|
|
|
"after" => __("after"));
|
2009-02-12 18:54:07 +00:00
|
|
|
|
|
|
|
if ($line["action_name"] == 'label') {
|
|
|
|
|
|
|
|
$tmp_result = db_query($link, "SELECT fg_color, bg_color
|
|
|
|
FROM ttrss_labels2 WHERE caption = '".
|
|
|
|
db_escape_string($line["action_param"])."' AND
|
|
|
|
owner_uid = " . $_SESSION["uid"]);
|
|
|
|
|
|
|
|
$fg_color = db_fetch_result($tmp_result, 0, "fg_color");
|
|
|
|
$bg_color = db_fetch_result($tmp_result, 0, "bg_color");
|
|
|
|
|
|
|
|
$tmp = "<div class='labelColorIndicator' id='LICID-$id'
|
|
|
|
style='color : $fg_color; background-color : $bg_color'>
|
|
|
|
α";
|
|
|
|
$tmp .= "</div>";
|
|
|
|
|
|
|
|
$line["action_param"] = "$tmp " . $line["action_param"];
|
|
|
|
}
|
|
|
|
|
2008-12-16 07:21:35 +00:00
|
|
|
if ($line["filter_type"] == 5) {
|
|
|
|
|
|
|
|
if (!strtotime($line["reg_exp"])) {
|
|
|
|
$line["reg_exp"] = "<span class=\"filterDateError\">" .
|
|
|
|
$line["reg_exp"] . "</span>";
|
|
|
|
}
|
|
|
|
|
|
|
|
$line["reg_exp"] = __("Date") . " " .
|
|
|
|
$filter_params[$line['filter_param']] . " " .
|
|
|
|
$line["reg_exp"];
|
|
|
|
}
|
|
|
|
|
2006-10-01 10:05:20 +00:00
|
|
|
if (!$enabled) {
|
|
|
|
$line["reg_exp"] = "<span class=\"insensitive\">" .
|
2007-03-05 11:02:18 +00:00
|
|
|
$line["reg_exp"] . " " . __("(Disabled)")."</span>";
|
2006-10-01 10:05:20 +00:00
|
|
|
$line["feed_title"] = "<span class=\"insensitive\">" .
|
|
|
|
$line["feed_title"] . "</span>";
|
|
|
|
$line["filter_type_descr"] = "<span class=\"insensitive\">" .
|
|
|
|
$line["filter_type_descr"] . "</span>";
|
|
|
|
$line["action_description"] = "<span class=\"insensitive\">" .
|
|
|
|
$line["action_description"] . "</span>";
|
2008-04-30 16:39:39 +00:00
|
|
|
$line["action_param"] = "<span class=\"insensitive\">" .
|
|
|
|
$line["action_param"] . "</span>";
|
2006-10-01 10:05:20 +00:00
|
|
|
}
|
2008-05-17 15:36:35 +00:00
|
|
|
|
2010-11-11 15:59:21 +00:00
|
|
|
$onclick = "onclick='editFilter($filter_id, event)' title='".__('Click to edit')."'";
|
2008-05-17 15:36:35 +00:00
|
|
|
|
2007-01-30 16:23:35 +00:00
|
|
|
$inverse_label = "";
|
|
|
|
|
|
|
|
if ($inverse) {
|
2007-03-05 11:02:18 +00:00
|
|
|
$inverse_label = " <span class='insensitive'>".__('(Inverse)')."</span>";
|
2007-01-30 16:23:35 +00:00
|
|
|
}
|
2008-12-13 14:02:19 +00:00
|
|
|
|
|
|
|
print "<td $onclick>" . $line["reg_exp"] . "$inverse_label</td>";
|
|
|
|
print "<td $onclick>" . $line["feed_title"] . "</td>";
|
2006-10-01 10:05:20 +00:00
|
|
|
|
2008-12-13 14:02:19 +00:00
|
|
|
print "<td $onclick>" . $line["filter_type_descr"] . "</td>";
|
2008-12-13 12:42:58 +00:00
|
|
|
print "<td $onclick>" . $line["action_param"] . "</td>";
|
2008-04-30 07:20:33 +00:00
|
|
|
|
2006-10-01 10:05:20 +00:00
|
|
|
print "</tr>";
|
|
|
|
|
|
|
|
++$lnum;
|
|
|
|
}
|
2008-05-17 03:32:36 +00:00
|
|
|
|
2006-10-01 10:05:20 +00:00
|
|
|
print "</table>";
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
2008-05-17 02:52:46 +00:00
|
|
|
print "<p>";
|
|
|
|
if (!$filter_search) {
|
2009-10-06 09:37:24 +00:00
|
|
|
print_warning(__('No filters defined.'));
|
2008-05-17 02:52:46 +00:00
|
|
|
} else {
|
2009-10-06 09:37:24 +00:00
|
|
|
print_warning(__('No matching filters found.'));
|
2008-05-17 02:52:46 +00:00
|
|
|
}
|
|
|
|
print "</p>";
|
2006-10-01 10:05:20 +00:00
|
|
|
|
|
|
|
}
|
2010-11-17 11:49:06 +00:00
|
|
|
|
|
|
|
print "</div>"; #pane
|
|
|
|
print "</div>"; #container
|
2006-10-01 10:05:20 +00:00
|
|
|
}
|
2009-01-18 08:28:42 +00:00
|
|
|
|
2006-10-01 10:05:20 +00:00
|
|
|
?>
|