2013-12-23 02:55:53 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// Display history page
|
2016-04-18 01:44:45 +02:00
|
|
|
Router\get_action('history', function () {
|
2016-04-17 23:35:50 +02:00
|
|
|
$order = Request\param('order', 'updated');
|
|
|
|
$direction = Request\param('direction', Model\Config\get('items_sorting_direction'));
|
2013-12-23 02:55:53 +01:00
|
|
|
$offset = Request\int_param('offset', 0);
|
2016-02-28 14:58:07 +01:00
|
|
|
$group_id = Request\int_param('group_id', null);
|
|
|
|
$feed_ids = array();
|
2016-04-18 01:34:54 +02:00
|
|
|
|
2016-05-03 10:45:07 +02:00
|
|
|
if ($group_id !== null) {
|
2016-02-28 14:58:07 +01:00
|
|
|
$feed_ids = Model\Group\get_feeds_by_group($group_id);
|
|
|
|
}
|
2016-02-28 20:41:14 +01:00
|
|
|
|
2015-04-19 08:08:31 +02:00
|
|
|
$items = Model\Item\get_all_by_status(
|
2014-12-24 23:54:27 +01:00
|
|
|
'read',
|
2016-02-28 14:58:07 +01:00
|
|
|
$feed_ids,
|
2014-12-24 23:54:27 +01:00
|
|
|
$offset,
|
|
|
|
Model\Config\get('items_per_page'),
|
2016-04-17 23:35:50 +02:00
|
|
|
$order,
|
|
|
|
$direction
|
2014-12-24 23:54:27 +01:00
|
|
|
);
|
2013-12-23 02:55:53 +01:00
|
|
|
|
2016-02-28 14:58:07 +01:00
|
|
|
$nb_items = Model\Item\count_by_status('read', $feed_ids);
|
2013-12-23 02:55:53 +01:00
|
|
|
|
|
|
|
Response\html(Template\layout('history', array(
|
2016-01-10 01:04:42 +01:00
|
|
|
'favicons' => Model\Favicon\get_item_favicons($items),
|
2015-01-29 23:28:18 +01:00
|
|
|
'original_marks_read' => Model\Config\get('original_marks_read'),
|
2014-12-24 23:54:27 +01:00
|
|
|
'items' => $items,
|
2016-04-17 23:35:50 +02:00
|
|
|
'order' => $order,
|
|
|
|
'direction' => $direction,
|
2014-05-29 16:57:23 +02:00
|
|
|
'display_mode' => Model\Config\get('items_display_mode'),
|
2016-02-27 20:21:18 +01:00
|
|
|
'item_title_link' => Model\Config\get('item_title_link'),
|
2016-02-28 14:58:07 +01:00
|
|
|
'group_id' => $group_id,
|
2013-12-23 02:55:53 +01:00
|
|
|
'nb_items' => $nb_items,
|
2014-11-15 14:32:31 +01:00
|
|
|
'nb_unread_items' => Model\Item\count_by_status('unread'),
|
2013-12-23 02:55:53 +01:00
|
|
|
'offset' => $offset,
|
|
|
|
'items_per_page' => Model\Config\get('items_per_page'),
|
2013-12-23 19:33:16 +01:00
|
|
|
'nothing_to_read' => Request\int_param('nothing_to_read'),
|
2013-12-23 02:55:53 +01:00
|
|
|
'menu' => 'history',
|
2016-02-28 14:58:07 +01:00
|
|
|
'groups' => Model\Group\get_all(),
|
2013-12-23 02:55:53 +01:00
|
|
|
'title' => t('History').' ('.$nb_items.')'
|
|
|
|
)));
|
|
|
|
});
|
|
|
|
|
|
|
|
// Confirmation box to flush history
|
2016-04-18 01:44:45 +02:00
|
|
|
Router\get_action('confirm-flush-history', function () {
|
2016-02-28 14:58:07 +01:00
|
|
|
$group_id = Request\int_param('group_id', null);
|
2016-04-18 01:34:54 +02:00
|
|
|
|
2013-12-23 02:55:53 +01:00
|
|
|
Response\html(Template\layout('confirm_flush_items', array(
|
2016-02-28 14:58:07 +01:00
|
|
|
'group_id' => $group_id,
|
2014-11-15 14:32:31 +01:00
|
|
|
'nb_unread_items' => Model\Item\count_by_status('unread'),
|
2013-12-23 02:55:53 +01:00
|
|
|
'menu' => 'history',
|
|
|
|
'title' => t('Confirmation')
|
|
|
|
)));
|
|
|
|
});
|
|
|
|
|
|
|
|
// Flush history
|
2016-04-18 01:44:45 +02:00
|
|
|
Router\get_action('flush-history', function () {
|
2016-02-28 14:58:07 +01:00
|
|
|
$group_id = Request\int_param('group_id', null);
|
2016-04-18 01:34:54 +02:00
|
|
|
|
2016-05-03 10:45:07 +02:00
|
|
|
if ($group_id !== null) {
|
2016-02-28 14:58:07 +01:00
|
|
|
Model\Item\mark_group_as_removed($group_id);
|
|
|
|
} else {
|
|
|
|
Model\Item\mark_all_as_removed();
|
|
|
|
}
|
2016-04-18 01:34:54 +02:00
|
|
|
|
2013-12-23 02:55:53 +01:00
|
|
|
Response\redirect('?action=history');
|
|
|
|
});
|