43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Jinove\Vinoteca\Controller;
|
|
|
|
use Bitrix\Main\Engine\ActionFilter\HttpMethod;
|
|
use Bitrix\Main\Engine\Controller;
|
|
use Bitrix\Main\Engine\Response\Component;
|
|
use Bitrix\Main\Error;
|
|
use Jinove\Vinoteca\News as NewsList;
|
|
|
|
class News extends Controller
|
|
{
|
|
public function configureActions(): array
|
|
{
|
|
return [
|
|
"page" => [
|
|
"prefilters" => [new HttpMethod([HttpMethod::METHOD_GET])],
|
|
],
|
|
];
|
|
}
|
|
|
|
public function pageAction(): ?Component
|
|
{
|
|
$page = (string)$this->getRequest()->getQuery("PAGEN_1");
|
|
if (!ctype_digit($page) || (int)$page < 1 || (int)$page > NewsList::pageCount()) {
|
|
$this->addError(new Error("Wrong page"));
|
|
|
|
return null;
|
|
}
|
|
$meta = NewsList::pageMeta((int)$page);
|
|
|
|
return new Component(
|
|
"bitrix:news.list",
|
|
NewsList::LIST_TEMPLATE,
|
|
NewsList::listParams(true),
|
|
[],
|
|
static fn(): array => ["title" => $meta["title"]]
|
|
);
|
|
}
|
|
}
|