diff --git a/classes/pref/filters.php b/classes/pref/filters.php index a371fcff4..ec0c3862a 100644 --- a/classes/pref/filters.php +++ b/classes/pref/filters.php @@ -43,8 +43,11 @@ class Pref_Filters extends Handler_Protected { return; } + function testFilterDo() { + require_once "include/rssfuncs.php"; + + $offset = (int) db_escape_string($_REQUEST["offset"]); - function testFilter() { $filter = array(); $filter["enabled"] = true; @@ -94,24 +97,14 @@ class Pref_Filters extends Handler_Protected { } } - $found = 0; - $offset = 0; - $limit = 30; - $started = time(); - - print __("Articles matching this filter:"); - - require_once "include/rssfuncs.php"; - - print "
"; - print " | "; + $line = " | ";
/*foreach ($filter['rules'] as $rule) {
- $reg_exp = $rule['reg_exp'];
$reg_exp = str_replace('/', '\/', $rule["reg_exp"]);
$line["title"] = preg_replace("/($reg_exp)/i",
@@ -166,25 +155,38 @@ class Pref_Filters extends Handler_Protected {
"$1", $content_preview);
}*/
- print $line["title"];
- print " " . $feed_title . " ";
- print "" . $content_preview . " ";
- print " " . mb_substr($line["date_entered"], 0, 16);
+ $line .= $line["title"];
+ $line .= "" . $feed_title . " ";
+ $line .= "" . $content_preview . " ";
+ $line .= " " . mb_substr($line["date_entered"], 0, 16);
- print " | |
" .
__("No recent articles matching this filter have been found.");
- }
+ }*/
+ print json_encode($rv);
+ }
+
+ function testFilter() {
+
+ if (isset($_REQUEST["offset"])) return $this->testFilterDo();
+
+ //print __("Articles matching this filter:");
+
+ print " Looking for articles... ";
+
+ print "";
+ print " ";
print "";
diff --git a/js/prefs.js b/js/prefs.js
index 66288764a..797e0e071 100644
--- a/js/prefs.js
+++ b/js/prefs.js
@@ -146,6 +146,7 @@ function editFilter(id) {
id: "filterEditDlg",
title: __("Edit Filter"),
style: "width: 600px",
+
test: function() {
var query = "backend.php?" + dojo.formToQuery("filter_edit_form") + "&savemode=test";
@@ -156,8 +157,61 @@ function editFilter(id) {
id: "filterTestDlg",
title: "Test Filter",
style: "width: 600px",
+ results: 0,
+ max_offset: 10000,
+ getTestResults: function(query, offset) {
+ var updquery = query + "&offset=" + offset;
+
+ console.log("getTestResults:" + offset);
+ //console.log(updquery);
+
+ new Ajax.Request("backend.php", {
+ parameters: updquery,
+ onComplete: function (transport) {
+
+ console.log(transport.responseText);
+
+ var result = JSON.parse(transport.responseText);
+
+ console.log("R:" + result);
+
+ //console.log("<<< " + transport.responseText);
+
+ if (result && dijit.byId("filterTestDlg") && dijit.byId("filterTestDlg").open) {
+ test_dlg.results += result.size();
+
+ $("prefFilterProgressMsg").innerHTML = __("Looking for articles (%d)...".replace("%d", offset));
+
+ console.log(offset + " " + test_dlg.max_offset);
+
+ for (var i = 0; i < result.size(); i++) {
+ $("prefFilterTestResultList").innerHTML += result[i];
+ }
+
+ if (test_dlg.results < 30 && offset < test_dlg.max_offset) {
+ window.setTimeout(function() {
+ //console.log("blaargh");
+
+ test_dlg.getTestResults(query, offset + 30);
+ }, 0);
+ } else {
+
+ // all done
+
+ }
+
+ } else {
+ console.log("can't parse results object / dialog closed");
+ }
+
+ } });
+ },
href: query});
+ dojo.connect(test_dlg, "onShow", null, function(e) {
+ test_dlg.getTestResults(query, 0);
+ });
+
test_dlg.show();
},
selectRules: function(select) {
|