Source for file captcha.php
Documentation is available at captcha.php
* @package Joomla.Libraries
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* Joomla! Captcha base object
* @package Joomla.Libraries
* An array of Observer objects to notify
* The state of the observable object
* A multi dimensional array of [function][] = key for observers
* Array of instances of this class.
private static $_instances =
array();
* @param string $captcha The editor to use.
* @param array $options Associative array of options.
* Returns the global Captcha object, only creating it
* if it doesn't already exist.
* @param string $captcha The plugin to use.
* @param array $options Associative array of options.
* @return JCaptcha Instance of this class.
public static function getInstance($captcha, array $options =
array())
if (empty(self::$_instances[$signature]))
self::$_instances[$signature] =
new JCaptcha($captcha, $options);
catch
(RuntimeException $e)
return self::$_instances[$signature];
* Fire the onInit event to initialise the captcha plug-in.
* @param string $id The id of the field.
* @return boolean True on success
$args['event'] =
'onInit';
$this->_captcha->update($args);
* Get the HTML for the captcha.
* @param string $name The control name.
* @param string $id The id for the control.
* @param string $class Value for the HTML class attribute
* @return mixed The return value of the function "onDisplay" of the selected Plugin.
public function display($name, $id, $class =
'')
// Check if captcha is already loaded.
// Initialise the Captcha.
$args['id'] =
$id ?
$id :
$name;
$args['class'] =
$class ?
'class="' .
$class .
'"' :
'';
$args['event'] =
'onDisplay';
return $this->_captcha->update($args);
* Checks if the answer is correct.
* @param string $code The answer.
* @return mixed The return value of the function "onCheckAnswer" of the selected Plugin.
// Check if captcha is already loaded
$args['event'] =
'onCheckAnswer';
return $this->_captcha->update($args);
* Load the Captcha plug-in.
* @param array $options Associative array of options.
* @throws RuntimeException
private function _load(array $options =
array())
// Build the path to the needed captcha plugin
$path =
JPATH_PLUGINS .
'/captcha/' .
$name .
'/' .
$name .
'.php';
throw
new RuntimeException(JText::sprintf('JLIB_CAPTCHA_ERROR_PLUGIN_NOT_FOUND', $name));
throw
new RuntimeException(JText::sprintf('JLIB_CAPTCHA_ERROR_PLUGIN_NOT_FOUND', $name));
$plugin->params =
$params;
// Build captcha plugin classname
$name =
'plgCaptcha' .
$this->_name;
$this->_captcha =
new $name($this, (array)
$plugin, $options);
* Get the state of the JEditor object
* @return mixed The state of the object.
* Attach an observer object
* @param object $observer An observer object to attach
public function attach($observer)
if (!isset
($observer['handler']) ||
!isset
($observer['event']) ||
!is_callable($observer['handler']))
// Make sure we haven't already attached this array as an observer
if (is_array($check) &&
$check['event'] ==
$observer['event'] &&
$check['handler'] ==
$observer['handler'])
$methods =
array($observer['event']);
if (!($observer instanceof
JEditor))
// Make sure we haven't already attached this object as an observer
if ($check instanceof
$class)
foreach ($methods as $method)
* Detach an observer object
* @param object $observer An observer object to detach.
* @return boolean True if the observer object was detached.
public function detach($observer)
Documentation generated on Tue, 19 Nov 2013 14:55:03 +0100 by phpDocumentor 1.4.3