} catch (PicoFeed\Reader\SubscriptionNotFoundException $e) { $error_message = t('Unable to find a subscription.'); } catch (PicoFeed\Reader\UnsupportedFeedFormatException $e) { $error_message = t('Unable to detect the feed format.'); } Model\Config\write_debug(); if (isset($feed_id) && $feed_id !== false) { Session\flash(t('Subscription added successfully.')); Response\redirect('?action=feed-items&feed_id=' . $feed_id); } else { if (!isset($error_message)) { $error_message = t('Error occured.'); } Session\flash_error($error_message); } Response\html(Template\layout('add', array('values' => $values + array('csrf' => Model\Config\generate_csrf()), 'nb_unread_items' => Model\Item\count_by_status('unread'), 'groups' => Model\Group\get_all(), 'menu' => 'feeds', 'title' => t('Subscriptions')))); }); // OPML export Router\get_action('export', function () { Response\force_download('feeds.opml'); Response\xml(Model\Feed\export_opml()); }); // OPML import form Router\get_action('import', function () { Response\html(Template\layout('import', array('errors' => array(), 'nb_unread_items' => Model\Item\count_by_status('unread'), 'menu' => 'feeds', 'title' => t('OPML Import')))); }); // OPML importation Router\post_action('import', function () { if (Model\Feed\import_opml(Request\file_content('file'))) { Session\flash(t('Your feeds have been imported.')); Response\redirect('?action=feeds');
$order = Request\param('order', 'updated'); $direction = Request\param('direction', Model\Config\get('items_sorting_direction')); $offset = Request\int_param('offset', 0); $group_id = Request\int_param('group_id', null); $feed_ids = array(); if (!is_null($group_id)) { $feed_ids = Model\Group\get_feeds_by_group($group_id); } $items = Model\Item\get_all_by_status('unread', $feed_ids, $offset, Model\Config\get('items_per_page'), $order, $direction); $nb_items = Model\Item\count_by_status('unread', $feed_ids); $nb_unread_items = Model\Item\count_by_status('unread'); if ($nb_unread_items === 0) { $action = Model\Config\get('redirect_nothing_to_read'); Response\redirect('?action=' . $action . '¬hing_to_read=1'); } Response\html(Template\layout('unread_items', array('favicons' => Model\Feed\get_item_favicons($items), 'original_marks_read' => Model\Config\get('original_marks_read'), 'order' => $order, 'direction' => $direction, 'display_mode' => Model\Config\get('items_display_mode'), 'group_id' => $group_id, 'items' => $items, 'nb_items' => $nb_items, 'nb_unread_items' => $nb_unread_items, 'offset' => $offset, 'items_per_page' => Model\Config\get('items_per_page'), 'title' => 'Miniflux (' . $nb_items . ')', 'menu' => 'unread', 'groups' => Model\Group\get_all()))); }); // Show item Router\get_action('show', function () { $id = Request\param('id'); $menu = Request\param('menu'); $item = Model\Item\get($id); $feed = Model\Feed\get($item['feed_id']); Model\Item\set_read($id); $item['status'] = 'read'; switch ($menu) { case 'unread': $nav = Model\Item\get_nav($item); break; case 'history': $nav = Model\Item\get_nav($item, array('read'));
}); // Enable a feed $server->register('feed.enable', function ($feed_id) { return Model\Feed\enable($feed_id); }); // Disable a feed $server->register('feed.disable', function ($feed_id) { return Model\Feed\disable($feed_id); }); // Update a feed $server->register('feed.update', function ($feed_id) { return Model\Feed\refresh($feed_id); }); // Get all groups $server->register('group.list', function () { return Model\Group\get_all(); }); // Get all items for a specific feed $server->register('item.feed.list', function ($feed_id, $offset = null, $limit = null) { return Model\Item\get_all_by_feed($feed_id, $offset, $limit); }); // Count all feed items $server->register('item.feed.count', function ($feed_id) { return Model\Item\count_by_feed($feed_id); }); // Get all bookmark items $server->register('item.bookmark.list', function ($offset = null, $limit = null) { return Model\Item\get_bookmarks($offset, $limit); }); // Count bookmarks $server->register('item.bookmark.count', function () {