blob: 927ec406ad9b4679af2446932b36e30ca65f960d (
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
<?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('unreadItemsCount',$counter);
$tmpl_feed->printpage();
}
else {
//TODO:handle error in this case
}
}
}
$allfeeds = isset($_['allfeeds']) ? $_['allfeeds'] : '';
$feedId = $_['feedid'];
$itemMapper = new OCA\News\ItemMapper();
$unreadItemCountAll = $itemMapper->countEveryItemByStatus(OCA\News\StatusFlag::UNREAD);
$starredCount = $itemMapper->countEveryItemByStatus(OCA\News\StatusFlag::IMPORTANT);
switch ($feedId) {
case -2:
$subscriptionsClass = "selected_feed";
$starredClass = "";
break;
case -1:
$subscriptionsClass = "";
$starredClass = "selected_feed";
break;
default:
$subscriptionsClass = "";
$starredClass = "";
break;
}
if($unreadItemCountAll > 0){
$allUnreadItemClass = "";
} else {
$allUnreadItemClass = "all_read";
}
if($starredCount > 0){
$starredCountClass = "";
} else {
$starredCountClass = "all_read";
}
?>
<li data-id="-2" class="subscriptions folder <?php echo $allUnreadItemClass ?>" id="<?php echo $subscriptionsClass ?>">
<a href="#" ><?php echo $l->t('New articles'); ?></a>
<span class="unreaditemcounter"><?php echo $unreadItemCountAll ?></span>
</li>
<li data-id="-1" class="starred folder <?php echo $starredCountClass ?>" id="<?php echo $starredClass ?>">
<a href="#" ><?php echo $l->t('Starred'); ?></a>
<span class="unreaditemcounter"><?php echo $starredCount ?></span>
</li>
<?php
print_collection_list($allfeeds);
|