Merge pull-request #493 and fix conflicts
This commit is contained in:
commit
2f06e6a346
@ -37,8 +37,17 @@ Router\get_action('bookmark', function() {
|
|||||||
Router\get_action('bookmarks', function() {
|
Router\get_action('bookmarks', function() {
|
||||||
|
|
||||||
$offset = Request\int_param('offset', 0);
|
$offset = Request\int_param('offset', 0);
|
||||||
$nb_items = Model\Item\count_bookmarks();
|
$group_id = Request\int_param('group_id', null);
|
||||||
$items = Model\Item\get_bookmarks($offset, Model\Config\get('items_per_page'));
|
$feed_ids = array();
|
||||||
|
if (! is_null($group_id)) {
|
||||||
|
$feed_ids = Model\Group\get_feeds_by_group($group_id);
|
||||||
|
}
|
||||||
|
$nb_items = Model\Item\count_bookmarks($feed_ids);
|
||||||
|
$items = Model\Item\get_bookmarks(
|
||||||
|
$offset,
|
||||||
|
Model\Config\get('items_per_page'),
|
||||||
|
$feed_ids
|
||||||
|
);
|
||||||
|
|
||||||
Response\html(Template\layout('bookmarks', array(
|
Response\html(Template\layout('bookmarks', array(
|
||||||
'favicons' => Model\Favicon\get_item_favicons($items),
|
'favicons' => Model\Favicon\get_item_favicons($items),
|
||||||
@ -47,6 +56,7 @@ Router\get_action('bookmarks', function() {
|
|||||||
'direction' => '',
|
'direction' => '',
|
||||||
'display_mode' => Model\Config\get('items_display_mode'),
|
'display_mode' => Model\Config\get('items_display_mode'),
|
||||||
'item_title_link' => Model\Config\get('item_title_link'),
|
'item_title_link' => Model\Config\get('item_title_link'),
|
||||||
|
'group_id' => $group_id,
|
||||||
'items' => $items,
|
'items' => $items,
|
||||||
'nb_items' => $nb_items,
|
'nb_items' => $nb_items,
|
||||||
'offset' => $offset,
|
'offset' => $offset,
|
||||||
@ -54,6 +64,7 @@ Router\get_action('bookmarks', function() {
|
|||||||
'nothing_to_read' => Request\int_param('nothing_to_read'),
|
'nothing_to_read' => Request\int_param('nothing_to_read'),
|
||||||
'nb_unread_items' => Model\Item\count_by_status('unread'),
|
'nb_unread_items' => Model\Item\count_by_status('unread'),
|
||||||
'menu' => 'bookmarks',
|
'menu' => 'bookmarks',
|
||||||
|
'groups' => Model\Group\get_all(),
|
||||||
'title' => t('Bookmarks').' ('.$nb_items.')'
|
'title' => t('Bookmarks').' ('.$nb_items.')'
|
||||||
)));
|
)));
|
||||||
});
|
});
|
||||||
|
@ -4,16 +4,23 @@
|
|||||||
Router\get_action('history', function() {
|
Router\get_action('history', function() {
|
||||||
|
|
||||||
$offset = Request\int_param('offset', 0);
|
$offset = Request\int_param('offset', 0);
|
||||||
$nb_items = Model\Item\count_by_status('read');
|
$group_id = Request\int_param('group_id', null);
|
||||||
|
$feed_ids = array();
|
||||||
|
if (! is_null($group_id)) {
|
||||||
|
$feed_ids = Model\Group\get_feeds_by_group($group_id);
|
||||||
|
}
|
||||||
|
|
||||||
$items = Model\Item\get_all_by_status(
|
$items = Model\Item\get_all_by_status(
|
||||||
'read',
|
'read',
|
||||||
array(),
|
$feed_ids,
|
||||||
$offset,
|
$offset,
|
||||||
Model\Config\get('items_per_page'),
|
Model\Config\get('items_per_page'),
|
||||||
'updated',
|
'updated',
|
||||||
Model\Config\get('items_sorting_direction')
|
Model\Config\get('items_sorting_direction')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$nb_items = Model\Item\count_by_status('read', $feed_ids);
|
||||||
|
|
||||||
Response\html(Template\layout('history', array(
|
Response\html(Template\layout('history', array(
|
||||||
'favicons' => Model\Favicon\get_item_favicons($items),
|
'favicons' => Model\Favicon\get_item_favicons($items),
|
||||||
'original_marks_read' => Model\Config\get('original_marks_read'),
|
'original_marks_read' => Model\Config\get('original_marks_read'),
|
||||||
@ -22,20 +29,23 @@ Router\get_action('history', function() {
|
|||||||
'direction' => '',
|
'direction' => '',
|
||||||
'display_mode' => Model\Config\get('items_display_mode'),
|
'display_mode' => Model\Config\get('items_display_mode'),
|
||||||
'item_title_link' => Model\Config\get('item_title_link'),
|
'item_title_link' => Model\Config\get('item_title_link'),
|
||||||
|
'group_id' => $group_id,
|
||||||
'nb_items' => $nb_items,
|
'nb_items' => $nb_items,
|
||||||
'nb_unread_items' => Model\Item\count_by_status('unread'),
|
'nb_unread_items' => Model\Item\count_by_status('unread'),
|
||||||
'offset' => $offset,
|
'offset' => $offset,
|
||||||
'items_per_page' => Model\Config\get('items_per_page'),
|
'items_per_page' => Model\Config\get('items_per_page'),
|
||||||
'nothing_to_read' => Request\int_param('nothing_to_read'),
|
'nothing_to_read' => Request\int_param('nothing_to_read'),
|
||||||
'menu' => 'history',
|
'menu' => 'history',
|
||||||
|
'groups' => Model\Group\get_all(),
|
||||||
'title' => t('History').' ('.$nb_items.')'
|
'title' => t('History').' ('.$nb_items.')'
|
||||||
)));
|
)));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Confirmation box to flush history
|
// Confirmation box to flush history
|
||||||
Router\get_action('confirm-flush-history', function() {
|
Router\get_action('confirm-flush-history', function() {
|
||||||
|
$group_id = Request\int_param('group_id', null);
|
||||||
Response\html(Template\layout('confirm_flush_items', array(
|
Response\html(Template\layout('confirm_flush_items', array(
|
||||||
|
'group_id' => $group_id,
|
||||||
'nb_unread_items' => Model\Item\count_by_status('unread'),
|
'nb_unread_items' => Model\Item\count_by_status('unread'),
|
||||||
'menu' => 'history',
|
'menu' => 'history',
|
||||||
'title' => t('Confirmation')
|
'title' => t('Confirmation')
|
||||||
@ -44,7 +54,11 @@ Router\get_action('confirm-flush-history', function() {
|
|||||||
|
|
||||||
// Flush history
|
// Flush history
|
||||||
Router\get_action('flush-history', function() {
|
Router\get_action('flush-history', function() {
|
||||||
|
$group_id = Request\int_param('group_id', null);
|
||||||
Model\Item\mark_all_as_removed();
|
if (!is_null($group_id)) {
|
||||||
|
Model\Item\mark_group_as_removed($group_id);
|
||||||
|
} else {
|
||||||
|
Model\Item\mark_all_as_removed();
|
||||||
|
}
|
||||||
Response\redirect('?action=history');
|
Response\redirect('?action=history');
|
||||||
});
|
});
|
||||||
|
@ -131,17 +131,18 @@ function count_by_status($status, $feed_ids = array())
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the number of bookmarks
|
// Get the number of bookmarks
|
||||||
function count_bookmarks()
|
function count_bookmarks($feed_ids = array())
|
||||||
{
|
{
|
||||||
return Database::getInstance('db')
|
return Database::getInstance('db')
|
||||||
->table('items')
|
->table('items')
|
||||||
->eq('bookmark', 1)
|
->eq('bookmark', 1)
|
||||||
|
->in('feed_id', $feed_ids)
|
||||||
->in('status', array('read', 'unread'))
|
->in('status', array('read', 'unread'))
|
||||||
->count();
|
->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get all bookmarks
|
// Get all bookmarks
|
||||||
function get_bookmarks($offset = null, $limit = null)
|
function get_bookmarks($offset = null, $limit = null, $feed_ids = array())
|
||||||
{
|
{
|
||||||
return Database::getInstance('db')
|
return Database::getInstance('db')
|
||||||
->table('items')
|
->table('items')
|
||||||
@ -163,6 +164,7 @@ function get_bookmarks($offset = null, $limit = null)
|
|||||||
'feeds.rtl'
|
'feeds.rtl'
|
||||||
)
|
)
|
||||||
->join('feeds', 'id', 'feed_id')
|
->join('feeds', 'id', 'feed_id')
|
||||||
|
->in('feed_id', $feed_ids)
|
||||||
->in('status', array('read', 'unread'))
|
->in('status', array('read', 'unread'))
|
||||||
->eq('bookmark', 1)
|
->eq('bookmark', 1)
|
||||||
->orderBy('updated', Config\get('items_sorting_direction'))
|
->orderBy('updated', Config\get('items_sorting_direction'))
|
||||||
@ -376,6 +378,19 @@ function mark_group_as_read($group_id)
|
|||||||
->update(array('status' => 'read'));
|
->update(array('status' => 'read'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mark all items of a group as removed
|
||||||
|
function mark_group_as_removed($group_id)
|
||||||
|
{
|
||||||
|
$feed_ids = Group\get_feeds_by_group($group_id);
|
||||||
|
|
||||||
|
return Database::getInstance('db')
|
||||||
|
->table('items')
|
||||||
|
->eq('status', 'read')
|
||||||
|
->eq('bookmark', 0)
|
||||||
|
->in('feed_id', $feed_ids)
|
||||||
|
->save(array('status' => 'removed', 'content' => ''));
|
||||||
|
}
|
||||||
|
|
||||||
// Mark all read items to removed after X days
|
// Mark all read items to removed after X days
|
||||||
function autoflush_read()
|
function autoflush_read()
|
||||||
{
|
{
|
||||||
|
@ -1,9 +1,21 @@
|
|||||||
<?php if (empty($items)): ?>
|
<?php if (empty($items) && is_null($group_id)): ?>
|
||||||
<p class="alert alert-info"><?= t('No bookmark') ?></p>
|
<p class="alert alert-info"><?= t('No bookmark') ?></p>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
|
|
||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<h2><?= t('Bookmarks') ?><span id="page-counter"><?= isset($nb_items) ? $nb_items : '' ?></span></h2>
|
<h2><?= t('Bookmarks') ?><span id="page-counter"><?= isset($nb_items) ? $nb_items : '' ?></span></h2>
|
||||||
|
<?php if (!empty($groups)): ?>
|
||||||
|
<nav>
|
||||||
|
<ul id="grouplist">
|
||||||
|
<?php foreach ($groups as $group): ?>
|
||||||
|
<li <?= $group['id'] == $group_id ? 'class="active"' : '' ?>>
|
||||||
|
<a href="?action=bookmarks&group_id=<?=$group['id']?>"><?=$group['title']?></a>
|
||||||
|
</li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php if ($nothing_to_read): ?>
|
<?php if ($nothing_to_read): ?>
|
||||||
@ -24,7 +36,7 @@
|
|||||||
)) ?>
|
)) ?>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
|
|
||||||
<?= \Template\load('paging', array('menu' => $menu, 'nb_items' => $nb_items, 'items_per_page' => $items_per_page, 'offset' => $offset, 'order' => $order, 'direction' => $direction)) ?>
|
<?= \Template\load('paging', array('menu' => $menu, 'nb_items' => $nb_items, 'items_per_page' => $items_per_page, 'offset' => $offset, 'order' => $order, 'direction' => $direction, 'group_id' => $group_id)) ?>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
@ -5,6 +5,6 @@
|
|||||||
<p class="alert alert-info"><?= t('Do you really want to remove these items from your history?') ?></p>
|
<p class="alert alert-info"><?= t('Do you really want to remove these items from your history?') ?></p>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<a href="?action=flush-history" class="btn btn-red"><?= t('Remove') ?></a>
|
<a href="?action=flush-history<?= is_null($group_id) ? '' : '&group_id='.$group_id ?>" class="btn btn-red"><?= t('Remove') ?></a>
|
||||||
<?= t('or') ?> <a href="?action=history"><?= t('cancel') ?></a>
|
<?= t('or') ?> <a href="?action=history<?= is_null($group_id) ? '' : '&group_id='.$group_id ?>"><?= t('cancel') ?></a>
|
||||||
</div>
|
</div>
|
@ -4,8 +4,20 @@
|
|||||||
|
|
||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<h2><?= t('History') ?><span id="page-counter"><?= isset($nb_items) ? $nb_items : '' ?></span></h2>
|
<h2><?= t('History') ?><span id="page-counter"><?= isset($nb_items) ? $nb_items : '' ?></span></h2>
|
||||||
|
<?php if (!empty($groups)): ?>
|
||||||
|
<nav>
|
||||||
|
<ul id="grouplist">
|
||||||
|
<?php foreach ($groups as $group): ?>
|
||||||
|
<li <?= $group['id'] == $group_id ? 'class="active"' : '' ?>>
|
||||||
|
<a href="?action=history&group_id=<?=$group['id']?>"><?=$group['title']?></a>
|
||||||
|
</li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="?action=confirm-flush-history"><?= t('flush all items') ?></a></li>
|
<li><a href="?action=confirm-flush-history<?= is_null($group_id) ? '' : '&group_id='.$group_id ?>"><?= t('flush all items') ?></a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -27,7 +39,7 @@
|
|||||||
)) ?>
|
)) ?>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
|
|
||||||
<?= \Template\load('paging', array('menu' => $menu, 'nb_items' => $nb_items, 'items_per_page' => $items_per_page, 'offset' => $offset, 'order' => $order, 'direction' => $direction)) ?>
|
<?= \Template\load('paging', array('menu' => $menu, 'nb_items' => $nb_items, 'items_per_page' => $items_per_page, 'offset' => $offset, 'order' => $order, 'direction' => $direction, 'group_id' => $group_id)) ?>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<div id="items-paging">
|
<div id="items-paging">
|
||||||
<?php if ($offset > 0): ?>
|
<?php if ($offset > 0): ?>
|
||||||
<a id="previous-page" href="?action=<?= $menu ?>&offset=<?= ($offset - $items_per_page) ?>&order=<?= $order ?>&direction=<?= $direction ?><?= isset($feed_id) ? '&feed_id='.$feed_id : '' ?>">« <?= t('Previous page') ?></a>
|
<a id="previous-page" href="?action=<?= $menu ?>&offset=<?= ($offset - $items_per_page) ?>&order=<?= $order ?>&direction=<?= $direction ?><?= isset($feed_id) ? '&feed_id='.$feed_id : '' ?><?= isset($group_id) ? '&group_id='.$group_id : '' ?>">« <?= t('Previous page') ?></a>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
<?php if (($nb_items - $offset) > $items_per_page): ?>
|
<?php if (($nb_items - $offset) > $items_per_page): ?>
|
||||||
|
Loading…
Reference in New Issue
Block a user