Beispiel #1
0
# FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  or visit
# http://www.gnu.org/licenses/gpl.html
#
###############################################################################
# E-mail:	   mbonetti at gmail dot com
# Web page:	   http://gregarius.net/
#
###############################################################################
require_once 'init.php';
$items = new PaginatedItemList(20);
$items->setRenderOptions(IL_NO_COLLAPSE);
if (array_key_exists('state', $_GET) && RSS_STATE_FLAG == $_GET['state']) {
    $items->populate("i.unread & " . RSS_MODE_FLAG_STATE);
    $GLOBALS['rss']->header = new Header(__('Flagged') . " " . __('items'));
} else {
    if (array_key_exists('state', $_GET) && RSS_STATE_STICKY == $_GET['state']) {
        $items->populate("i.unread & " . RSS_MODE_STICKY_STATE);
        $GLOBALS['rss']->header = new Header(__('Sticky') . " " . __('items'));
    } else {
        $items->populate("i.unread & " . RSS_MODE_FLAG_STATE . " OR i.unread & " . RSS_MODE_STICKY_STATE);
        $GLOBALS['rss']->header = new Header(__('items'));
    }
}
$GLOBALS['rss']->feedList = new FeedList(false);
$GLOBALS['rss']->appendContentObject($items);
$GLOBALS['rss']->renderWithTemplate('index.php');
Beispiel #2
0
function readItems($limit)
{
    _pf('read items');
    /*
       $hiddenIds = getHiddenChannelIds();
    if (count($hiddenIds)) {
    	$sqlWhereHidden = " and c.id not in (" . implode(',',$hiddenIds) . ") ";
    } else {
    	$sqlWhereHidden = "";
    }
    */
    $readItems = new PaginatedItemList();
    $readItems->setRenderOptions(IL_TITLE_NO_ESCAPE);
    if (getConfig('rss.config.feedgrouping')) {
        if ($limit <= 0) {
            return;
        }
        $sql = "select " . " c.id" . " from " . getTable("channels") . " c " . " inner join " . getTable("folders") . " f on f.id = c.parent ";
        // $sql .= $sqlWhereHidden;
        $sql .= " where not(c.mode & " . RSS_MODE_DELETED_STATE . ") ";
        if (getConfig('rss.config.absoluteordering')) {
            $sql .= " order by f.position asc, c.position asc";
        } else {
            $sql .= " order by f.name asc, c.title asc";
        }
        $res1 = rss_query($sql);
        while ($readItems->itemCount < $limit && (list($cid) = rss_fetch_row($res1))) {
            $sqlWhere = " not(i.unread & " . RSS_MODE_UNREAD_STATE . ") and i.cid= {$cid}";
            $sqlWhere .= " and i.pubdate <= now() ";
            $readItems->populate($sqlWhere, "", 0, 2, ITEM_SORT_HINT_READ);
            //what if we have less than 2 items.
        }
    } else {
        if ($limit <= 0) {
            return;
        }
        $sqlWhere = " not(i.unread & " . RSS_MODE_UNREAD_STATE . ")  ";
        $sqlWhere .= " and i.pubdate <= now() ";
        //	$sqlWhere .= $sqlWhereHidden;
        $readItems->populate($sqlWhere, "", 0, $limit, ITEM_SORT_HINT_READ);
        $readItems->setRenderOptions(IL_NO_COLLAPSE | IL_TITLE_NO_ESCAPE);
    }
    $readItems->setTitle(__('Recent items'));
    $GLOBALS['rss']->appendContentObject($readItems);
    _pf('end read items');
}
Beispiel #3
0
 foreach ($tarr as $ttkn) {
     $twhere .= " t.tag='" . trim(rss_real_escape_string($ttkn)) . "' or";
 }
 $twhere .= " 1=0";
 $sql = "select fid, count(*) as cnt from " . getTable('metatag') . " m " . "inner join " . getTable('tag') . " t on t.id = m.tid " . " where ({$twhere}) " . " and m.ttype = 'item'" . " group by fid order by 2 desc";
 $res = rss_query($sql);
 $ids = array();
 while ((list($id, $cnt) = rss_fetch_row($res)) && $cnt >= count($tarr)) {
     $ids[] = $id;
 }
 $gotsome = count($ids) > 0;
 $taggedItems = new PaginatedItemList();
 if ($gotsome) {
     $sqlWhere = " i.id in (" . implode(",", $ids) . ") ";
     // include deprecated feeds while showing tags.
     $taggedItems->populate($sqlWhere, "", 0, -1, ITEM_SORT_HINT_MIXED, true);
     $rtags = relatedTags($tarr);
     $related = array();
     foreach ($rtags as $rtag => $cnt) {
         $relLbl = "<a href=\"" . getPath() . "" . (getConfig('rss.output.usemodrewrite') ? "tag/{$rtag}" : "tags.php?tag={$rtag}") . "" . "\">{$rtag}</a>";
         $relPlus = array_key_exists($rtag, $taggedItems->allTags);
         if ($relPlus) {
             $relLbl .= sprintf('&nbsp;[<a title="%d %s %s \'%s %s %s"\' href="%s+%s">+</a>]', $cnt, $cnt > 1 ? __('items') : __('item'), $cnt > 1 || $cnt == 0 ? __('tagged') : __('tagged'), htmlspecialchars($hrTag, ENT_QUOTES), __('and'), htmlspecialchars($rtag, ENT_QUOTES), getPath(getConfig('rss.output.usemodrewrite') ? "tag/{$rtag}" : "tags.php?tag={$rtag}"), htmlspecialchars($urlTag, ENT_QUOTES));
             "&nbsp;[<a " . "title=\"{$cnt} " . ($cnt > 1 ? __('items') : __('item')) . " " . ($cnt > 1 || $cnt == 0 ? __('tagged') : __('tagged')) . " '" . htmlspecialchars($hrTag, ENT_QUOTES) . " " . __('and') . " " . htmlspecialchars($rtag, ENT_QUOTES) . "'\" " . "href=\"" . getPath() . "" . (getConfig('rss.output.usemodrewrite') ? "tag/{$rtag}" : "tags.php?tag={$rtag}") . "" . "+" . $urlTag . "\">+</a>]";
         }
         $idx = $relPlus ? $taggedItems->allTags[$rtag] : 0;
         $related["{$idx}" . "_" . "{$rtag}"] = $relLbl . "";
     }
     krsort($related);
 }
 // done! Render some stuff
