Beispiel #1
0
    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');
    } else {
        Session\flash_error(t('Unable to import your OPML file.'));
        Response\redirect('?action=import');
    }
});
Beispiel #2
0
Router\get_action('bookmarks', function () {
    $offset = Request\int_param('offset', 0);
    $nb_items = Model\Item\count_bookmarks();
    $items = Model\Item\get_bookmarks($offset, Model\Config\get('items_per_page'));
    Response\html(Template\layout('bookmarks', array('favicons' => Model\Favicon\get_item_favicons($items), 'original_marks_read' => Model\Config\get('original_marks_read'), 'order' => '', 'direction' => '', 'display_mode' => Model\Config\get('items_display_mode'), 'items' => $items, 'nb_items' => $nb_items, 'offset' => $offset, 'items_per_page' => Model\Config\get('items_per_page'), 'nothing_to_read' => Request\int_param('nothing_to_read'), 'nb_unread_items' => Model\Item\count_by_status('unread'), 'menu' => 'bookmarks', 'title' => t('Bookmarks') . ' (' . $nb_items . ')')));
});
// Display bookmark feeds
Router\get_action('bookmark-feed', function () {
    // Select database if the parameter is set
    $database = Request\param('database');
    if (!empty($database)) {
        Model\Database\select($database);
    }
    // Check token
    $feed_token = Model\Config\get('feed_token');
    $request_token = Request\param('token');
    if ($feed_token !== $request_token) {
        Response\text('Access Forbidden', 403);
    }
    // Build Feed
    $writer = new Atom();
    $writer->title = t('Bookmarks') . ' - Miniflux';
    $writer->site_url = Helper\get_current_base_url();
    $writer->feed_url = $writer->site_url . '?action=bookmark-feed&token=' . urlencode($feed_token);
    $bookmarks = Model\Item\get_bookmarks();
    foreach ($bookmarks as $bookmark) {
        $article = Model\Item\get($bookmark['id']);
        $writer->items[] = array('id' => $article['id'], 'title' => $article['title'], 'updated' => $article['updated'], 'url' => $article['url'], 'content' => $article['content']);
    }
    Response\xml($writer->execute());
});