Captcha/ReCaptcha.php

Show: PublicProtectedPrivateinherited
Table of Contents
Zend Framework

LICENSE

This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.

Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Captcha  
Subpackage
Adapter  

\Zend_Captcha_ReCaptcha

Package: Zend\Captcha\Adapter
ReCaptcha adapter

Allows to insert captchas driven by ReCaptcha service

Parent(s)
\Zend_Captcha_Base < \Zend_Validate_Abstract
See
\global\http://recaptcha.net/apidocs/captcha/  
Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Version
$Id: ReCaptcha.php 24593 2012-01-05 20:35:02Z matthew $  

Constants

>VConstant  MISSING_VALUE = 'missingValue'
>VConstant  ERR_CAPTCHA = 'errCaptcha'
>VConstant  BAD_CAPTCHA = 'badCaptcha'

Properties

>VPropertyprotected$_CHALLENGE = 'recaptcha_challenge_field'
Default value'recaptcha_challenge_field'Details
Type
n/a
>VPropertyprotected$_RESPONSE = 'recaptcha_response_field'
Default value'recaptcha_response_field'Details
Type
n/a
>VPropertyprotected\Zend_Translate $_defaultTranslator
staticinherited
Default translation object for all validate objects
Inherited from: \Zend_Validate_Abstract::$$_defaultTranslator\Zend_Captcha_Base::$$_defaultTranslator
>VPropertyprotectedarray $_errors = array()
inherited
Array of validation failure message codes
Inherited from: \Zend_Validate_Abstract::$$_errors\Zend_Captcha_Base::$$_errors
Default valuearray()Details
Type
array
Inherited_from
\Zend_Validate_Abstract::$$_errors  
Inherited_from
\Zend_Captcha_Base::$$_errors  
>VPropertyprotectedInteger $_messageLength = -1
staticinherited
Limits the maximum returned length of a error message
Inherited from: \Zend_Validate_Abstract::$$_messageLength\Zend_Captcha_Base::$$_messageLength
Default value-1Details
Type
Integer
Inherited_from
\Zend_Validate_Abstract::$$_messageLength  
Inherited_from
\Zend_Captcha_Base::$$_messageLength  
>VPropertyprotectedarray $_messageTemplates = array(self::MISSING_VALUE => 'Missing captcha fields', self::ERR_CAPTCHA => 'Failed to validate captcha', self::BAD_CAPTCHA => 'Captcha value is wrong: %value%')
Error messages
Default valuearray(self::MISSING_VALUE => 'Missing captcha fields', self::ERR_CAPTCHA => 'Failed to validate captcha', self::BAD_CAPTCHA => 'Captcha value is wrong: %value%')Details
Type
array
>VPropertyprotectedarray $_messageVariables = array()
inherited
Additional variables available for validation failure messages
Inherited from: \Zend_Validate_Abstract::$$_messageVariables\Zend_Captcha_Base::$$_messageVariables
Default valuearray()Details
Type
array
Inherited_from
\Zend_Validate_Abstract::$$_messageVariables  
Inherited_from
\Zend_Captcha_Base::$$_messageVariables  
>VPropertyprotectedarray $_messages = array()
inherited
Array of validation failure messages
Inherited from: \Zend_Validate_Abstract::$$_messages\Zend_Captcha_Base::$$_messages
Default valuearray()Details
Type
array
Inherited_from
\Zend_Validate_Abstract::$$_messages  
Inherited_from
\Zend_Captcha_Base::$$_messages  
>VPropertyprotectedstring $_name
inherited
Element name
Inherited from: \Zend_Captcha_Base::$$_name

Useful to generate/check form fields

