diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index bac834d..9f9fbd5 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -42,7 +42,8 @@ class Configuration implements ConfigurationInterface ->scalarNode('max_front_lines')->defaultValue(null)->end() ->scalarNode('max_behind_lines')->defaultValue(null)->end() ->scalarNode('interpolation')->defaultValue(true)->end() - ->arrayNode('background_color')->prototype('scalar')->end() + ->arrayNode('text_color')->prototype('scalar')->end()->end() + ->arrayNode('background_color')->prototype('scalar')->end()->end() ->end() ; diff --git a/DependencyInjection/GregwarCaptchaExtension.php b/DependencyInjection/GregwarCaptchaExtension.php index 75b7246..83f4ddb 100755 --- a/DependencyInjection/GregwarCaptchaExtension.php +++ b/DependencyInjection/GregwarCaptchaExtension.php @@ -33,10 +33,6 @@ class GregwarCaptchaExtension extends Extension $container->setParameter('gregwar_captcha.config.expiration', $config['expiration']); $container->setParameter('gregwar_captcha.config.whitelist_key', $config['whitelist_key']); - if ($config['reload'] && !$config['as_url']) { - throw new \InvalidArgumentException('GregwarCaptcha: The reload option cannot be set without as_url, see the README for more information'); - } - $resources = $container->getParameter('twig.form.resources'); $container->setParameter('twig.form.resources', array_merge(array('GregwarCaptchaBundle::captcha.html.twig'), $resources)); } diff --git a/Generator/CaptchaGenerator.php b/Generator/CaptchaGenerator.php index e419580..60db59b 100644 --- a/Generator/CaptchaGenerator.php +++ b/Generator/CaptchaGenerator.php @@ -98,8 +98,17 @@ class CaptchaGenerator $this->builder->setMaxFrontLines($options['max_front_lines']); $this->builder->setMaxBehindLines($options['max_behind_lines']); - if ($options['background_color'] != array()) { - if (count($options['background_color'])!=3) { + if (isset($options['text_color']) && $options['text_color']) { + if (count($options['text_color']) !== 3) { + throw new \RuntimeException('text_color should be an array of r, g and b'); + } + + $color = $options['text_color']; + $this->builder->setTextColor($color[0], $color[1], $color[2]); + } + + if (isset($options['background_color']) && $options['background_color']) { + if (count($options['background_color']) !== 3) { throw new \RuntimeException('background_color should be an array of r, g and b'); } diff --git a/README.md b/README.md index 33ee8fa..9a81582 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,7 @@ You can define the following configuration options globally or on the CaptchaTyp * **length**: the length of the captcha (number of chars, default 5) * **quality**: jpeg quality of captchas (default=15) * **charset**: the charset used for code generation (default=abcdefhjkmnprstuvwxyz23456789) -* **font**: the font to use (default=Generator/Font/captcha.ttf) +* **font**: the font to use (default is random among some pre-provided fonts), this should be an absolute path * **keep_value**: the value will be the same until the form is posted, even if the page is refreshed (default=true) * **as_file**: if set to true an image file will be created instead of embedding to please IE6/7 (default=false) * **as_url**: if set to true, a URL will be used in the image tag and will handle captcha generation. This can be used in a multiple-server environment and support IE6/7 (default=false) diff --git a/Resources/translations/gregwar_captcha.ru.yml b/Resources/translations/gregwar_captcha.ru.yml new file mode 100644 index 0000000..a311cfa --- /dev/null +++ b/Resources/translations/gregwar_captcha.ru.yml @@ -0,0 +1 @@ +Renew: Обновить \ No newline at end of file diff --git a/Resources/translations/validators.ru.yml b/Resources/translations/validators.ru.yml new file mode 100644 index 0000000..dd4b7fa --- /dev/null +++ b/Resources/translations/validators.ru.yml @@ -0,0 +1 @@ +Bad code value: Неправильный код diff --git a/Type/CaptchaType.php b/Type/CaptchaType.php index 2a90ed7..2b10374 100644 --- a/Type/CaptchaType.php +++ b/Type/CaptchaType.php @@ -90,6 +90,10 @@ class CaptchaType extends AbstractType { $isHuman = false; + if ($options['reload'] && !$options['as_url']) { + throw new \InvalidArgumentException('GregwarCaptcha: The reload option cannot be set without as_url, see the README for more information'); + } + if ($options['humanity'] > 0) { $humanityKey = $this->key.'_humanity'; if ($this->session->get($humanityKey, 0) > 0) {