diff --git a/src/Controller/Server/Nex.php b/src/Controller/Server/Nex.php index 3e7ae43..86367cc 100644 --- a/src/Controller/Server/Nex.php +++ b/src/Controller/Server/Nex.php @@ -167,36 +167,36 @@ class Nex implements MessageComponentInterface { $lines[] = $channel->description . PHP_EOL; } - } - // Get channel items - foreach ((array) $this->_database->getChannelItems(0, 20) as $channelItem) - { - $lines[] = sprintf( - '=> /%d.gmi %s %s', - $channelItem->id, - $channelItem->pubTime ? - date( - 'Y-m-d', - $channelItem->pubTime - ) : '', - \Yggverse\Pulsar\Model\Filter::string( - $channelItem->title - ) - ); - - if ($channelItem->description) + // Get channel items + foreach ((array) $this->_database->getChannelItems($channel->id, 0, 20) as $channelItem) { - $lines[] = \Yggverse\Pulsar\Model\Filter::text( - $channelItem->description - ) . PHP_EOL; - } + $lines[] = sprintf( + '=> /%d.gmi %s %s', + $channelItem->id, + $channelItem->pubTime ? + date( + 'Y-m-d', + $channelItem->pubTime + ) : '', + \Yggverse\Pulsar\Model\Filter::string( + $channelItem->title + ) + ); - if ($channelItem->content) - { - $lines[] = \Yggverse\Pulsar\Model\Filter::text( - $channelItem->content - ) . PHP_EOL; + if ($channelItem->description) + { + $lines[] = \Yggverse\Pulsar\Model\Filter::text( + $channelItem->description + ) . PHP_EOL; + } + + if ($channelItem->content) + { + $lines[] = \Yggverse\Pulsar\Model\Filter::text( + $channelItem->content + ) . PHP_EOL; + } } } diff --git a/src/Model/Database.php b/src/Model/Database.php index 423cb30..9f41323 100644 --- a/src/Model/Database.php +++ b/src/Model/Database.php @@ -198,13 +198,15 @@ class Database } public function getChannelItems( + int $channelId, int $start = 0, int $limit = 20 ): ?array { $query = $this->_database->query( sprintf( - 'SELECT * FROM `channelItem` ORDER BY `pubTime` DESC, `time` DESC, `id` DESC LIMIT %d,%d', + 'SELECT * FROM `channelItem` WHERE `channelId` = %d ORDER BY `pubTime` DESC, `time` DESC, `id` DESC LIMIT %d,%d', + $channelId, $start, $limit )