Details
Type
string
Inherited_from
\Zend_Captcha_Base::$$_name  
>VPropertyprotectedbool $_obscureValue = false
inherited
Flag indidcating whether or not value should be obfuscated in error messages
Inherited from: \Zend_Validate_Abstract::$$_obscureValue\Zend_Captcha_Base::$$_obscureValue
Default valuefalseDetails
Type
bool
Inherited_from
\Zend_Validate_Abstract::$$_obscureValue  
Inherited_from
\Zend_Captcha_Base::$$_obscureValue  
>VPropertyprotectedarray $_options = array()
inherited
Captcha options
Inherited from: \Zend_Captcha_Base::$$_options
Default valuearray()Details
Type
array
Inherited_from
\Zend_Captcha_Base::$$_options  
>VPropertyprotected\Zend_Service_Recaptcha $_service
Recaptcha service object
Details
Type
\Zend_Service_Recaptcha
>VPropertyprotectedarray $_serviceOptions = array()
Options defined by the service
Default valuearray()Details
Type
array
>VPropertyprotectedarray $_serviceParams = array()
Parameters defined by the service
Default valuearray()Details
Type
array
>VPropertyprotectedarray $_skipOptions = array('options', 'config')
inherited
Options to skip when processing options
Inherited from: \Zend_Captcha_Base::$$_skipOptions
Default valuearray('options', 'config')Details
Type
array
Inherited_from
\Zend_Captcha_Base::$$_skipOptions  
>VPropertyprotected\Zend_Translate $_translator
>VPropertyprotectedBoolean $_translatorDisabled = false
Default valuefalseDetails
Type
Boolean
Inherited_from
\Zend_Validate_Abstract::$$_translatorDisabled  
Inherited_from
\Zend_Captcha_Base::$$_translatorDisabled  
>VPropertyprotectedmixed $_value
inherited
The value to be validated
Inherited from: \Zend_Validate_Abstract::$$_value\Zend_Captcha_Base::$$_value
Details
Type
mixed
Inherited_from
\Zend_Validate_Abstract::$$_value  
Inherited_from
\Zend_Captcha_Base::$$_value  

Methods

methodpublic__construct(array | \Zend_Config $options = null) : void

Constructor

Parameters
NameTypeDescription
$optionsarray | \Zend_Config
methodpublic__get(string $property) : mixed
inherited

Magic function returns the value of the requested property, if and only if it is the value or a message variable.

Inherited from: \Zend_Validate_Abstract::__get()\Zend_Captcha_Base::__get()
Parameters
NameTypeDescription
$propertystring
Returns
TypeDescription
mixed
Throws
ExceptionDescription
\Zend_Validate_Exception
methodprotected_createMessage(string $messageKey, string $value) : string
inherited

Constructs and returns a validation failure message with the given message key and value.

Inherited from: \Zend_Validate_Abstract::_createMessage()\Zend_Captcha_Base::_createMessage()

Returns null if and only if $messageKey does not correspond to an existing template.

If a translator is available and a translation exists for $messageKey, the translation will be used.

Parameters
NameTypeDescription
$messageKeystring
$valuestring
Returns
TypeDescription
string
methodprotected_error(string $messageKey, string $value = null) : void
Parameters
NameTypeDescription
$messageKeystring
$valuestring

OPTIONAL

methodprotected_setValue(mixed $value) : void
inherited

Sets the value to be validated and clears the messages and errors arrays

Inherited from: \Zend_Validate_Abstract::_setValue()\Zend_Captcha_Base::_setValue()
Parameters
NameTypeDescription
$valuemixed
methodpublicgenerate() : string

Generate captcha

Returns
TypeDescription
string
Details
See
\Zend_Form_Captcha_Adapter::generate()  
methodpublicgetDecorator() : string

Get captcha decorator

By default, return null, indicating no extra decorator needed.

Returns
TypeDescription
string
methodpublicgetDefaultTranslator() : \Zend_Translate_Adapter | null
staticinherited

Get default translation object for all validate objects

Inherited from: \Zend_Validate_Abstract::getDefaultTranslator()\Zend_Captcha_Base::getDefaultTranslator()
Returns
TypeDescription
\Zend_Translate_Adapter | null
methodpublicgetErrors() : array
inherited

Returns array of validation failure message codes

Inherited from: \Zend_Validate_Abstract::getErrors()\Zend_Captcha_Base::getErrors()
Returns
TypeDescription
array
methodpublicgetMessageLength() : integer
staticinherited

Returns the maximum allowed message length

