First cut of read bookmarked item page (#14)

- Added Bookmarked link to header if items exist
This commit is contained in:
2024-05-23 23:02:07 -04:00
parent f4273935cb
commit 2495136fc9
2 changed files with 43 additions and 14 deletions

View File

@@ -52,13 +52,29 @@ function title_bar(): void {
default => FRC_VERSION
}; ?>
<header hx-target=#main hx-push-url=true>
<div><?=hx_get('/', 'Feed Reader Central', 'class=title')?><span class=version>v<?=$version?></span></div>
<div><a href=/ class=title>Feed Reader Central</a><span class=version>v<?=$version?></span></div>
<div><?php
if (array_key_exists(Key::USER_ID, $_SESSION)) { ?>
<?=hx_get('/feeds', 'Feeds')?> | <?=hx_get('/docs/', 'Docs')?> |
<a href=/user/log-off>Log Off</a><?php
if ($_SESSION[Key::USER_EMAIL] != Security::SINGLE_USER_EMAIL) { ?>
| <?=$_SESSION[Key::USER_EMAIL]?><?php
if (array_key_exists(Key::USER_ID, $_SESSION)) {
$db = Data::getConnection();
try {
$bookQuery = $db->prepare(<<<'SQL'
SELECT EXISTS(
SELECT 1
FROM item INNER JOIN feed ON item.feed_id = feed.id
WHERE feed.user_id = :id AND item.is_bookmarked = 1)
SQL);
$bookQuery->bindValue(':id', $_SESSION[Key::USER_ID]);
$bookResult = $bookQuery->execute();
$hasBookmarks = $bookResult ? $bookResult->fetchArray(SQLITE3_NUM)[0] : false; ?>
<?=hx_get('/feeds', 'Feeds')?> |
<?=$hasBookmarks ? hx_get('/?bookmarked', 'Bookmarked') . ' | ' : ''?>
<?=hx_get('/docs/', 'Docs')?> |
<a href=/user/log-off>Log Off</a><?php
if ($_SESSION[Key::USER_EMAIL] != Security::SINGLE_USER_EMAIL) { ?>
| <?=$_SESSION[Key::USER_EMAIL]?><?php
}
} finally {
$db->close();
}
} else { ?>
<?=hx_get('/user/log-on', 'Log On')?> | <?=hx_get('/docs/', 'Docs')?><?php