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 } } }
<?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');