Add bottom item naviguation everywhere
This commit is contained in:
parent
f6ea4c419d
commit
5096c3bd6c
53
index.php
53
index.php
@ -87,38 +87,37 @@ Router\get_action('show-help', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Show item without bottom nav
|
// Show item
|
||||||
Router\get_action('show', function() {
|
Router\get_action('show', function() {
|
||||||
|
|
||||||
$id = Request\param('id');
|
$id = Request\param('id');
|
||||||
|
$menu = Request\param('menu');
|
||||||
$item = Model\get_item($id);
|
$item = Model\get_item($id);
|
||||||
$feed = Model\get_feed($item['feed_id']);
|
$feed = Model\get_feed($item['feed_id']);
|
||||||
|
|
||||||
Model\set_item_read($id);
|
Model\set_item_read($id);
|
||||||
|
|
||||||
Response\html(Template\layout('show_item', array(
|
switch ($menu) {
|
||||||
'item' => $item,
|
case 'unread':
|
||||||
'feed' => $feed,
|
$nav = Model\get_nav_item($item);
|
||||||
'menu' => 'show'
|
break;
|
||||||
)));
|
case 'history':
|
||||||
});
|
$nav = Model\get_nav_item($item, array('read'));
|
||||||
|
break;
|
||||||
|
case 'feed-items':
|
||||||
// Show item with bottom nav
|
$nav = Model\get_nav_item($item, array('unread', 'read'));
|
||||||
Router\get_action('read', function() {
|
break;
|
||||||
|
case 'bookmarks':
|
||||||
$id = Request\param('id');
|
$nav = Model\get_nav_item($item, array('unread', 'read'), array(1));
|
||||||
$item = Model\get_item($id);
|
break;
|
||||||
$feed = Model\get_feed($item['feed_id']);
|
}
|
||||||
$nav = Model\get_nav_item($item); // must be placed before set_item_read()
|
|
||||||
|
|
||||||
Model\set_item_read($id);
|
|
||||||
|
|
||||||
Response\html(Template\layout('show_item', array(
|
Response\html(Template\layout('show_item', array(
|
||||||
'item' => $item,
|
'item' => $item,
|
||||||
'feed' => $feed,
|
'feed' => $feed,
|
||||||
'item_nav' => $nav,
|
'item_nav' => isset($nav) ? $nav : null,
|
||||||
'menu' => 'read'
|
'menu' => $menu,
|
||||||
|
'title' => $item['title']
|
||||||
)));
|
)));
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -212,21 +211,17 @@ Router\post_action('change-item-status', function() {
|
|||||||
Router\get_action('bookmark', function() {
|
Router\get_action('bookmark', function() {
|
||||||
|
|
||||||
$id = Request\param('id');
|
$id = Request\param('id');
|
||||||
$redirect = Request\param('redirect', 'unread');
|
$menu = Request\param('menu', 'unread');
|
||||||
|
$source = Request\param('source', 'unread');
|
||||||
$offset = Request\int_param('offset', 0);
|
$offset = Request\int_param('offset', 0);
|
||||||
|
|
||||||
Model\set_bookmark_value($id, Request\int_param('value'));
|
Model\set_bookmark_value($id, Request\int_param('value'));
|
||||||
|
|
||||||
if ($redirect === 'show') {
|
if ($source === 'show') {
|
||||||
|
Response\Redirect('?action=show&menu='.$menu.'&id='.$id);
|
||||||
Response\Redirect('?action=show&id='.$id);
|
|
||||||
}
|
|
||||||
else if ($redirect === 'read') {
|
|
||||||
|
|
||||||
Response\Redirect('?action=read&id='.$id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Response\Redirect('?action='.$redirect.'&offset='.$offset);
|
Response\Redirect('?action='.$menu.'&offset='.$offset);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
|
'Listing' => 'Liste',
|
||||||
'content downloaded' => 'contenu téléchargé',
|
'content downloaded' => 'contenu téléchargé',
|
||||||
'in progress...' => 'en cours...',
|
'in progress...' => 'en cours...',
|
||||||
'unable to fetch content' => 'impossible de récupérer l\'article',
|
'unable to fetch content' => 'impossible de récupérer l\'article',
|
||||||
|
45
model.php
45
model.php
@ -470,24 +470,53 @@ function get_item($id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function get_nav_item($item)
|
function get_nav_item($item, $status = array('unread'), $bookmark = array(1, 0))
|
||||||
{
|
{
|
||||||
$unread_items = \PicoTools\singleton('db')
|
$items = \PicoTools\singleton('db')
|
||||||
->table('items')
|
->table('items')
|
||||||
->columns('items.id')
|
->columns('id', 'status', 'title')
|
||||||
->eq('status', 'unread')
|
->in('bookmark', $bookmark)
|
||||||
|
->neq('status', 'removed')
|
||||||
->desc('updated')
|
->desc('updated')
|
||||||
->findAll();
|
->findAll();
|
||||||
|
|
||||||
$next_item = null;
|
$next_item = null;
|
||||||
$previous_item = null;
|
$previous_item = null;
|
||||||
|
|
||||||
for ($i = 0, $ilen = count($unread_items); $i < $ilen; $i++) {
|
for ($i = 0, $ilen = count($items); $i < $ilen; $i++) {
|
||||||
|
|
||||||
if ($unread_items[$i]['id'] == $item['id']) {
|
if ($items[$i]['id'] == $item['id']) {
|
||||||
|
|
||||||
|
if ($i > 0) {
|
||||||
|
|
||||||
|
$j = $i - 1;
|
||||||
|
|
||||||
|
while ($j >= 0) {
|
||||||
|
|
||||||
|
if (in_array($items[$j]['status'], $status)) {
|
||||||
|
$previous_item = $items[$j];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$j--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($i < ($ilen - 1)) {
|
||||||
|
|
||||||
|
$j = $i + 1;
|
||||||
|
|
||||||
|
while ($j < $ilen) {
|
||||||
|
|
||||||
|
if (in_array($items[$j]['status'], $status)) {
|
||||||
|
$next_item = $items[$j];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$j++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($i > 0) $previous_item = $unread_items[$i - 1];
|
|
||||||
if ($i < ($ilen - 1)) $next_item = $unread_items[$i + 1];
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
<article id="item-<?= $item['id'] ?>" data-item-id="<?= $item['id'] ?>">
|
<article id="item-<?= $item['id'] ?>" data-item-id="<?= $item['id'] ?>">
|
||||||
<h2>
|
<h2>
|
||||||
<a
|
<a
|
||||||
href="?action=show&id=<?= $item['id'] ?>"
|
href="?action=show&menu=bookmarks&id=<?= $item['id'] ?>"
|
||||||
data-item-id="<?= $item['id'] ?>"
|
data-item-id="<?= $item['id'] ?>"
|
||||||
id="open-<?= $item['id'] ?>"
|
id="open-<?= $item['id'] ?>"
|
||||||
>
|
>
|
||||||
@ -25,7 +25,7 @@
|
|||||||
<?= dt('%e %B %Y %k:%M', $item['updated']) ?> |
|
<?= dt('%e %B %Y %k:%M', $item['updated']) ?> |
|
||||||
|
|
||||||
<span class="hide-mobile">
|
<span class="hide-mobile">
|
||||||
<a href="?action=bookmark&value=0&id=<?= $item['id'] ?>&redirect=bookmarks&offset=<?= $offset ?>">
|
<a href="?action=bookmark&value=0&id=<?= $item['id'] ?>&menu=bookmarks&offset=<?= $offset ?>">
|
||||||
<?= t('remove bookmark') ?>
|
<?= t('remove bookmark') ?>
|
||||||
</a> |
|
</a> |
|
||||||
</span>
|
</span>
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
<h2>
|
<h2>
|
||||||
<?= $item['bookmark'] ? '★ ' : '' ?>
|
<?= $item['bookmark'] ? '★ ' : '' ?>
|
||||||
<a
|
<a
|
||||||
href="?action=show&id=<?= $item['id'] ?>"
|
href="?action=show&menu=feed-items&id=<?= $item['id'] ?>"
|
||||||
data-item-id="<?= $item['id'] ?>"
|
data-item-id="<?= $item['id'] ?>"
|
||||||
id="open-<?= $item['id'] ?>"
|
id="open-<?= $item['id'] ?>"
|
||||||
>
|
>
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<h2>
|
<h2>
|
||||||
<?= $item['bookmark'] ? '★ ' : '' ?>
|
<?= $item['bookmark'] ? '★ ' : '' ?>
|
||||||
<a
|
<a
|
||||||
href="?action=show&id=<?= $item['id'] ?>"
|
href="?action=show&menu=history&id=<?= $item['id'] ?>"
|
||||||
data-item-id="<?= $item['id'] ?>"
|
data-item-id="<?= $item['id'] ?>"
|
||||||
id="open-<?= $item['id'] ?>"
|
id="open-<?= $item['id'] ?>"
|
||||||
>
|
>
|
||||||
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
<?php if (! $item['bookmark']): ?>
|
<?php if (! $item['bookmark']): ?>
|
||||||
<span class="hide-mobile">
|
<span class="hide-mobile">
|
||||||
<a id="bookmark-<?= $item['id'] ?>" href="?action=bookmark&value=1&id=<?= $item['id'] ?>&redirect=history&offset=<?= $offset ?>"><?= t('bookmark') ?></a> |
|
<a id="bookmark-<?= $item['id'] ?>" href="?action=bookmark&value=1&id=<?= $item['id'] ?>&menu=history&offset=<?= $offset ?>"><?= t('bookmark') ?></a> |
|
||||||
</span>
|
</span>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
|
@ -15,9 +15,9 @@
|
|||||||
<span class="hide-mobile"><?= dt('%e %B %Y - %k:%M', $item['updated']) ?> |</span>
|
<span class="hide-mobile"><?= dt('%e %B %Y - %k:%M', $item['updated']) ?> |</span>
|
||||||
|
|
||||||
<?php if ($item['bookmark']): ?>
|
<?php if ($item['bookmark']): ?>
|
||||||
<a href="?action=bookmark&value=0&id=<?= $item['id'] ?>&redirect=<?= $menu ?>"><?= t('remove bookmark') ?></a>
|
<a href="?action=bookmark&value=0&id=<?= $item['id'] ?>&source=show&menu=<?= $menu ?>"><?= t('remove bookmark') ?></a>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<a href="?action=bookmark&value=1&id=<?= $item['id'] ?>&redirect=<?= $menu ?>"><?= t('bookmark') ?></a>
|
<a href="?action=bookmark&value=1&id=<?= $item['id'] ?>&source=show&menu=<?= $menu ?>"><?= t('bookmark') ?></a>
|
||||||
<?php endif ?> |
|
<?php endif ?> |
|
||||||
|
|
||||||
<span id="download-item"
|
<span id="download-item"
|
||||||
@ -39,7 +39,7 @@
|
|||||||
<nav>
|
<nav>
|
||||||
<span class="nav-left">
|
<span class="nav-left">
|
||||||
<?php if ($item_nav['previous']): ?>
|
<?php if ($item_nav['previous']): ?>
|
||||||
<a href="?action=read&id=<?= $item_nav['previous']['id'] ?>" id="previous-item">« <?= t('Previous') ?></a>
|
<a href="?action=show&menu=<?= $menu ?>&id=<?= $item_nav['previous']['id'] ?>" id="previous-item" title="<?= t($item_nav['previous']['title']) ?>">« <?= t('Previous') ?></a>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
« <?= t('Previous') ?>
|
« <?= t('Previous') ?>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
@ -47,19 +47,19 @@
|
|||||||
|
|
||||||
<span class="nav-middle">
|
<span class="nav-middle">
|
||||||
<?php if ($item_nav['previous'] && $item_nav['next']): ?>
|
<?php if ($item_nav['previous'] && $item_nav['next']): ?>
|
||||||
<a href="?action=default#item-<?= $item_nav['next']['id'] ?>"><?= t('Unread items') ?></a>
|
<a href="?action=<?= $menu ?>&feed_id=<?= $feed['id'] ?>#item-<?= $item_nav['next']['id'] ?>"><?= t('Listing') ?></a>
|
||||||
<?php elseif ($item_nav['previous'] && ! $item_nav['next']): ?>
|
<?php elseif ($item_nav['previous'] && ! $item_nav['next']): ?>
|
||||||
<a href="?action=default#item-<?= $item_nav['previous']['id'] ?>"><?= t('Unread items') ?></a>
|
<a href="?action=<?= $menu ?>&feed_id=<?= $feed['id'] ?>#item-<?= $item_nav['previous']['id'] ?>"><?= t('Listing') ?></a>
|
||||||
<?php elseif (! $item_nav['previous'] && $item_nav['next']): ?>
|
<?php elseif (! $item_nav['previous'] && $item_nav['next']): ?>
|
||||||
<a href="?action=default#item-<?= $item_nav['next']['id'] ?>"><?= t('Unread items') ?></a>
|
<a href="?action=<?= $menu ?>&feed_id=<?= $feed['id'] ?>#item-<?= $item_nav['next']['id'] ?>"><?= t('Listing') ?></a>
|
||||||
<?php elseif (! $item_nav['previous'] && ! $item_nav['next']): ?>
|
<?php elseif (! $item_nav['previous'] && ! $item_nav['next']): ?>
|
||||||
<a href="?action=default"><?= t('Unread items') ?></a>
|
<a href="?action=<?= $menu ?>&feed_id=<?= $feed['id'] ?>"><?= t('Unread items') ?></a>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span class="nav-right">
|
<span class="nav-right">
|
||||||
<?php if ($item_nav['next']): ?>
|
<?php if ($item_nav['next']): ?>
|
||||||
<a href="?action=read&id=<?= $item_nav['next']['id'] ?>" id="next-item"><?= t('Next') ?> »</a>
|
<a href="?action=show&menu=<?= $menu ?>&id=<?= $item_nav['next']['id'] ?>" id="next-item" title="<?= t($item_nav['next']['title']) ?>"><?= t('Next') ?> »</a>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<?= t('Next') ?> »
|
<?= t('Next') ?> »
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
<h2>
|
<h2>
|
||||||
<?= $item['bookmark'] ? '★ ' : '' ?>
|
<?= $item['bookmark'] ? '★ ' : '' ?>
|
||||||
<a
|
<a
|
||||||
href="?action=read&id=<?= $item['id'] ?>"
|
href="?action=show&menu=unread&id=<?= $item['id'] ?>"
|
||||||
data-item-id="<?= $item['id'] ?>"
|
data-item-id="<?= $item['id'] ?>"
|
||||||
id="open-<?= $item['id'] ?>"
|
id="open-<?= $item['id'] ?>"
|
||||||
>
|
>
|
||||||
@ -37,9 +37,9 @@
|
|||||||
|
|
||||||
<span class="hide-mobile">
|
<span class="hide-mobile">
|
||||||
<?php if ($item['bookmark']): ?>
|
<?php if ($item['bookmark']): ?>
|
||||||
<a id="bookmark-<?= $item['id'] ?>" href="?action=bookmark&value=0&id=<?= $item['id'] ?>&redirect=unread&offset=<?= $offset ?>"><?= t('remove bookmark') ?></a> |
|
<a id="bookmark-<?= $item['id'] ?>" href="?action=bookmark&value=0&id=<?= $item['id'] ?>&menu=unread&offset=<?= $offset ?>"><?= t('remove bookmark') ?></a> |
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<a id="bookmark-<?= $item['id'] ?>" href="?action=bookmark&value=1&id=<?= $item['id'] ?>&redirect=unread&offset=<?= $offset ?>"><?= t('bookmark') ?></a> |
|
<a id="bookmark-<?= $item['id'] ?>" href="?action=bookmark&value=1&id=<?= $item['id'] ?>&menu=unread&offset=<?= $offset ?>"><?= t('bookmark') ?></a> |
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user