Merge branch 'master' of github.com:Gregwar/CaptchaBundle

This commit is contained in:
Gregwar 2013-08-14 09:45:48 +02:00
commit e3727a975d
7 changed files with 20 additions and 8 deletions

View File

@ -42,7 +42,8 @@ class Configuration implements ConfigurationInterface
->scalarNode('max_front_lines')->defaultValue(null)->end() ->scalarNode('max_front_lines')->defaultValue(null)->end()
->scalarNode('max_behind_lines')->defaultValue(null)->end() ->scalarNode('max_behind_lines')->defaultValue(null)->end()
->scalarNode('interpolation')->defaultValue(true)->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() ->end()
; ;

View File

@ -33,10 +33,6 @@ class GregwarCaptchaExtension extends Extension
$container->setParameter('gregwar_captcha.config.expiration', $config['expiration']); $container->setParameter('gregwar_captcha.config.expiration', $config['expiration']);
$container->setParameter('gregwar_captcha.config.whitelist_key', $config['whitelist_key']); $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'); $resources = $container->getParameter('twig.form.resources');
$container->setParameter('twig.form.resources', array_merge(array('GregwarCaptchaBundle::captcha.html.twig'), $resources)); $container->setParameter('twig.form.resources', array_merge(array('GregwarCaptchaBundle::captcha.html.twig'), $resources));
} }

View File

@ -98,8 +98,17 @@ class CaptchaGenerator
$this->builder->setMaxFrontLines($options['max_front_lines']); $this->builder->setMaxFrontLines($options['max_front_lines']);
$this->builder->setMaxBehindLines($options['max_behind_lines']); $this->builder->setMaxBehindLines($options['max_behind_lines']);
if ($options['background_color'] != array()) { if (isset($options['text_color']) && $options['text_color']) {
if (count($options['background_color'])!=3) { 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'); throw new \RuntimeException('background_color should be an array of r, g and b');
} }

View File

@ -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) * **length**: the length of the captcha (number of chars, default 5)
* **quality**: jpeg quality of captchas (default=15) * **quality**: jpeg quality of captchas (default=15)
* **charset**: the charset used for code generation (default=abcdefhjkmnprstuvwxyz23456789) * **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) * **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_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) * **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)

View File

@ -0,0 +1 @@
Renew: Обновить

View File

@ -0,0 +1 @@
Bad code value: Неправильный код

View File

@ -90,6 +90,10 @@ class CaptchaType extends AbstractType
{ {
$isHuman = false; $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) { if ($options['humanity'] > 0) {
$humanityKey = $this->key.'_humanity'; $humanityKey = $this->key.'_humanity';
if ($this->session->get($humanityKey, 0) > 0) { if ($this->session->get($humanityKey, 0) > 0) {