Example #1
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));
});
Example #2
0
        Response\redirect('?action=config');
    }
    Response\html(Template\layout('config', array('errors' => $errors, 'values' => Model\Config\get_all() + array('csrf' => Model\Config\generate_csrf()), 'languages' => Model\Config\get_languages(), 'timezones' => Model\Config\get_timezones(), 'autoflush_read_options' => Model\Config\get_autoflush_read_options(), 'autoflush_unread_options' => Model\Config\get_autoflush_unread_options(), 'paging_options' => Model\Config\get_paging_options(), 'theme_options' => Model\Config\get_themes(), 'sorting_options' => Model\Config\get_sorting_directions(), 'redirect_nothing_to_read_options' => Model\Config\get_nothing_to_read_redirections(), 'display_mode' => Model\Config\get_display_mode(), 'nb_unread_items' => Model\Item\count_by_status('unread'), 'menu' => 'config', 'title' => t('Preferences'))));
});
// Get configuration parameters (AJAX request)
Router\post_action('get-config', function () {
    $return = array();
    $options = Request\values();
    if (empty($options)) {
        $return = Model\Config\get_all();
    } else {
        foreach ($options as $name) {
            $return[$name] = Model\Config\get($name);
        }
    }
    Response\json($return);
});
// Display help page
Router\get_action('help', function () {
    Response\html(Template\layout('help', array('config' => Model\Config\get_all(), 'nb_unread_items' => Model\Item\count_by_status('unread'), 'menu' => 'config', 'title' => t('Preferences'))));
});
// Display about page
Router\get_action('about', function () {
    Response\html(Template\layout('about', array('csrf' => Model\Config\generate_csrf(), 'config' => Model\Config\get_all(), 'nb_unread_items' => Model\Item\count_by_status('unread'), 'menu' => 'config', 'title' => t('Preferences'))));
});
// Display database page
Router\get_action('database', function () {
    Response\html(Template\layout('database', array('csrf' => Model\Config\generate_csrf(), 'config' => Model\Config\get_all(), 'db_size' => filesize(\Model\Database\get_path()), 'nb_unread_items' => Model\Item\count_by_status('unread'), 'menu' => 'config', 'title' => t('Preferences'))));
});
// Display API page
Router\get_action('api', function () {
Example #3
0
<?php

use PicoFarad\Router;
use PicoFarad\Response;
use PicoFarad\Request;
use PicoFarad\Session;
use PicoFarad\Template;
use PicoFeed\Syndication\Atom;
// Ajax call to add or remove a bookmark
Router\post_action('bookmark', function () {
    $id = Request\param('id');
    $value = Request\int_param('value');
    Response\json(array('id' => $id, 'value' => $value, 'result' => Model\Item\set_bookmark_value($id, $value)));
});
// Add new bookmark
Router\get_action('bookmark', function () {
    $id = Request\param('id');
    $menu = Request\param('menu', 'unread');
    $source = Request\param('source', 'unread');
    $offset = Request\int_param('offset', 0);
    $feed_id = Request\int_param('feed_id', 0);
    Model\Item\set_bookmark_value($id, Request\int_param('value'));
    if ($source === 'show') {
        Response\Redirect('?action=show&menu=' . $menu . '&id=' . $id);
    }
    Response\Redirect('?action=' . $menu . '&offset=' . $offset . '&feed_id=' . $feed_id . '#item-' . $id);
});
// Display bookmarks page
Router\get_action('bookmarks', function () {
    $offset = Request\int_param('offset', 0);
    $nb_items = Model\Item\count_bookmarks();
Example #4
0
    } else {
        Session\flash_error(t('Unable to remove this subscription.'));
    }
    Response\redirect('?action=feeds');
});
// 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\Feed\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'))));