summaryrefslogtreecommitdiffstats
path: root/templates/part.feeds.php
blob: 044d954ab2a90e080ad46aa3b67c6a1f3e74394a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php

	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->findAll($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('unreadItems',$counter);
				$tmpl_feed->printpage();
			}
			else {
			//TODO:handle error in this case
			}
		}
	
	}

	$allfeeds = isset($_['allfeeds']) ? $_['allfeeds'] : '';
	
	print_collection_list($allfeeds);