"; // unread items first! $sql = "select i.title, c.title, c.id, i.unread, " ." i.url, i.description, c.icon, " ." if (i.pubdate is null, unix_timestamp(i.added), unix_timestamp(i.pubdate)) as ts, " ." i.pubdate is not null as ispubdate, " ." i.id " ." from item i, channels c, folders f " ." where i.cid = c.id and i.unread=1 and f.id=c.parent"; if (defined('ABSOLUTE_ORDERING') && ABSOLUTE_ORDERING) { $sql .= " order by f.position asc, c.position asc"; } else { $sql .=" order by c.parent asc, c.title asc"; } $sql .=", i.added desc, i.id asc"; // Problem: to limit or not to limit? // Should the frontpage get the whole load of unread items // for a channel or not. And if not, should the user get them // all when he click the channel title? //." limit " . ITEMS_ON_CHANNELVIEW ; $res0=rss_query($sql); if (rss_num_rows($res0) > 0) { markAllReadForm(); while (list($title_,$ctitle_, $cid_, $unread_, $url_, $descr_, $icon_, $ts_, $iispubdate_, $iid_) = rss_fetch_row($res0)) { $items[] = array($cid_, $ctitle_, $icon_ , $title_ , 1 , $url_ , $descr_, $ts_, $iispubdate_, $iid_ ); } itemsList ( sprintf(H2_UNREAD_ITEMS , rss_num_rows($res0)), $items ); } // next: unread. Must find a better solution instead of iterating over the channels twice. $sql = "select " ." c.id, c.title, c.icon " ." from channels c, folders f " ." where c.parent = f.id "; if (defined('ABSOLUTE_ORDERING') && ABSOLUTE_ORDERING) { $sql .= " order by f.position asc, c.position asc"; } else { $sql .=" order by c.parent asc, c.title asc"; } $res1=rss_query($sql); $items = array(); while (list($cid,$ctitle, $icon) = rss_fetch_row($res1)) { $sql = "select cid, title, url, description, unread, " ." if (pubdate is null, unix_timestamp(added), unix_timestamp(pubdate)) as ts, " ." pubdate is not null as ispubdate, " ." id " ." from item " ." where cid = $cid and unread = 0" ." order by added desc, id asc " ." limit 2"; $res = rss_query($sql); if (rss_num_rows($res) > 0) { while (list($cid, $ititle, $url, $description, $unread, $ts, $ispubdate, $iid) = rss_fetch_row($res)) { $items[] = array($cid,$ctitle,$icon,$ititle,$unread,$url,$description, $ts, $ispubdate, $iid); } } } itemsList(H2_RECENT_ITEMS,$items); echo "\n"; } function markAllReadForm() { echo "
" ."

" ."
"; } ?>