API Documentation

Captcha/Word.php

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-2011 Zend Technologies USA Inc. (http://www.zend.com)  
license
New BSD License  
package
Zend_Captcha  
subpackage
Adapter  

\Zend_Captcha_Word

Word-based captcha adapter

Generates random word which user should recognise

Extends from
\Zend_Captcha_Base
category
Zend  
copyright
Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)  
license
New BSD License  
package
Zend_Captcha  
subpackage
Adapter  
version
$Id: Word.php 23775 2011-03-01 17:25:24Z ralph $  

Constants

Constant  MISSING_VALUE = 'missingValue'
Constant  MISSING_ID = 'missingID'
Constant  BAD_CAPTCHA = 'badCaptcha'

Properties

Propertypublic  $C= 'array'
static
Default valuearrayDetails
Type
Propertypublic  $CN= 'array'
static
Default valuearrayDetails
Type
Propertypublic  $V= 'array'
static
Default valuearrayDetails
Type
Propertypublic  $VN= 'array'
static
Default valuearrayDetails
Type
Propertyprotectedstring  $_id= ''

Random session ID

Details
Type
string
Propertyprotectedboolean  $_keepSession= 'false'

Should generate() keep session or create a new one?

Default valuefalseDetails
Type
boolean
Propertyprotectedarray  $_messageTemplates= 'array'

Error messages

Default valuearrayDetails
Type
array
Propertyprotected\Zend_Session_Namespace  $_session= ''

Session

Propertyprotectedstring  $_sessionClass= 'Zend_Session_Namespace'

Class name for sessions

Default valueZend_Session_NamespaceDetails
Type
string
Propertyprotectedinteger  $_timeout= '300'

Session lifetime for the captcha data

Default value300Details
Type
integer
Propertyprotectedboolean  $_useNumbers= 'true'

Should the numbers be used or only letters

Default valuetrueDetails
Type
boolean
Propertyprotectedstring  $_word= ''

Generated word

Details
Type
string
Propertyprotectedinteger  $_wordlen= '8'

Length of the word to generate

Default value8Details
Type
integer

Methods

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

Constructor

Inherited from: \Zend_Captcha_Base::__construct()
Parameters
Name Type Description
$options array|\Zend_Config
methodpublic__get( string $property ) : mixed

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()
Parameters
Name Type Description
$property string
Returns
Type Description
mixed
Throws
Exception Description
\Zend_Validate_Exception
methodprotected_createMessage( string $messageKey, string $value ) : string

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

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

methodprotected_generateWord( ) : string

Generate new random word

Returns
Type Description
string
methodprotected_setId( string $id ) : void

Set captcha identifier

Parameters
Name Type Description
$id string return Zend_Captcha_Word
methodprotected_setValue( mixed $value ) : void

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

Inherited from: \Zend_Validate_Abstract::_setValue()
Parameters
Name Type Description
$value mixed
methodprotected_setWord( string $word ) : \Zend_Captcha_Word

Set captcha word

Parameters
Name Type Description
$word string
Returns
Type Description
\Zend_Captcha_Word
methodpublicgenerate( ) : string

Generate new session ID and new word

Returns
Type Description
string session ID
methodpublicgetDecorator( ) : string

Get captcha decorator

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

Returns
Type Description
string
methodpublicgetDefaultTranslator( ) : \Zend_Translate_Adapter|null
static

Get default translation object for all validate objects

Inherited from: \Zend_Validate_Abstract::getDefaultTranslator()
Returns
Type Description
\Zend_Translate_Adapternull
methodpublicgetErrors( ) : array

Returns array of validation failure message codes

Inherited from: \Zend_Validate_Abstract::getErrors()
Returns
Type Description
array
Details
deprecated
Since 1.5.0  
methodpublicgetId( ) : string

Retrieve captcha ID

Returns
Type Description
string
methodpublicgetMessageLength( ) : integer
static

Returns the maximum allowed message length

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

Returns the message templates from the validator

Inherited from: \Zend_Validate_Abstract::getMessageTemplates()
Returns
Type Description
array
methodpublicgetMessageVariables( ) : array

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

Inherited from: \Zend_Validate_Abstract::getMessageVariables()
Returns
Type Description
array
methodpublicgetMessages( ) : array

Returns array of validation failure messages

Inherited from: \Zend_Validate_Abstract::getMessages()

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

Get name

Inherited from: \Zend_Captcha_Base::getName()
Returns
Type Description
string
methodpublicgetObscureValue( ) : bool

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

Inherited from: \Zend_Validate_Abstract::getObscureValue()
Returns
Type Description
bool
methodpublicgetOptions( ) : array

Retrieve options representing object state

Inherited from: \Zend_Captcha_Base::getOptions()
Returns
Type Description
array
methodpublicgetSession( ) : \Zend_Session_Namespace

Get session object

Returns
Type Description
\Zend_Session_Namespace
methodpublicgetSessionClass( ) : string

Retrieve session class to utilize

Returns
Type Description
string
methodpublicgetTimeout( ) : int

Get session token timeout

