Completed result/option migration

- Change casing on exposed constants
- Add file-level phpdoc
This commit is contained in:
2024-07-25 21:14:57 -04:00
parent 1d5a3c1c7a
commit 6dc264d34c
34 changed files with 658 additions and 383 deletions

View File

@@ -1,11 +1,15 @@
<?php declare(strict_types=1);
<?php
/**
* Feed Maintenance Page
*
* List feeds and provide links for maintenance actions
*
* @author Daniel J. Summers <daniel@bitbadger.solutions>
* @license MIT
*/
declare(strict_types=1);
use BitBadger\PDODocument\{Custom, Field, Query};
use BitBadger\PDODocument\Mapper\{ArrayMapper, DocumentMapper};
use FeedReaderCentral\{Feed, Key, Table};
@@ -14,14 +18,14 @@ include '../start.php';
FeedReaderCentral\Security::verifyUser();
$field = Field::EQ('user_id', $_SESSION[Key::USER_ID], ':user');
$feeds = Custom::list(Query\Find::byFields(Table::FEED, [$field]) . " ORDER BY lower(data->>'title')",
$field = Field::EQ('user_id', $_SESSION[Key::UserId], ':user');
$feeds = Custom::list(Query\Find::byFields(Table::Feed, [$field]) . " ORDER BY lower(data->>'title')",
$field->appendParameter([]), new DocumentMapper(Feed::class));
page_head('Your Feeds');
echo '<h1>Your Feeds</h1><article><p class=action_buttons>' . hx_get('/feed/?id=-1', 'Add Feed') . '</p>';
foreach ($feeds->items() as /** @var Feed $feed */ $feed) {
$item = Table::ITEM;
$feeds->iter(function (Feed $feed) {
$item = Table::Item;
$counts = Custom::single(<<<SQL
SELECT (SELECT COUNT(*) FROM $item WHERE data->>'feed_id' = :feed) AS total,
(SELECT COUNT(*) FROM $item WHERE data->>'feed_id' = :feed AND data->>'is_read' = 0) AS unread,
@@ -39,6 +43,6 @@ foreach ($feeds->items() as /** @var Feed $feed */ $feed) {
. ' hx-confirm="Are you sure you want to delete &ldquo;' . htmlspecialchars($feed->title)
. '&rdquo;? This will remove the feed and all its items, including unread and bookmarked.">Delete</a>'
. '</span>';
}
});
echo '</article>';
page_foot();