2024-04-05 00:49:25 +00:00
|
|
|
<?php
|
2024-04-06 15:02:48 +00:00
|
|
|
/**
|
|
|
|
* Home Page
|
|
|
|
*
|
|
|
|
* Displays a list of unread feed items for the current user
|
|
|
|
*/
|
|
|
|
|
2024-04-05 00:49:25 +00:00
|
|
|
include '../start.php';
|
|
|
|
|
2024-04-06 02:14:24 +00:00
|
|
|
Security::verifyUser();
|
|
|
|
|
2024-04-13 16:10:07 +00:00
|
|
|
$db = Data::getConnection();
|
|
|
|
$result = $db->query(<<<'SQL'
|
|
|
|
SELECT item.id, item.title AS item_title, coalesce(item.updated_on, item.published_on) AS as_of,
|
|
|
|
feed.title AS feed_title
|
|
|
|
FROM item
|
|
|
|
INNER JOIN feed ON feed.id = item.feed_id
|
|
|
|
WHERE item.is_read = 0
|
|
|
|
ORDER BY coalesce(item.updated_on, item.published_on) DESC
|
|
|
|
SQL);
|
|
|
|
$item = $result ? $result->fetchArray(SQLITE3_ASSOC) : false;
|
|
|
|
|
2024-04-12 02:01:36 +00:00
|
|
|
page_head('Welcome'); ?>
|
2024-04-13 16:10:07 +00:00
|
|
|
<h1>Your Unread Items</h1>
|
|
|
|
<article><?php
|
|
|
|
if ($item) {
|
|
|
|
while ($item) {
|
|
|
|
try {
|
|
|
|
$asOf = (new DateTimeImmutable($item['as_of']))->format(DATE_TIME_FORMAT);
|
|
|
|
} catch (Exception) {
|
|
|
|
$asOf = '(invalid date)';
|
|
|
|
} ?>
|
|
|
|
<p><a href=/item/view?id=<?=$item['id']?>><?=htmlentities($item['item_title'])?></a><br>
|
|
|
|
<?=htmlentities($item['feed_title'])?><br><small><em><?=$asOf?></em></small><?php
|
|
|
|
$item = $result->fetchArray(SQLITE3_ASSOC);
|
|
|
|
}
|
|
|
|
} else { ?>
|
|
|
|
<p>There are no unread items</p><?php
|
|
|
|
} ?>
|
|
|
|
</article><?php
|
|
|
|
|
2024-04-05 00:49:25 +00:00
|
|
|
page_foot();
|
2024-04-13 16:10:07 +00:00
|
|
|
$db->close();
|