mostly implement async filter test dialog
This commit is contained in:
parent
a007c18dff
commit
261226a3a5
|
@ -47,6 +47,7 @@ class Pref_Filters extends Handler_Protected {
|
||||||
require_once "include/rssfuncs.php";
|
require_once "include/rssfuncs.php";
|
||||||
|
|
||||||
$offset = (int) db_escape_string($_REQUEST["offset"]);
|
$offset = (int) db_escape_string($_REQUEST["offset"]);
|
||||||
|
$limit = (int) db_escape_string($_REQUEST["limit"]);
|
||||||
|
|
||||||
$filter = array();
|
$filter = array();
|
||||||
|
|
||||||
|
@ -112,6 +113,7 @@ class Pref_Filters extends Handler_Protected {
|
||||||
ttrss_feeds.title AS feed_title,
|
ttrss_feeds.title AS feed_title,
|
||||||
ttrss_feed_categories.id AS cat_id,
|
ttrss_feed_categories.id AS cat_id,
|
||||||
content,
|
content,
|
||||||
|
date_entered,
|
||||||
link,
|
link,
|
||||||
author,
|
author,
|
||||||
tag_cache
|
tag_cache
|
||||||
|
@ -123,7 +125,7 @@ class Pref_Filters extends Handler_Protected {
|
||||||
ref_id = ttrss_entries.id AND
|
ref_id = ttrss_entries.id AND
|
||||||
($scope_qpart) AND
|
($scope_qpart) AND
|
||||||
ttrss_user_entries.owner_uid = " . $_SESSION["uid"] . "
|
ttrss_user_entries.owner_uid = " . $_SESSION["uid"] . "
|
||||||
ORDER BY date_entered DESC LIMIT 30 OFFSET $offset");
|
ORDER BY date_entered DESC LIMIT $limit OFFSET $offset");
|
||||||
|
|
||||||
while ($line = db_fetch_assoc($result)) {
|
while ($line = db_fetch_assoc($result)) {
|
||||||
|
|
||||||
|
@ -142,10 +144,10 @@ class Pref_Filters extends Handler_Protected {
|
||||||
|
|
||||||
if ($line["feed_title"]) $feed_title = "(" . $line["feed_title"] . ")";
|
if ($line["feed_title"]) $feed_title = "(" . $line["feed_title"] . ")";
|
||||||
|
|
||||||
$line = "<td width='5%' align='center'><input dojoType=\"dijit.form.CheckBox\"
|
$tmp = "<tr><td width='5%' align='center'><input dojoType=\"dijit.form.CheckBox\"
|
||||||
checked=\"1\" disabled=\"1\" type=\"checkbox\"></td><td>";
|
checked=\"1\" disabled=\"1\" type=\"checkbox\"></td><td>";
|
||||||
|
|
||||||
/*foreach ($filter['rules'] as $rule) {
|
foreach ($filter['rules'] as $rule) {
|
||||||
$reg_exp = str_replace('/', '\/', $rule["reg_exp"]);
|
$reg_exp = str_replace('/', '\/', $rule["reg_exp"]);
|
||||||
|
|
||||||
$line["title"] = preg_replace("/($reg_exp)/i",
|
$line["title"] = preg_replace("/($reg_exp)/i",
|
||||||
|
@ -153,16 +155,21 @@ class Pref_Filters extends Handler_Protected {
|
||||||
|
|
||||||
$content_preview = preg_replace("/($reg_exp)/i",
|
$content_preview = preg_replace("/($reg_exp)/i",
|
||||||
"<span class=\"highlight\">$1</span>", $content_preview);
|
"<span class=\"highlight\">$1</span>", $content_preview);
|
||||||
}*/
|
}
|
||||||
|
|
||||||
$line .= $line["title"];
|
$tmp .= "<strong>" . $line["title"] . "</strong>";
|
||||||
$line .= "<div class='small' style='float : right'>" . $feed_title . "</div>";
|
$tmp .= "<div class='small' style='float : right'>" . $feed_title . "</div>";
|
||||||
$line .= "<div class=\"insensitive\">" . $content_preview . "</div>";
|
$tmp .= "<div class=\"insensitive\">" . $content_preview . "</div>";
|
||||||
$line .= " " . mb_substr($line["date_entered"], 0, 16);
|
$tmp .= " " . mb_substr($line["date_entered"], 0, 16);
|
||||||
|
$tmp .= "</td></tr>";
|
||||||
|
|
||||||
$line .= "</td></tr>";
|
array_push($rv, $tmp);
|
||||||
|
|
||||||
|
/*array_push($rv, array("title" => $line["title"],
|
||||||
|
"content" => $content_preview,
|
||||||
|
"date" => $line["date_entered"],
|
||||||
|
"feed" => $line["feed_title"])); */
|
||||||
|
|
||||||
array_push($rv, $line);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,7 +190,7 @@ class Pref_Filters extends Handler_Protected {
|
||||||
|
|
||||||
//print __("Articles matching this filter:");
|
//print __("Articles matching this filter:");
|
||||||
|
|
||||||
print "<div><img src='images/indicator_tiny.gif'> <span id='prefFilterProgressMsg'>Looking for articles...</span></div>";
|
print "<div><img id='prefFilterLoadingIndicator' src='images/indicator_tiny.gif'> <span id='prefFilterProgressMsg'>Looking for articles...</span></div>";
|
||||||
|
|
||||||
print "<br/><div class=\"filterTestHolder\">";
|
print "<br/><div class=\"filterTestHolder\">";
|
||||||
print "<table width=\"100%\" cellspacing=\"0\" id=\"prefFilterTestResultList\">";
|
print "<table width=\"100%\" cellspacing=\"0\" id=\"prefFilterTestResultList\">";
|
||||||
|
|
|
@ -131,6 +131,100 @@ function editUser(id, event) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function editFilterTest(query) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
if (dijit.byId("filterTestDlg"))
|
||||||
|
dijit.byId("filterTestDlg").destroyRecursive();
|
||||||
|
|
||||||
|
var test_dlg = new dijit.Dialog({
|
||||||
|
id: "filterTestDlg",
|
||||||
|
title: "Test Filter",
|
||||||
|
style: "width: 600px",
|
||||||
|
results: 0,
|
||||||
|
limit: 100,
|
||||||
|
max_offset: 10000,
|
||||||
|
getTestResults: function(query, offset) {
|
||||||
|
var updquery = query + "&offset=" + offset + "&limit=" + test_dlg.limit;
|
||||||
|
|
||||||
|
console.log("getTestResults:" + offset);
|
||||||
|
|
||||||
|
new Ajax.Request("backend.php", {
|
||||||
|
parameters: updquery,
|
||||||
|
onComplete: function (transport) {
|
||||||
|
try {
|
||||||
|
var result = JSON.parse(transport.responseText);
|
||||||
|
|
||||||
|
if (result && dijit.byId("filterTestDlg") && dijit.byId("filterTestDlg").open) {
|
||||||
|
test_dlg.results += result.size();
|
||||||
|
|
||||||
|
console.log("got results:" + result.size());
|
||||||
|
|
||||||
|
$("prefFilterProgressMsg").innerHTML = __("Looking for articles (%d processed, %f found)...")
|
||||||
|
.replace("%f", test_dlg.results)
|
||||||
|
.replace("%d", offset);
|
||||||
|
|
||||||
|
console.log(offset + " " + test_dlg.max_offset);
|
||||||
|
|
||||||
|
for (var i = 0; i < result.size(); i++) {
|
||||||
|
var tmp = new Element("table");
|
||||||
|
tmp.innerHTML = result[i];
|
||||||
|
dojo.parser.parse(tmp);
|
||||||
|
|
||||||
|
$("prefFilterTestResultList").innerHTML += tmp.innerHTML;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (test_dlg.results < 30 && offset < test_dlg.max_offset) {
|
||||||
|
|
||||||
|
// get the next batch
|
||||||
|
window.setTimeout(function () {
|
||||||
|
test_dlg.getTestResults(query, offset + test_dlg.limit);
|
||||||
|
}, 0);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// all done
|
||||||
|
|
||||||
|
Element.hide("prefFilterLoadingIndicator");
|
||||||
|
|
||||||
|
if (test_dlg.results == 0) {
|
||||||
|
$("prefFilterTestResultList").innerHTML = "<tr><td align='center'>No recent articles matching this filter have been found.</td></tr>";
|
||||||
|
$("prefFilterProgressMsg").innerHTML = "Articles matching this filter:";
|
||||||
|
} else {
|
||||||
|
$("prefFilterProgressMsg").innerHTML = __("Found %d articles matching this filter:")
|
||||||
|
.replace("%d", test_dlg.results);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (!result) {
|
||||||
|
console.log("getTestResults: can't parse results object");
|
||||||
|
|
||||||
|
Element.hide("prefFilterLoadingIndicator");
|
||||||
|
|
||||||
|
notify_error("Error while trying to get filter test results.");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
console.log("getTestResults: dialog closed, bailing out.");
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
exception_error("editFilterTest/inner", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
} });
|
||||||
|
},
|
||||||
|
href: query});
|
||||||
|
|
||||||
|
dojo.connect(test_dlg, "onLoad", null, function(e) {
|
||||||
|
test_dlg.getTestResults(query, 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test_dlg.show();
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
exception_error("editFilterTest", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function editFilter(id) {
|
function editFilter(id) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
@ -150,69 +244,7 @@ function editFilter(id) {
|
||||||
test: function() {
|
test: function() {
|
||||||
var query = "backend.php?" + dojo.formToQuery("filter_edit_form") + "&savemode=test";
|
var query = "backend.php?" + dojo.formToQuery("filter_edit_form") + "&savemode=test";
|
||||||
|
|
||||||
if (dijit.byId("filterTestDlg"))
|
editFilterTest(query);
|
||||||
dijit.byId("filterTestDlg").destroyRecursive();
|
|
||||||
|
|
||||||
var test_dlg = new dijit.Dialog({
|
|
||||||
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) {
|
selectRules: function(select) {
|
||||||
$$("#filterDlg_Matches input[type=checkbox]").each(function(e) {
|
$$("#filterDlg_Matches input[type=checkbox]").each(function(e) {
|
||||||
|
|
Loading…
Reference in New Issue