From c01619d835a093fe5711c8ff1765c27c1b5c4df9 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 15 Jan 2017 14:51:55 -0500 Subject: [PATCH] Display list of groups for each subscription --- app/controllers/feed.php | 10 +++++----- app/helpers/template.php | 6 ++++++ app/models/feed.php | 3 ++- app/templates/feeds.php | 11 +++++++++++ assets/css/app.css | 23 +++++++++++++++++++++++ assets/css/app.min.css | 2 +- tests/unit/FeedModelTest.php | 2 +- 7 files changed, 49 insertions(+), 8 deletions(-) diff --git a/app/controllers/feed.php b/app/controllers/feed.php index 52249af..a8b0269 100644 --- a/app/controllers/feed.php +++ b/app/controllers/feed.php @@ -127,20 +127,20 @@ Router\get_action('feeds', function () { $user_id = SessionStorage::getInstance()->getUserId(); $nothing_to_read = Request\int_param('nothing_to_read'); $nb_unread_items = Model\Item\count_by_status($user_id, 'unread'); - $feeds = Model\Feed\get_feeds_with_items_count($user_id); + $feeds = Model\Feed\get_feeds_with_items_count_and_groups($user_id); if ($nothing_to_read === 1 && $nb_unread_items > 0) { Response\redirect('?action=unread'); } Response\html(Template\layout('feeds', array( - 'favicons' => Model\Favicon\get_feeds_favicons($feeds), - 'feeds' => $feeds, + 'favicons' => Model\Favicon\get_feeds_favicons($feeds), + 'feeds' => $feeds, 'nothing_to_read' => $nothing_to_read, 'nb_unread_items' => $nb_unread_items, 'nb_failed_feeds' => Model\Feed\count_failed_feeds($user_id), - 'menu' => 'feeds', - 'title' => t('Subscriptions') + 'menu' => 'feeds', + 'title' => t('Subscriptions'), ))); }); diff --git a/app/helpers/template.php b/app/helpers/template.php index 1d29f1a..6d6b5c8 100644 --- a/app/helpers/template.php +++ b/app/helpers/template.php @@ -120,3 +120,9 @@ function relative_time($timestamp, $fallback_date_format = '%e %B %Y %k:%M') return \dt($fallback_date_format, $timestamp); } + +function link($label, $action, array $params = array()) +{ + $params['action'] = $action; + return sprintf('%s', http_build_query($params, '', '&'), escape($label)); +} diff --git a/app/models/feed.php b/app/models/feed.php index 050d154..4f7b451 100644 --- a/app/models/feed.php +++ b/app/models/feed.php @@ -55,7 +55,7 @@ function get_feeds($user_id) ->findAll(); } -function get_feeds_with_items_count($user_id) +function get_feeds_with_items_count_and_groups($user_id) { $feeds_count = array(); $feeds = get_feeds($user_id); @@ -82,6 +82,7 @@ function get_feeds_with_items_count($user_id) foreach ($feeds as &$feed) { $feed['items_unread'] = isset($feeds_count[$feed['id']]) ? $feeds_count[$feed['id']]['unread'] : 0; $feed['items_total'] = isset($feeds_count[$feed['id']]) ? $feeds_count[$feed['id']]['total'] : 0; + $feed['groups'] = Group\get_feed_groups($feed['id']); } return $feeds; diff --git a/app/templates/feeds.php b/app/templates/feeds.php index 8e56613..e2af71a 100644 --- a/app/templates/feeds.php +++ b/app/templates/feeds.php @@ -51,6 +51,17 @@ + + + + +