Author: garak
Date: 2010-08-31 09:22:48 +0200 (Tue, 31 Aug 2010)
New Revision: 30789
Modified:
plugins/sfReCaptchaPlugin/branches/1.3/README
plugins/sfReCaptchaPlugin/branches/1.3/lib/form/reCaptchaDoctrineForm.class.php
plugins/sfReCaptchaPlugin/branches/1.3/lib/form/reCaptchaForm.class.php
plugins/sfReCaptchaPlugin/branches/1.3/lib/form/reCaptchaPropelForm.class.php
plugins/sfReCaptchaPlugin/branches/1.3/lib/helper/recaptchaHelper.php
plugins/sfReCaptchaPlugin/branches/1.3/lib/validator/sfValidatorSchemaReCaptcha.class.php
Log:
[sfReCaptchaPlugin] added option to validator to use classic invalid error
(closes #3372)
Modified: plugins/sfReCaptchaPlugin/branches/1.3/README
===================================================================
--- plugins/sfReCaptchaPlugin/branches/1.3/README 2010-08-31 07:00:04 UTC
(rev 30788)
+++ plugins/sfReCaptchaPlugin/branches/1.3/README 2010-08-31 07:22:48 UTC
(rev 30789)
@@ -36,41 +36,6 @@
[yml]
all:
recaptcha:
- publickey: "foo"
- privatekey: "bar"
- mailhide:
- publickey: "foo"
- privatekey: "bar"
-
-Example
--------
-
-You need to enable the `recaptcha` module in your applications `settings.yml`:
-
- [yml]
- all:
- .settings:
- enabled_modules: [default, recaptcha]
-
-and clear your cache afterwards:
-
- $ symfony cc
-
-You can use the reCaptchaForm, like in the example provided in the example
module.
-You can try it by navigating to:
-
- http://foobar.com/frontend_dev.php/recaptcha
-
-or for Mailhide example, to:
-
- http://foobar.com/frontend_dev.php/recaptcha/mailhide
-
-Anyway, since CAPTCHA is not testable, you should consider a different
approach.
-First, define another key in your `app.yml`, under `recaptcha`:
-
- [yml]
- all:
- recaptcha:
active: true
publickey: "foo"
privatekey: "bar"
@@ -136,8 +101,8 @@
<?php echo recaptcha_get_html(sfConfig::get('app_recaptcha_publickey'),
$form['response']->getError()) ?>
<?php endif ?>
-If you are using a form bound to an ORM, you should extend reCaptchaPropelForm
-or reCaptchaDoctrineForm instead of reCaptchaForm.
+If you are using a form bound to an ORM, you should extend
`reCaptchaPropelForm`
+or `reCaptchaDoctrineForm` instead of `reCaptchaForm`.
If you can't modify form extension, you need a bit more work.
Put this code in the `configure()` method of your form:
@@ -181,12 +146,32 @@
<?php echo recaptcha_get_html(sfConfig::get('app_recaptcha_publickey'),
$form['response']->getError()) ?>
<?php endif ?>
+>**TIP**
+>You can customize aspect and culture of widget with some JavaScript options,
like in the
+>following example (must be set *before* `recaptcha_get_html()`)
+>
+> [php]
+> <script type="text/javascript">var
RecaptchaOptions={theme:'white',lang:'<?php echo $sf_user->getCulture()
?>'}</script>
+>
+>You can also force validator to use `invalid` error instead of Recaptcha
default error message,
+>by passing `use_invalid_error` option:
+>
+> [php]
+> $this->validatorSchema->setOption('use_invalid_error', true);
+>
+>and then customize error in your template:
+>
+> [php]
+> $recaptchaErrorCode = $form['recaptcha']->hasError() ?
'incorrect-captcha-sol' : null;
+> echo recaptcha_get_html(sfConfig::get('app_recaptcha_publickey'),
$recaptchaErrorCode);
+
+
Issue with iframe
-----------------
If you need an output compliant with XHTML strict, you can pass an optional
- 4th parameter to `recaptcha_get_html()`, that forces use of `object` tag
+4th parameter to `recaptcha_get_html()`, that forces use of `object` tag
instead of the unsupported `iframe`:
[php]
Modified:
plugins/sfReCaptchaPlugin/branches/1.3/lib/form/reCaptchaDoctrineForm.class.php
===================================================================
---
plugins/sfReCaptchaPlugin/branches/1.3/lib/form/reCaptchaDoctrineForm.class.php
2010-08-31 07:00:04 UTC (rev 30788)
+++
plugins/sfReCaptchaPlugin/branches/1.3/lib/form/reCaptchaDoctrineForm.class.php
2010-08-31 07:22:48 UTC (rev 30789)
@@ -8,6 +8,7 @@
* @package symfony
* @subpackage form
* @author Massimiliano Arione <[email protected]>
+ * @version SVN: $Id$
*/
class reCaptchaDoctrineForm extends BaseFormDoctrine
{
Property changes on:
plugins/sfReCaptchaPlugin/branches/1.3/lib/form/reCaptchaDoctrineForm.class.php
___________________________________________________________________
Added: svn:keyword
+ Id
Modified:
plugins/sfReCaptchaPlugin/branches/1.3/lib/form/reCaptchaForm.class.php
===================================================================
--- plugins/sfReCaptchaPlugin/branches/1.3/lib/form/reCaptchaForm.class.php
2010-08-31 07:00:04 UTC (rev 30788)
+++ plugins/sfReCaptchaPlugin/branches/1.3/lib/form/reCaptchaForm.class.php
2010-08-31 07:22:48 UTC (rev 30789)
@@ -8,6 +8,7 @@
* @package symfony
* @subpackage form
* @author Massimiliano Arione <[email protected]>
+ * @version SVN: $Id$
*/
class reCaptchaForm extends BaseForm
{
Property changes on:
plugins/sfReCaptchaPlugin/branches/1.3/lib/form/reCaptchaForm.class.php
___________________________________________________________________
Added: svn:keyword
+ Id
Modified:
plugins/sfReCaptchaPlugin/branches/1.3/lib/form/reCaptchaPropelForm.class.php
===================================================================
---
plugins/sfReCaptchaPlugin/branches/1.3/lib/form/reCaptchaPropelForm.class.php
2010-08-31 07:00:04 UTC (rev 30788)
+++
plugins/sfReCaptchaPlugin/branches/1.3/lib/form/reCaptchaPropelForm.class.php
2010-08-31 07:22:48 UTC (rev 30789)
@@ -8,6 +8,7 @@
* @package symfony
* @subpackage form
* @author Massimiliano Arione <[email protected]>
+ * @version SVN: $Id$
*/
class reCaptchaPropelForm extends BaseFormPropel
{
Property changes on:
plugins/sfReCaptchaPlugin/branches/1.3/lib/form/reCaptchaPropelForm.class.php
___________________________________________________________________
Added: svn:keyword
+ Id
Modified: plugins/sfReCaptchaPlugin/branches/1.3/lib/helper/recaptchaHelper.php
===================================================================
--- plugins/sfReCaptchaPlugin/branches/1.3/lib/helper/recaptchaHelper.php
2010-08-31 07:00:04 UTC (rev 30788)
+++ plugins/sfReCaptchaPlugin/branches/1.3/lib/helper/recaptchaHelper.php
2010-08-31 07:22:48 UTC (rev 30789)
@@ -3,6 +3,7 @@
* reCAPTCHA symfony helper.
* Mostly from http://recaptcha.net/plugins/php/
* @author Massimiliano Arione
+ * @version SVN: $Id$
*
*
* Copyright (c) 2007 reCAPTCHA -- http://recaptcha.net
Property changes on:
plugins/sfReCaptchaPlugin/branches/1.3/lib/helper/recaptchaHelper.php
___________________________________________________________________
Added: svn:keyword
+ Id
Modified:
plugins/sfReCaptchaPlugin/branches/1.3/lib/validator/sfValidatorSchemaReCaptcha.class.php
===================================================================
---
plugins/sfReCaptchaPlugin/branches/1.3/lib/validator/sfValidatorSchemaReCaptcha.class.php
2010-08-31 07:00:04 UTC (rev 30788)
+++
plugins/sfReCaptchaPlugin/branches/1.3/lib/validator/sfValidatorSchemaReCaptcha.class.php
2010-08-31 07:22:48 UTC (rev 30789)
@@ -3,7 +3,8 @@
/**
* sfValidatorSchemaReCaptcha validates a reCAPTCHA (recaptcha.net).
*
- * @author Arthur Koziel <[email protected]>
+ * @author Arthur Koziel <[email protected]>
+ * @version SVN: $Id$
*/
class sfValidatorSchemaReCaptcha extends sfValidatorSchema
{
@@ -12,7 +13,7 @@
*
* Available options:
*
- * * challange_field: The challange field name
+ * * challenge_field: The challenge field name
* * response_field: The response field name
* * throw_global_error: Whether to throw a global error (false by default)
or an error tied to the response field
*
@@ -27,8 +28,8 @@
{
$this->addOption('challenge_field', $challengeField);
$this->addOption('response_field', $responseField);
-
$this->addOption('throw_global_error', false);
+ $this->addOption('use_invalid_error', false);
parent::__construct(null, $options, $messages);
}
@@ -56,7 +57,8 @@
if (!$resp->is_valid)
{
- $error = new sfValidatorError($this, $resp->error, array(
+ $errorMessage = $this->getOption('use_invalid_error') ? 'invalid' :
$resp->error;
+ $error = new sfValidatorError($this, $errorMessage, array(
'challenge_field' => $this->getOption('challenge_field'),
'response_field' => $this->getOption('response_field'),
));
Property changes on:
plugins/sfReCaptchaPlugin/branches/1.3/lib/validator/sfValidatorSchemaReCaptcha.class.php
___________________________________________________________________
Added: svn:keyword
+ Id
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.