MediaWiki REL1_34
HTMLHCaptchaField.php
Go to the documentation of this file.
1<?php
2
4
5use Html;
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}
The parent class to generate form fields.
This class is a collection of static functions that serve two purposes:
Definition Html.php:49
string $key
Public key parameter to be passed to hCaptcha.
string $error
Error returned by hCaptcha in the previous round.
getInputHTML( $value)
This function must be implemented to return the HTML to generate the input object itself....