Procházet zdrojové kódy

Update Redirect page

You can set the display time (greater than 0 seconds!) along with the message text.
Visman před 2 roky
rodič
revize
f5e2d22aa0
1 změnil soubory, kde provedl 7 přidání a 4 odebrání
  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;
             return $this;
         }
         }
 
 
         $this->nameTpl = 'layouts/redirect';
         $this->nameTpl = 'layouts/redirect';
         $this->robots  = 'noindex';
         $this->robots  = 'noindex';
         $this->message = $message;
         $this->message = $message;
-        $this->timeout = $this->c->config->i_redirect_delay;
+        $this->timeout = $timeout > 0 ? $timeout : $this->c->config->i_redirect_delay;
 
 
         return $this;
         return $this;
     }
     }
@@ -68,7 +71,7 @@ class Redirect extends Page
     protected function getHttpHeaders(): array
     protected function getHttpHeaders(): array
     {
     {
         if (
         if (
-            $this->c->config->i_redirect_delay < 1
+            $this->timeout < 1
             || null === $this->nameTpl
             || null === $this->nameTpl
         ) {
         ) {
             $this->httpStatus = 302;
             $this->httpStatus = 302;