瀏覽代碼

Update Redirect page

You can set the display time (greater than 0 seconds!) along with the message text.
Visman 2 年之前
父節點
當前提交
f5e2d22aa0
共有 1 個文件被更改,包括 7 次插入4 次删除
  1. 7 4
      app/Models/Pages/Redirect.php

+ 7 - 4
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;