mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 22:10:45 +02:00
[ticket/17413] Add language and theme settings for turnstile
PHPBB-17413
This commit is contained in:
@@ -53,6 +53,13 @@ class turnstile extends base
|
||||
/** @var string Service name */
|
||||
protected string $service_name = '';
|
||||
|
||||
/** @var array|string[] Supported themes for Turnstile CAPTCHA */
|
||||
protected static array $supported_themes = [
|
||||
'light',
|
||||
'dark',
|
||||
'auto'
|
||||
];
|
||||
|
||||
/**
|
||||
* Constructor for turnstile captcha plugin
|
||||
*
|
||||
@@ -205,6 +212,7 @@ class turnstile extends base
|
||||
$this->template->assign_vars([
|
||||
'S_TURNSTILE_AVAILABLE' => $this->is_available(),
|
||||
'TURNSTILE_SITEKEY' => $this->config->offsetGet('captcha_turnstile_sitekey'),
|
||||
'TURNSTILE_THEME' => $this->config->offsetGet('captcha_turnstile_theme'),
|
||||
'U_TURNSTILE_SCRIPT' => self::SCRIPT_URL,
|
||||
]);
|
||||
|
||||
@@ -214,6 +222,7 @@ class turnstile extends base
|
||||
public function get_demo_template(): string
|
||||
{
|
||||
$this->template->assign_vars([
|
||||
'TURNSTILE_THEME' => $this->config->offsetGet('captcha_turnstile_theme'),
|
||||
'U_TURNSTILE_SCRIPT' => self::SCRIPT_URL,
|
||||
]);
|
||||
|
||||
@@ -254,6 +263,12 @@ class turnstile extends base
|
||||
}
|
||||
}
|
||||
|
||||
$captcha_theme = $this->request->variable('captcha_turnstile_theme', self::$supported_themes[0]);
|
||||
if (in_array($captcha_theme, self::$supported_themes))
|
||||
{
|
||||
$this->config->set('captcha_turnstile_theme', $captcha_theme);
|
||||
}
|
||||
|
||||
$this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_CONFIG_VISUAL');
|
||||
trigger_error($this->language->lang('CONFIG_UPDATED') . adm_back_link($module->u_action));
|
||||
}
|
||||
@@ -270,9 +285,11 @@ class turnstile extends base
|
||||
}
|
||||
|
||||
$this->template->assign_vars(array(
|
||||
'CAPTCHA_PREVIEW' => $this->get_demo_template(),
|
||||
'CAPTCHA_NAME' => $this->service_name,
|
||||
'U_ACTION' => $module->u_action,
|
||||
'CAPTCHA_PREVIEW' => $this->get_demo_template(),
|
||||
'CAPTCHA_NAME' => $this->service_name,
|
||||
'CAPTCHA_TURNSTILE_THEME' => $this->config->offsetGet('captcha_turnstile_theme'),
|
||||
'CAPTCHA_TURNSTILE_THEMES' => self::$supported_themes,
|
||||
'U_ACTION' => $module->u_action,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@@ -20,7 +20,8 @@ class turnstile_captcha extends migration
|
||||
public function effectively_installed(): bool
|
||||
{
|
||||
return $this->config->offsetExists('captcha_turnstile_sitekey')
|
||||
&& $this->config->offsetExists('captcha_turnstile_secret');
|
||||
&& $this->config->offsetExists('captcha_turnstile_secret')
|
||||
&& $this->config->offsetExists('captcha_turnstile_theme');
|
||||
}
|
||||
|
||||
public static function depends_on(): array
|
||||
@@ -35,6 +36,7 @@ class turnstile_captcha extends migration
|
||||
return [
|
||||
['config.add', ['captcha_turnstile_sitekey', '']],
|
||||
['config.add', ['captcha_turnstile_secret', '']],
|
||||
['config.add', ['captcha_turnstile_theme', 'light']],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -43,6 +45,7 @@ class turnstile_captcha extends migration
|
||||
return [
|
||||
['config.remove', ['captcha_turnstile_sitekey']],
|
||||
['config.remove', ['captcha_turnstile_secret']],
|
||||
['config.remove', ['captcha_turnstile_theme']],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -403,6 +403,7 @@ class language
|
||||
$this->lang['USER_LANG'] = $lang_values['user_lang'] ?? 'en-gb';
|
||||
$this->lang['PLURAL_RULE'] = $lang_values['plural_rule'] ?? 1;
|
||||
$this->lang['RECAPTCHA_LANG'] = $lang_values['recaptcha_lang'] ?? 'en-GB';
|
||||
$this->lang['TURNSTILE_LANG'] = $lang_values['turnstile_lang'] ?? 'auto'; // default to auto mode
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -110,16 +110,17 @@ class language_file_helper
|
||||
}
|
||||
|
||||
return [
|
||||
'iso' => $data['extra']['language-iso'],
|
||||
'name' => $data['extra']['english-name'],
|
||||
'local_name' => $data['extra']['local-name'],
|
||||
'author' => implode(', ', $authors),
|
||||
'version' => $data['version'],
|
||||
'phpbb_version' => $data['extra']['phpbb-version'],
|
||||
'direction' => $data['extra']['direction'],
|
||||
'user_lang' => $data['extra']['user-lang'],
|
||||
'plural_rule' => $data['extra']['plural-rule'],
|
||||
'recaptcha_lang'=> $data['extra']['recaptcha-lang'],
|
||||
'iso' => $data['extra']['language-iso'],
|
||||
'name' => $data['extra']['english-name'],
|
||||
'local_name' => $data['extra']['local-name'],
|
||||
'author' => implode(', ', $authors),
|
||||
'version' => $data['version'],
|
||||
'phpbb_version' => $data['extra']['phpbb-version'],
|
||||
'direction' => $data['extra']['direction'],
|
||||
'user_lang' => $data['extra']['user-lang'],
|
||||
'plural_rule' => $data['extra']['plural-rule'],
|
||||
'recaptcha_lang' => $data['extra']['recaptcha-lang'],
|
||||
'turnstile_lang' => $data['extra']['turnstile-lang'] ?? '',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user