Captcha

Implements \Joomla\Event\DispatcherAwareInterface

Joomla! Captcha base object

abstract
since

2.5

Methods

__construct

Class constructor.

__construct(string $captcha, array $options) 
since

2.5

throws

\RuntimeException

Arguments

$captcha

stringThe plugin to use.

$options

arrayAssociative array of options.

_load

Load the Captcha plugin.

_load(array $options = array()) : void
since

2.5

throws

\RuntimeException

Arguments

$options

arrayAssociative array of options.

checkAnswer

Checks if the answer is correct.

checkAnswer(string $code) : boolean
since

2.5

throws

\RuntimeException

Arguments

$code

stringThe answer.

Response

booleanWhether the provided answer was correct

display

Get the HTML for the captcha.

display(string $name, string $id, string $class = '') : string
since

2.5

throws

\RuntimeException

Arguments

$name

stringThe control name.

$id

stringThe id for the control.

$class

stringValue for the HTML class attribute

Response

stringThe return value of the function "onDisplay" of the selected Plugin.

getInstance

Returns the global Captcha object, only creating it if it doesn't already exist.

getInstance(string $captcha, array $options = array()) : \Joomla\CMS\Captcha\Captcha|null
static
since

2.5

throws

\RuntimeException

Arguments

$captcha

stringThe plugin to use.

$options

arrayAssociative array of options.

Response

\Joomla\CMS\Captcha\Captcha|nullInstance of this class.

initialise

Fire the onInit event to initialise the captcha plugin.

initialise(string $id) : boolean
since

2.5

throws

\RuntimeException

Arguments

$id

stringThe id of the field.

Response

booleanTrue on success

setupField

Method to react on the setup of a captcha field. Gives the possibility to change the field and/or the XML element for the field.

setupField(\Joomla\CMS\Form\Field\CaptchaField $field, \SimpleXMLElement $element) : void

Arguments

$field

\Joomla\CMS\Form\Field\CaptchaFieldCaptcha field instance

$element

\SimpleXMLElementXML form definition

update

Method to call the captcha callback if it exist.

update(string $name,  &$args) : mixed
since

4.0.0

Arguments

$name

stringCallback name

$args

Response

mixed

Properties

captcha

Captcha Plugin object

since

2.5

Type(s)

\Joomla\CMS\Plugin\CMSPlugin

name

Editor Plugin name

since

2.5

Type(s)

string

instances

Array of instances of this class.

static
since

2.5

Type(s)

array<mixed,\Joomla\CMS\Captcha\Captcha>