Inherited from: \Zend_Validate_Abstract::getMessageLength()\Zend_Captcha_Base::getMessageLength()
Returns
TypeDescription
integer
methodpublicgetMessageTemplates() : array
inherited

Returns the message templates from the validator

Inherited from: \Zend_Validate_Abstract::getMessageTemplates()\Zend_Captcha_Base::getMessageTemplates()
Returns
TypeDescription
array
methodpublicgetMessageVariables() : array
inherited

Returns an array of the names of variables that are used in constructing validation failure messages

Inherited from: \Zend_Validate_Abstract::getMessageVariables()\Zend_Captcha_Base::getMessageVariables()
Returns
TypeDescription
array
methodpublicgetMessages() : array
inherited

Returns an array of messages that explain why the most recent isValid() call returned false.

Inherited from: \Zend_Validate_Interface::getMessages()\Zend_Captcha_Adapter::getMessages()\Zend_Captcha_Base::getMessages()

The array keys are validation failure message identifiers, and the array values are the corresponding human-readable message strings.

If isValid() was never called or if the most recent isValid() call returned true, then this method returns an empty array.

Returns
TypeDescription
array
methodpublicgetName() : string
inherited

Get name

Inherited from: \Zend_Captcha_Base::getName()
Returns
TypeDescription
string
methodpublicgetObscureValue() : bool
inherited

Retrieve flag indicating whether or not value should be obfuscated in messages

Inherited from: \Zend_Validate_Abstract::getObscureValue()\Zend_Captcha_Base::getObscureValue()
Returns
TypeDescription
bool
methodpublicgetOptions() : array
inherited

Retrieve options representing object state

Inherited from: \Zend_Captcha_Base::getOptions()
Returns
TypeDescription
array
methodpublicgetPrivkey() : string

Retrieve ReCaptcha Private key

Returns
TypeDescription
string
methodpublicgetPubkey() : string

Retrieve ReCaptcha Public key

Returns
TypeDescription
string
methodpublicgetService() : \Zend_Service_ReCaptcha

Retrieve ReCaptcha service object

Returns
TypeDescription
\Zend_Service_ReCaptcha
methodpublicgetTranslator() : \Zend_Translate_Adapter | null
inherited

Return translation object

Inherited from: \Zend_Validate_Abstract::getTranslator()\Zend_Captcha_Base::getTranslator()
Returns
TypeDescription
\Zend_Translate_Adapter | null
methodpublichasDefaultTranslator() : boolean
staticinherited

Is there a default translation object set?

Inherited from: \Zend_Validate_Abstract::hasDefaultTranslator()\Zend_Captcha_Base::hasDefaultTranslator()
Returns
TypeDescription
boolean
methodpublichasTranslator() : bool
inherited

Does this validator have its own specific translator?

Inherited from: \Zend_Validate_Abstract::hasTranslator()\Zend_Captcha_Base::hasTranslator()
Returns
TypeDescription
bool
methodpublicisValid(mixed $value,  $context = null) : boolean

Validate captcha

If $value fails validation, then this method returns false, and getMessages() will return an array of messages that explain why the validation failed.

Parameters
NameTypeDescription
$valuemixed
$context
Returns
TypeDescription
boolean
Throws
ExceptionDescription
\Zend_Validate_ExceptionIf validation of $value is impossible
Details
See
\Zend_Validate_Interface::isValid()  
methodpublicrender(\Zend_View_Interface $view = null, mixed $element = null) : string

Render captcha

Parameters
NameTypeDescription
$view\Zend_View_Interface
$elementmixed
Returns
TypeDescription
string
methodpublicsetConfig(\Zend_Config $config) : \Zend_Captcha_Base
inherited

Set object state from config object

Inherited from: \Zend_Captcha_Base::setConfig()
Parameters
NameTypeDescription
$config\Zend_Config
Returns
TypeDescription
\Zend_Captcha_Base
methodpublicsetDefaultTranslator(\Zend_Translate | \Zend_Translate_Adapter | null $translator = null) : void
staticinherited

Set default translation object for all validate objects

