<?php use PicoFarad\Router; use PicoFarad\Response; use PicoFarad\Request; use PicoFarad\Session; use PicoFarad\Template; // Display unread items Router\get_action('unread', function () { Model\Item\autoflush_read(); Model\Item\autoflush_unread(); $order = Request\param('order', 'updated'); $direction = Request\param('direction', Model\Config\get('items_sorting_direction')); $offset = Request\int_param('offset', 0); $items = Model\Item\get_all('unread', $offset, Model\Config\get('items_per_page'), $order, $direction); $nb_items = Model\Item\count_by_status('unread'); if ($nb_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'), 'items' => $items, 'nb_items' => $nb_items, 'nb_unread_items' => $nb_items, 'offset' => $offset, 'items_per_page' => Model\Config\get('items_per_page'), 'title' => 'Miniflux (' . $nb_items . ')', 'menu' => 'unread'))); }); // 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) {
}); // 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('unread', $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('read', $offset, $limit); }); // Count all read items $server->register('item.count_read', function () { return Model\Item\count_by_status('read'); }); // Get one item $server->register('item.info', function ($item_id) { return Model\Item\get($item_id); }); // Delete an item $server->register('item.delete', function ($item_id) { return Model\Item\set_removed($item_id); }); // Mark item as read $server->register('item.mark_as_read', function ($item_id) {
return Model\Item\set_read($item_id); }); // Mark item as unread $server->register('item.mark_as_unread', function ($item_id) { return Model\Item\set_unread($item_id); }); // Change the status of list of items $server->register('item.set_list_status', function ($status, array $items) { return Model\Item\set_status($status, $items); }); // Flush all read items $server->register('item.flush', function () { return Model\Item\mark_all_as_removed(); }); // Mark all unread items as read $server->register('item.mark_all_as_read', function () { return Model\Item\mark_all_as_read(); }); // Get all items with the content $server->register('item.get_all', function () { return Model\Item\get_all(); }); // Get all items since a date $server->register('item.get_all_since', function ($timestamp) { return Model\Item\get_all_since($timestamp); }); // Get all items id and status $server->register('item.get_all_status', function () { return Model\Item\get_all_status(); }); echo $server->execute();
<?php use PicoFarad\Router; use PicoFarad\Response; use PicoFarad\Request; use PicoFarad\Session; use PicoFarad\Template; // 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('read', $offset, Model\Config\get('items_per_page'), 'updated', Model\Config\get('items_sorting_direction')); Response\html(Template\layout('history', array('favicons' => Model\Feed\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'); });