Bladeren bron

Override bbcode settings

Visman 4 jaren geleden
bovenliggende
commit
80224917ec

+ 17 - 7
app/Core/Parser.php

@@ -64,11 +64,21 @@ class Parser extends Parserus
     public function prepare(string $text, bool $isSignature = false): string
     public function prepare(string $text, bool $isSignature = false): string
     {
     {
         if ($isSignature) {
         if ($isSignature) {
-            $whiteList = '1' == $this->c->config->p_sig_bbcode ? $this->c->BBCODE_INFO['forSign'] : [];
-            $blackList = '1' == $this->c->config->p_sig_img_tag ? [] : ['img'];
+            $whiteList = '1' == $this->c->config->p_sig_bbcode
+                ? (empty($this->c->config->a_bb_white_sig) && empty($this->c->config->a_bb_black_sig)
+                    ? null
+                    : $this->c->config->a_bb_white_sig
+                )
+                : [];
+            $blackList = null;
         } else {
         } else {
-            $whiteList = '1' == $this->c->config->p_message_bbcode ? null : [];
-            $blackList = '1' == $this->c->config->p_message_img_tag ? [] : ['img'];
+            $whiteList = '1' == $this->c->config->p_message_bbcode
+                ? (empty($this->c->config->a_bb_white_mes) && empty($this->c->config->a_bb_black_mes)
+                    ? null
+                    : $this->c->config->a_bb_white_mes
+                )
+                : [];
+            $blackList = null;
         }
         }
 
 
         $this->setAttr('isSign', $isSignature)
         $this->setAttr('isSign', $isSignature)
@@ -92,7 +102,7 @@ class Parser extends Parserus
         // при null предполагается брать данные после prepare()
         // при null предполагается брать данные после prepare()
         if (null !== $text) {
         if (null !== $text) {
             $whiteList = '1' == $this->c->config->p_message_bbcode ? null : [];
             $whiteList = '1' == $this->c->config->p_message_bbcode ? null : [];
-            $blackList = '1' == $this->c->config->p_message_img_tag ? [] : ['img'];
+            $blackList = $this->c->config->a_bb_black_mes;
 
 
             $this->setAttr('isSign', false)
             $this->setAttr('isSign', false)
                  ->setWhiteList($whiteList)
                  ->setWhiteList($whiteList)
@@ -117,8 +127,8 @@ class Parser extends Parserus
     {
     {
         // при null предполагается брать данные после prepare()
         // при null предполагается брать данные после prepare()
         if (null !== $text) {
         if (null !== $text) {
-            $whiteList = '1' == $this->c->config->p_sig_bbcode ? $this->c->BBCODE_INFO['forSign'] : [];
-            $blackList = '1' == $this->c->config->p_sig_img_tag ? [] : ['img'];
+            $whiteList = '1' == $this->c->config->p_sig_bbcode ? null : [];
+            $blackList = $this->c->config->a_bb_black_sig;
 
 
             $this->setAttr('isSign', true)
             $this->setAttr('isSign', true)
                  ->setWhiteList($whiteList)
                  ->setWhiteList($whiteList)

+ 7 - 3
app/Models/Pages/Admin/Install.php

@@ -14,6 +14,8 @@ class Install extends Admin
 {
 {
     const PHP_MIN = '7.3.0';
     const PHP_MIN = '7.3.0';
 
 
+    const JSON_OPTIONS = \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE | \JSON_THROW_ON_ERROR;
+
     /**
     /**
      * Для MySQL
      * Для MySQL
      * @var string
      * @var string
@@ -1110,12 +1112,10 @@ class Install extends Admin
             'o_feed_type'             => 2,
             'o_feed_type'             => 2,
             'o_feed_ttl'              => 0,
             'o_feed_ttl'              => 0,
             'p_message_bbcode'        => 1,
             'p_message_bbcode'        => 1,
-            'p_message_img_tag'       => 1,
             'p_message_all_caps'      => 1,
             'p_message_all_caps'      => 1,
             'p_subject_all_caps'      => 1,
             'p_subject_all_caps'      => 1,
             'p_sig_all_caps'          => 1,
             'p_sig_all_caps'          => 1,
             'p_sig_bbcode'            => 1,
             'p_sig_bbcode'            => 1,
-            'p_sig_img_tag'           => 0,
             'p_force_guest_email'     => 1,
             'p_force_guest_email'     => 1,
             'o_pms_enabled'           => 1,                    // New PMS - Visman
             'o_pms_enabled'           => 1,                    // New PMS - Visman
             'o_pms_min_kolvo'         => 0,
             'o_pms_min_kolvo'         => 0,
@@ -1138,6 +1138,10 @@ class Install extends Admin
             'o_enable_acaptcha'       => 1, // математическая каптча
             'o_enable_acaptcha'       => 1, // математическая каптча
             'st_max_users'            => 1,    // статистика по максимуму юзеров - Visman
             'st_max_users'            => 1,    // статистика по максимуму юзеров - Visman
             'st_max_users_time'       => \time(),
             'st_max_users_time'       => \time(),
+            'a_bb_white_mes'          => \json_encode([], self::JSON_OPTIONS),
+            'a_bb_white_sig'          => \json_encode(['b', 'i', 'u', 'color', 'colour', 'email', 'url'], self::JSON_OPTIONS),
+            'a_bb_black_mes'          => \json_encode([], self::JSON_OPTIONS),
+            'a_bb_black_sig'          => \json_encode([], self::JSON_OPTIONS),
         ];
         ];
         foreach ($pun_config as $conf_name => $conf_value) {
         foreach ($pun_config as $conf_name => $conf_value) {
             $this->c->DB->exec('INSERT INTO ::config (conf_name, conf_value) VALUES (?s, ?s)', [$conf_name, $conf_value]);
             $this->c->DB->exec('INSERT INTO ::config (conf_name, conf_value) VALUES (?s, ?s)', [$conf_name, $conf_value]);
@@ -1180,7 +1184,7 @@ class Install extends Admin
         foreach ($bbcodes as $bbcode) {
         foreach ($bbcodes as $bbcode) {
             $vars = [
             $vars = [
                 ':tag'       => $bbcode['tag'],
                 ':tag'       => $bbcode['tag'],
-                ':structure' => \json_encode($bbcode, \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE | \JSON_THROW_ON_ERROR),
+                ':structure' => \json_encode($bbcode, self::JSON_OPTIONS),
             ];
             ];
             $this->c->DB->exec($query, $vars);
             $this->c->DB->exec($query, $vars);
         }
         }

+ 2 - 18
app/Models/Pages/Admin/Parser/Edit.php

@@ -23,9 +23,7 @@ class Edit extends Parser
                 ])->addRules([
                 ])->addRules([
                     'token'               => 'token:AdminParser',
                     'token'               => 'token:AdminParser',
                     'p_message_bbcode'    => 'required|integer|in:0,1',
                     'p_message_bbcode'    => 'required|integer|in:0,1',
-                    'p_message_img_tag'   => 'required|integer|in:0,1',
                     'p_sig_bbcode'        => 'required|integer|in:0,1',
                     'p_sig_bbcode'        => 'required|integer|in:0,1',
-                    'p_sig_img_tag'       => 'required|integer|in:0,1',
                     'o_smilies'           => 'required|integer|in:0,1',
                     'o_smilies'           => 'required|integer|in:0,1',
                     'o_smilies_sig'       => 'required|integer|in:0,1',
                     'o_smilies_sig'       => 'required|integer|in:0,1',
                     'o_make_links'        => 'required|integer|in:0,1',
                     'o_make_links'        => 'required|integer|in:0,1',
@@ -82,7 +80,7 @@ class Edit extends Parser
 
 
         $yn = [1 => __('Yes'), 0 => __('No')];
         $yn = [1 => __('Yes'), 0 => __('No')];
 
 
-        $form['sets']['posting'] = [
+        $form['sets']['bbcode'] = [
             'legend' => __('BBCode subhead'),
             'legend' => __('BBCode subhead'),
             'fields' => [
             'fields' => [
                 'p_message_bbcode' => [
                 'p_message_bbcode' => [
@@ -99,20 +97,6 @@ class Edit extends Parser
                     'caption' => __('BBCode sigs label'),
                     'caption' => __('BBCode sigs label'),
                     'info'    => __('BBCode sigs help'),
                     'info'    => __('BBCode sigs help'),
                 ],
                 ],
-                'p_message_img_tag' => [
-                    'type'    => 'radio',
-                    'value'   => $config->p_message_img_tag,
-                    'values'  => $yn,
-                    'caption' => __('Image tag label'),
-                    'info'    => __('Image tag help'),
-                ],
-                'p_sig_img_tag' => [
-                    'type'    => 'radio',
-                    'value'   => $config->p_sig_img_tag,
-                    'values'  => $yn,
-                    'caption' => __('Image tag sigs label'),
-                    'info'    => __('Image tag sigs help'),
-                ],
                 'o_make_links' => [
                 'o_make_links' => [
                     'type'    => 'radio',
                     'type'    => 'radio',
                     'value'   => $config->o_make_links,
                     'value'   => $config->o_make_links,
@@ -130,7 +114,7 @@ class Edit extends Parser
             ],
             ],
         ];
         ];
 
 
-        $form['sets']['signatures'] = [
+        $form['sets']['smilies'] = [
             'legend' => __('Smilies subhead'),
             'legend' => __('Smilies subhead'),
             'fields' => [
             'fields' => [
                 'o_smilies' => [
                 'o_smilies' => [

+ 18 - 1
app/Models/Pages/Admin/Update.php

@@ -24,6 +24,8 @@ class Update extends Admin
 
 
     const CONFIG_FILE = 'main.php';
     const CONFIG_FILE = 'main.php';
 
 
+    const JSON_OPTIONS = \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE | \JSON_THROW_ON_ERROR;
+
     public function __construct(Container $container)
     public function __construct(Container $container)
     {
     {
         parent::__construct($container);
         parent::__construct($container);
@@ -738,13 +740,28 @@ class Update extends Admin
         foreach ($bbcodes as $bbcode) {
         foreach ($bbcodes as $bbcode) {
             $vars = [
             $vars = [
                 ':tag'       => $bbcode['tag'],
                 ':tag'       => $bbcode['tag'],
-                ':structure' => \json_encode($bbcode, \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE | \JSON_THROW_ON_ERROR),
+                ':structure' => \json_encode($bbcode, self::JSON_OPTIONS),
             ];
             ];
             $this->c->DB->exec($query, $vars);
             $this->c->DB->exec($query, $vars);
         }
         }
 
 
+        $this->c->config->a_bb_white_mes = [];
+        $this->c->config->a_bb_white_sig = ['b', 'i', 'u', 'color', 'colour', 'email', 'url'];
+        $this->c->config->a_bb_black_mes = [];
+        $this->c->config->a_bb_black_sig = [];
+
         unset($this->c->config->o_quote_depth);
         unset($this->c->config->o_quote_depth);
+        unset($this->c->config->p_sig_img_tag);
+        unset($this->c->config->p_message_img_tag);
 
 
         $this->c->config->save();
         $this->c->config->save();
+
+        $coreConfig = new CoreConfig($this->c->DIR_CONFIG . '/' . self::CONFIG_FILE);
+
+        $result = $coreConfig->delete(
+            'BBCODE_INFO=>forSign',
+        );
+
+        $coreConfig->save();
     }
     }
 }
 }

+ 2 - 0
app/Models/Pages/PostFormTrait.php

@@ -86,12 +86,14 @@ trait PostFormTrait
             'caption'  => __('Message'),
             'caption'  => __('Message'),
             'required' => true,
             'required' => true,
             'value'    => $vars['message'] ?? null,
             'value'    => $vars['message'] ?? null,
+/* ????
             'bb'       => [
             'bb'       => [
                 ['link', __('BBCode'), __('1' == $this->c->config->p_message_bbcode ? 'on' : 'off')],
                 ['link', __('BBCode'), __('1' == $this->c->config->p_message_bbcode ? 'on' : 'off')],
                 ['link', __('url tag'), __('1' == $this->c->config->p_message_bbcode && '1' == $this->user->g_post_links ? 'on' : 'off')],
                 ['link', __('url tag'), __('1' == $this->c->config->p_message_bbcode && '1' == $this->user->g_post_links ? 'on' : 'off')],
                 ['link', __('img tag'), __('1' == $this->c->config->p_message_bbcode && '1' == $this->c->config->p_message_img_tag ? 'on' : 'off')],
                 ['link', __('img tag'), __('1' == $this->c->config->p_message_bbcode && '1' == $this->c->config->p_message_img_tag ? 'on' : 'off')],
                 ['link', __('Smilies'), __('1' == $this->c->config->o_smilies ? 'on' : 'off')],
                 ['link', __('Smilies'), __('1' == $this->c->config->o_smilies ? 'on' : 'off')],
             ],
             ],
+*/
             'autofocus' => $autofocus,
             'autofocus' => $autofocus,
         ];
         ];
         $form['sets']['uesm'] = [
         $form['sets']['uesm'] = [

+ 0 - 1
app/config/main.dist.php

@@ -35,7 +35,6 @@ return [
     'GROUP_GUEST'      => 3,
     'GROUP_GUEST'      => 3,
     'GROUP_MEMBER'     => 4,
     'GROUP_MEMBER'     => 4,
     'BBCODE_INFO'      => [
     'BBCODE_INFO'      => [
-        'forSign'  => ['b', 'i', 'u', 'color', 'colour', 'email', 'img', 'url'],
         'smTpl'    => '<img src="{url}" alt="{alt}">',
         'smTpl'    => '<img src="{url}" alt="{alt}">',
         'smTplTag' => 'img',
         'smTplTag' => 'img',
         'smTplBl'  => ['url'],
         'smTplBl'  => ['url'],

+ 0 - 12
app/lang/en/admin_parser.po

@@ -27,24 +27,12 @@ msgstr "BBCode"
 msgid "BBCode help"
 msgid "BBCode help"
 msgstr "Allow BBCode in posts (recommended)."
 msgstr "Allow BBCode in posts (recommended)."
 
 
-msgid "Image tag label"
-msgstr "Image tag"
-
-msgid "Image tag help"
-msgstr "Allow the BBCode [img][/img] tag in posts."
-
 msgid "BBCode sigs label"
 msgid "BBCode sigs label"
 msgstr "BBCodes in signatures"
 msgstr "BBCodes in signatures"
 
 
 msgid "BBCode sigs help"
 msgid "BBCode sigs help"
 msgstr "Allow BBCodes in user signatures."
 msgstr "Allow BBCodes in user signatures."
 
 
-msgid "Image tag sigs label"
-msgstr "Image tag in signatures"
-
-msgid "Image tag sigs help"
-msgstr "Allow the BBCode [img][/img] tag in user signatures (not recommended)."
-
 msgid "Smilies subhead"
 msgid "Smilies subhead"
 msgstr "Smilies"
 msgstr "Smilies"
 
 

+ 0 - 12
app/lang/ru/admin_parser.po

@@ -27,24 +27,12 @@ msgstr "BBcode в сообщениях"
 msgid "BBCode help"
 msgid "BBCode help"
 msgstr "Разрешить BB-коды в сообщениях (рекомендуется)."
 msgstr "Разрешить BB-коды в сообщениях (рекомендуется)."
 
 
-msgid "Image tag label"
-msgstr "Тег IMG в сообщениях"
-
-msgid "Image tag help"
-msgstr "Разрешить тег [img][/img] в сообщениях."
-
 msgid "BBCode sigs label"
 msgid "BBCode sigs label"
 msgstr "BBcode в подписях"
 msgstr "BBcode в подписях"
 
 
 msgid "BBCode sigs help"
 msgid "BBCode sigs help"
 msgstr "Разрешить BB-коды в подписях пользователей."
 msgstr "Разрешить BB-коды в подписях пользователей."
 
 
-msgid "Image tag sigs label"
-msgstr "Тег IMG в подписях"
-
-msgid "Image tag sigs help"
-msgstr "Разрешить тег [img][/img] в подписях пользователей (не рекомендуется)."
-
 msgid "Smilies subhead"
 msgid "Smilies subhead"
 msgstr "Смайлы"
 msgstr "Смайлы"