mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ConfirmEdit
synced 2024-11-15 11:59:33 +00:00
3e3b91b527
Also remove references to "two words" from ReCaptcha labels. The captcha image doesn't always contain two words. Bug: T110302 Change-Id: I544656289480056152a1db195babb6dadf29bc71
52 lines
1.4 KiB
PHP
52 lines
1.4 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Creates a ReCaptcha widget. Does not return any data; handling the data submitted by the
|
|
* widget is callers' responsibility.
|
|
*/
|
|
class HTMLReCaptchaField extends HTMLFormField {
|
|
/** @var string Public key parameter to be passed to ReCaptcha. */
|
|
protected $key;
|
|
|
|
/** @var string Theme parameter to be passed to ReCaptcha. */
|
|
protected $theme;
|
|
|
|
/** @var bool Use secure connection to ReCaptcha. */
|
|
protected $secure;
|
|
|
|
/** @var string Error returned by ReCaptcha in the previous round. */
|
|
protected $error;
|
|
|
|
/**
|
|
* Parameters:
|
|
* - key: (string, required) ReCaptcha public key
|
|
* - theme: (string, required) ReCaptcha theme
|
|
* - secure: (bool) Use secure connection to ReCaptcha
|
|
* - error: (string) ReCaptcha error from previous round
|
|
* @param array $params
|
|
*/
|
|
public function __construct( array $params ) {
|
|
$params += [
|
|
'secure' => true,
|
|
'error' => null,
|
|
];
|
|
parent::__construct( $params );
|
|
|
|
$this->key = $params['key'];
|
|
$this->theme = $params['theme'];
|
|
$this->secure = $params['secure'];
|
|
$this->error = $params['error'];
|
|
}
|
|
|
|
public function getInputHTML( $value ) {
|
|
$attribs = $this->getAttributes( [ 'tabindex' ] ) + [ 'theme' => $this->theme ];
|
|
$js = 'var RecaptchaOptions = ' . Xml::encodeJsVar( $attribs );
|
|
$widget = recaptcha_get_html( $this->key, $this->error, $this->secure );
|
|
return Html::inlineScript( $js ) . $widget;
|
|
}
|
|
|
|
public function skipLoadData( $request ) {
|
|
return true;
|
|
}
|
|
}
|