function outputFeedList($link, $tags = false) { print "<ul class=\"feedList\" id=\"feedList\">"; $owner_uid = $_SESSION["uid"]; /* virtual feeds */ if (get_pref($link, 'ENABLE_FEED_CATS')) { $cat_hidden = get_pref($link, "_COLLAPSED_SPECIAL"); printCategoryHeader($link, -1, $cat_hidden, false); } foreach (array(-4, -3, -1, -2, 0) as $i) { printFeedEntry($i, "virt", false, false, false, $link); } if (get_pref($link, 'ENABLE_FEED_CATS')) { print "</ul></li>"; } if (!$tags) { $result = db_query($link, "SELECT * FROM\n\t\t\t\t\tttrss_labels2 WHERE owner_uid = '{$owner_uid}' ORDER by caption"); if (db_num_rows($result) > 0) { if (get_pref($link, 'ENABLE_FEED_CATS')) { $cat_hidden = get_pref($link, "_COLLAPSED_LABELS"); printCategoryHeader($link, -2, $cat_hidden, true); } else { print "<li><hr></li>"; } } while ($line = db_fetch_assoc($result)) { $label_id = -$line['id'] - 11; $count = getFeedUnread($link, $label_id); printFeedEntry($label_id, "label", $line["caption"], $count, false, $link, false, false, false, $line['fg_color'], $line['bg_color']); } 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 = "order_id,category,unread DESC,title"; } else { $order_by_qpart = "order_id,category,title"; } } else { if (get_pref($link, "FEEDS_SORT_BY_UNREAD")) { $order_by_qpart = "unread DESC,title"; } else { $order_by_qpart = "title"; } } $age_qpart = getMaxAgeSubquery(); $query = "SELECT ttrss_feeds.*,\n\t\t\t\t" . SUBSTRING_FOR_DATE . "(last_updated,1,19) AS last_updated_noms,\n\t\t\t\tcat_id,last_error,\n\t\t\t\tttrss_feed_categories.title AS category,\n\t\t\t\tttrss_feed_categories.collapsed,\n\t\t\t\tvalue AS unread\t\n\t\t\t\tFROM ttrss_feeds LEFT JOIN ttrss_feed_categories\n\t\t\t\t\tON (ttrss_feed_categories.id = cat_id)\t\t\t\n\t\t\t\tLEFT JOIN ttrss_counters_cache \n\t\t\t\t\tON\n\t\t\t\t\t\t(ttrss_feeds.id = feed_id)\n\t\t\t\tWHERE \n\t\t\t\t\tttrss_feeds.owner_uid = '{$owner_uid}' AND parent_feed IS NULL\n\t\t\t\tORDER BY {$order_by_qpart}"; $result = db_query($link, $query); $actid = $_REQUEST["actid"]; /* real feeds */ $lnum = 0; $total_unread = 0; $category = ""; $short_date = get_pref($link, 'SHORT_DATE_FORMAT'); while ($line = db_fetch_assoc($result)) { $feed = htmlspecialchars(trim($line["title"])); if (!$feed) { $feed = "[Untitled]"; } $feed_id = $line["id"]; $unread = $line["unread"]; $subop = $_REQUEST["subop"]; 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 SUM(value) AS unread FROM ttrss_feeds, ttrss_counters_cache \n\t\t\t\t\t\tWHERE parent_feed = '{$feed_id}' AND feed_id = id"); $unread += db_fetch_result($tmp_result, 0, "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 ($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 = sql_bool_to_bool($line["collapsed"]); // workaround for NULL category if ($category == __("Uncategorized")) { $collapsed = get_pref($link, "_COLLAPSED_UNCAT"); } $cat_id = (int) $cat_id; printCategoryHeader($link, $cat_id, $collapsed, true); } printFeedEntry($feed_id, $class, $feed, $unread, false, $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 "<ul class=\"feedCatList\">"; } $age_qpart = getMaxAgeSubquery(); $result = db_query($link, "SELECT tag_name,SUM((SELECT COUNT(int_id) \n\t\t\t\tFROM ttrss_user_entries,ttrss_entries WHERE int_id = post_int_id \n\t\t\t\t\tAND ref_id = id AND {$age_qpart}\n\t\t\t\t\tAND unread = true)) AS count FROM ttrss_tags \n\t\t\t\t\tWHERE owner_uid = " . $_SESSION['uid'] . " GROUP BY tag_name \n\t\t\t\t\tORDER BY count DESC LIMIT 50"); $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"; 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>"; } } print "</ul>"; }
function outputFeedList($link, $special = true) { $feedlist = array(); $enable_cats = get_pref($link, 'ENABLE_FEED_CATS'); $feedlist['identifier'] = 'id'; $feedlist['label'] = 'name'; $feedlist['items'] = array(); $owner_uid = $_SESSION["uid"]; /* virtual feeds */ if ($special) { if ($enable_cats) { $cat_hidden = get_pref($link, "_COLLAPSED_SPECIAL"); $cat = feedlist_init_cat($link, -1, $cat_hidden); } else { $cat['items'] = array(); } foreach (array(-4, -3, -1, -2, 0) as $i) { array_push($cat['items'], feedlist_init_feed($link, $i)); } if ($enable_cats) { array_push($feedlist['items'], $cat); } else { $feedlist['items'] = array_merge($feedlist['items'], $cat['items']); } $result = db_query($link, "SELECT * FROM\n\t\t\t\tttrss_labels2 WHERE owner_uid = '{$owner_uid}' ORDER by caption"); if (db_num_rows($result) > 0) { if (get_pref($link, 'ENABLE_FEED_CATS')) { $cat_hidden = get_pref($link, "_COLLAPSED_LABELS"); $cat = feedlist_init_cat($link, -2, $cat_hidden); } else { $cat['items'] = array(); } while ($line = db_fetch_assoc($result)) { $label_id = -$line['id'] - 11; $count = getFeedUnread($link, $label_id); $feed = feedlist_init_feed($link, $label_id, false, $count); $feed['fg_color'] = $line['fg_color']; $feed['bg_color'] = $line['bg_color']; array_push($cat['items'], $feed); } if ($enable_cats) { array_push($feedlist['items'], $cat); } else { $feedlist['items'] = array_merge($feedlist['items'], $cat['items']); } } } /* if (get_pref($link, 'ENABLE_FEED_CATS')) { if (get_pref($link, "FEEDS_SORT_BY_UNREAD")) { $order_by_qpart = "order_id,category,unread DESC,title"; } else { $order_by_qpart = "order_id,category,title"; } } else { if (get_pref($link, "FEEDS_SORT_BY_UNREAD")) { $order_by_qpart = "unread DESC,title"; } else { $order_by_qpart = "title"; } } */ /* real feeds */ if ($enable_cats) { $order_by_qpart = "ttrss_feed_categories.order_id,category,\n\t\t\t\tttrss_feeds.order_id,title"; } else { $order_by_qpart = "title"; } $age_qpart = getMaxAgeSubquery(); $query = "SELECT ttrss_feeds.id, ttrss_feeds.title,\n\t\t\t" . SUBSTRING_FOR_DATE . "(last_updated,1,19) AS last_updated_noms,\n\t\t\tcat_id,last_error,\n\t\t\tttrss_feed_categories.title AS category,\n\t\t\tttrss_feed_categories.collapsed,\n\t\t\tvalue AS unread\n\t\t\tFROM ttrss_feeds LEFT JOIN ttrss_feed_categories\n\t\t\t\tON (ttrss_feed_categories.id = cat_id)\n\t\t\tLEFT JOIN ttrss_counters_cache\n\t\t\t\tON\n\t\t\t\t\t(ttrss_feeds.id = feed_id)\n\t\t\tWHERE\n\t\t\t\tttrss_feeds.owner_uid = '{$owner_uid}'\n\t\t\tORDER BY {$order_by_qpart}"; $result = db_query($link, $query); $actid = $_REQUEST["actid"]; if (db_num_rows($result) > 0) { $category = ""; if (!$enable_cats) { $cat['items'] = array(); } else { $cat = false; } while ($line = db_fetch_assoc($result)) { $feed = htmlspecialchars(trim($line["title"])); if (!$feed) { $feed = "[Untitled]"; } $feed_id = $line["id"]; $unread = $line["unread"]; $cat_id = $line["cat_id"]; $tmp_category = $line["category"]; if (!$tmp_category) { $tmp_category = __("Uncategorized"); } if ($category != $tmp_category && $enable_cats) { $category = $tmp_category; $collapsed = sql_bool_to_bool($line["collapsed"]); // workaround for NULL category if ($category == __("Uncategorized")) { $collapsed = get_pref($link, "_COLLAPSED_UNCAT"); } if ($cat) { array_push($feedlist['items'], $cat); } $cat = feedlist_init_cat($link, $cat_id, $collapsed); } $updated = make_local_datetime($link, $line["updated_noms"], false); array_push($cat['items'], feedlist_init_feed($link, $feed_id, $feed, $unread, $line['last_error'], $updated)); } if ($enable_cats) { array_push($feedlist['items'], $cat); } else { $feedlist['items'] = array_merge($feedlist['items'], $cat['items']); } } return $feedlist; }