diff --git a/src/Brickner/Podsumer/State.php b/src/Brickner/Podsumer/State.php
index 3f9e28f..70e1d71 100755
--- a/src/Brickner/Podsumer/State.php
+++ b/src/Brickner/Podsumer/State.php
@@ -205,6 +205,15 @@ public function getFeedItems(int $feed_id): array
return (false === $result) ? [] : $result;
}
+ public function getAllItems(): array
+ {
+ $sql = 'SELECT items.name, items.feed_id, items.id, items.guid, items.audio_url, items.audio_file, COALESCE(items.image, feeds.image) AS image, items.size, items.published, items.description, items.playback_position, feeds.name AS feed_name FROM items JOIN feeds ON feeds.id = items.feed_id ORDER BY items.published DESC';
+
+ $result = $this->query($sql);
+
+ return (false === $result) ? [] : $result;
+ }
+
public function getFeedItemsPage(int $feed_id, int $limit, int $page = 1): array
{
$offset = ($page - 1) * $limit;
@@ -212,6 +221,7 @@ public function getFeedItemsPage(int $feed_id, int $limit, int $page = 1): array
$params = ['id' => $feed_id, 'limit' => $limit, 'offset' => $offset];
$result = $this->query($sql, $params);
+
return (false === $result) ? [] : $result;
}
diff --git a/templates/base.html.php b/templates/base.html.php
index 7237788..abba0b3 100755
--- a/templates/base.html.php
+++ b/templates/base.html.php
@@ -11,6 +11,8 @@
Feeds
|
+ Episodes
+ |
OPML
|
= round($db_size/1024/1024/1024, 2) ?> GB
diff --git a/templates/episodes.html.php b/templates/episodes.html.php
new file mode 100644
index 0000000..d07580d
--- /dev/null
+++ b/templates/episodes.html.php
@@ -0,0 +1,32 @@
+
+ if (empty($items)): ?>
+
+
No Episodes
+
+ else: ?>
+ foreach ($items as $item): ?>
+
+
+
+
+
+ = $item['name'] ?>
+
+
+
+ = $item['feed_name'] ?>
+ |
+ = round($item['size'] / 1024 / 1024, 1) ?>MB
+ |
+ = date('m/d/Y', strtotime($item['published'])); ?>
+ if (!empty($item['audio_file'])) { ?>
+ |
+ Delete Audio
+ } ?>
+
+
+ = substr(strip_tags($item['description']), 0, 360); ?>
+
+ endforeach ?>
+ endif ?>
+
diff --git a/tests/Brickner/Podsumer/StateTest.php b/tests/Brickner/Podsumer/StateTest.php
index c1c48c8..c199ebd 100644
--- a/tests/Brickner/Podsumer/StateTest.php
+++ b/tests/Brickner/Podsumer/StateTest.php
@@ -84,6 +84,14 @@ public function testGetFeedItems()
$this->assertEquals(4, count($items));
}
+ public function testGetAllItems()
+ {
+ $this->feed = new Feed(self::TEST_FEED_URL);
+ $this->state->addFeed($this->feed);
+ $items = $this->state->getAllItems();
+ $this->assertEquals(4, count($items));
+ }
+
public function testGetFeedItemsPage()
{
$this->feed = new Feed(self::TEST_FEED_URL);
diff --git a/www/index.php b/www/index.php
index 5071587..7d3077b 100755
--- a/www/index.php
+++ b/www/index.php
@@ -40,6 +40,18 @@ function home(array $args): void
Template::render($main, 'home', $vars);
}
+#[Route('/episodes', 'GET', true)]
+function episodes(array $args): void
+{
+ global $main;
+
+ $vars = [
+ 'items' => $main->getState()->getAllItems()
+ ];
+
+ Template::render($main, 'episodes', $vars);
+}
+
/**
* Add new feed(s)
* Path: /add