rework filter dialog to make feed/category selection easier
This commit is contained in:
parent
183ca8b940
commit
4c9d0490c6
|
@ -548,8 +548,8 @@ class Dlg extends Handler_Protected {
|
||||||
print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"inverse\" id=\"inverse\">
|
print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"inverse\" id=\"inverse\">
|
||||||
<label for=\"inverse\">".__('Inverse match')."</label><hr/>";
|
<label for=\"inverse\">".__('Inverse match')."</label><hr/>";
|
||||||
|
|
||||||
print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"cat_filter\" id=\"cat_filter\" onchange=\"filterDlgCheckCat(this)\">
|
# print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"cat_filter\" id=\"cat_filter\" onchange=\"filterDlgCheckCat(this)\">
|
||||||
<label for=\"cat_filter\">".__('Apply to category')."</label><hr/>";
|
# <label for=\"cat_filter\">".__('Apply to category')."</label><hr/>";
|
||||||
|
|
||||||
|
|
||||||
print "</div>";
|
print "</div>";
|
||||||
|
|
|
@ -225,8 +225,8 @@ class Pref_Filters extends Handler_Protected {
|
||||||
|
|
||||||
$reg_exp = htmlspecialchars(db_fetch_result($result, 0, "reg_exp"));
|
$reg_exp = htmlspecialchars(db_fetch_result($result, 0, "reg_exp"));
|
||||||
$filter_type = db_fetch_result($result, 0, "filter_type");
|
$filter_type = db_fetch_result($result, 0, "filter_type");
|
||||||
$feed_id = db_fetch_result($result, 0, "feed_id");
|
$feed_id = (int) db_fetch_result($result, 0, "feed_id");
|
||||||
$cat_id = db_fetch_result($result, 0, "cat_id");
|
$cat_id = (int) db_fetch_result($result, 0, "cat_id");
|
||||||
$action_id = db_fetch_result($result, 0, "action_id");
|
$action_id = db_fetch_result($result, 0, "action_id");
|
||||||
$action_param = db_fetch_result($result, 0, "action_param");
|
$action_param = db_fetch_result($result, 0, "action_param");
|
||||||
$filter_param = db_fetch_result($result, 0, "filter_param");
|
$filter_param = db_fetch_result($result, 0, "filter_param");
|
||||||
|
@ -289,21 +289,11 @@ class Pref_Filters extends Handler_Protected {
|
||||||
|
|
||||||
print __("in") . " ";
|
print __("in") . " ";
|
||||||
|
|
||||||
$hidden = $cat_filter ? "style='display:none'" : "";
|
print "<span id='filterDlg_feeds'>";
|
||||||
|
print_feed_select($this->link, "feed_id", ($cat_filter) ? "CAT:$cat_id" : $feed_id,
|
||||||
print "<span id='filterDlg_feeds' $hidden>";
|
|
||||||
print_feed_select($this->link, "feed_id", $feed_id,
|
|
||||||
'dojoType="dijit.form.FilteringSelect"');
|
'dojoType="dijit.form.FilteringSelect"');
|
||||||
print "</span>";
|
print "</span>";
|
||||||
|
|
||||||
$hidden = $cat_filter ? "" : "style='display:none'";
|
|
||||||
|
|
||||||
print "<span id='filterDlg_cats' $hidden>";
|
|
||||||
print_feed_cat_select($this->link, "cat_id", $cat_id,
|
|
||||||
'dojoType="dijit.form.FilteringSelect"');
|
|
||||||
print "</span>";
|
|
||||||
|
|
||||||
|
|
||||||
print "</div>";
|
print "</div>";
|
||||||
|
|
||||||
print "<div class=\"dlgSec\">".__("Perform Action")."</div>";
|
print "<div class=\"dlgSec\">".__("Perform Action")."</div>";
|
||||||
|
@ -369,14 +359,14 @@ class Pref_Filters extends Handler_Protected {
|
||||||
print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"inverse\" id=\"inverse\" $checked>
|
print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"inverse\" id=\"inverse\" $checked>
|
||||||
<label for=\"inverse\">".__('Inverse match')."</label><hr/>";
|
<label for=\"inverse\">".__('Inverse match')."</label><hr/>";
|
||||||
|
|
||||||
if ($cat_filter) {
|
# if ($cat_filter) {
|
||||||
$checked = "checked=\"1\"";
|
# $checked = "checked=\"1\"";
|
||||||
} else {
|
# } else {
|
||||||
$checked = "";
|
# $checked = "";
|
||||||
}
|
# }
|
||||||
|
|
||||||
print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"cat_filter\" id=\"cat_filter\" onchange=\"filterDlgCheckCat(this)\" $checked>
|
# print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"cat_filter\" id=\"cat_filter\" onchange=\"filterDlgCheckCat(this)\" $checked>
|
||||||
<label for=\"cat_filter\">".__('Apply to category')."</label><hr/>";
|
# <label for=\"cat_filter\">".__('Apply to category')."</label><hr/>";
|
||||||
|
|
||||||
print "</div>";
|
print "</div>";
|
||||||
print "</div>";
|
print "</div>";
|
||||||
|
@ -412,23 +402,25 @@ class Pref_Filters extends Handler_Protected {
|
||||||
$action_param_label = db_escape_string($_REQUEST["action_param_label"]);
|
$action_param_label = db_escape_string($_REQUEST["action_param_label"]);
|
||||||
$enabled = checkbox_to_sql_bool(db_escape_string($_REQUEST["enabled"]));
|
$enabled = checkbox_to_sql_bool(db_escape_string($_REQUEST["enabled"]));
|
||||||
$inverse = checkbox_to_sql_bool(db_escape_string($_REQUEST["inverse"]));
|
$inverse = checkbox_to_sql_bool(db_escape_string($_REQUEST["inverse"]));
|
||||||
$cat_filter = checkbox_to_sql_bool(db_escape_string($_REQUEST["cat_filter"]));
|
|
||||||
$cat_id = db_escape_string($_REQUEST['cat_id']);
|
|
||||||
|
|
||||||
# for the time being, no other filters use params anyway...
|
# for the time being, no other filters use params anyway...
|
||||||
$filter_param = db_escape_string($_REQUEST["filter_date_modifier"]);
|
$filter_param = db_escape_string($_REQUEST["filter_date_modifier"]);
|
||||||
|
|
||||||
if (!$feed_id) {
|
if (strpos($feed_id, "CAT:") === 0) {
|
||||||
$feed_id = 'NULL';
|
$cat_filter = true;
|
||||||
|
$cat_id = (int) substr($feed_id, 4);
|
||||||
|
$feed_id = "NULL";
|
||||||
} else {
|
} else {
|
||||||
$feed_id = sprintf("'%s'", db_escape_string($feed_id));
|
$cat_filter = false;
|
||||||
|
$feed_id = (int) $feed_id;
|
||||||
|
$cat_id = "NULL";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$cat_id) {
|
$raw_feed_id = (int) $feed_id;
|
||||||
$cat_id = 'NULL';
|
$raw_cat_id = (int) $cat_id;
|
||||||
} else {
|
|
||||||
$cat_id = sprintf("'%d'", db_escape_string($cat_id));
|
if (!$feed_id) $feed_id = "NULL";
|
||||||
}
|
if (!$cat_id) $feed_id = "NULL";
|
||||||
|
|
||||||
/* When processing 'assign label' filters, action_param_label dropbox
|
/* When processing 'assign label' filters, action_param_label dropbox
|
||||||
* overrides action_param */
|
* overrides action_param */
|
||||||
|
@ -450,7 +442,7 @@ class Pref_Filters extends Handler_Protected {
|
||||||
filter_type = '$filter_type',
|
filter_type = '$filter_type',
|
||||||
enabled = $enabled,
|
enabled = $enabled,
|
||||||
inverse = $inverse,
|
inverse = $inverse,
|
||||||
cat_filter = $cat_filter,
|
cat_filter = ".bool_to_sql_bool($cat_filter).",
|
||||||
action_param = '$action_param',
|
action_param = '$action_param',
|
||||||
filter_param = '$filter_param'
|
filter_param = '$filter_param'
|
||||||
WHERE id = '$filter_id' AND owner_uid = " . $_SESSION["uid"]);
|
WHERE id = '$filter_id' AND owner_uid = " . $_SESSION["uid"]);
|
||||||
|
@ -458,8 +450,7 @@ class Pref_Filters extends Handler_Protected {
|
||||||
|
|
||||||
$this->filter_test($filter_type, $reg_exp,
|
$this->filter_test($filter_type, $reg_exp,
|
||||||
$action_id, $action_param, $filter_param, sql_bool_to_bool($inverse),
|
$action_id, $action_param, $filter_param, sql_bool_to_bool($inverse),
|
||||||
(int) $_REQUEST["feed_id"], (int) $_REQUEST['cat_id'],
|
$raw_feed_id, $raw_cat_id, $cat_filter);
|
||||||
sql_bool_to_bool($cat_filter));
|
|
||||||
|
|
||||||
print "<div align='center'>";
|
print "<div align='center'>";
|
||||||
print "<button dojoType=\"dijit.form.Button\"
|
print "<button dojoType=\"dijit.form.Button\"
|
||||||
|
@ -485,29 +476,33 @@ class Pref_Filters extends Handler_Protected {
|
||||||
$regexp = db_escape_string(trim($_REQUEST["reg_exp"]));
|
$regexp = db_escape_string(trim($_REQUEST["reg_exp"]));
|
||||||
$filter_type = db_escape_string(trim($_REQUEST["filter_type"]));
|
$filter_type = db_escape_string(trim($_REQUEST["filter_type"]));
|
||||||
$feed_id = db_escape_string($_REQUEST["feed_id"]);
|
$feed_id = db_escape_string($_REQUEST["feed_id"]);
|
||||||
$cat_id = db_escape_string($_REQUEST["cat_id"]);
|
# $cat_id = db_escape_string($_REQUEST["cat_id"]);
|
||||||
$action_id = db_escape_string($_REQUEST["action_id"]);
|
$action_id = db_escape_string($_REQUEST["action_id"]);
|
||||||
$action_param = db_escape_string($_REQUEST["action_param"]);
|
$action_param = db_escape_string($_REQUEST["action_param"]);
|
||||||
$action_param_label = db_escape_string($_REQUEST["action_param_label"]);
|
$action_param_label = db_escape_string($_REQUEST["action_param_label"]);
|
||||||
$inverse = checkbox_to_sql_bool(db_escape_string($_REQUEST["inverse"]));
|
$inverse = checkbox_to_sql_bool(db_escape_string($_REQUEST["inverse"]));
|
||||||
$cat_filter = checkbox_to_sql_bool(db_escape_string($_REQUEST["cat_filter"]));
|
# $cat_filter = checkbox_to_sql_bool(db_escape_string($_REQUEST["cat_filter"]));
|
||||||
|
|
||||||
# for the time being, no other filters use params anyway...
|
# for the time being, no other filters use params anyway...
|
||||||
$filter_param = db_escape_string($_REQUEST["filter_date_modifier"]);
|
$filter_param = db_escape_string($_REQUEST["filter_date_modifier"]);
|
||||||
|
|
||||||
if (!$regexp) return;
|
if (!$regexp) return;
|
||||||
|
|
||||||
if (!$feed_id) {
|
if (strpos($feed_id, "CAT:") === 0) {
|
||||||
$feed_id = 'NULL';
|
$cat_filter = true;
|
||||||
|
$cat_id = (int) substr($feed_id, 4);
|
||||||
|
$feed_id = "NULL";
|
||||||
} else {
|
} else {
|
||||||
$feed_id = sprintf("'%s'", db_escape_string($feed_id));
|
$cat_filter = false;
|
||||||
|
$feed_id = (int) $feed_id;
|
||||||
|
$cat_id = "NULL";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$cat_id) {
|
$raw_feed_id = (int) $feed_id;
|
||||||
$cat_id = 'NULL';
|
$raw_cat_id = (int) $cat_id;
|
||||||
} else {
|
|
||||||
$cat_id = sprintf("'%d'", db_escape_string($cat_id));
|
if (!$feed_id) $feed_id = "NULL";
|
||||||
}
|
if (!$cat_id) $feed_id = "NULL";
|
||||||
|
|
||||||
/* When processing 'assign label' filters, action_param_label dropbox
|
/* When processing 'assign label' filters, action_param_label dropbox
|
||||||
* overrides action_param */
|
* overrides action_param */
|
||||||
|
@ -527,7 +522,7 @@ class Pref_Filters extends Handler_Protected {
|
||||||
VALUES
|
VALUES
|
||||||
('$regexp', '$filter_type','".$_SESSION["uid"]."',
|
('$regexp', '$filter_type','".$_SESSION["uid"]."',
|
||||||
$feed_id, '$action_id', '$action_param', $inverse,
|
$feed_id, '$action_id', '$action_param', $inverse,
|
||||||
'$filter_param', $cat_id, $cat_filter)");
|
'$filter_param', $cat_id, ".bool_to_sql_bool($cat_filter).")");
|
||||||
|
|
||||||
if (db_affected_rows($this->link, $result) != 0) {
|
if (db_affected_rows($this->link, $result) != 0) {
|
||||||
print T_sprintf("Created filter <b>%s</b>", htmlspecialchars($regexp));
|
print T_sprintf("Created filter <b>%s</b>", htmlspecialchars($regexp));
|
||||||
|
@ -537,8 +532,8 @@ class Pref_Filters extends Handler_Protected {
|
||||||
|
|
||||||
$this->filter_test($filter_type, $regexp,
|
$this->filter_test($filter_type, $regexp,
|
||||||
$action_id, $action_param, $filter_param, sql_bool_to_bool($inverse),
|
$action_id, $action_param, $filter_param, sql_bool_to_bool($inverse),
|
||||||
(int) $_REQUEST["feed_id"], (int) $_REQUEST['cat_id'],
|
$raw_feed_id, $raw_cat_id,
|
||||||
sql_bool_to_bool($cat_filter));
|
$cat_filter);
|
||||||
|
|
||||||
print "<div align='center'>";
|
print "<div align='center'>";
|
||||||
print "<button dojoType=\"dijit.form.Button\"
|
print "<button dojoType=\"dijit.form.Button\"
|
||||||
|
|
|
@ -1887,34 +1887,98 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function print_feed_select($link, $id, $default_id = "",
|
function print_feed_select($link, $id, $default_id = "",
|
||||||
$attributes = "", $include_all_feeds = true) {
|
$attributes = "", $include_all_feeds = true,
|
||||||
|
$root_id = false, $nest_level = 0) {
|
||||||
|
|
||||||
print "<select id=\"$id\" name=\"$id\" $attributes>";
|
if (!$root_id) {
|
||||||
if ($include_all_feeds) {
|
print "<select id=\"$id\" name=\"$id\" $attributes>";
|
||||||
print "<option value=\"0\">".__('All feeds')."</option>";
|
if ($include_all_feeds) {
|
||||||
|
$is_selected = ("0" == $default_id) ? "selected=\"1\"" : "";
|
||||||
|
print "<option $is_selected value=\"0\">".__('All feeds')."</option>";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = db_query($link, "SELECT id,title FROM ttrss_feeds
|
if (get_pref($link, 'ENABLE_FEED_CATS')) {
|
||||||
WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title");
|
|
||||||
|
|
||||||
if (db_num_rows($result) > 0 && $include_all_feeds) {
|
if ($root_id)
|
||||||
print "<option disabled>--------</option>";
|
$parent_qpart = "parent_cat = '$root_id'";
|
||||||
}
|
else
|
||||||
|
$parent_qpart = "parent_cat IS NULL";
|
||||||
|
|
||||||
while ($line = db_fetch_assoc($result)) {
|
$result = db_query($link, "SELECT id,title,
|
||||||
if ($line["id"] == $default_id) {
|
(SELECT COUNT(id) FROM ttrss_feed_categories AS c2 WHERE
|
||||||
$is_selected = "selected=\"1\"";
|
c2.parent_cat = ttrss_feed_categories.id) AS num_children
|
||||||
} else {
|
FROM ttrss_feed_categories
|
||||||
$is_selected = "";
|
WHERE owner_uid = ".$_SESSION["uid"]." AND $parent_qpart ORDER BY title");
|
||||||
|
|
||||||
|
while ($line = db_fetch_assoc($result)) {
|
||||||
|
|
||||||
|
for ($i = 0; $i < $nest_level; $i++)
|
||||||
|
$line["title"] = " - " . $line["title"];
|
||||||
|
|
||||||
|
$is_selected = ("CAT:".$line["id"] == $default_id) ? "selected=\"1\"" : "";
|
||||||
|
|
||||||
|
printf("<option $is_selected value='CAT:%d'>%s</option>",
|
||||||
|
$line["id"], htmlspecialchars($line["title"]));
|
||||||
|
|
||||||
|
if ($line["num_children"] > 0)
|
||||||
|
print_feed_select($link, $id, $default_id, $attributes,
|
||||||
|
$include_all_feeds, $line["id"], $nest_level+1);
|
||||||
|
|
||||||
|
$feed_result = db_query($link, "SELECT id,title FROM ttrss_feeds
|
||||||
|
WHERE cat_id = '".$line["id"]."' AND owner_uid = ".$_SESSION["uid"] . " ORDER BY title");
|
||||||
|
|
||||||
|
while ($fline = db_fetch_assoc($feed_result)) {
|
||||||
|
$is_selected = ($fline["id"] == $default_id) ? "selected=\"1\"" : "";
|
||||||
|
|
||||||
|
$fline["title"] = " + " . $fline["title"];
|
||||||
|
|
||||||
|
for ($i = 0; $i < $nest_level; $i++)
|
||||||
|
$fline["title"] = " - " . $fline["title"];
|
||||||
|
|
||||||
|
printf("<option $is_selected value='%d'>%s</option>",
|
||||||
|
$fline["id"], htmlspecialchars($fline["title"]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$title = truncate_string(htmlspecialchars($line["title"]), 40);
|
if (!$root_id) {
|
||||||
|
$is_selected = ($default_id == "CAT:0") ? "selected=\"1\"" : "";
|
||||||
|
|
||||||
printf("<option $is_selected value='%d'>%s</option>",
|
printf("<option $is_selected value='CAT:0'>%s</option>",
|
||||||
$line["id"], $title);
|
__("Uncategorized"));
|
||||||
|
|
||||||
|
$feed_result = db_query($link, "SELECT id,title FROM ttrss_feeds
|
||||||
|
WHERE cat_id IS NULL AND owner_uid = ".$_SESSION["uid"] . " ORDER BY title");
|
||||||
|
|
||||||
|
while ($fline = db_fetch_assoc($feed_result)) {
|
||||||
|
$is_selected = ($fline["id"] == $default_id && !$default_is_cat) ? "selected=\"1\"" : "";
|
||||||
|
|
||||||
|
$fline["title"] = " + " . $fline["title"];
|
||||||
|
|
||||||
|
for ($i = 0; $i < $nest_level; $i++)
|
||||||
|
$fline["title"] = " - " . $fline["title"];
|
||||||
|
|
||||||
|
printf("<option $is_selected value='%d'>%s</option>",
|
||||||
|
$fline["id"], htmlspecialchars($fline["title"]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$result = db_query($link, "SELECT id,title FROM ttrss_feeds
|
||||||
|
WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title");
|
||||||
|
|
||||||
|
while ($line = db_fetch_assoc($result)) {
|
||||||
|
|
||||||
|
$is_selected = ($line["id"] == $default_id) ? "selected=\"1\"" : "";
|
||||||
|
|
||||||
|
printf("<option $is_selected value='%d'>%s</option>",
|
||||||
|
$line["id"], htmlspecialchars($line["title"]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print "</select>";
|
if (!$root_id) {
|
||||||
|
print "</select>";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function print_feed_cat_select($link, $id, $default_id,
|
function print_feed_cat_select($link, $id, $default_id,
|
||||||
|
|
|
@ -545,21 +545,6 @@ function fatalError(code, msg, ext_info) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function filterDlgCheckCat(sender) {
|
|
||||||
try {
|
|
||||||
if (sender.checked) {
|
|
||||||
Element.show('filterDlg_cats');
|
|
||||||
Element.hide('filterDlg_feeds');
|
|
||||||
} else {
|
|
||||||
Element.show('filterDlg_feeds');
|
|
||||||
Element.hide('filterDlg_cats');
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (e) {
|
|
||||||
exception_error("filterDlgCheckCat", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function filterDlgCheckType(sender) {
|
function filterDlgCheckType(sender) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue