コード例 #1
0
ファイル: part.feeds.php プロジェクト: blablubli/owncloudapps
function print_collection_list($list)
{
    foreach ($list as $collection) {
        if ($collection instanceof OCA\News\Folder) {
            $tmpl_folder = new OCP\Template("news", "part.listfolder");
            $tmpl_folder->assign('folder', $collection);
            $tmpl_folder->printpage();
            print_collection_list($collection->getChildren());
            echo '</ul></li>';
        } elseif ($collection instanceof OCA\News\Feed) {
            //onhover $(element).attr('id', 'newID');
            $itemmapper = new OCA\News\ItemMapper();
            $items = $itemmapper->findByFeedId($collection->getId());
            $counter = 0;
            foreach ($items as $item) {
                if (!$item->isRead()) {
                    ++$counter;
                }
            }
            $tmpl_feed = new OCP\Template("news", "part.listfeed");
            $tmpl_feed->assign('feed', $collection);
            $tmpl_feed->assign('unreadItemsCount', $counter);
            $tmpl_feed->printpage();
        } else {
            //TODO:handle error in this case
        }
    }
}
コード例 #2
0
ファイル: importopml.php プロジェクト: netcon-source/apps
function importFeed($feedurl, $folderid, $feedtitle)
{
    global $eventSource;
    global $l;
    $feedmapper = new OCA\News\FeedMapper();
    $feedid = $feedmapper->findIdFromUrl($feedurl);
    if ($feedid === null) {
        $feed = OCA\News\Utils::slimFetch($feedurl);
        if ($feed !== null) {
            $feed->setTitle($feedtitle);
            //we want the title of the feed to be the one from the opml file
            $feedid = $feedmapper->save($feed, $folderid);
            $itemmapper = new OCA\News\ItemMapper(OCP\USER::getUser());
            $unreadItemsCount = $itemmapper->countAllStatus($feedid, OCA\News\StatusFlag::UNREAD);
            $tmpl_listfeed = new OCP\Template("news", "part.listfeed");
            $tmpl_listfeed->assign('feed', $feed);
            $tmpl_listfeed->assign('unreadItemsCount', $unreadItemsCount);
            $listfeed = $tmpl_listfeed->fetchPage();
            $eventSource->send('progress', array('data' => array('type' => 'feed', 'folderid' => $folderid, 'listfeed' => $listfeed)));
        }
    } else {
        OCP\Util::writeLog('news', 'ajax/importopml.php: This feed is already here: ' . $feedurl, OCP\Util::WARN);
        return true;
    }
    if ($feed === null || !$feedid) {
        OCP\Util::writeLog('news', 'ajax/importopml.php: Error adding feed: ' . $feedurl, OCP\Util::ERROR);
        return false;
    }
    return true;
}
コード例 #3
0
ファイル: updatefeed.php プロジェクト: netcon-source/apps
*
* This file is licensed under the Affero General Public License version 3 or later.
* See the COPYING-README file
*
*/
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('news');
OCP\JSON::callCheck();
session_write_close();
$userid = OCP\USER::getUser();
$feedid = $_POST['feedid'];
$feedurl = $_POST['feedurl'];
$folderid = $_POST['folderid'];
$newfeed = OCA\News\Utils::fetch($feedurl);
$newfeedid = false;
if ($newfeed !== null) {
    $feedmapper = new OCA\News\FeedMapper();
    $newfeedid = $feedmapper->save($newfeed, $folderid);
}
$l = OC_L10N::get('news');
if (!$newfeedid) {
    OCP\JSON::error(array('data' => array('message' => $l->t('Error updating feed.'))));
    OCP\Util::writeLog('news', 'ajax/updatefeed.php: Error updating feed: ' . $_POST['feedid'], OCP\Util::ERROR);
    exit;
} else {
    $itemmapper = new OCA\News\ItemMapper($userid);
    $unreadcounter = $itemmapper->countAllStatus($newfeedid, OCA\News\StatusFlag::UNREAD);
    OCP\JSON::success(array('data' => array('message' => $l->t('Feed updated!'), 'unreadcount' => $unreadcounter)));
    exit;
}
コード例 #4
0
*
* @author Bernhard Posselt
* Copyright (c) 2012 - Bernhard Posselt <*****@*****.**>
*
* This file is licensed under the Affero General Public License version 3 or later.
* See the COPYING-README file
*
*/
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('news');
OCP\JSON::callCheck();
session_write_close();
$feedId = $_POST['feedId'];
$mostRecentItemId = (int) $_POST['mostRecentItemId'];
$itemMapper = new OCA\News\ItemMapper();
//echo $mostRecentItem->getDate();
switch ($feedId) {
    case -2:
        $items = $itemMapper->findEveryItemByStatus(OCA\News\StatusFlag::UNREAD);
        break;
    case -1:
        $items = $itemMapper->findEveryItemByStatus(OCA\News\StatusFlag::UNREAD | OCA\News\StatusFlag::IMPORTANT);
        break;
    default:
        $items = $itemMapper->findAllStatus($feedId, OCA\News\StatusFlag::UNREAD);
        break;
}
// FIXME: maybe there is a way to set all items read in the
// FeedMapper instead of iterating through every item and updating as
// necessary
コード例 #5
0
ファイル: setitemstatus.php プロジェクト: netcon-source/apps
*
* @author Alessandro Cosentino
* Copyright (c) 2012 - Alessandro Cosentino <*****@*****.**>
*
* This file is licensed under the Affero General Public License version 3 or later.
* See the COPYING-README file
*
*/
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('news');
OCP\JSON::callCheck();
session_write_close();
$itemId = $_POST['itemId'];
$status = $_POST['status'];
$itemMapper = new OCA\News\ItemMapper();
$item = $itemMapper->findById($itemId);
switch ($status) {
    case 'read':
        $item->setRead();
        break;
    case 'unread':
        $item->setUnread();
        break;
    case 'important':
        $item->setImportant();
        break;
    case 'unimportant':
        $item->setUnimportant();
        break;
    default:
コード例 #6
0
ファイル: createfeed.php プロジェクト: blablubli/owncloudapps
OCP\JSON::checkAppEnabled('news');
OCP\JSON::callCheck();
session_write_close();
$userid = OCP\USER::getUser();
$feedurl = trim($_POST['feedurl']);
$folderid = trim($_POST['folderid']);
$feedmapper = new OCA\News\FeedMapper($userid);
$feedid = $feedmapper->findIdFromUrl($feedurl);
$l = OC_L10N::get('news');
if ($feedid === null) {
    $feed = OCA\News\Utils::fetch($feedurl);
    if ($feed !== null) {
        $feedid = $feedmapper->save($feed, $folderid);
    }
} else {
    OCP\JSON::error(array('data' => array('message' => $l->t('Feed already exists.'))));
    OCP\Util::writeLog('news', 'ajax/createfeed.php: Error adding feed: ' . $_POST['feedurl'], OCP\Util::ERROR);
    exit;
}
if ($feed === null || !$feedid) {
    OCP\JSON::error(array('data' => array('message' => $l->t('Error adding feed.'))));
    OCP\Util::writeLog('news', 'ajax/createfeed.php: Error adding feed: ' . $_POST['feedurl'], OCP\Util::ERROR);
    exit;
}
$itemmapper = new OCA\News\ItemMapper($userid);
$unreadItemsCount = $itemmapper->countAllStatus($feedid, OCA\News\StatusFlag::UNREAD);
$tmpl_listfeed = new OCP\Template("news", "part.listfeed");
$tmpl_listfeed->assign('feed', $feed);
$tmpl_listfeed->assign('unreadItemsCount', $unreadItemsCount);
$listfeed = $tmpl_listfeed->fetchPage();
OCP\JSON::success(array('data' => array('message' => $l->t('Feed added!'), 'feedid' => $feedid, 'listfeed' => $listfeed)));
コード例 #7
0
ファイル: loadfeed.php プロジェクト: blablubli/owncloudapps
*/
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('news');
OCP\JSON::callCheck();
session_write_close();
$userid = OCP\USER::getUser();
$feedId = $_POST['id'];
$feedType = $_POST['type'];
OCP\Config::setUserValue(OCP\USER::getUser(), 'news', 'lastViewedFeed', $feedId);
OCP\Config::setUserValue(OCP\USER::getUser(), 'news', 'lastViewedFeedType', $feedType);
$l = OC_L10N::get('news');
$itemsTpl = new OCP\Template("news", "part.items");
$itemsTpl->assign('feedid', $feedId);
$feedItems = $itemsTpl->fetchPage();
$itemMapper = new OCA\News\ItemMapper();
switch ($feedId) {
    case -1:
        $feedTitle = $l->t('Starred');
        $unreadItemCount = $itemMapper->countAllStatus($feedId, OCA\News\StatusFlag::IMPORTANT);
        break;
    case -2:
        $feedTitle = $l->t('New articles');
        $unreadItemCount = $itemMapper->countEveryItemByStatus(OCA\News\StatusFlag::UNREAD);
        break;
    default:
        $feedMapper = new OCA\News\FeedMapper();
        $feed = $feedMapper->findById($feedId);
        $feedTitle = $feed->getTitle();
        $unreadItemCount = $itemMapper->countAllStatus($feedId, OCA\News\StatusFlag::UNREAD);
        break;
コード例 #8
0
ファイル: part.items.php プロジェクト: blablubli/owncloudapps
<?php

$feedId = isset($_['feedid']) ? $_['feedid'] : '';
$itemMapper = new OCA\News\ItemMapper();
$showAll = OCP\Config::getUserValue(OCP\USER::getUser(), 'news', 'showAll');
$specialfeed = false;
if ($feedId == -1 || $feedId == -2) {
    //TODO: change this values, too obscure
    $specialfeed = true;
    $status = $feedId == -1 ? OCA\News\StatusFlag::IMPORTANT : OCA\News\StatusFlag::UNREAD;
    $items = $itemMapper->findEveryItemByStatus($status);
} else {
    if ($showAll) {
        $items = $itemMapper->findByFeedId($feedId);
    } else {
        $items = $itemMapper->findAllStatus($feedId, OCA\News\StatusFlag::UNREAD);
    }
}
echo '<ul>';
foreach ($items as $item) {
    if ($item->isRead()) {
        $newsItemClass = "read";
    } else {
        $newsItemClass = "";
    }
    if ($item->isImportant()) {
        $starClass = 'important';
        $startTitle = $l->t('Mark as unimportant');
    } else {
        $starClass = '';
        $startTitle = $l->t('Mark as important');
コード例 #9
0
ファイル: test.php プロジェクト: blablubli/owncloudapps
<?php

$itemmapper = new OCA\News\ItemMapper();
$items = $itemmapper->findAllStatus(155, OCA\News\StatusFlag::UNREAD);
foreach ($items as $item) {
    echo $item->getTitle();
}