Beispiel #4
0
function doItems($cids, $fid, $vfid, $title, $iid, $y, $m, $d, $nv, $show_what, $show_private)
{
    $do_show = $show_what;
    //should we honour unread-only?
    if ($show_what == SHOW_UNREAD_ONLY) {
        // permalink will always be printed
        if ($iid != "") {
            $do_show = SHOW_READ_AND_UNREAD;
        } else {
            // archives, folders, channels
            $sql = "select count(*) from " . getTable('item') . " where" . " (unread & " . RSS_MODE_UNREAD_STATE . ")" . " and not(unread & " . RSS_MODE_DELETED_STATE . ") ";
            //archive?
            if ($m > 0 && $y > 0) {
                $sql .= " and month(ifnull(pubdate,added))= {$m} " . " and year(ifnull(pubdate, added))= {$y} ";
                if ($d > 0) {
                    $sql .= " and dayofmonth(ifnull(pubdate,added))= {$d} ";
                }
            }
            if ($cids && count($cids)) {
                $sql .= " and cid in (" . implode(',', $cids) . ")";
            }
            list($unreadCount) = rss_fetch_row(rss_query($sql));
            if ($unreadCount == 0) {
                $do_show = SHOW_READ_AND_UNREAD;
            }
        }
    }
    $items = new PaginatedItemList();
    $severalFeeds = $fid != null || $vfid != null;
    if ($severalFeeds && !getConfig('rss.config.feedgrouping')) {
        $sqlWhere = "(";
        foreach ($cids as $cid) {
            $sqlWhere .= " i.cid = {$cid} or ";
        }
        $sqlWhere .= " 1=0) ";
        $hint = ITEM_SORT_HINT_MIXED;
        if ($do_show == SHOW_UNREAD_ONLY) {
            $sqlWhere .= " and (i.unread & " . RSS_MODE_UNREAD_STATE . ") ";
            $hint = ITEM_SORT_HINT_UNREAD;
        }
        // how many items should we display in a folder view?
        // default to numitemsonpage.
        $cnt = getConfig('rss.output.frontpage.numitems');
        // if that is set to zero, use itemsinchannelview times the number of feeds in the folder
        if ($cnt == 0) {
            $cnt = count($cids) * getConfig('rss.output.itemsinchannelview');
        }
        // should that be zero too, go for a fixed value
        if ($cnt == 0) {
            // arbitrary!
            $cnt = 50;
        }
        $items->populate($sqlWhere, "", 0, $cnt, $hint);
    } else {
        if (!isset($cids)) {
            $cids = array(-1);
        }
        foreach ($cids as $cid) {
            $hint = ITEM_SORT_HINT_MIXED;
            if ($cid > -1) {
                $sqlWhere = "i.cid = {$cid}";
                if ($do_show == SHOW_UNREAD_ONLY) {
                    $sqlWhere .= " and (i.unread & " . RSS_MODE_UNREAD_STATE . ") ";
                    $hint = ITEM_SORT_HINT_UNREAD;
                }
            } else {
                $sqlWhere = " 1 = 1 ";
            }
            if ($iid != "") {
                $sqlWhere .= " and i.id={$iid}";
            }
            if ($m > 0 && $y > 0) {
                $sqlWhere .= " and month(ifnull(i.pubdate,i.added))= {$m} " . " and year(ifnull(i.pubdate, i.added))= {$y} ";
                if ($d > 0) {
                    $sqlWhere .= " and dayofmonth(ifnull(i.pubdate,i.added))= {$d} ";
                }
            }
            if ($m == 0 && $y == 0) {
                $sqlLimit = getConfig('rss.output.itemsinchannelview');
            } else {
                $sqlLimit = RSS_DB_MAX_QUERY_RESULTS;
            }
            /*
            $sqlOrder = " order by i.unread & ".RSS_MODE_UNREAD_STATE." desc";
            if(getConfig("rss.config.datedesc")){
            	$sqlOrder .= ", ts desc, i.id asc";
            } else {
            	$sqlOrder .= ", ts asc, i.id asc";
            }
            */
            $sqlOrder = "";
            $items->populate($sqlWhere, $sqlOrder, 0, $sqlLimit, $hint, true);
        }
    }
    if ($items->unreadCount && $iid == "") {
        $items->preRender[] = array("showViewForm", array($show_what, $show_private));
        if (!$severalFeeds) {
            $items->preRender[] = array("markReadForm", $cid);
            $title .= " " . sprintf(__('<strong id="%s" style="%s">(%d unread)</strong>'), "ucnt", "", $items->unreadCount);
        } else {
            if (!$vfid) {
                list($fid) = rss_fetch_row(rss_query('select parent from ' . getTable('channels') . 'where id = ' . $cids[0]));
                $title .= " " . sprintf(__('<strong id="%s" style="%s">(%d unread)</strong>'), "ucnt", "", $items->unreadCount);
                $items->preRender[] = array("markFolderReadForm", $fid);
            } else {
                list($fid) = $vfid;
                $title .= " " . sprintf(__('<strong id="%s" style="%s">(%d unread)</strong>'), "ucnt", "", $items->unreadCount);
                $items->preRender[] = array("markVirtualFolderReadForm", $vfid);
            }
        }
    }
    $items->setTitle($title);
    if ($severalFeeds) {
        $items->setRenderOptions(IL_NO_COLLAPSE | IL_FOLDER_VIEW);
    } elseif ($cid && $cid > -1) {
        $items->setRenderOptions(IL_CHANNEL_VIEW);
    } else {
        $items->setRenderOptions(IL_NO_COLLAPSE | IL_FOLDER_VIEW);
    }
    $items->setRenderOptions(IL_TITLE_NO_ESCAPE);
    if ($nv != null) {
        list($prev, $succ, $up) = $nv;
        $readMoreNav = "";
        if ($prev != null) {
            $lbl = $prev['lbl'];
            if (function_exists('mb_strlen') && function_exists('mb_substr') && mb_strlen($lbl) > 40) {
                $lbl = mb_substr($lbl, 0, 37) . "...";
            } elseif (strlen($lbl) > 40) {
                $lbl = substr($lbl, 0, 37) . "...";
            }
            $readMoreNav .= "<a href=\"" . $prev['url'] . "\" class=\"fl\">" . ACT_NAV_PREV_PREFIX . "{$lbl}</a>\n";
        }
        if ($succ != null) {
            $lbl = $succ['lbl'];
            if (function_exists('mb_strlen') && function_exists('mb_substr') && mb_strlen($lbl) > 40) {
                $lbl = mb_substr($lbl, 0, 37) . "...";
            } elseif (strlen($lbl) > 40) {
                $lbl = substr($lbl, 0, 37) . "...";
            }
            $readMoreNav .= "<a href=\"" . $succ['url'] . "\" class=\"fr\">{$lbl}" . ACT_NAV_SUCC_POSTFIX . "</a>\n";
        }
        if ($readMoreNav != "") {
            $items->afterList = "<div class=\"readmore\">{$readMoreNav}" . "<hr class=\"clearer hidden\"/>\n</div>\n";
        }
    }
    $GLOBALS['rss']->appendContentObject($items);
}