Captcha/Word.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_Word

Package: Zend\Captcha\Adapter
Word-based captcha adapter

Generates random word which user should recognise

Parent(s)
\Zend_Captcha_Base < \Zend_Validate_Abstract
Children
\Zend_Captcha_Figlet
\Zend_Captcha_Image
\Zend_Captcha_Dumb
Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Version
$Id: Word.php 24593 2012-01-05 20:35:02Z matthew $  

Constants

>VConstant  MISSING_VALUE = 'missingValue'
>VConstant  MISSING_ID = 'missingID'
>VConstant  BAD_CAPTCHA = 'badCaptcha'

Properties

>VPropertypublic$C = array("b", "c", "d", "f", "g", "h", "j", "k", "m", "n", "p", "q", "r", "s", "t", "u", "v", "w", "x", "z")
static
Default valuearray("b", "c", "d", "f", "g", "h", "j", "k", "m", "n", "p", "q", "r", "s", "t", "u", "v", "w", "x", "z")Details
Type
n/a
>VPropertypublic$CN = array("b", "c", "d", "f", "g", "h", "j", "k", "m", "n", "p", "q", "r", "s", "t", "u", "v", "w", "x", "z", "2", "3", "4", "5", "6", "7", "8", "9")
static
Default valuearray("b", "c", "d", "f", "g", "h", "j", "k", "m", "n", "p", "q", "r", "s", "t", "u", "v", "w", "x", "z", "2", "3", "4", "5", "6", "7", "8", "9")Details
Type
n/a
>VPropertypublic$V = array("a", "e", "i", "o", "u", "y")
static
Default valuearray("a", "e", "i", "o", "u", "y")Details
Type
n/a
>VPropertypublic$VN = array("a", "e", "i", "o", "u", "y", "2", "3", "4", "5", "6", "7", "8", "9")
static
Default valuearray("a", "e", "i", "o", "u", "y", "2", "3", "4", "5", "6", "7", "8", "9")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  
>VPropertyprotectedstring $_id
Random session ID
Details
Type
string
>VPropertyprotectedboolean $_keepSession = false
Should generate() keep session or create a new one?
Default valuefalseDetails
Type
boolean
>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 => 'Empty captcha value', self::MISSING_ID => 'Captcha ID field is missing', self::BAD_CAPTCHA => 'Captcha value is wrong')
Error messages
Default valuearray(self::MISSING_VALUE => 'Empty captcha value', self::MISSING_ID => 'Captcha ID field is missing', self::BAD_CAPTCHA => 'Captcha value is wrong')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_Session_Namespace $_session
Session
>VPropertyprotectedstring $_sessionClass = 'Zend_Session_Namespace'
Class name for sessions
Default value'Zend_Session_Namespace'Details
Type
string
>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  
>VPropertyprotectedinteger $_timeout = 300
Session lifetime for the captcha data
Default value300Details
Type
integer
>VPropertyprotected\Zend_Translate $_translator
>VPropertyprotectedBoolean $_translatorDisabled = false
Default valuefalseDetails
Type
Boolean
Inherited_from
\Zend_Validate_Abstract::$$_translatorDisabled  
Inherited_from
\Zend_Captcha_Base::$$_translatorDisabled  
>VPropertyprotectedboolean $_useNumbers = true
Should the numbers be used or only letters
Default valuetrueDetails
Type
boolean
>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  
>VPropertyprotectedstring $_word
Generated word
Details
Type
string
>VPropertyprotectedinteger $_wordlen = 8
Length of the word to generate
Default value8Details
Type
integer

Methods

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

Constructor

Inherited from: \Zend_Captcha_Base::__construct()
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_generateRandomId() : void

methodprotected_generateWord() : string

Generate new random word

Returns
TypeDescription
string
methodprotected_setId(string $id) : void

Set captcha identifier

Parameters
NameTypeDescription
$idstring

return Zend_Captcha_Word

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
methodprotected_setWord(string $word) : \Zend_Captcha_Word

Set captcha word

Parameters
NameTypeDescription
$wordstring
Returns
TypeDescription
\Zend_Captcha_Word
methodpublicgenerate() : string

Generate new session ID and new word

Returns
TypeDescription
stringsession ID
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
methodpublicgetId() : string

Retrieve captcha ID

Returns
TypeDescription
string
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
methodpublicgetSession() : \Zend_Session_Namespace

Get session object

Returns
TypeDescription
\Zend_Session_Namespace
methodpublicgetSessionClass() : string

Retrieve session class to utilize

Returns
TypeDescription
string
methodpublicgetTimeout() : int

Get session token timeout

Returns
TypeDescription
int
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
methodpublicgetUseNumbers() : bool

Numbers should be included in the pattern?

Returns
TypeDescription
bool
methodpublicgetWord() : string

Get captcha word

Returns
TypeDescription
string
methodpublicgetWordlen() : integer

Retrieve word length to use when genrating captcha

Returns
TypeDescription
integer
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 the word

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
inherited

Display the captcha

Inherited from: \Zend_Captcha_Adapter::render()\Zend_Captcha_Base::render()
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
methodpublicsetKeepSession(bool $keepSession) : \Zend_Captcha_Word

Sets if session should be preserved on generate()

Parameters
NameTypeDescription
$keepSessionbool

Should session be kept on generate()?

Returns
TypeDescription
\Zend_Captcha_Word
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, string $value) : \Zend_Form_Element
inherited

Set single option for the object

Inherited from: \Zend_Captcha_Base::setOption()
Parameters
NameTypeDescription
$keystring
$valuestring
Returns
TypeDescription
\Zend_Form_Element
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
methodpublicsetSession(\Zend_Session_Namespace $session) : \Zend_Captcha_Word

Set session namespace object

Parameters
NameTypeDescription
$session\Zend_Session_Namespace
Returns
TypeDescription
\Zend_Captcha_Word
methodpublicsetSessionClass(string $_sessionClass) : \Zend_Captcha_Word

Set session class for persistence

Parameters
NameTypeDescription
$_sessionClassstring
Returns
TypeDescription
\Zend_Captcha_Word
methodpublicsetTimeout(int $ttl) : \Zend_Captcha_Word

Set timeout for session token

Parameters
NameTypeDescription
$ttlint
Returns
TypeDescription
\Zend_Captcha_Word
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
methodpublicsetUseNumbers(bool $_useNumbers) : \Zend_Captcha_Word

Set if numbers should be included in the pattern

Parameters
NameTypeDescription
$_useNumbersbool

numbers should be included in the pattern?

Returns
TypeDescription
\Zend_Captcha_Word
methodpublicsetWordlen(integer $wordlen) : \Zend_Captcha_Word

Set word length of captcha

Parameters
NameTypeDescription
$wordleninteger
Returns
TypeDescription
\Zend_Captcha_Word
methodpublictranslatorIsDisabled() : bool
Returns
TypeDescription
bool
Documentation was generated by phpDocumentor 2.0.0a12.