Selaa lähdekoodia

Remove double escaping special characters in the page title

Visman 3 vuotta sitten
vanhempi
commit
49d30dde62

+ 13 - 15
app/Models/Page.php

@@ -304,9 +304,9 @@ abstract class Page extends Model
         if (empty($titles)) {
             $titles = $this->titles;
         }
-        $titles[] = $this->c->config->o_board_title;
+        $titles[] = ['%s', $this->c->config->o_board_title];
 
-        return \implode(__('Title separator'), $titles);
+        return \implode(__('Title separator'), \array_map('\\ForkBB\\__', $titles));
     }
 
     /**
@@ -435,7 +435,7 @@ abstract class Page extends Model
      * Дописывает в массив титула страницы новый элемент
      * $this->titles = ...
      */
-    public function settitles(string $value): void
+    public function settitles(/* string|array */ $value): void
     {
         $attr = $this->getAttr('titles', []);
         $attr[] = $value;
@@ -476,23 +476,21 @@ abstract class Page extends Model
             // модель
             if ($crumb instanceof Model) {
                 do {
-                    $name = $crumb->name ?? '<no name>';
+                    $name = $crumb->name ?? 'NO NAME';
 
-                    if (\is_array($name)) {
-                        $result[] = [$crumb, $name, $active];
-                    } else {
-                        $result[] = [$crumb, ['%s', $name], $active];
+                    if (! \is_array($name)) {
+                        $name = ['%s', $name];
                     }
 
-                    $active = null;
-                    $name   = __($name);
+                    $result[]     = [$crumb, $name, $active];
+                    $active       = null;
+                    $this->titles = $name;
 
                     if ($crumb->page > 1) {
-                        $name .= __([' Page %s', $crumb->page]);
+                        $this->titles = ['Page %s', $crumb->page];
                     }
 
-                    $this->titles = $name;
-                    $crumb        = $crumb->parent;
+                    $crumb = $crumb->parent;
                 } while (
                     $crumb instanceof Model
                     && null !== $crumb->parent
@@ -500,11 +498,11 @@ abstract class Page extends Model
             // ссылка (передана массивом)
             } elseif (\is_array($crumb)) {
                 $result[]     = [$crumb[0], $crumb[1], $active];
-                $this->titles = __($crumb[1]);
+                $this->titles = $crumb[1];
             // строка
             } else {
                 $result[]     = [null, (string) $crumb, $active];
-                $this->titles = __((string) $crumb);
+                $this->titles = (string) $crumb;
             }
 
             $active = null;

+ 1 - 1
app/Models/Pages/Admin/Host.php

@@ -32,7 +32,7 @@ class Host extends Admin
         $host = \gethostbyaddr($ip);
 
         $this->nameTpl = 'message';
-        $this->titles  = __('Info');
+        $this->titles  = 'Info';
         $this->back    = true;
         $this->fIswev  = [
             'i',

+ 3 - 3
app/Models/Pages/Auth.php

@@ -95,7 +95,7 @@ class Auth extends Page
         $this->nameTpl    = 'login';
         $this->onlinePos  = 'login';
         $this->robots     = 'noindex';
-        $this->titles     = __('Login');
+        $this->titles     = 'Login';
         $this->regLink    = 1 === $this->c->config->b_regs_allow ? $this->c->Router->link('Register') : null;
 
         $username         = $v ? $v->username : $username;
@@ -314,7 +314,7 @@ class Auth extends Page
         $this->nameTpl    = 'passphrase_reset';
         $this->onlinePos  = 'passphrase_reset';
         $this->robots     = 'noindex';
-        $this->titles     = __('Passphrase reset');
+        $this->titles     = 'Passphrase reset';
         $this->form       = $this->formForget($v ? $v->email : $email);
 
         return $this;
@@ -441,7 +441,7 @@ class Auth extends Page
         $this->nameTpl    = 'change_passphrase';
         $this->onlinePos  = 'change_passphrase';
         $this->robots     = 'noindex';
-        $this->titles     = __('Passphrase reset');
+        $this->titles     = 'Passphrase reset';
         $this->form       = $this->formChange($args);
 
         return $this;

+ 1 - 1
app/Models/Pages/Ban.php

@@ -25,7 +25,7 @@ class Ban extends Page
         $this->nameTpl    = 'ban';
 #       $this->onlinePos  = 'ban';
 #       $this->robots     = 'noindex';
-        $this->titles     = __('Info');
+        $this->titles     = 'Info';
         $this->ban        = $user->banInfo;
         $this->adminEmail = $this->c->config->o_admin_email;
         $this->bannedIp   = $user->isGuest;

+ 1 - 1
app/Models/Pages/Maintenance.php

@@ -26,7 +26,7 @@ class Maintenance extends Page
         $this->nameTpl            = 'maintenance';
 #       $this->onlinePos          = null; //????
 #       $this->robots             = 'noindex';
-        $this->titles             = __('Maintenance');
+        $this->titles             = 'Maintenance';
 #       $this->fNavigation        = null; //????
 #       $this->maintenanceMessage = $this->c->config->o_maintenance_message;
 

+ 1 - 1
app/Models/Pages/Message.php

@@ -22,7 +22,7 @@ class Message extends Page
     {
         $this->nameTpl    = 'message';
         $this->httpStatus = \max(200, $status);
-        $this->titles     = __('Info');
+        $this->titles     = 'Info';
         $this->back       = $back;
 
         if (! empty($headers)) {

+ 1 - 1
app/Models/Pages/Register.php

@@ -81,7 +81,7 @@ class Register extends Page
         $this->fIndex     = self::FI_REG;
         $this->nameTpl    = 'register';
         $this->onlinePos  = 'register';
-        $this->titles     = __('Register');
+        $this->titles     = 'Register';
         $this->robots     = 'noindex';
         $this->form       = $this->formReg($v);
 

+ 2 - 2
app/lang/en/common.po

@@ -203,8 +203,8 @@ msgstr[1] "<b>%s</b> Views"
 msgid "Pages"
 msgstr "Pages:"
 
-msgid " Page %s"
-msgstr " (Page %s)"
+msgid "Page %s"
+msgstr "Page %s"
 
 msgid "Page %1$s of %2$s"
 msgstr "Page %1$s of %2$s ·"

+ 2 - 2
app/lang/ru/common.po

@@ -205,8 +205,8 @@ msgstr[2] "<b>%s</b> Просмотров"
 msgid "Pages"
 msgstr "Страницы"
 
-msgid " Page %s"
-msgstr " (Страница %s)"
+msgid "Page %s"
+msgstr "Страница %s"
 
 msgid "Page %1$s of %2$s"
 msgstr "Страница %1$s из %2$s ·"

+ 1 - 1
app/templates/layouts/main.forkbb.php

@@ -3,7 +3,7 @@
 <head>
   <meta charset="utf-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
-  <title>{{ $p->pageTitle }}</title>
+  <title>{!! $p->pageTitle !!}</title>
 @foreach ($p->pageHeaders as $pageHeader)
     @if ('style' === $pageHeader['type'])
   <style>{!! $pageHeader['values'][0] !!}</style>

+ 1 - 1
app/templates/layouts/redirect.forkbb.php

@@ -4,7 +4,7 @@
   <meta charset="utf-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <meta http-equiv="refresh" content="{{ $p->timeout }};URL={{ $p->link }}">
-  <title>{{ $p->pageTitle }}</title>
+  <title>{!! $p->pageTitle !!}</title>
 @foreach ($p->pageHeaders as $pageHeader)
     @if ('style' === $pageHeader['type'])
   <style>{!! $pageHeader['values'][0] !!}</style>