Example #1
0
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();
    $items = Model\Item\get_bookmarks($offset, Model\Config\get('items_per_page'));
    Response\html(Template\layout('bookmarks', array('favicons' => Model\Feed\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 () {
    // Check token
Example #2
0
});
// 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 () {
    return Model\Item\count_bookmarks();
});
// Add a bookmark
$server->register('item.bookmark.create', function ($item_id) {
    return Model\Item\set_bookmark_value($item_id, 1);
});
// Remove a bookmark
$server->register('item.bookmark.delete', function ($item_id) {
    return Model\Item\set_bookmark_value($item_id, 0);
});
// Get all unread items
$server->register('item.list_unread', function ($offset = null, $limit = null) {
    return Model\Item\get_all_by_status('unread', array(), $offset, $limit);
});
// Count all unread items
$server->register('item.count_unread', function () {
    return Model\Item\count_by_status('unread');
});
// Get all read items
$server->register('item.list_read', function ($offset = null, $limit = null) {
    return Model\Item\get_all_by_status('read', array(), $offset, $limit);
});
// Count all read items
$server->register('item.count_read', function () {