Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F6170376
HTMLHCaptchaField.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
HTMLHCaptchaField.php
View Options
<?php
namespace
MediaWiki\Extension\ConfirmEdit\hCaptcha
;
use
MediaWiki\Html\Html
;
use
MediaWiki\HTMLForm\HTMLFormField
;
class
HTMLHCaptchaField
extends
HTMLFormField
{
/** @var string Public key parameter to be passed to hCaptcha. */
protected
$key
;
/** @var string Error returned by hCaptcha in the previous round. */
protected
$error
;
/**
* Parameters:
* - key: (string, required) Public key
* - error: (string) Error from the previous captcha round
* @param array $params
*/
public
function
__construct
(
array
$params
)
{
$params
+=
[
'error'
=>
null
];
parent
::
__construct
(
$params
);
$this
->
key
=
$params
[
'key'
];
$this
->
error
=
$params
[
'error'
];
$this
->
mName
=
'h-captcha-response'
;
}
/** @inheritDoc */
public
function
getInputHTML
(
$value
)
{
$out
=
$this
->
mParent
->
getOutput
();
$config
=
$this
->
mParent
->
getConfig
();
$url
=
$config
->
get
(
'HCaptchaApiUrl'
);
$out
->
addHeadItem
(
'h-captcha'
,
"<script src=
\"
$url
\"
async defer></script>"
);
HCaptcha
::
addCSPSources
(
$out
->
getCSP
()
);
$output
=
Html
::
element
(
'div'
,
[
'class'
=>
[
'h-captcha'
,
'mw-confirmedit-captcha-fail'
=>
(
bool
)
$this
->
error
,
],
'data-sitekey'
=>
$this
->
key
,
]
);
if
(
$config
->
get
(
'HCaptchaPassiveMode'
)
)
{
$output
.=
$this
->
getMessage
(
'hcaptcha-privacy-policy'
)->
parse
();
}
return
$output
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Oct 8 2026, 20:52 (7 w, 1 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
0c/31/2913f688bbe1068d59a372a3f304
Default Alt Text
HTMLHCaptchaField.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment