Commit 54bb810b authored by minakshiPh's avatar minakshiPh Committed by elachlan

Issue #2798991 by minakshiPh, naveenvalecha, shruti1803, rasikap, keshav.k,...

Issue #2798991 by minakshiPh, naveenvalecha, shruti1803, rasikap, keshav.k, Yogesh Pawar: Fix coding standards & replace the deprecated methods
parent f6c89e88
......@@ -132,9 +132,8 @@ function captcha_install() {
}
// Explain to users that page caching may be disabled.
if ($config = \Drupal::config('system.performance')
->get('cache.page.use_internal') != 0
) {
$config = \Drupal::config('system.performance')->get('cache.page.use_internal');
if ($config != 0) {
drupal_set_message(\Drupal::translation()
->translate('Note that the CAPTCHA module disables <a href="@performance_admin">page caching</a> of pages that include a CAPTCHA challenge.',
[
......
......@@ -186,7 +186,6 @@ function captcha_form_alter(array &$form, FormStateInterface $form_state, $form_
];
if ($captcha_point !== NULL && $captcha_point->getCaptchaType()) {
$markup = '<a href="@change">change</a>';
$captcha_element['#title'] = $captcha_point->status() ? t('CAPTCHA: challenge "@type" enabled', ['@type' => $captcha_point->getCaptchaType()]) : t('CAPTCHA: challenge "@type" disabled', ['@type' => $captcha_point->getCaptchaType()]);
$captcha_point->status() ? $captcha_element['#description'] = t('Untrusted users will see a CAPTCHA here (<a href="@settings">general CAPTCHA settings</a>).',
[
......@@ -198,8 +197,7 @@ function captcha_form_alter(array &$form, FormStateInterface $form_state, $form_
$captcha_element['challenge'] = [
'#type' => 'item',
'#title' => t('Enabled challenge'),
'#markup' => t($markup, [
'%type' => $captcha_point->getCaptchaType(),
'#markup' => t('<a href="@change">change</a>', [
'@change' => $captcha_point->url('edit-form', [
'query' => Drupal::destination()
->getAsArray(),
......
......@@ -151,6 +151,7 @@ function _image_captcha_check_setup($check_fonts = TRUE) {
if ($check_fonts) {
// Check availability of enabled fonts.
$fonts = _image_captcha_get_enabled_fonts();
$readable_fonts = array();
list($readable_fonts, $problem_fonts) = _image_captcha_check_fonts($fonts);
if (count($problem_fonts) != 0) {
$status = $status | IMAGE_CAPTCHA_ERROR_TTF_FILE_READ_PROBLEM;
......
......@@ -260,6 +260,8 @@ class ImageCaptchaSettingsForm extends ConfigFormBase {
$form_state->setErrorByName('image_captcha_image_allowed_chars', t('The built-in font only supports Latin2 characters. Only use "a" to "z" and numbers.'));
}
}
$readable_fonts = array();
list($readable_fonts, $problem_fonts) = _image_captcha_check_fonts($fonts);
if (count($problem_fonts) > 0) {
$form_state->setErrorByName('image_captcha_fonts', t('The following fonts are not readable: %fonts.', ['%fonts' => implode(', ', $problem_fonts)]));
......
......@@ -155,8 +155,7 @@ class CaptchaImageResponse extends Response {
// Do we need to draw in RTL mode?
global $language;
$rtl = $language->direction && ((bool) $this->config->get('image_captcha_rtl_support'));
$result = $this->printString($image, $width, $height, $fonts, $font_size, $code);
if (!$result) {
return FALSE;
......@@ -339,7 +338,6 @@ class CaptchaImageResponse extends Response {
$foreground_rgb = $this->hexToRgb($this->config->get('image_captcha_foreground_color'));
$background_rgb = $this->hexToRgb($this->config->get('image_captcha_background_color'));
$background_color = imagecolorallocate($image, $background_rgb[0], $background_rgb[1], $background_rgb[2]);
$foreground_color = imagecolorallocate($image, $foreground_rgb[0], $foreground_rgb[1], $foreground_rgb[2]);
// Precalculate the value ranges for color randomness.
$foreground_randomness = $this->config->get('image_captcha_foreground_color_randomness');
......
......@@ -37,8 +37,9 @@ class CaptchaExamplesForm extends FormBase {
$form['info'] = [
'#markup' => $this->t('This page gives an overview of all available challenge types, generated with their current settings.'),
];
foreach (\Drupal::moduleHandler()
->getImplementations('captcha') as $mkey => $module) {
$modules_list = \Drupal::moduleHandler()->getImplementations('captcha');
foreach ($modules_list as $mkey => $module) {
$challenges = call_user_func_array($module . '_captcha', ['list']);
if ($challenges) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment