MediaWiki  1.34.4
HTMLHCaptchaField.php
Go to the documentation of this file.
1 <?php
2 
4 
5 use Html;
6 use HTMLFormField;
7 
10  protected $key;
11 
13  protected $error;
14 
21  public function __construct( array $params ) {
22  $params += [ 'error' => null ];
23  parent::__construct( $params );
24 
25  $this->key = $params['key'];
26  $this->error = $params['error'];
27 
28  $this->mName = 'h-captcha-response';
29  }
30 
34  public function getInputHTML( $value ) {
35  $out = $this->mParent->getOutput();
36 
37  $out->addHeadItem(
38  'h-captcha',
39  "<script src=\"https://hcaptcha.com/1/api.js\" async defer></script>"
40  );
41  return Html::element( 'div', [
42  'class' => [
43  'h-captcha',
44  'mw-confirmedit-captcha-fail' => (bool)$this->error,
45  ],
46  'data-sitekey' => $this->key,
47  ] );
48  }
49 }
MediaWiki\Extensions\ConfirmEdit\hCaptcha\HTMLHCaptchaField\getInputHTML
getInputHTML( $value)
This function must be implemented to return the HTML to generate the input object itself....
Definition: HTMLHCaptchaField.php:34
MediaWiki\Extensions\ConfirmEdit\hCaptcha\HTMLHCaptchaField\$key
string $key
Public key parameter to be passed to hCaptcha.
Definition: HTMLHCaptchaField.php:10
MediaWiki\Extensions\ConfirmEdit\hCaptcha\HTMLHCaptchaField\$error
string $error
Error returned by hCaptcha in the previous round.
Definition: HTMLHCaptchaField.php:13
MediaWiki\Extensions\ConfirmEdit\hCaptcha\HTMLHCaptchaField\__construct
__construct(array $params)
Parameters:
Definition: HTMLHCaptchaField.php:21
HTMLFormField
The parent class to generate form fields.
Definition: HTMLFormField.php:7
MediaWiki\Extensions\ConfirmEdit\hCaptcha
Definition: HCaptcha.php:3
MediaWiki\Extensions\ConfirmEdit\hCaptcha\HTMLHCaptchaField
Definition: HTMLHCaptchaField.php:8
Html\element
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:231
Html
This class is a collection of static functions that serve two purposes:
Definition: Html.php:49