Beispiel #1
0
});
// Refresh one feed and redirect to unread items
Router\get_action('refresh-feed', function () {
    $feed_id = Request\int_param('feed_id');
    $redirect = Request\param('redirect', 'unread');
    Model\Feed\refresh($feed_id);
    Response\redirect('?action=' . $redirect . '&feed_id=' . $feed_id);
});
// Ajax call to refresh one feed
Router\post_action('refresh-feed', function () {
    $feed_id = Request\int_param('feed_id', 0);
    Response\json(array('feed_id' => $feed_id, 'result' => Model\Feed\refresh($feed_id), 'items_count' => Model\Feed\count_items($feed_id)));
});
// Display all feeds
Router\get_action('feeds', function () {
    $nothing_to_read = Request\int_param('nothing_to_read');
    $nb_unread_items = Model\Item\count_by_status('unread');
    // possible with remember me function
    if ($nothing_to_read === 1 && $nb_unread_items > 0) {
        Response\redirect('?action=unread');
    }
    Response\html(Template\layout('feeds', array('favicons' => Model\Favicon\get_all_favicons(), 'feeds' => Model\Feed\get_all_item_counts(), 'nothing_to_read' => $nothing_to_read, 'nb_unread_items' => $nb_unread_items, 'nb_failed_feeds' => Model\Feed\count_failed_feeds(), 'menu' => 'feeds', 'title' => t('Subscriptions'))));
});
// Display form to add one feed
Router\get_action('add', function () {
    $values = array('download_content' => 0, 'rtl' => 0, 'cloak_referrer' => 0, 'create_group' => '', 'feed_group_ids' => array());
    Response\html(Template\layout('add', array('values' => $values + array('csrf' => Model\Config\generate_csrf()), 'errors' => array(), 'nb_unread_items' => Model\Item\count_by_status('unread'), 'groups' => Model\Group\get_all(), 'menu' => 'feeds', 'title' => t('New subscription'))));
});
// Add a feed with the form or directly from the url, it can be used by a bookmarklet by example
Router\action('subscribe', function () {
    if (Request\is_post()) {
Beispiel #2
0
<?php

// Display history page
Router\get_action('history', function () {
    $offset = Request\int_param('offset', 0);
    $nb_items = Model\Item\count_by_status('read');
    $items = Model\Item\get_all_by_status('read', array(), $offset, Model\Config\get('items_per_page'), 'updated', Model\Config\get('items_sorting_direction'));
    Response\html(Template\layout('history', array('favicons' => Model\Favicon\get_item_favicons($items), 'original_marks_read' => Model\Config\get('original_marks_read'), 'items' => $items, 'order' => '', 'direction' => '', 'display_mode' => Model\Config\get('items_display_mode'), 'nb_items' => $nb_items, 'nb_unread_items' => Model\Item\count_by_status('unread'), 'offset' => $offset, 'items_per_page' => Model\Config\get('items_per_page'), 'nothing_to_read' => Request\int_param('nothing_to_read'), 'menu' => 'history', 'title' => t('History') . ' (' . $nb_items . ')')));
});
// Confirmation box to flush history
Router\get_action('confirm-flush-history', function () {
    Response\html(Template\layout('confirm_flush_items', array('nb_unread_items' => Model\Item\count_by_status('unread'), 'menu' => 'history', 'title' => t('Confirmation'))));
});
// Flush history
Router\get_action('flush-history', function () {
    Model\Item\mark_all_as_removed();
    Response\redirect('?action=history');
});
Beispiel #3
0
    $feed_id = Request\int_param('feed_id', 0);
    Model\Item\set_read($id);
    Response\Redirect('?action=' . $redirect . '&offset=' . $offset . '&feed_id=' . $feed_id . '#item-' . $id);
});
// Mark item as unread and redirect to the listing page
Router\get_action('mark-item-unread', function () {
    $id = Request\param('id');
    $redirect = Request\param('redirect', 'history');
    $offset = Request\int_param('offset', 0);
    $feed_id = Request\int_param('feed_id', 0);
    Model\Item\set_unread($id);
    Response\Redirect('?action=' . $redirect . '&offset=' . $offset . '&feed_id=' . $feed_id . '#item-' . $id);
});
// Mark item as removed and redirect to the listing page
Router\get_action('mark-item-removed', function () {
    $id = Request\param('id');
    $redirect = Request\param('redirect', 'history');
    $offset = Request\int_param('offset', 0);
    $feed_id = Request\int_param('feed_id', 0);
    Model\Item\set_removed($id);
    Response\Redirect('?action=' . $redirect . '&offset=' . $offset . '&feed_id=' . $feed_id);
});
Router\post_action('latest-feeds-items', function () {
    $items = Model\Item\get_latest_feeds_items();
    $nb_unread_items = Model\Item\count_by_status('unread');
    $feeds = array_reduce($items, function ($result, $item) {
        $result[$item['id']] = array('time' => $item['updated'] ?: 0, 'status' => $item['status']);
        return $result;
    }, array());
    Response\json(array('feeds' => $feeds, 'nbUnread' => $nb_unread_items));
});