diff options
-rw-r--r-- | css/news.css | 2 | ||||
-rw-r--r-- | templates/main.php | 2 | ||||
-rw-r--r-- | templates/part.feeds.php | 102 |
3 files changed, 75 insertions, 31 deletions
diff --git a/css/news.css b/css/news.css index 2d048bd22..1e05c61e9 100644 --- a/css/news.css +++ b/css/news.css @@ -272,7 +272,7 @@ div.feed_controls { font-weight: bold; } - #feeds li.feed a.all_read { + #feeds li.feed a.all_read, #feeds .all_read { font-weight: normal; } diff --git a/templates/main.php b/templates/main.php index 037865466..3ec909b7d 100644 --- a/templates/main.php +++ b/templates/main.php @@ -12,8 +12,6 @@ echo $this->inc("part.items.header"); <div id="leftcontent" class="leftcontent"> <div id="feeds"> <ul data-id="0"> - <li data-id="-2" class="subscriptions folder" id="<?php if($_['feedid'] == -2){ echo 'selected_feed'; } ?>"><a href="#" ><?php echo $l->t('New articles'); ?></a></li> - <li data-id="-1" class="starred folder" id="<?php if($_['feedid'] == -1){ echo 'selected_feed'; } ?>"><a href="#" ><?php echo $l->t('Starred'); ?></a></li> <?php echo $this->inc("part.feeds"); ?> </ul> </div> diff --git a/templates/part.feeds.php b/templates/part.feeds.php index 683d535cd..927ec406a 100644 --- a/templates/part.feeds.php +++ b/templates/part.feeds.php @@ -1,36 +1,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 +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'] : ''; +} + +$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); |