Override bbcode settings

This commit is contained in:
Visman 2020-09-21 11:31:55 +07:00
parent 3c3d0850b9
commit 80224917ec
8 changed files with 46 additions and 54 deletions

View file

@ -64,11 +64,21 @@ class Parser extends Parserus
public function prepare(string $text, bool $isSignature = false): string
{
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 {
$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)
@ -92,7 +102,7 @@ class Parser extends Parserus
// при null предполагается брать данные после prepare()
if (null !== $text) {
$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)
->setWhiteList($whiteList)
@ -117,8 +127,8 @@ class Parser extends Parserus
{
// при null предполагается брать данные после prepare()
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)
->setWhiteList($whiteList)

View file

@ -14,6 +14,8 @@ class Install extends Admin
{
const PHP_MIN = '7.3.0';
const JSON_OPTIONS = \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE | \JSON_THROW_ON_ERROR;
/**
* Для MySQL
* @var string
@ -1110,12 +1112,10 @@ class Install extends Admin
'o_feed_type' => 2,
'o_feed_ttl' => 0,
'p_message_bbcode' => 1,
'p_message_img_tag' => 1,
'p_message_all_caps' => 1,
'p_subject_all_caps' => 1,
'p_sig_all_caps' => 1,
'p_sig_bbcode' => 1,
'p_sig_img_tag' => 0,
'p_force_guest_email' => 1,
'o_pms_enabled' => 1, // New PMS - Visman
'o_pms_min_kolvo' => 0,
@ -1138,6 +1138,10 @@ class Install extends Admin
'o_enable_acaptcha' => 1, // математическая каптча
'st_max_users' => 1, // статистика по максимуму юзеров - Visman
'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) {
$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) {
$vars = [
':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);
}

View file

@ -23,9 +23,7 @@ class Edit extends Parser
])->addRules([
'token' => 'token:AdminParser',
'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_img_tag' => 'required|integer|in:0,1',
'o_smilies' => 'required|integer|in:0,1',
'o_smilies_sig' => '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')];
$form['sets']['posting'] = [
$form['sets']['bbcode'] = [
'legend' => __('BBCode subhead'),
'fields' => [
'p_message_bbcode' => [
@ -99,20 +97,6 @@ class Edit extends Parser
'caption' => __('BBCode sigs label'),
'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' => [
'type' => 'radio',
'value' => $config->o_make_links,
@ -130,7 +114,7 @@ class Edit extends Parser
],
];
$form['sets']['signatures'] = [
$form['sets']['smilies'] = [
'legend' => __('Smilies subhead'),
'fields' => [
'o_smilies' => [

View file

@ -24,6 +24,8 @@ class Update extends Admin
const CONFIG_FILE = 'main.php';
const JSON_OPTIONS = \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE | \JSON_THROW_ON_ERROR;
public function __construct(Container $container)
{
parent::__construct($container);
@ -738,13 +740,28 @@ class Update extends Admin
foreach ($bbcodes as $bbcode) {
$vars = [
':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->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->p_sig_img_tag);
unset($this->c->config->p_message_img_tag);
$this->c->config->save();
$coreConfig = new CoreConfig($this->c->DIR_CONFIG . '/' . self::CONFIG_FILE);
$result = $coreConfig->delete(
'BBCODE_INFO=>forSign',
);
$coreConfig->save();
}
}

View file

@ -86,12 +86,14 @@ trait PostFormTrait
'caption' => __('Message'),
'required' => true,
'value' => $vars['message'] ?? null,
/* ????
'bb' => [
['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', __('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')],
],
*/
'autofocus' => $autofocus,
];
$form['sets']['uesm'] = [

View file

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

View file

@ -27,24 +27,12 @@ msgstr "BBCode"
msgid "BBCode help"
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"
msgstr "BBCodes in signatures"
msgid "BBCode sigs help"
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"
msgstr "Smilies"

View file

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