$subop = $_GET["subop"];
+ if ($subop == "edit") {
+
+ $label_id = db_escape_string($_GET["id"]);
+
+ $result = db_query($link, "SELECT sql_exp,description FROM ttrss_labels WHERE
+ owner_uid = ".$_SESSION["uid"]." AND id = '$label_id' ORDER by description");
+
+ $line = db_fetch_assoc($result);
+
+ $sql_exp = htmlspecialchars(db_unescape_string($line["sql_exp"]));
+ $description = htmlspecialchars(db_unescape_string($line["description"]));
+
+ print "<div id=\"infoBoxTitle\">Label editor</div>";
+ print "<div class=\"infoBoxContents\">";
+
+ print "<form id=\"label_edit_form\">";
+
+ print "<input type=\"hidden\" name=\"op\" value=\"pref-labels\">";
+ print "<input type=\"hidden\" name=\"id\" value=\"$label_id\">";
+ print "<input type=\"hidden\" name=\"subop\" value=\"editSave\">";
+
+ print "<table width='100%'>";
+
+ print "<tr><td>Caption:</td>
+ <td><input onkeypress=\"return filterCR(event)\"
+ onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
+ name=\"description\" class=\"iedit\" value=\"$description\">";
+
+ print "</td></tr>";
+
+ print "<tr><td colspan=\"2\">
+ <p>SQL Expression:</p>";
+
+ print "<textarea onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
+ rows=\"4\" name=\"sql_exp\" class=\"iedit\">$sql_exp</textarea>";
+
+ print "</td></tr></table>";
+
+ print "</form>";
+
+ print "<div style=\"display : none\" id=\"label_test_result\"></div>";
+
+ print "<div align='right'>";
+
+ print "<input type=\"submit\" onclick=\"labelTest()\" value=\"Test\">
+ ";
+
+ print "<input type=\"submit\"
+ id=\"infobox_submit\"
+ class=\"button\" onclick=\"return labelEditSave()\"
+ value=\"Save\"> ";
+
+ print "<input class=\"button\"
+ type=\"submit\" onclick=\"return labelEditCancel()\"
+ value=\"Cancel\">";
+
+ print "</div>";
+
+ return;
+ }
+
if ($subop == "test") {
$expr = db_unescape_string(trim($_GET["expr"]));
$descr = db_unescape_string(trim($_GET["descr"]));
- print "<div id=\"infoBoxTitle\">Test label: $descr</div>";
+ print "<div>";
- print "<div class='infoBoxContents'>";
-
-# print "<h1>Label «$descr»</h1>";
+ error_reporting(0);
-// print "<p><b>Expression</b>: $expr</p>";
$result = db_query($link,
"SELECT count(ttrss_entries.id) AS num_matches
WHERE ($expr) AND
ttrss_user_entries.ref_id = ttrss_entries.id AND
ttrss_user_entries.feed_id = ttrss_feeds.id AND
- ttrss_user_entries.owner_uid = " . $_SESSION["uid"]);
+ ttrss_user_entries.owner_uid = " . $_SESSION["uid"], false);
+
+ error_reporting (DEFAULT_ERROR_LEVEL);
+
+ if (!$result) {
+ print "<p>" . db_last_error($link) . "</p>";
+ print "</div>";
+ return;
+ }
$num_matches = db_fetch_result($result, 0, "num_matches");;
if ($num_matches > 0) {
- print "<p>Query returned <b>$num_matches</b> matches, showing first 15:</p>";
+ print "<p>Query returned <b>$num_matches</b> matches, showing up to first 10:</p>";
$result = db_query($link,
"SELECT ttrss_entries.title,
ttrss_user_entries.ref_id = ttrss_entries.id
AND ttrss_user_entries.feed_id = ttrss_feeds.id
AND ttrss_user_entries.owner_uid = " . $_SESSION["uid"] . "
- ORDER BY date_entered DESC LIMIT 15");
+ ORDER BY date_entered DESC LIMIT 10", false);
- print "<ul class=\"filterTestResults\">";
+ print "<ul class=\"labelTestResults\">";
$row_class = "even";
print "</div>";
- print "<div align='center'>
- <input type='submit' class='button'
- onclick=\"closeInfoBox()\" value=\"Close this window\"></div>";
return;
}
$line["description"] = htmlspecialchars(
db_unescape_string($line["description"]));
- if (!$edit_label_id || $subop != "edit") {
+ if (!$line["description"]) $line["description"] = "[No caption]";
- if (!$line["description"]) $line["description"] = "[No caption]";
-
- print "<td align='center'><input onclick='toggleSelectPrefRow(this, \"label\");'
+ print "<td align='center'><input onclick='toggleSelectPrefRow(this, \"label\");'
type=\"checkbox\" id=\"LICHK-".$line["id"]."\"></td>";
- print "<td><a href=\"javascript:editLabel($label_id);\">" .
- $line["sql_exp"] . "</td>";
+ print "<td><a href=\"javascript:editLabel($label_id);\">" .
+ $line["sql_exp"] . "</td>";
- print "<td><a href=\"javascript:editLabel($label_id);\">" .
- $line["description"] . "</td>";
-
- } else if ($label_id != $edit_label_id) {
-
- if (!$line["description"]) $line["description"] = "[No description]";
-
- print "<td align='center'><input disabled=\"true\" type=\"checkbox\"
- id=\"LICHK-".$line["id"]."\"></td>";
-
- print "<td>".$line["sql_exp"]."</td>";
- print "<td>".$line["description"]."</td>";
-
- } else {
-
- print "<td align='center'><input disabled=\"true\" type=\"checkbox\" checked>";
-
- print "<input type=\"hidden\" name=\"id\" value=\"$label_id\">";
- print "<input type=\"hidden\" name=\"op\" value=\"pref-labels\">";
- print "<input type=\"hidden\" name=\"subop\" value=\"editSave\">";
-
- print "</td>";
-
- print "<td><input onkeypress=\"return filterCR(event)\"
- class=\"iedit\" name=\"sql_exp\" value=\"".$line["sql_exp"]."\"></td>";
-
- print "<td><input onkeypress=\"return filterCR(event)\"
- class=\"iedit\" name=\"description\" value=\"".$line["description"]."\"></td>";
- }
-
+ print "<td><a href=\"javascript:editLabel($label_id);\">" .
+ $line["description"] . "</td>";
print "</tr>";
}
}
+function labeltest_callback() {
+ var container = document.getElementById('label_test_result');
+ if (xmlhttp.readyState == 4) {
+ container.innerHTML=xmlhttp.responseText;
+ notify("");
+ }
+}
+
function feed_browser_callback() {
var container = document.getElementById('prefContent');
if (xmlhttp.readyState == 4) {
active_label = id;
+ selectTableRowsByIdPrefix('prefLabelList', 'LILRR-', 'LICHK-', false);
+ selectTableRowById('LILRR-'+id, 'LICHK-'+id, true);
+
xmlhttp.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
param_escape(id), true);
- xmlhttp.onreadystatechange=labellist_callback;
+ xmlhttp.onreadystatechange=infobox_callback;
xmlhttp.send(null);
}
function labelTest() {
+ var container = document.getElementById('label_test_result');
+ container.style.display = "block";
+ container.innerHTML = "<p>Loading, please wait...</p>";
+
var form = document.forms['label_edit_form'];
var sql_exp = form.sql_exp.value;
xmlhttp.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
param_escape(sql_exp) + "&descr=" + param_escape(description), true);
- xmlhttp.onreadystatechange=infobox_callback;
+ xmlhttp.onreadystatechange=labeltest_callback;
xmlhttp.send(null);
return false;
active_label = false;
-// notify("Operation cancelled.");
-
+ selectPrefRows('label', false); // cleanup feed selection
closeInfoBox();
- xmlhttp.open("GET", "backend.php?op=pref-labels", true);
- xmlhttp.onreadystatechange=labellist_callback;
- xmlhttp.send(null);
-
return false;
}
} else if (kind == "label") {
opbarid = "labelOpToolbar";
nrow = "LILRR-";
- nchk = "LCHK-";
+ nchk = "LICHK-";
lname = "prefLabelList";
} else if (kind == "user") {
opbarid = "userOpToolbar";