mirror of
https://github.com/YGGverse/Pulsar.git
synced 2026-03-31 17:55:37 +00:00
add record exist validation on route request
This commit is contained in:
parent
cf36d79cad
commit
67c6fab4cf
1 changed files with 80 additions and 76 deletions
|
|
@ -88,52 +88,54 @@ class Nex implements MessageComponentInterface
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Chanel item
|
// Chanel item
|
||||||
case (bool) preg_match('/\/(?<id>\d+)($|\.gmi)$/i', $request, $attribute):
|
case preg_match(
|
||||||
|
'/\/(?<id>\d+)($|\.gmi)$/i',
|
||||||
|
$request,
|
||||||
|
$attribute
|
||||||
|
) && $channelItem = $this->_database->getChannelItem(
|
||||||
|
$attribute['id']
|
||||||
|
):
|
||||||
|
|
||||||
$lines = [];
|
$lines = [];
|
||||||
|
|
||||||
// Get channel item info
|
if ($channelItem->title)
|
||||||
if ($channelItem = $this->_database->getChannelItem($attribute['id']))
|
|
||||||
{
|
{
|
||||||
if ($channelItem->title)
|
$lines[] = sprintf(
|
||||||
{
|
'# %s',
|
||||||
$lines[] = sprintf(
|
\Yggverse\Pulsar\Model\Filter::string(
|
||||||
'# %s',
|
$channelItem->title
|
||||||
\Yggverse\Pulsar\Model\Filter::string(
|
)
|
||||||
$channelItem->title
|
);
|
||||||
)
|
}
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($channelItem->pubTime)
|
if ($channelItem->pubTime)
|
||||||
{
|
{
|
||||||
$lines[] = date(
|
$lines[] = date(
|
||||||
'c',
|
'c',
|
||||||
$channelItem->pubTime
|
$channelItem->pubTime
|
||||||
) . PHP_EOL;
|
) . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($channelItem->description)
|
if ($channelItem->description)
|
||||||
{
|
{
|
||||||
$lines[] = \Yggverse\Pulsar\Model\Filter::text(
|
$lines[] = \Yggverse\Pulsar\Model\Filter::text(
|
||||||
$channelItem->description
|
$channelItem->description
|
||||||
) . PHP_EOL;
|
) . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($channelItem->content)
|
if ($channelItem->content)
|
||||||
{
|
{
|
||||||
$lines[] = \Yggverse\Pulsar\Model\Filter::text(
|
$lines[] = \Yggverse\Pulsar\Model\Filter::text(
|
||||||
$channelItem->content
|
$channelItem->content
|
||||||
) . PHP_EOL;
|
) . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($channelItem->link)
|
if ($channelItem->link)
|
||||||
{
|
{
|
||||||
$lines[] = sprintf(
|
$lines[] = sprintf(
|
||||||
'=> %s',
|
'=> %s',
|
||||||
$channelItem->link
|
$channelItem->link
|
||||||
);
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get channel info
|
// Get channel info
|
||||||
|
|
@ -155,52 +157,54 @@ class Nex implements MessageComponentInterface
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Channel page
|
// Channel page
|
||||||
case (bool) preg_match('/^\/(?<alias>.+)$/i', $request, $attribute):
|
case preg_match(
|
||||||
|
'/^\/(?<alias>.+)$/i',
|
||||||
|
$request,
|
||||||
|
$attribute
|
||||||
|
) && $channel = $this->_database->getChannelByAlias(
|
||||||
|
$attribute['alias']
|
||||||
|
):
|
||||||
|
|
||||||
$lines = [];
|
$lines = [];
|
||||||
|
|
||||||
// Get channel info
|
if ($channel->title)
|
||||||
if ($channel = $this->_database->getChannelByAlias($attribute['alias']))
|
|
||||||
{
|
{
|
||||||
if ($channel->title)
|
$lines[] = sprintf(
|
||||||
|
'# %s',
|
||||||
|
\Yggverse\Pulsar\Model\Filter::string(
|
||||||
|
$channel->title
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($channel->description)
|
||||||
|
{
|
||||||
|
$lines[] = $channel->description . PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get channel items
|
||||||
|
foreach ((array) $this->_database->getChannelItems($channel->id, 0, 20) as $channelItem)
|
||||||
|
{
|
||||||
|
$lines[] = sprintf(
|
||||||
|
'=> %d.gmi %s',
|
||||||
|
$channelItem->id,
|
||||||
|
\Yggverse\Pulsar\Model\Filter::string(
|
||||||
|
$channelItem->title
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($channelItem->description)
|
||||||
{
|
{
|
||||||
$lines[] = sprintf(
|
$lines[] = \Yggverse\Pulsar\Model\Filter::text(
|
||||||
'# %s',
|
$channelItem->description
|
||||||
\Yggverse\Pulsar\Model\Filter::string(
|
) . PHP_EOL;
|
||||||
$channel->title
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($channel->description)
|
if ($channelItem->content)
|
||||||
{
|
{
|
||||||
$lines[] = $channel->description . PHP_EOL;
|
$lines[] = \Yggverse\Pulsar\Model\Filter::text(
|
||||||
}
|
$channelItem->content
|
||||||
|
) . PHP_EOL;
|
||||||
// Get channel items
|
|
||||||
foreach ((array) $this->_database->getChannelItems($channel->id, 0, 20) as $channelItem)
|
|
||||||
{
|
|
||||||
$lines[] = sprintf(
|
|
||||||
'=> %d.gmi %s',
|
|
||||||
$channelItem->id,
|
|
||||||
\Yggverse\Pulsar\Model\Filter::string(
|
|
||||||
$channelItem->title
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue