diff --git a/functions.js b/functions.js
index 3b18b007..ee92674e 100644
--- a/functions.js
+++ b/functions.js
@@ -969,6 +969,24 @@ function quickAddFilter() {
id: "filterEditDlg",
title: __("Create Filter"),
style: "width: 600px",
+ test: function() {
+ if (this.validate()) {
+
+ if (dijit.byId("filterTestDlg"))
+ dijit.byId("filterTestDlg").destroyRecursive();
+
+ tdialog = new dijit.Dialog({
+ id: "filterTestDlg",
+ title: __("Filter Test Results"),
+ style: "width: 600px",
+ href: "backend.php?savemode=test&" +
+ dojo.objectToQuery(dialog.attr('value')),
+ });
+
+ tdialog.show();
+
+ }
+ },
execute: function() {
if (this.validate()) {
diff --git a/modules/popup-dialog.php b/modules/popup-dialog.php
index dbbd1fb3..78962dc6 100644
--- a/modules/popup-dialog.php
+++ b/modules/popup-dialog.php
@@ -526,6 +526,9 @@
print "
";
+ print " ";
+
print " ";
@@ -267,6 +364,7 @@
if ($memcache) $memcache->flush();
+ $savemode = db_escape_string($_REQUEST["savemode"]);
$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"]);
@@ -297,7 +395,8 @@
$action_param = (int) str_replace("+", "", $action_param);
}
- $result = db_query($link, "UPDATE ttrss_filters SET
+ if ($savemode != "test") {
+ $result = db_query($link, "UPDATE ttrss_filters SET
reg_exp = '$reg_exp',
feed_id = $feed_id,
action_id = '$action_id',
@@ -307,6 +406,21 @@
action_param = '$action_param',
filter_param = '$filter_param'
WHERE id = '$filter_id' AND owner_uid = " . $_SESSION["uid"]);
+ } else {
+
+ filter_test($link, $filter_type, $reg_exp,
+ $action_id, $action_param, $filter_param, sql_bool_to_bool($inverse),
+ $feed_id);
+
+ print "";
+ print "";
+ print "
";
+
+ }
+
+ return;
}
if ($subop == "remove") {
@@ -325,6 +439,7 @@
if ($memcache) $memcache->flush();
+ $savemode = db_escape_string($_REQUEST["savemode"]);
$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"]);
@@ -355,15 +470,31 @@
$action_param = (int) str_replace("+", "", $action_param);
}
- $result = db_query($link,
- "INSERT INTO ttrss_filters (reg_exp,filter_type,owner_uid,feed_id,
- action_id, action_param, inverse, filter_param)
- VALUES
- ('$regexp', '$filter_type','".$_SESSION["uid"]."',
- $feed_id, '$action_id', '$action_param', $inverse, '$filter_param')");
+ if ($savemode != "test") {
+ $result = db_query($link,
+ "INSERT INTO ttrss_filters (reg_exp,filter_type,owner_uid,feed_id,
+ action_id, action_param, inverse, filter_param)
+ VALUES
+ ('$regexp', '$filter_type','".$_SESSION["uid"]."',
+ $feed_id, '$action_id', '$action_param', $inverse,
+ '$filter_param')");
+
+ if (db_affected_rows($link, $result) != 0) {
+ print T_sprintf("Created filter %s", htmlspecialchars($regexp));
+ }
+
+ } else {
+
+ filter_test($link, $filter_type, $regexp,
+ $action_id, $action_param, $filter_param, sql_bool_to_bool($inverse),
+ $feed_id);
+
+ print "";
+ print "";
+ print "
";
- if (db_affected_rows($link, $result) != 0) {
- print T_sprintf("Created filter %s", htmlspecialchars($regexp));
}
return;
diff --git a/prefs.js b/prefs.js
index 05052093..2a054df5 100644
--- a/prefs.js
+++ b/prefs.js
@@ -180,7 +180,24 @@ function editFilter(id) {
} });
}
},
+ test: function() {
+ if (this.validate()) {
+ if (dijit.byId("filterTestDlg"))
+ dijit.byId("filterTestDlg").destroyRecursive();
+
+ tdialog = new dijit.Dialog({
+ id: "filterTestDlg",
+ title: __("Filter Test Results"),
+ style: "width: 600px",
+ href: "backend.php?savemode=test&" +
+ dojo.objectToQuery(dialog.attr('value')),
+ });
+
+ tdialog.show();
+
+ }
+ },
execute: function() {
if (this.validate()) {