49 lines
1.3 KiB
PHP
49 lines
1.3 KiB
PHP
<?php
|
|
/**
|
|
* Home Page
|
|
*
|
|
* Displays a list of unread feed items for the current user
|
|
*/
|
|
|
|
include '../start.php';
|
|
|
|
Security::verifyUser();
|
|
|
|
$db = Data::getConnection();
|
|
|
|
if (array_key_exists('refresh', $_GET)) {
|
|
$refreshResult = Feed::refreshAll($db);
|
|
if (array_key_exists('ok', $refreshResult)) {
|
|
add_info('All feeds refreshed successfully');
|
|
} else {
|
|
add_error(nl2br($refreshResult['error']));
|
|
}
|
|
}
|
|
|
|
$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;
|
|
|
|
page_head('Welcome'); ?>
|
|
<h1>Your Unread Items <a href=/?refresh><small><small><em>(Refresh All Feeds)</em></small></small></a></h1>
|
|
<article><?php
|
|
if ($item) {
|
|
while ($item) { ?>
|
|
<p><a href=/item?id=<?=$item['id']?>><?=$item['item_title']?></a><br>
|
|
<?=$item['feed_title']?><br><small><em><?=date_time($item['as_of'])?></em></small><?php
|
|
$item = $result->fetchArray(SQLITE3_ASSOC);
|
|
}
|
|
} else { ?>
|
|
<p>There are no unread items</p><?php
|
|
} ?>
|
|
</article><?php
|
|
|
|
page_foot();
|
|
$db->close();
|