Captcha/ReCaptcha.php

Show: inherited
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 [email protected] 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

Constant  MISSING_VALUE = 'missingValue'
Constant  ERR_CAPTCHA = 'errCaptcha'
Constant  BAD_CAPTCHA = 'badCaptcha'

Properties

Propertyprotected$_CHALLENGE = 'recaptcha_challenge_field'
Default value'recaptcha_challenge_field'Details
Type
n/a
Propertyprotected$_RESPONSE = 'recaptcha_response_field'
Default value'recaptcha_response_field'Details
Type
n/a
Propertyprotected\Zend_Translate $_defaultTranslator =
staticinherited

Default translation object for all validate objects

Inherited from: \Zend_Validate_Abstract::$$_defaultTranslator\Zend_Captcha_Base::$$_defaultTranslator
Propertyprotectedarray $_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  
PropertyprotectedInteger $_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  
Propertyprotectedarray $_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
Propertyprotectedarray $_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  
Propertyprotectedarray $_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  
Propertyprotectedstring $_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  
Propertyprotectedbool $_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  
Propertyprotectedarray $_options = array()
inherited

Captcha options

Inherited from: \Zend_Captcha_Base::$$_options
Default valuearray()Details
Type
array
Inherited_from
\Zend_Captcha_Base::$$_options  
Propertyprotected\Zend_Service_Recaptcha $_service =

Recaptcha service object

Details
Type
\Zend_Service_Recaptcha
Propertyprotectedarray $_serviceOptions = array()

Options defined by the service

Default valuearray()Details
Type
array
Propertyprotectedarray $_serviceParams = array()

Parameters defined by the service

Default valuearray()Details
Type
array
Propertyprotectedarray $_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  
Propertyprotected\Zend_Translate $_translator =
PropertyprotectedBoolean $_translatorDisabled = false
Default valuefalseDetails
Type
Boolean
Inherited_from
\Zend_Validate_Abstract::$$_translatorDisabled  
Inherited_from
\Zend_Captcha_Base::$$_translatorDisabled  
Propertyprotectedmixed $_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
Name Type Description
$options array | \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
Name Type Description
$property string
Returns
Type Description
mixed
Throws
Exception Description
\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
Name Type Description
$messageKey string
$value string
Returns
Type Description
string
methodprotected_error(string $messageKey, string $value = null) : void
Parameters
Name Type Description
$messageKey string
$value string

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
Name Type Description
$value mixed
methodpublicgenerate() : string

Generate captcha

Returns
Type Description
string
Details
See
\global\Zend_Form_Captcha_Adapter::generate()  
methodpublicgetDecorator() : string

Get captcha decorator

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

Returns
Type Description
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
Type Description
\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
Type Description
array
methodpublicgetMessageLength() : integer
staticinherited

Returns the maximum allowed message length

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

Returns the message templates from the validator

Inherited from: \Zend_Validate_Abstract::getMessageTemplates()\Zend_Captcha_Base::getMessageTemplates()
Returns
Type Description
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
Type Description
array
methodpublicgetMessages() : array
inherited

Returns array of validation failure messages

Inherited from: \Zend_Validate_Abstract::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
Type Description
array
methodpublicgetName() : string
inherited

Get name

Inherited from: \Zend_Captcha_Base::getName()
Returns
Type Description
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
Type Description
bool
methodpublicgetOptions() : array
inherited

Retrieve options representing object state

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

Retrieve ReCaptcha Private key

Returns
Type Description
string
methodpublicgetPubkey() : string

Retrieve ReCaptcha Public key

Returns
Type Description
string
methodpublicgetService() : \Zend_Service_ReCaptcha

Retrieve ReCaptcha service object

Returns
Type Description
\Zend_Service_ReCaptcha
methodpublicgetTranslator() : \Zend_Translate_Adapter | null
inherited

Return translation object

Inherited from: \Zend_Validate_Abstract::getTranslator()\Zend_Captcha_Base::getTranslator()
Returns
Type Description
\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
Type Description
boolean
methodpublichasTranslator() : bool
inherited

Does this validator have its own specific translator?

Inherited from: \Zend_Validate_Abstract::hasTranslator()\Zend_Captcha_Base::hasTranslator()
Returns
Type Description
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
Name Type Description
$value mixed
$context
Returns
Type Description
boolean
Throws
Exception Description
\Zend_Validate_Exception If validation of $value is impossible
Details
See
\global\Zend_Validate_Interface::isValid()  
methodpublicrender(\Zend_View_Interface $view = null, mixed $element = null) : string

Render captcha

Parameters
Name Type Description
$view \Zend_View_Interface
$element mixed
Returns
Type Description
string
methodpublicsetConfig(\Zend_Config $config) : \Zend_Captcha_Base
inherited

Set object state from config object

Inherited from: \Zend_Captcha_Base::setConfig()
Parameters
Name Type Description
$config \Zend_Config
Returns
Type Description
\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
Name Type Description
$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
Name Type Description
$flag bool
Returns
Type Description
\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
Name Type Description
$messageString string
$messageKey string

OPTIONAL

Returns
Type Description
\Zend_Validate_Abstract Provides a fluent interface
Throws
Exception Description
\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
Name Type Description
$length integer
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
Name Type Description
$messages array
Returns
Type Description
\Zend_Validate_Abstract
methodpublicsetName(string $name) : \Zend_Captcha_Adapter
inherited

Set name

Inherited from: \Zend_Captcha_Base::setName()
Parameters
Name Type Description
$name string
Returns
Type Description
\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
Name Type Description
$flag bool
Returns
Type Description
\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
Name Type Description
$key string
$value mixed
Returns
Type Description
\Zend_Captcha_ReCaptcha
methodpublicsetOptions(array $options = null) : \Zend_Form_Element
inherited

Set object state from options array

Inherited from: \Zend_Captcha_Base::setOptions()
Parameters
Name Type Description
$options array
Returns
Type Description
\Zend_Form_Element
methodpublicsetPrivkey(string $privkey) : \Zend_Captcha_ReCaptcha

Set ReCaptcha Private key

Parameters
Name Type Description
$privkey string
Returns
Type Description
\Zend_Captcha_ReCaptcha
methodpublicsetPubkey(string $pubkey) : \Zend_Captcha_ReCaptcha

Set ReCaptcha public key

Parameters
Name Type Description
$pubkey string
Returns
Type Description
\Zend_Captcha_ReCaptcha
methodpublicsetService(\Zend_Service_ReCaptcha $service) : \Zend_Captcha_ReCaptcha

Set service object

Parameters
Name Type Description
$service \Zend_Service_ReCaptcha
Returns
Type Description
\Zend_Captcha_ReCaptcha
methodpublicsetTranslator(\Zend_Translate | \Zend_Translate_Adapter | null $translator = null) : \Zend_Validate_Abstract
inherited

Set translation object

Inherited from: \Zend_Validate_Abstract::setTranslator()\Zend_Captcha_Base::setTranslator()
Parameters
Name Type Description
$translator \Zend_Translate | \Zend_Translate_Adapter | null
Returns
Type Description
\Zend_Validate_Abstract
methodpublictranslatorIsDisabled() : bool
Returns
Type Description
bool
Documentation was generated by phpDocumentor 2.0.0a8.