improved starred/unstarred function, code refactoring using a mode
session var ('default', 'starred', 'history')
This commit is contained in:
parent
e56cfa612a
commit
8951ba8f45
@ -1 +0,0 @@
|
||||
Deny from all
|
61
index.php
61
index.php
@ -104,7 +104,6 @@ Router\get_action('show', function() {
|
||||
|
||||
|
||||
Router\get_action('show_starred_item', function() {
|
||||
|
||||
$id = Model\decode_item_id(Request\param('id'));
|
||||
|
||||
Response\html(Template\layout('starred_item', array(
|
||||
@ -148,7 +147,7 @@ Router\get_action('mark-item-read', function() {
|
||||
|
||||
$id = Model\decode_item_id(Request\param('id'));
|
||||
Model\set_item_read($id);
|
||||
Response\Redirect('?action=default');
|
||||
Response\Redirect('?action='.$_SESSION['MODE']);
|
||||
});
|
||||
|
||||
|
||||
@ -156,15 +155,7 @@ Router\get_action('mark-item-unread', function() {
|
||||
|
||||
$id = Model\decode_item_id(Request\param('id'));
|
||||
Model\set_item_unread($id);
|
||||
Response\Redirect('?action=history');
|
||||
});
|
||||
|
||||
|
||||
Router\get_action('mark-read-item-unread', function() {
|
||||
|
||||
$id = Model\decode_item_id(Request\param('id'));
|
||||
Model\set_item_unread($id);
|
||||
Response\Redirect('?action=history');
|
||||
Response\Redirect('?action='.$_SESSION['MODE']);
|
||||
});
|
||||
|
||||
|
||||
@ -172,15 +163,7 @@ Router\get_action('mark-item-removed', function() {
|
||||
|
||||
$id = Model\decode_item_id(Request\param('id'));
|
||||
Model\set_item_removed($id);
|
||||
Response\Redirect('?action=history');
|
||||
});
|
||||
|
||||
|
||||
Router\get_action('mark-starred-item-removed', function() {
|
||||
|
||||
$id = Model\decode_item_id(Request\param('id'));
|
||||
Model\set_item_removed($id);
|
||||
Response\Redirect('?action=starred');
|
||||
Response\Redirect('?action='.$_SESSION['MODE']);
|
||||
});
|
||||
|
||||
|
||||
@ -199,43 +182,20 @@ Router\post_action('mark-item-unread', function() {
|
||||
Response\json(array('Ok'));
|
||||
});
|
||||
|
||||
Router\get_action('mark-read-item-starred', function() {
|
||||
|
||||
Router\get_action('mark-item-starred', function() {
|
||||
|
||||
$id = Model\decode_item_id(Request\param('id'));
|
||||
Model\set_item_starred($id);
|
||||
Response\Redirect('?action=history');
|
||||
Response\Redirect('?action='.$_SESSION['MODE']);
|
||||
});
|
||||
|
||||
|
||||
Router\get_action('mark-read-item-unstarred', function() {
|
||||
Router\get_action('mark-item-unstarred', function() {
|
||||
|
||||
$id = Model\decode_item_id(Request\param('id'));
|
||||
Model\set_item_unstarred($id);
|
||||
Response\Redirect('?action=history');
|
||||
});
|
||||
|
||||
|
||||
Router\get_action('mark-starred-item-unstarred', function() {
|
||||
|
||||
$id = Model\decode_item_id(Request\param('id'));
|
||||
Model\set_item_unstarred($id);
|
||||
Response\Redirect('?action=starred');
|
||||
});
|
||||
|
||||
|
||||
Router\get_action('mark-unread-item-starred', function() {
|
||||
|
||||
$id = Model\decode_item_id(Request\param('id'));
|
||||
Model\set_item_starred($id);
|
||||
Response\Redirect('?action=default');
|
||||
});
|
||||
|
||||
|
||||
Router\get_action('mark-unread-item-unstarred', function() {
|
||||
|
||||
$id = Model\decode_item_id(Request\param('id'));
|
||||
Model\set_item_unstarred($id);
|
||||
Response\Redirect('?action=default');
|
||||
Response\Redirect('?action='.$_SESSION['MODE']);
|
||||
});
|
||||
|
||||
|
||||
@ -251,7 +211,7 @@ Router\post_action('change-item-status', function() {
|
||||
|
||||
|
||||
Router\get_action('history', function() {
|
||||
|
||||
$_SESSION['MODE']='history';
|
||||
Response\html(Template\layout('history', array(
|
||||
'items' => Model\get_read_items(),
|
||||
'menu' => 'history'
|
||||
@ -260,7 +220,7 @@ Router\get_action('history', function() {
|
||||
|
||||
|
||||
Router\get_action('starred', function() {
|
||||
|
||||
$_SESSION['MODE']='starred';
|
||||
Response\html(Template\layout('starred', array(
|
||||
'items' => Model\get_starred_items(),
|
||||
'menu' => 'starred'
|
||||
@ -481,6 +441,7 @@ Router\post_action('config', function() {
|
||||
|
||||
|
||||
Router\notfound(function() {
|
||||
$_SESSION['MODE']='default';
|
||||
|
||||
Model\autoflush();
|
||||
|
||||
|
@ -13,4 +13,4 @@
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-blue"><?= t('Add') ?></button>
|
||||
</div>
|
||||
</form>
|
||||
</form>
|
||||
|
@ -1,4 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
@ -29,15 +29,13 @@
|
||||
|
||||
|
||||
<?php if (isset($item['starred']) && $item['starred']=='starred'): ?>
|
||||
<a href="?action=mark-unread-item-unstarred&id=<?= $item_id ?>"><?= t('mark as unstarred') ?></a> |
|
||||
<a href="?action=mark-item-unstarred&id=<?= $item_id ?>"><?= t('mark as unstarred') ?></a> |
|
||||
<?php else: ?>
|
||||
<a href="?action=mark-unread-item-starred&id=<?= $item_id ?>"><?= t('mark as starred') ?></a> |
|
||||
<a href="?action=mark-item-starred&id=<?= $item_id ?>"><?= t('mark as starred') ?></a> |
|
||||
<?php endif ?>
|
||||
|
||||
|
||||
|
||||
|
||||
<a href="?action=mark-read-item-unread&id=<?= $item_id ?>"><?= t('mark as unread') ?></a> |
|
||||
<a href="?action=mark-item-unread&id=<?= $item_id ?>"><?= t('mark as unread') ?></a> |
|
||||
<a href="?action=mark-item-removed&id=<?= $item_id ?>"><?= t('remove') ?></a> |
|
||||
<a
|
||||
href="<?= $item['url'] ?>"
|
||||
|
@ -13,9 +13,9 @@
|
||||
<?= Helper\get_host_from_url($item['url']) ?> |
|
||||
<?= dt('%A %e %B %Y %k:%M', $item['updated']) ?> |
|
||||
<?php if (isset($item['starred']) && $item['starred']=='starred'): ?>
|
||||
<a href="?action=mark-read-item-unstarred&id=<?= $item_id ?>"><?= t('mark as unstarred') ?></a>
|
||||
<a href="?action=mark-item-unstarred&id=<?= $item_id ?>"><?= t('mark as unstarred') ?></a>
|
||||
<?php else: ?>
|
||||
<a href="?action=mark-read-item-starred&id=<?= $item_id ?>"><?= t('mark as starred') ?></a>
|
||||
<a href="?action=mark-item-starred&id=<?= $item_id ?>"><?= t('mark as starred') ?></a>
|
||||
<?php endif ?>
|
||||
|
||||
</p>
|
||||
|
@ -14,7 +14,7 @@
|
||||
<article id="item-<?= $item_id ?>" data-item-id="<?= $item_id ?>">
|
||||
<h2>
|
||||
<a
|
||||
href="?action=show_starred_item&id=<?= $item_id ?>"
|
||||
href="?action=read_starred&id=<?= $item_id ?>"
|
||||
id="open-<?= $item_id ?>"
|
||||
>
|
||||
<?= Helper\escape($item['title']) ?>
|
||||
@ -23,8 +23,8 @@
|
||||
<p>
|
||||
<?= Helper\get_host_from_url($item['url']) ?> |
|
||||
<?= dt('%A %e %B %Y %k:%M', $item['updated']) ?> |
|
||||
<a href="?action=mark-starred-item-unstarred&id=<?= $item_id ?>"><?= t('mark as unstarred') ?></a> |
|
||||
<a href="?action=mark-starred-item-removed&id=<?= $item_id ?>"><?= t('remove') ?></a> |
|
||||
<a href="?action=mark-item-unstarred&id=<?= $item_id ?>"><?= t('mark as unstarred') ?></a> |
|
||||
<a href="?action=mark-item-removed&id=<?= $item_id ?>"><?= t('remove') ?></a> |
|
||||
<a
|
||||
href="<?= $item['url'] ?>"
|
||||
id="original-<?= $item_id ?>"
|
||||
|
@ -27,15 +27,7 @@
|
||||
</span>
|
||||
|
||||
<span class="nav-middle">
|
||||
<?php if ($item_nav['previous'] && $item_nav['next']): ?>
|
||||
<a href="?action=default#item-<?= Model\encode_item_id($item_nav['next']['id']) ?>"><?= t('Unread items') ?></a>
|
||||
<?php elseif ($item_nav['previous'] && ! $item_nav['next']): ?>
|
||||
<a href="?action=default#item-<?= Model\encode_item_id($item_nav['previous']['id']) ?>"><?= t('Unread items') ?></a>
|
||||
<?php elseif (! $item_nav['previous'] && $item_nav['next']): ?>
|
||||
<a href="?action=default#item-<?= Model\encode_item_id($item_nav['next']['id']) ?>"><?= t('Unread items') ?></a>
|
||||
<?php elseif (! $item_nav['previous'] && ! $item_nav['next']): ?>
|
||||
<a href="?action=default"><?= t('Unread items') ?></a>
|
||||
<?php endif ?>
|
||||
<a href="?action=starred"><?= t('Starred') ?></a>
|
||||
</span>
|
||||
|
||||
<span class="nav-right">
|
||||
|
@ -31,9 +31,9 @@
|
||||
|
||||
|
||||
<?php if (isset($item['starred']) && $item['starred']=='starred'): ?>
|
||||
<a href="?action=mark-unread-item-unstarred&id=<?= $item_id ?>"><?= t('mark as unstarred') ?></a> |
|
||||
<a href="?action=mark-item-unstarred&id=<?= $item_id ?>"><?= t('mark as unstarred') ?></a> |
|
||||
<?php else: ?>
|
||||
<a href="?action=mark-unread-item-starred&id=<?= $item_id ?>"><?= t('mark as starred') ?></a> |
|
||||
<a href="?action=mark-item-starred&id=<?= $item_id ?>"><?= t('mark as starred') ?></a> |
|
||||
<?php endif ?>
|
||||
|
||||
<a href="?action=mark-item-read&id=<?= $item_id ?>"><?= t('mark as read') ?></a> |
|
||||
|
Loading…
Reference in New Issue
Block a user