From f5e2d22aa0dde0742df2b95e90ca49316358010d Mon Sep 17 00:00:00 2001 From: Visman Date: Fri, 12 May 2023 20:28:04 +0700 Subject: [PATCH] Update Redirect page You can set the display time (greater than 0 seconds!) along with the message text. --- app/Models/Pages/Redirect.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/Models/Pages/Redirect.php b/app/Models/Pages/Redirect.php index e62513be..40aeb2b4 100644 --- a/app/Models/Pages/Redirect.php +++ b/app/Models/Pages/Redirect.php @@ -46,17 +46,20 @@ class Redirect extends Page /** * Задает сообщение */ - public function message(string|array $message): Page + public function message(string|array $message, ?int $timeout = 0): Page { // переадресация без вывода сообщения - if ($this->c->config->i_redirect_delay < 1) { + if ( + $timeout < 1 + && $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; + $this->timeout = $timeout > 0 ? $timeout : $this->c->config->i_redirect_delay; return $this; } @@ -68,7 +71,7 @@ class Redirect extends Page protected function getHttpHeaders(): array { if ( - $this->c->config->i_redirect_delay < 1 + $this->timeout < 1 || null === $this->nameTpl ) { $this->httpStatus = 302;