Returns
Type Description
int
methodpublicgetTranslator( ) : \Zend_Translate_Adapter|null

Return translation object

Inherited from: \Zend_Validate_Abstract::getTranslator()
Returns
Type Description
\Zend_Translate_Adapternull
methodpublicgetUseNumbers( ) : bool

Numbers should be included in the pattern?

Returns
Type Description
bool
methodpublicgetWord( ) : string

Get captcha word

Returns
Type Description
string
methodpublicgetWordlen( ) : integer

Retrieve word length to use when genrating captcha

Returns
Type Description
integer
methodpublichasDefaultTranslator( ) : boolean
static

Is there a default translation object set?

Inherited from: \Zend_Validate_Abstract::hasDefaultTranslator()
Returns
Type Description
boolean
methodpublichasTranslator( ) : bool

Does this validator have its own specific translator?

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

Display the captcha

Inherited from: \Zend_Captcha_Adapter::render()
Parameters
Name Type Description
$view \Zend_View_Interface
$element mixed
Returns
Type Description
string
methodpublicsetConfig( \Zend_Config $config ) : \Zend_Captcha_Base

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
static

Set default translation object for all validate objects

Inherited from: \Zend_Validate_Abstract::setDefaultTranslator()
Parameters
Name Type Description
$translator \Zend_Translate|\Zend_Translate_Adapter|null
methodpublicsetDisableTranslator( bool $flag ) : \Zend_Validate_Abstract

Indicate whether or not translation should be disabled

Inherited from: \Zend_Validate_Abstract::setDisableTranslator()
Parameters
Name Type Description
$flag bool
Returns
Type Description
\Zend_Validate_Abstract
methodpublicsetKeepSession( bool $keepSession ) : \Zend_Captcha_Word

Sets if session should be preserved on generate()

Parameters
Name Type Description
$keepSession bool

Should session be kept on generate()?

Returns
Type Description
\Zend_Captcha_Word
methodpublicsetMessage( string $messageString, string $messageKey = null ) : \Zend_Validate_Abstract

Sets the validation failure message template for a particular key

Inherited from: \Zend_Validate_Abstract::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 ) : void
static

Sets the maximum allowed message length

Inherited from: \Zend_Validate_Abstract::setMessageLength()
Parameters
Name Type Description
$length integer
methodpublicsetMessages( array $messages ) : \Zend_Validate_Abstract

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()
Parameters
Name Type Description
$messages array
Returns
Type Description
\Zend_Validate_Abstract
methodpublicsetName( string $name ) : \Zend_Captcha_Adapter

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

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

Inherited from: \Zend_Validate_Abstract::setObscureValue()
Parameters
Name Type Description
$flag bool
Returns
Type Description
\Zend_Validate_Abstract
methodpublicsetOption( string $key, string $value ) : \Zend_Form_Element

Set single option for the object

Inherited from: \Zend_Captcha_Base::setOption()
Parameters
Name Type Description
$key string
$value string
Returns
Type Description
\Zend_Form_Element
methodpublicsetOptions( array $options = null ) : \Zend_Form_Element

Set object state from options array

Inherited from: \Zend_Captcha_Base::setOptions()
Parameters
Name Type Description
$options array
Returns
Type Description
\Zend_Form_Element
methodpublicsetSession( \Zend_Session_Namespace $session ) : \Zend_Captcha_Word

Set session namespace object

Parameters
Name Type Description
$session \Zend_Session_Namespace
Returns
Type Description
\Zend_Captcha_Word
methodpublicsetSessionClass( string $_sessionClass ) : \Zend_Captcha_Word

Set session class for persistence

Parameters
Name Type Description
$_sessionClass string
Returns
Type Description
\Zend_Captcha_Word
methodpublicsetTimeout( int $ttl ) : \Zend_Captcha_Word

Set timeout for session token

Parameters
Name Type Description
$ttl int
Returns
Type Description
\Zend_Captcha_Word
methodpublicsetTranslator( \Zend_Translate|\Zend_Translate_Adapter|null $translator = null ) : \Zend_Validate_Abstract

Set translation object

Inherited from: \Zend_Validate_Abstract::setTranslator()
Parameters
Name Type Description
$translator \Zend_Translate|\Zend_Translate_Adapter|null
Returns
Type Description
\Zend_Validate_Abstract
methodpublicsetUseNumbers( bool $_useNumbers ) : \Zend_Captcha_Word

Set if numbers should be included in the pattern

Parameters
Name Type Description
$_useNumbers bool

numbers should be included in the pattern?

Returns
Type Description
\Zend_Captcha_Word
methodpublicsetWordlen( integer $wordlen ) : \Zend_Captcha_Word

Set word length of captcha

Parameters
Name Type Description
$wordlen integer
Returns
Type Description
\Zend_Captcha_Word
methodpublictranslatorIsDisabled( ) : bool

Is translation disabled?

Inherited from: \Zend_Validate_Abstract::translatorIsDisabled()
Returns
Type Description
bool
Documentation was generated by DocBlox 0.13.3.