. * * @copyright (c) Visman * @license The MIT License (MIT) */ declare(strict_types=1); namespace ForkBB\Models\Pages; use ForkBB\Models\Page; use function \ForkBB\__; class Redirect extends Page { /** * Перенаправление на главную страницу форума */ public function toIndex(): Page { return $this->page('Index'); //->message('Redirecting to index'); } /** * Задает адрес перехода */ public function page(string $marker, array $args = []): Page { $this->link = $this->c->Router->link($marker, $args); return $this; } /** * Задает ссылку для перехода */ public function url(string $url): Page { $this->link = $url; return $this; } /** * Задает сообщение */ public function message(/* string|array */ $message): Page { // переадресация без вывода сообщения if ($this->c->config->i_redirect_delay < 1) { return $this; } $this->nameTpl = 'layouts/redirect'; $this->robots = 'noindex'; $this->message = $message; $this->timeout = $this->c->config->i_redirect_delay; return $this; } /** * Возвращает HTTP заголовки страницы * $this->httpHeaders */ protected function getHttpHeaders(): array { if ( $this->c->config->i_redirect_delay < 1 || null === $this->nameTpl ) { $this->httpStatus = 302; $this->nameTpl = null; $this->header('Location', $this->link); } return parent::getHttpHeaders(); } /** * Подготовка страницы к отображению */ public function prepare(): void { } }