id = $id; $this->title = $title; $this->url = $url; $this->publicUrl = preg_replace( '|(https?://)([^:]+:[^@]+@)(.+)$|','\1\3',$url ); $this->siteurl = $siteurl; $this->name = $name; $this->parent = $parent; if ( getConfig('rss.output.showfavicons') && $icon){ if (substr($icon,0,5) == 'blob:') { $this->icon = getPath() . "extlib/favicon.php?url=". rss_real_escape_string(substr($icon,5)); } else { $this->icon = $icon; } } elseif (getConfig('rss.output.showfavicons')) { $this->icon = getExternalThemeFile("media/noicon.png"); } else { $this->icon = false; } $this->descr = $descr; $this->mode = $mode; if (getConfig('rss.output.usemodrewrite')) { //$this->rlink = getPath().preg_replace("/[^a-zA-Z0-9_]/", "_", $title)."/"; /* EXPERIMENTAL! */ $this->rlink = getPath() . utf8_uri_encode(preg_replace('/[\s&\/\+]/','_',$title)) . "/"; } else { $this->rlink = getPath()."feed.php?channel=$id"; } if ($unreadCount > 0) { $this->rdLbl= sprintf(__('(%d unread)'), "cid$id","",$unreadCount); $this->class_= "feed title unread"; } else { $this->rdLbl= ""; $this->class_= "feed title"; } } /** * Renders this FeedListItem: Moves the superglobal "current feed" pointer * to this, then includes the relevant template */ function render() { $GLOBALS['rss']->currentFeedsFeed = $this; eval($GLOBALS['rss'] ->getCachedTemplateFile("feedsfeed.php")); } } class FeedFolder { var $feeds = array (); var $name; var $id; var $isCollapsed = false; var $rlink; var $isRootFolder = false; var $rootList; function FeedFolder($name, $id, &$rootList) { $this->name = $name; $this->id = $id; if (getConfig('rss.output.usemodrewrite')) { $this->rlink = getPath().preg_replace("/[^a-zA-Z0-9_]/", "_", $name)."/"; } else { $this->rlink = getPath()."feed.php?folder=$id"; } $this->isRootFolder = ($id == 0); $this->rootList = $rootList; } function render() { $GLOBALS['rss']->currentFeedsFolder = $this; eval($GLOBALS['rss'] ->getCachedTemplateFile("feedsfolder.php")); } } class FeedList { var $collapsed_folders = array (); var $collapsed_ids = array (); var $folders = array (); var $activeId; var $feedCount = 0; var $columnTitle; var $stats; function FeedList($activeId) { _pf('FeedList() ctor'); $this ->columnTitle= __('Feeds'); $this->activeId = $activeId; $this->loadCollapsedState(); $this->populate(); } function getStats() { _pf('getStats()'); _pf(' ... unreadCount'); $unread = getUnreadCount(null, null); _pf(' ... done: unreadCount'); _pf(' ... totalCount'); $sql = "select count(*) from ".getTable("item2user") . "i " . " inner join " . getTable('channels2user') . " c2u " ." on i.fkcid=c2u.fkcid where i.flgdeleted=0 " ." and c2u.fkuid=" . rss_user_id() ." and i.fkuid=" . rss_user_id() ." and c2u.flgdeleted=0" . (hidePrivate()? " and i.flgprivate=0":""); //echo $sql; $res = rss_query($sql); list ($total) = rss_fetch_row($res); _pf(' ... done: totalCount'); _pf(' ... feedsCount'); $res = rss_query("select count(*) from " .getTable("channels2user")." where flgdeleted=0 " ." and fkuid=" . rss_user_id() . (hidePrivate()? " and flgprivate=0":"") ); list ($channelcount) = rss_fetch_row($res); _pf(' ... done: feedsCount'); $this ->stats = sprintf(__('%d items (%d unread) in %d feeds'), $total, $unread, $channelcount); _pf('done: getStats()'); return $this -> stats; } function loadCollapsedState() { _pf('FeedList->loadCollapsedState()...'); if (getConfig('rss.output.channelcollapse')) { //read per-user stored collapsed folders if (array_key_exists(COLLAPSED_FOLDERS_COOKIE, $_COOKIE)) { $this->collapsed_ids = explode(":", $_COOKIE[COLLAPSED_FOLDERS_COOKIE]); } elseif (empty($this->collapsed_ids) && getConfig("rss.output.channelcollapsedefault")) { // Lets collapse all folders $res = rss_query("select id from " . getTable('folders') . " where id != 0"); while (list ($this->collapsed_ids[]) = rss_fetch_row($res)) { } if (!headers_sent()) { // Sajax does not allow us to set cookies setcookie(COLLAPSED_FOLDERS_COOKIE, implode(":", $this->collapsed_ids ) , time()+COOKIE_LIFESPAN,getPath()); } } //get unread count per folder $sql = "select f.id, f.name, count(*) as cnt " ." from " . getTable('item2user') ." i2u " . " inner join " . getTable('channels2user') . " c2u on c2u.fkuid=" . rss_user_id() . " inner join " . getTable('channels') . " c on c.id = c2u.fkcid" . " inner join " . getTable('folders') ." f on c.parent=f.id" ." where i2u.flgunread =1 " ." and i2u.flgdeleted=0 "; if (hidePrivate()) { $sql .=" and i2u.flgprivate =0 "; } $sql .= " and c2u.flgdeleted=0 " ." group by f.id"; _pf('query'); $res = rss_query($sql); _pf('ok'); while (list ($cid, $cname, $cuc) = rss_fetch_row($res)) { $this->collapsed_folders[$cid] = $cuc; } sort($this->collapsed_ids); } _pf('done'); } function getFeedCount() { return $this -> feedCount; } function populate() { _pf('FeedList->populate() ...'); $sql = "select " ." c.id, c.title, c.url, c.siteurl, f.name, c.parent, c2u.icon, c.descr, c2u.flgdeleted,c2u.flgprivate " ." from ".getTable("channels")." c " . " inner join " . getTable("channels2user")." c2u on c2u.fkcid=c.id " . " inner join " . getTable("folders") . " f on f.id = c.parent " ." where c2u.fkuid=" . rss_user_id(); if (hidePrivate()) { $sql .= " and c2u.flgprivate=0 "; } $sql .= " and c2u.flgdeleted=0 "; if (getConfig('rss.config.absoluteordering')) { $sql .= " order by f.position asc, c.position asc"; } else { $sql .= " order by f.name, c.title asc"; } $res = rss_query($sql); $this -> feedCount = rss_num_rows($res); $ucres = rss_query ("select fkcid, count(*) from " .getTable("item2user") ." i2u where i2u.flgunread=1 and i2u.flgdeleted=0 and i2u.fkuid=" .rss_user_id() ." group by i2u.fkcid"); $uc = array(); while (list($uccid,$ucuc) = rss_fetch_row($ucres)) { $uc[$uccid]=$ucuc; } while (list ($cid, $ctitle, $curl, $csiteurl, $fname, $cparent, $cico, $cdescr, $cmode) = rss_fetch_row($res)) { $ucc= 0; if (array_key_exists($cid,$uc)) { $ucc=$uc[$cid]; } $f = new FeedListItem($cid, $ctitle, $curl, $csiteurl, $fname, $cparent, $cico, $cdescr, $cmode, $ucc); $f -> isActiveFeed = ($this->activeId && $cid == $this->activeId ); if (!array_key_exists($cparent, $this->folders)) { $this->folders[$cparent] = new FeedFolder($fname, $cparent,$this); } $this->folders[$cparent]->feeds[] = $f; $this->folders[$cparent]->isCollapsed = in_array($cparent, $this->collapsed_ids) && ($cparent > 0); } _pf('done'); } function render() { _pf('FeedList->render() ...'); eval($GLOBALS['rss'] ->getCachedTemplateFile("feeds.php")); _pf('done'); } } ?>