Inherited from: \Zend_Validate_Abstract::setDefaultTranslator()\Zend_Captcha_Base::setDefaultTranslator()
Parameters
NameTypeDescription
$translator\Zend_Translate | \Zend_Translate_Adapter | null
methodpublicsetDisableTranslator(bool $flag) : \Zend_Validate_Abstract
inherited

Indicate whether or not translation should be disabled

Inherited from: \Zend_Validate_Abstract::setDisableTranslator()\Zend_Captcha_Base::setDisableTranslator()
Parameters
NameTypeDescription
$flagbool
Returns
TypeDescription
\Zend_Validate_Abstract
methodpublicsetMessage(string $messageString, string $messageKey = null) : \Zend_Validate_Abstract
inherited

Sets the validation failure message template for a particular key

Inherited from: \Zend_Validate_Abstract::setMessage()\Zend_Captcha_Base::setMessage()
Parameters
NameTypeDescription
$messageStringstring
$messageKeystring

OPTIONAL

Returns
TypeDescription
\Zend_Validate_AbstractProvides a fluent interface
Throws
ExceptionDescription
\Zend_Validate_Exception
methodpublicsetMessageLength(integer $length = -1) : void
staticinherited

Sets the maximum allowed message length

Inherited from: \Zend_Validate_Abstract::setMessageLength()\Zend_Captcha_Base::setMessageLength()
Parameters
NameTypeDescription
$lengthinteger
methodpublicsetMessages(array $messages) : \Zend_Validate_Abstract
inherited

Sets validation failure message templates given as an array, where the array keys are the message keys, and the array values are the message template strings.

Inherited from: \Zend_Validate_Abstract::setMessages()\Zend_Captcha_Base::setMessages()
Parameters
NameTypeDescription
$messagesarray
Returns
TypeDescription
\Zend_Validate_Abstract
methodpublicsetName(string $name) : \Zend_Captcha_Adapter
inherited

Set name

Inherited from: \Zend_Captcha_Base::setName()
Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
\Zend_Captcha_Adapter
methodpublicsetObscureValue(bool $flag) : \Zend_Validate_Abstract
inherited

Set flag indicating whether or not value should be obfuscated in messages

Inherited from: \Zend_Validate_Abstract::setObscureValue()\Zend_Captcha_Base::setObscureValue()
Parameters
NameTypeDescription
$flagbool
Returns
TypeDescription
\Zend_Validate_Abstract
methodpublicsetOption(string $key, mixed $value) : \Zend_Captcha_ReCaptcha

Set option

If option is a service parameter, proxies to the service. The same goes for any service options (distinct from service params)

Parameters
NameTypeDescription
$keystring
$valuemixed
Returns
TypeDescription
\Zend_Captcha_ReCaptcha
methodpublicsetOptions(array $options = null) : \Zend_Form_Element
inherited

Set object state from options array

Inherited from: \Zend_Captcha_Base::setOptions()
Parameters
NameTypeDescription
$optionsarray
Returns
TypeDescription
\Zend_Form_Element
methodpublicsetPrivkey(string $privkey) : \Zend_Captcha_ReCaptcha

Set ReCaptcha Private key

Parameters
NameTypeDescription
$privkeystring
Returns
TypeDescription
\Zend_Captcha_ReCaptcha
methodpublicsetPubkey(string $pubkey) : \Zend_Captcha_ReCaptcha

Set ReCaptcha public key

Parameters
NameTypeDescription
$pubkeystring
Returns
TypeDescription
\Zend_Captcha_ReCaptcha
methodpublicsetService(\Zend_Service_ReCaptcha $service) : \Zend_Captcha_ReCaptcha

Set service object

Parameters
NameTypeDescription
$service\Zend_Service_ReCaptcha
Returns
TypeDescription
\Zend_Captcha_ReCaptcha
methodpublicsetTranslator(\Zend_Translate | \Zend_Translate_Adapter | null $translator = null) : \Zend_Validate_Abstract
Parameters
NameTypeDescription
$translator\Zend_Translate | \Zend_Translate_Adapter | null
Returns
TypeDescription
\Zend_Validate_Abstract
methodpublictranslatorIsDisabled() : bool
Returns
TypeDescription
bool
Documentation was generated by phpDocumentor 2.0.0a12.