/* virtual feeds */
+ if (get_pref($link, 'ENABLE_FEED_CATS')) {
+ print "<li class=\"feedCat\">Special</li>";
+ print "<ul class=\"feedCatList\">";
+ }
+
$result = db_query($link, "SELECT count(id) as num_starred
FROM ttrss_entries,ttrss_user_entries
WHERE marked = true AND
printFeedEntry(-1, $class, "Starred articles", $num_starred,
"images/mark_set.png", $link);
+ if (get_pref($link, 'ENABLE_FEED_CATS')) {
+ print "</ul>";
+ }
+
if (get_pref($link, 'ENABLE_LABELS')) {
$result = db_query($link, "SELECT id,sql_exp,description FROM
ttrss_labels WHERE owner_uid = '$owner_uid' ORDER by description");
if (db_num_rows($result) > 0) {
- print "<li><hr></li>";
+ if (get_pref($link, 'ENABLE_FEED_CATS')) {
+ print "<li class=\"feedCat\">Labels</li>";
+ print "<ul class=\"feedCatList\">";
+ } else {
+ print "<li><hr></li>";
+ }
}
while ($line = db_fetch_assoc($result)) {
$class, $line["description"], $count, "images/label.png", $link);
}
+
+ if (db_num_rows($result) > 0) {
+ if (get_pref($link, 'ENABLE_FEED_CATS')) {
+ print "</ul>";
+ }
+ }
+
+ }
+
+// if (!get_pref($link, 'ENABLE_FEED_CATS')) {
+ print "<li><hr></li>";
+// }
+
+ if (get_pref($link, 'ENABLE_FEED_CATS')) {
+ $order_by_qpart = "category,title";
+ } else {
+ $order_by_qpart = "title";
}
-
- print "<li><hr></li>";
$result = db_query($link, "SELECT *,
(SELECT count(id) FROM ttrss_entries,ttrss_user_entries
(SELECT count(id) FROM ttrss_entries,ttrss_user_entries
WHERE feed_id = ttrss_feeds.id AND unread = true
AND ttrss_user_entries.ref_id = ttrss_entries.id
- AND owner_uid = '$owner_uid') as unread
- FROM ttrss_feeds WHERE owner_uid = '$owner_uid' ORDER BY title");
+ AND owner_uid = '$owner_uid') as unread,
+ (SELECT title FROM ttrss_feed_categories
+ WHERE id = cat_id) AS category
+ FROM ttrss_feeds WHERE owner_uid = '$owner_uid' ORDER BY $order_by_qpart");
$actid = $_GET["actid"];
$lnum = 0;
$total_unread = 0;
+
+ $category = "";
while ($line = db_fetch_assoc($result)) {
$total = $line["total"];
$unread = $line["unread"];
+
+ $tmp_category = $line["category"];
+
+ if (!$tmp_category) {
+ $tmp_category = "Uncategorized";
+ }
// $class = ($lnum % 2) ? "even" : "odd";
}
$total_unread += $unread;
+
+ if ($category != $tmp_category && get_pref($link, 'ENABLE_FEED_CATS')) {
+
+ if ($category) {
+ print "</li></ul></li>";
+ }
+
+ $category = $tmp_category;
+
+ print "<li class=\"feedCat\">$category</li>";
+ print "<li><ul class=\"feedCatList\">";
+ }
- printFeedEntry($feed_id, $class, $feed, $unread, "icons/$feed_id.ico", $link);
+ printFeedEntry($feed_id, $class, $feed, $unread,
+ "icons/$feed_id.ico", $link);
++$lnum;
}
+
} else {
// tags
$feed_link = db_escape_string($_GET["l"]);
$upd_intl = db_escape_string($_GET["ui"]);
$purge_intl = db_escape_string($_GET["pi"]);
- $feed_id = $_GET["id"];
+ $feed_id = db_escape_string($_GET["id"]);
+ $cat_id = db_escape_string($_GET["catid"]);
if (strtoupper($upd_intl) == "DEFAULT")
$upd_intl = 0;
if (strtoupper($purge_intl) == "DISABLED")
$purge_intl = -1;
+ if ($cat_id != 0) {
+ $category_qpart = "cat_id = '$cat_id'";
+ } else {
+ $category_qpart = 'cat_id = NULL';
+ }
+
$result = db_query($link, "UPDATE ttrss_feeds SET
+ $category_qpart,
title = '$feed_title', feed_url = '$feed_link',
update_interval = '$upd_intl',
- purge_interval = '$purge_intl'
+ purge_interval = '$purge_intl'
WHERE id = '$feed_id' AND owner_uid = " . $_SESSION["uid"]);
}
}
}
+ if ($subop == "addCat") {
+
+ if (!WEB_DEMO_MODE) {
+
+ $feed_cat = db_escape_string(trim($_GET["cat"]));
+
+ $result = db_query($link,
+ "SELECT id FROM ttrss_feed_categories
+ WHERE title = '$feed_cat' AND owner_uid = ".$_SESSION["uid"]);
+
+ if (db_num_rows($result) == 0) {
+
+ $result = db_query($link,
+ "INSERT INTO ttrss_feed_categories (owner_uid,title)
+ VALUES ('".$_SESSION["uid"]."', '$feed_cat')");
+
+ } else {
+
+ print "<div class=\"warning\">
+ Category <b>$feed_cat</b> already exists in the database.
+ </div>";
+ }
+
+
+ }
+ }
+
+ if ($subop == "removeCats") {
+
+ if (!WEB_DEMO_MODE) {
+
+ $ids = split(",", $_GET["ids"]);
+
+ foreach ($ids as $id) {
+
+ db_query($link, "BEGIN");
+
+ $result = db_query($link,
+ "SELECT count(id) as num_feeds FROM ttrss_feeds
+ WHERE cat_id = '$id'");
+
+ $num_feeds = db_fetch_result($result, 0, "num_feeds");
+
+ if ($num_feeds == 0) {
+ db_query($link, "DELETE FROM ttrss_feed_categories
+ WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]);
+ } else {
+
+ print "<div class=\"warning\">
+ Unable to delete non empty feed categories.</div>";
+
+ }
+
+ db_query($link, "COMMIT");
+ }
+ }
+ }
+
$result = db_query($link, "SELECT id,title,feed_url,last_error
FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
}
+ if (get_pref($link, 'ENABLE_FEED_CATS')) {
+
+ // print "<h3>Categories</h3>";
+
+ print "<div class=\"prefGenericAddBox\">
+ <input id=\"fadd_cat\" size=\"40\"> <input
+ type=\"submit\" class=\"button\"
+ onclick=\"javascript:addFeedCat()\" value=\"Add category\"></div>";
+
+ $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories
+ WHERE owner_uid = ".$_SESSION["uid"]."
+ ORDER BY title");
+
+ print "<p><table width=\"100%\" class=\"prefFeedCatList\" id=\"prefFeedCatList\">";
+ print "<tr class=\"title\">
+ <td width=\"10%\">Select</td><td width=\"80%\">Title</td>
+ </tr>";
+
+ $lnum = 0;
+
+ while ($line = db_fetch_assoc($result)) {
+
+ $class = ($lnum % 2) ? "even" : "odd";
+
+ $cat_id = $line["id"];
+
+ $edit_cat_id = $_GET["id"];
+
+ if ($subop == "editCat" && $cat_id != $edit_cat_id) {
+ $class .= "Grayed";
+ }
+
+ print "<tr class=\"$class\" id=\"FCATR-$cat_id\">";
+
+ $edit_title = htmlspecialchars(db_unescape_string($line["title"]));
+
+ if (!$edit_cat_id || $subop != "editCat") {
+
+ print "<td><input onclick='toggleSelectRow(this);'
+ type=\"checkbox\" id=\"FCCHK-".$line["id"]."\"></td>";
+
+ print "<td><a href=\"javascript:editFeedCat($cat_id);\">" .
+ $edit_title . "</a></td>";
+
+ } else if ($cat_id != $edit_cat_id) {
+
+ print "<td><input disabled=\"true\" type=\"checkbox\"
+ id=\"FRCHK-".$line["id"]."\"></td>";
+
+ print "<td>$edit_title</td>";
+
+ } else {
+
+ print "<td><input disabled=\"true\" type=\"checkbox\" checked></td>";
+
+ print "<td><input id=\"iedit_title\" value=\"$edit_title\"></td>";
+
+ }
+
+ print "</tr>";
+
+ ++$lnum;
+ }
+
+ if ($lnum == 0) {
+ print "<tr><td colspan=\"5\" align=\"center\">No categories defined.</td></tr>";
+ }
+
+ print "</table>";
+
+ print "<p>";
+
+ if ($subop == "editCat") {
+ print "Edit category:
+ <input type=\"submit\" class=\"button\"
+ onclick=\"javascript:feedCatEditCancel()\" value=\"Cancel\">
+ <input type=\"submit\" class=\"button\"
+ onclick=\"javascript:feedCatEditSave()\" value=\"Save\">";
+ } else {
+
+ print "
+ Selection:
+ <input type=\"submit\" class=\"button\"
+ onclick=\"javascript:editSelectedFeedCat()\" value=\"Edit\">
+ <input type=\"submit\" class=\"button\"
+ onclick=\"javascript:removeSelectedFeedCats()\" value=\"Remove\">";
+ }
+ }
+
+// print "<h3>Feeds</h3>";
+
+ print "<hr><p>";
+
print "<div class=\"prefGenericAddBox\">
<input id=\"fadd_link\" size=\"40\"> <input
type=\"submit\" class=\"button\"
$result = db_query($link, "SELECT
id,title,feed_url,substring(last_updated,1,16) as last_updated,
- update_interval,purge_interval
+ update_interval,purge_interval,
+ (SELECT title FROM ttrss_feed_categories
+ WHERE id = cat_id) AS category
FROM
ttrss_feeds WHERE owner_uid = '".$_SESSION["uid"]."' ORDER by title");
print "<p><table width=\"100%\" class=\"prefFeedList\" id=\"prefFeedList\">";
print "<tr class=\"title\">
- <td> </td><td>Select</td><td width=\"30%\">Title</td>
- <td width=\"30%\">Link</td>
- <td width=\"10%\">Update Interval</td>
+ <td> </td><td>Select</td><td width=\"20%\">Title</td>
+ <td width=\"20%\">Link</td>";
+
+ if (get_pref($link, 'ENABLE_FEED_CATS')) {
+ print "<td width=\"10%\">Category</td>";
+ }
+
+ print "<td width=\"10%\">Update Interval</td>
<td width=\"10%\">Purge Days</td>
<td>Last updated</td></tr>";
$edit_title = htmlspecialchars(db_unescape_string($line["title"]));
$edit_link = htmlspecialchars(db_unescape_string($line["feed_url"]));
+ $edit_cat = htmlspecialchars(db_unescape_string($line["category"]));
+
+ if (!$edit_cat) $edit_cat = "Uncategorized";
if (!$edit_feed_id || $subop != "edit") {
print "<td><a href=\"javascript:editFeed($feed_id);\">" .
$edit_title . "</a></td>";
+
print "<td><a href=\"javascript:editFeed($feed_id);\">" .
$edit_link . "</a></td>";
+ print "<td><a href=\"javascript:editFeed($feed_id);\">" .
+ $edit_cat . "</a></td>";
+
if ($line["update_interval"] == "0")
$line["update_interval"] = "Default";
print "<td>$edit_title</td>";
print "<td>$edit_link</td>";
+ print "<td>$edit_cat</td>";
if ($line["update_interval"] == "0")
$line["update_interval"] = "Default";
print "<td><input id=\"iedit_title\" value=\"$edit_title\"></td>";
print "<td><input id=\"iedit_link\" value=\"$edit_link\"></td>";
- print "<td><input id=\"iedit_updintl\" value=\"".$line["update_interval"]."\"></td>";
- print "<td><input id=\"iedit_purgintl\" value=\"".$line["purge_interval"]."\"></td>";
+
+ print "<td>";
+
+ print "<select id=\"iedit_fcat\">";
+
+ print "<option id=\"0\">Uncategorized</option>";
+
+ if (db_num_rows($result) > 0) {
+ print "<option disabled>--------</option>";
+ }
+
+ $tmp_result = db_query($link, "SELECT id,title FROM ttrss_feed_categories
+ WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title");
+
+ while ($tmp_line = db_fetch_assoc($tmp_result)) {
+ if ($tmp_line["id"] == $line["cat_id"]) {
+ $is_selected = "selected";
+ } else {
+ $is_selected = "";
+ }
+ printf("<option $is_selected id='%d'>%s</option>",
+ $tmp_line["id"], $tmp_line["title"]);
+ }
+
+ print "</select></td>";
+
+ print "</td>";
+
+ print "<td><input id=\"iedit_updintl\"
+ value=\"".$line["update_interval"]."\"></td>";
+ print "<td><input id=\"iedit_purgintl\"
+ value=\"".$line["purge_interval"]."\"></td>";
}
var xmlhttp = false;
var active_feed = false;
+var active_feed_cat = false;
var active_filter = false;
var active_label = false;
var active_user = false;
}
+function addFeedCat() {
+
+ if (!xmlhttp_ready(xmlhttp)) {
+ printLockingError();
+ return
+ }
+
+ var cat = document.getElementById("fadd_cat");
+
+ if (cat.value.length == 0) {
+ notify("Missing feed category.");
+ } else {
+ notify("Adding feed category...");
+
+ xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=addCat&cat=" +
+ param_escape(cat.value), true);
+ xmlhttp.onreadystatechange=feedlist_callback;
+ xmlhttp.send(null);
+
+ link.value = "";
+
+ }
+
+}
function addUser() {
if (!xmlhttp_ready(xmlhttp)) {
}
-function getSelectedLabels() {
-
- var content = document.getElementById("prefLabelList");
-
- var sel_rows = new Array();
+function editFeedCat(cat) {
- for (i = 0; i < content.rows.length; i++) {
- if (content.rows[i].className.match("Selected")) {
- var row_id = content.rows[i].id.replace("LILRR-", "");
- sel_rows.push(row_id);
- }
+ if (!xmlhttp_ready(xmlhttp)) {
+ printLockingError();
+ return
}
- return sel_rows;
-}
-
-function getSelectedUsers() {
-
- var content = document.getElementById("prefUserList");
+ active_feed_cat = cat;
- var sel_rows = new Array();
-
- for (i = 0; i < content.rows.length; i++) {
- if (content.rows[i].className.match("Selected")) {
- var row_id = content.rows[i].id.replace("UMRR-", "");
- sel_rows.push(row_id);
- }
- }
+ xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCat&id=" +
+ param_escape(cat), true);
+ xmlhttp.onreadystatechange=feedlist_callback;
+ xmlhttp.send(null);
- return sel_rows;
}
+function getSelectedLabels() {
+ return getSelectedTableRowIds("prefLabelList", "LILRR");
+}
-function getSelectedFilters() {
-
- var content = document.getElementById("prefFilterList");
-
- var sel_rows = new Array();
-
- for (i = 0; i < content.rows.length; i++) {
- if (content.rows[i].className.match("Selected")) {
- var row_id = content.rows[i].id.replace("FILRR-", "");
- sel_rows.push(row_id);
- }
- }
-
- return sel_rows;
+function getSelectedUsers() {
+ return getSelectedTableRowIds("prefUserList", "UMRR");
}
function getSelectedFeeds() {
+ return getSelectedTableRowIds("prefFeedList", "FEEDR");
+}
- var content = document.getElementById("prefFeedList");
-
- var sel_rows = new Array();
-
- for (i = 0; i < content.rows.length; i++) {
- if (content.rows[i].className.match("Selected")) {
- var row_id = content.rows[i].id.replace("FEEDR-", "");
- sel_rows.push(row_id);
- }
- }
+function getSelectedFilters() {
+ return getSelectedTableRowIds("prefFilterList", "FILRR");
+}
- return sel_rows;
+function getSelectedFeedCats() {
+ return getSelectedTableRowIds("prefFeedCatList", "FCATR");
}
+
function readSelectedFeeds() {
if (!xmlhttp_ready(xmlhttp)) {
}
+function removeSelectedFeedCats() {
+
+ if (!xmlhttp_ready(xmlhttp)) {
+ printLockingError();
+ return
+ }
+
+ var sel_rows = getSelectedFeedCats();
+
+ if (sel_rows.length > 0) {
+
+ notify("Removing selected categories...");
+
+ xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=removeCats&ids="+
+ param_escape(sel_rows.toString()), true);
+ xmlhttp.onreadystatechange=feedlist_callback;
+ xmlhttp.send(null);
+
+ } else {
+
+ notify("Please select some feeds first.");
+
+ }
+
+}
+
function feedEditCancel() {
if (!xmlhttp_ready(xmlhttp)) {
}
+function feedCatEditCancel() {
+
+ if (!xmlhttp_ready(xmlhttp)) {
+ printLockingError();
+ return
+ }
+
+ active_feed_cat = false;
+
+ notify("Operation cancelled.");
+
+ xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
+ xmlhttp.onreadystatechange=feedlist_callback;
+ xmlhttp.send(null);
+
+}
+
function feedEditSave() {
var feed = active_feed;
var title = document.getElementById("iedit_title").value;
var upd_intl = document.getElementById("iedit_updintl").value;
var purge_intl = document.getElementById("iedit_purgintl").value;
+ var fcat = document.getElementById("iedit_fcat");
+
+ var fcat_id = fcat[fcat.selectedIndex].id;
// notify("Saving feed.");
xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editSave&id=" +
feed + "&l=" + param_escape(link) + "&t=" + param_escape(title) +
- "&ui=" + param_escape(upd_intl) + "&pi=" + param_escape(purge_intl), true);
+ "&ui=" + param_escape(upd_intl) + "&pi=" + param_escape(purge_intl) +
+ "&catid=" + param_escape(fcat_id), true);
xmlhttp.onreadystatechange=feedlist_callback;
xmlhttp.send(null);
}
+function editSelectedFeedCat() {
+ var rows = getSelectedFeedCats();
+
+ if (rows.length == 0) {
+ notify("No categories are selected.");
+ return;
+ }
+
+ if (rows.length > 1) {
+ notify("Please select one category.");
+ return;
+ }
+
+ notify("");
+
+ editFeedCat(rows[0]);
+
+}
+
function localPiggieFunction(enable) {
if (enable) {
piggie.style.display = "block";