gracube updates, code cleanup

This commit is contained in:
Andrew Dolgov 2006-10-01 10:08:55 +01:00
parent 140eda6c57
commit f407c08674
5 changed files with 323 additions and 302 deletions

View File

@ -122,293 +122,6 @@
if (!sanity_check($link)) { return; } if (!sanity_check($link)) { return; }
function outputFeedList($link, $tags = false) {
print "<ul class=\"feedList\" id=\"feedList\">\n";
$owner_uid = $_SESSION["uid"];
if (!$tags) {
/* virtual feeds */
if (get_pref($link, 'ENABLE_FEED_CATS')) {
print "<li class=\"feedCat\">Special</li>";
print "<li id=\"feedCatHolder\"><ul class=\"feedCatList\">";
}
$num_starred = getFeedUnread($link, -1);
$class = "virt";
if ($num_starred > 0) $class .= "Unread";
printFeedEntry(-1, $class, "Starred articles", $num_starred,
"images/mark_set.png", $link);
if (get_pref($link, 'ENABLE_FEED_CATS')) {
print "</ul>\n";
}
if (GLOBAL_ENABLE_LABELS && 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) {
if (get_pref($link, 'ENABLE_FEED_CATS')) {
print "<li class=\"feedCat\">Labels</li>";
print "<li id=\"feedCatHolder\"><ul class=\"feedCatList\">";
} else {
print "<li><hr></li>";
}
}
while ($line = db_fetch_assoc($result)) {
error_reporting (0);
$label_id = -$line['id'] - 11;
$count = getFeedUnread($link, $label_id);
$class = "label";
if ($count > 0) {
$class .= "Unread";
}
error_reporting (DEFAULT_ERROR_LEVEL);
printFeedEntry($label_id,
$class, db_unescape_string($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')) {
if (get_pref($link, "FEEDS_SORT_BY_UNREAD")) {
$order_by_qpart = "category,unread DESC,title";
} else {
$order_by_qpart = "category,title";
}
} else {
if (get_pref($link, "FEEDS_SORT_BY_UNREAD")) {
$order_by_qpart = "unread DESC,title";
} else {
$order_by_qpart = "title";
}
}
$result = db_query($link, "SELECT ttrss_feeds.*,
SUBSTRING(last_updated,1,19) AS last_updated_noms,
(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,
cat_id,last_error,
ttrss_feed_categories.title AS category,
ttrss_feed_categories.collapsed
FROM ttrss_feeds LEFT JOIN ttrss_feed_categories
ON (ttrss_feed_categories.id = cat_id)
WHERE
ttrss_feeds.hidden = false AND
ttrss_feeds.owner_uid = '$owner_uid' AND parent_feed IS NULL
ORDER BY $order_by_qpart");
$actid = $_GET["actid"];
/* real feeds */
$lnum = 0;
$total_unread = 0;
$category = "";
$short_date = get_pref($link, 'SHORT_DATE_FORMAT');
while ($line = db_fetch_assoc($result)) {
$feed = db_unescape_string($line["title"]);
$feed_id = $line["id"];
$subop = $_GET["subop"];
$unread = $line["unread"];
if (get_pref($link, 'HEADLINES_SMART_DATE')) {
$last_updated = smart_date_time(strtotime($line["last_updated_noms"]));
} else {
$last_updated = date($short_date, strtotime($line["last_updated_noms"]));
}
$rtl_content = sql_bool_to_bool($line["rtl_content"]);
if ($rtl_content) {
$rtl_tag = "dir=\"RTL\"";
} else {
$rtl_tag = "";
}
$tmp_result = db_query($link,
"SELECT id,COUNT(unread) AS unread
FROM ttrss_feeds LEFT JOIN ttrss_user_entries
ON (ttrss_feeds.id = ttrss_user_entries.feed_id)
WHERE parent_feed = '$feed_id' AND unread = true
GROUP BY ttrss_feeds.id");
if (db_num_rows($tmp_result) > 0) {
while ($l = db_fetch_assoc($tmp_result)) {
$unread += $l["unread"];
}
}
$cat_id = $line["cat_id"];
$tmp_category = $line["category"];
if (!$tmp_category) {
$tmp_category = "Uncategorized";
}
// $class = ($lnum % 2) ? "even" : "odd";
if ($line["last_error"]) {
$class = "error";
} else {
$class = "feed";
}
if ($unread > 0) $class .= "Unread";
if ($actid == $feed_id) {
$class .= "Selected";
}
$total_unread += $unread;
if ($category != $tmp_category && get_pref($link, 'ENABLE_FEED_CATS')) {
if ($category) {
print "</ul></li>";
}
$category = $tmp_category;
$collapsed = $line["collapsed"];
// workaround for NULL category
if ($category == "Uncategorized") {
if ($_COOKIE["ttrss_vf_uclps"] == 1) {
$collapsed = "t";
}
}
if ($collapsed == "t" || $collapsed == "1") {
$holder_class = "invisible";
$ellipsis = "...";
} else {
$holder_class = "";
$ellipsis = "";
}
$cat_id = sprintf("%d", $cat_id);
$cat_unread = getCategoryUnread($link, $cat_id);
print "<li class=\"feedCat\" id=\"FCAT-$cat_id\">
<a id=\"FCATN-$cat_id\" href=\"javascript:toggleCollapseCat($cat_id)\">$tmp_category</a>
<a href=\"javascript:viewCategory($cat_id)\" id=\"FCAP-$cat_id\">
<span id=\"FCATCTR-$cat_id\"
class=\"$catctr_class\">($cat_unread unread)$ellipsis</span>
</a></li>";
// !!! NO SPACE before <ul...feedCatList - breaks firstChild DOM function
// -> keyboard navigation, etc.
print "<li id=\"feedCatHolder\" class=\"$holder_class\"><ul class=\"feedCatList\" id=\"FCATLIST-$cat_id\">";
}
printFeedEntry($feed_id, $class, $feed, $unread,
"icons/$feed_id.ico", $link, $rtl_content,
$last_updated, $line["last_error"]);
++$lnum;
}
if (db_num_rows($result) == 0) {
print "<li>No feeds to display.</li>";
}
} else {
// tags
/* $result = db_query($link, "SELECT tag_name,count(ttrss_entries.id) AS count
FROM ttrss_tags,ttrss_entries,ttrss_user_entries WHERE
post_int_id = ttrss_user_entries.int_id AND
unread = true AND ref_id = ttrss_entries.id
AND ttrss_tags.owner_uid = '$owner_uid' GROUP BY tag_name
UNION
select tag_name,0 as count FROM ttrss_tags WHERE owner_uid = '$owner_uid'
ORDER BY tag_name"); */
if (get_pref($link, 'ENABLE_FEED_CATS')) {
print "<li class=\"feedCat\">Tags</li>";
print "<li id=\"feedCatHolder\"><ul class=\"feedCatList\">";
}
$result = db_query($link, "SELECT tag_name,SUM((SELECT COUNT(int_id)
FROM ttrss_user_entries WHERE int_id = post_int_id
AND unread = true)) AS count FROM ttrss_tags
WHERE owner_uid = 2 GROUP BY tag_name ORDER BY tag_name");
$tags = array();
while ($line = db_fetch_assoc($result)) {
$tags[$line["tag_name"]] += $line["count"];
}
foreach (array_keys($tags) as $tag) {
$unread = $tags[$tag];
$class = "tag";
if ($unread > 0) {
$class .= "Unread";
}
printFeedEntry($tag, $class, $tag, $unread, "images/tag.png", $link);
}
if (db_num_rows($result) == 0) {
print "<li>No tags to display.</li>";
}
if (get_pref($link, 'ENABLE_FEED_CATS')) {
print "</ul>\n";
}
}
print "</ul>";
}
if ($op == "rpc") { if ($op == "rpc") {
handle_rpc_request($link); handle_rpc_request($link);
} }

View File

@ -130,13 +130,15 @@ function notify_real(msg, doc, no_hide, is_err) {
} }
if (is_err) { if (is_err) {
n.style.backgroundColor = "#ffcccc"; n.className = "notifyError";
n.style.color = "black"; // n.style.backgroundColor = "#ffcccc";
n.style.borderColor = "#ff0000"; // n.style.color = "black";
// n.style.borderColor = "#ff0000";
} else { } else {
n.style.backgroundColor = "#fff7d5"; n.className = "notify";
n.style.borderColor = "#d7c47a"; // n.style.backgroundColor = "#fff7d5";
n.style.color = "black"; // n.style.borderColor = "#d7c47a";
// n.style.color = "black";
} }
// msg = "<img src='images/live_com_loading.gif'> " + msg; // msg = "<img src='images/live_com_loading.gif'> " + msg;

View File

@ -2705,4 +2705,290 @@
} }
function outputFeedList($link, $tags = false) {
print "<ul class=\"feedList\" id=\"feedList\">\n";
$owner_uid = $_SESSION["uid"];
if (!$tags) {
/* virtual feeds */
if (get_pref($link, 'ENABLE_FEED_CATS')) {
print "<li class=\"feedCat\">Special</li>";
print "<li id=\"feedCatHolder\"><ul class=\"feedCatList\">";
}
$num_starred = getFeedUnread($link, -1);
$class = "virt";
if ($num_starred > 0) $class .= "Unread";
printFeedEntry(-1, $class, "Starred articles", $num_starred,
"images/mark_set.png", $link);
if (get_pref($link, 'ENABLE_FEED_CATS')) {
print "</ul>\n";
}
if (GLOBAL_ENABLE_LABELS && 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) {
if (get_pref($link, 'ENABLE_FEED_CATS')) {
print "<li class=\"feedCat\">Labels</li>";
print "<li id=\"feedCatHolder\"><ul class=\"feedCatList\">";
} else {
print "<li><hr></li>";
}
}
while ($line = db_fetch_assoc($result)) {
error_reporting (0);
$label_id = -$line['id'] - 11;
$count = getFeedUnread($link, $label_id);
$class = "label";
if ($count > 0) {
$class .= "Unread";
}
error_reporting (DEFAULT_ERROR_LEVEL);
printFeedEntry($label_id,
$class, db_unescape_string($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')) {
if (get_pref($link, "FEEDS_SORT_BY_UNREAD")) {
$order_by_qpart = "category,unread DESC,title";
} else {
$order_by_qpart = "category,title";
}
} else {
if (get_pref($link, "FEEDS_SORT_BY_UNREAD")) {
$order_by_qpart = "unread DESC,title";
} else {
$order_by_qpart = "title";
}
}
$result = db_query($link, "SELECT ttrss_feeds.*,
SUBSTRING(last_updated,1,19) AS last_updated_noms,
(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,
cat_id,last_error,
ttrss_feed_categories.title AS category,
ttrss_feed_categories.collapsed
FROM ttrss_feeds LEFT JOIN ttrss_feed_categories
ON (ttrss_feed_categories.id = cat_id)
WHERE
ttrss_feeds.hidden = false AND
ttrss_feeds.owner_uid = '$owner_uid' AND parent_feed IS NULL
ORDER BY $order_by_qpart");
$actid = $_GET["actid"];
/* real feeds */
$lnum = 0;
$total_unread = 0;
$category = "";
$short_date = get_pref($link, 'SHORT_DATE_FORMAT');
while ($line = db_fetch_assoc($result)) {
$feed = db_unescape_string($line["title"]);
$feed_id = $line["id"];
$subop = $_GET["subop"];
$unread = $line["unread"];
if (get_pref($link, 'HEADLINES_SMART_DATE')) {
$last_updated = smart_date_time(strtotime($line["last_updated_noms"]));
} else {
$last_updated = date($short_date, strtotime($line["last_updated_noms"]));
}
$rtl_content = sql_bool_to_bool($line["rtl_content"]);
if ($rtl_content) {
$rtl_tag = "dir=\"RTL\"";
} else {
$rtl_tag = "";
}
$tmp_result = db_query($link,
"SELECT id,COUNT(unread) AS unread
FROM ttrss_feeds LEFT JOIN ttrss_user_entries
ON (ttrss_feeds.id = ttrss_user_entries.feed_id)
WHERE parent_feed = '$feed_id' AND unread = true
GROUP BY ttrss_feeds.id");
if (db_num_rows($tmp_result) > 0) {
while ($l = db_fetch_assoc($tmp_result)) {
$unread += $l["unread"];
}
}
$cat_id = $line["cat_id"];
$tmp_category = $line["category"];
if (!$tmp_category) {
$tmp_category = "Uncategorized";
}
// $class = ($lnum % 2) ? "even" : "odd";
if ($line["last_error"]) {
$class = "error";
} else {
$class = "feed";
}
if ($unread > 0) $class .= "Unread";
if ($actid == $feed_id) {
$class .= "Selected";
}
$total_unread += $unread;
if ($category != $tmp_category && get_pref($link, 'ENABLE_FEED_CATS')) {
if ($category) {
print "</ul></li>";
}
$category = $tmp_category;
$collapsed = $line["collapsed"];
// workaround for NULL category
if ($category == "Uncategorized") {
if ($_COOKIE["ttrss_vf_uclps"] == 1) {
$collapsed = "t";
}
}
if ($collapsed == "t" || $collapsed == "1") {
$holder_class = "invisible";
$ellipsis = "...";
} else {
$holder_class = "";
$ellipsis = "";
}
$cat_id = sprintf("%d", $cat_id);
$cat_unread = getCategoryUnread($link, $cat_id);
print "<li class=\"feedCat\" id=\"FCAT-$cat_id\">
<a id=\"FCATN-$cat_id\" href=\"javascript:toggleCollapseCat($cat_id)\">$tmp_category</a>
<a href=\"javascript:viewCategory($cat_id)\" id=\"FCAP-$cat_id\">
<span id=\"FCATCTR-$cat_id\"
class=\"$catctr_class\">($cat_unread unread)$ellipsis</span>
</a></li>";
// !!! NO SPACE before <ul...feedCatList - breaks firstChild DOM function
// -> keyboard navigation, etc.
print "<li id=\"feedCatHolder\" class=\"$holder_class\"><ul class=\"feedCatList\" id=\"FCATLIST-$cat_id\">";
}
printFeedEntry($feed_id, $class, $feed, $unread,
"icons/$feed_id.ico", $link, $rtl_content,
$last_updated, $line["last_error"]);
++$lnum;
}
if (db_num_rows($result) == 0) {
print "<li>No feeds to display.</li>";
}
} else {
// tags
/* $result = db_query($link, "SELECT tag_name,count(ttrss_entries.id) AS count
FROM ttrss_tags,ttrss_entries,ttrss_user_entries WHERE
post_int_id = ttrss_user_entries.int_id AND
unread = true AND ref_id = ttrss_entries.id
AND ttrss_tags.owner_uid = '$owner_uid' GROUP BY tag_name
UNION
select tag_name,0 as count FROM ttrss_tags WHERE owner_uid = '$owner_uid'
ORDER BY tag_name"); */
if (get_pref($link, 'ENABLE_FEED_CATS')) {
print "<li class=\"feedCat\">Tags</li>";
print "<li id=\"feedCatHolder\"><ul class=\"feedCatList\">";
}
$result = db_query($link, "SELECT tag_name,SUM((SELECT COUNT(int_id)
FROM ttrss_user_entries WHERE int_id = post_int_id
AND unread = true)) AS count FROM ttrss_tags
WHERE owner_uid = 2 GROUP BY tag_name ORDER BY tag_name");
$tags = array();
while ($line = db_fetch_assoc($result)) {
$tags[$line["tag_name"]] += $line["count"];
}
foreach (array_keys($tags) as $tag) {
$unread = $tags[$tag];
$class = "tag";
if ($unread > 0) {
$class .= "Unread";
}
printFeedEntry($tag, $class, $tag, $unread, "images/tag.png", $link);
}
if (db_num_rows($result) == 0) {
print "<li>No tags to display.</li>";
}
if (get_pref($link, 'ENABLE_FEED_CATS')) {
print "</ul>\n";
}
}
print "</ul>";
}
?> ?>

View File

@ -6,6 +6,13 @@ a:hover {
color : gray; color : gray;
} }
.notify {
border-color : #999;
background-color : #f9f9f9;
color : black;
-moz-border-radius : 0px;
}
div.notice { div.notice {
background : #f9f9f9; background : #f9f9f9;
border : 1px solid #999999; border : 1px solid #999999;
@ -49,7 +56,7 @@ div.postReply > div.postHeader {
.evenUnreadSelected, .evenSelectedUnread, .evenUnreadSelected td, .evenUnreadSelected, .evenSelectedUnread, .evenUnreadSelected td,
.evenSelectedUnread td { .evenSelectedUnread td {
background-color : #fff7d5; background-color : #ffcccc;
font-weight : bold; font-weight : bold;
border-width : 1px 0px 1px 0px; border-width : 1px 0px 1px 0px;
border-style : solid; border-style : solid;
@ -58,19 +65,19 @@ div.postReply > div.postHeader {
.oddUnreadSelected, .oddSelectedUnread, .oddUnreadSelected td, .oddUnreadSelected, .oddSelectedUnread, .oddUnreadSelected td,
.oddSelectedUnread td { .oddSelectedUnread td {
background-color : #fff7d5; background-color : #ffcccc;
font-weight : bold; font-weight : bold;
} }
.evenSelected, .evenSelected td { .evenSelected, .evenSelected td {
background-color : #fff7d5; background-color : #ffcccc;
border-width : 1px 0px 1px 0px; border-width : 1px 0px 1px 0px;
border-style : solid; border-style : solid;
border-color : #ebebeb; border-color : #ebebeb;
} }
.oddSelected, .evenSelected td { .oddSelected, .evenSelected td {
background-color : #fff7d5; background-color : #ffcccc;
} }
.evenGrayed, .evenGrayed td { .evenGrayed, .evenGrayed td {
@ -189,7 +196,7 @@ tr.title td a:hover {
} }
span.contentPreview:hover { span.contentPreview:hover {
color : black; color : gray;
} }
#dispSwitch a:hover { #dispSwitch a:hover {
@ -320,7 +327,7 @@ div.headlines_cdm {
} }
#headlinesContainer { #headlinesContainer {
margin-left : 1px; margin-left : 0px;
background-color : white; background-color : white;
} }
@ -390,3 +397,4 @@ div.return a:hover {
border-style : solid; border-style : solid;
} }

View File

@ -214,9 +214,9 @@ input.editbox {
padding-left : 2px; padding-left : 2px;
} }
.notify { #notify {
background : #fff7d5; border-width : 1px;
border : 1px solid #d7c47a; border-style : solid;
top : 10px; top : 10px;
right : 35%; right : 35%;
min-width : 30%; min-width : 30%;
@ -230,6 +230,18 @@ input.editbox {
padding : 5px 5px 5px 5px; padding : 5px 5px 5px 5px;
} }
.notify {
border-color : #d7c47a;
background-color : #fff7d5;
color : black;
}
.notifyError {
background-color : #ffcccc;
border-color : #ff0000;
color : black;
}
#dispSwitch { #dispSwitch {
font-size : x-small; font-size : x-small;
text-align : right; text-align : right;