mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ConfirmEdit
synced 2024-09-24 10:49:46 +00:00
Merge "Add a way to use different tab indexes for CAPTCHA input form"
This commit is contained in:
commit
bc66060763
|
@ -90,7 +90,7 @@ class FancyCaptcha extends SimpleCaptcha {
|
|||
* Insert the captcha prompt into the edit form.
|
||||
* @param OutputPage $out
|
||||
*/
|
||||
function getForm( OutputPage $out ) {
|
||||
function getForm( OutputPage $out, $tabIndex = 1 ) {
|
||||
global $wgOut, $wgEnableAPI;
|
||||
|
||||
// Uses addModuleStyles so it is loaded when JS is disabled.
|
||||
|
@ -139,7 +139,7 @@ class FancyCaptcha extends SimpleCaptcha {
|
|||
'autocorrect' => 'off',
|
||||
'autocapitalize' => 'off',
|
||||
'required' => 'required',
|
||||
'tabindex' => 1,
|
||||
'tabindex' => $tabIndex,
|
||||
'placeholder' => wfMessage( 'createacct-imgcaptcha-ph' )
|
||||
)
|
||||
); // tab in before the edit textarea
|
||||
|
|
|
@ -20,12 +20,12 @@ class MathCaptcha extends SimpleCaptcha {
|
|||
* Produce a nice little form
|
||||
* @param OutputPage $out
|
||||
*/
|
||||
function getForm( OutputPage $out ) {
|
||||
function getForm( OutputPage $out, $tabIndex = 1 ) {
|
||||
list( $sum, $answer ) = $this->pickSum();
|
||||
$index = $this->storeCaptcha( array( 'answer' => $answer ) );
|
||||
|
||||
$form = '<table><tr><td>' . $this->fetchMath( $sum ) . '</td>';
|
||||
$form .= '<td>' . Html::input( 'wpCaptchaWord', false, false, array( 'tabindex' => '1', 'autocomplete' => 'off', 'required' ) ) . '</td></tr></table>';
|
||||
$form .= '<td>' . Html::input( 'wpCaptchaWord', false, false, array( 'tabindex' => $tabIndex, 'autocomplete' => 'off', 'required' ) ) . '</td></tr></table>';
|
||||
$form .= Html::hidden( 'wpCaptchaId', $index );
|
||||
return $form;
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ class QuestyCaptcha extends SimpleCaptcha {
|
|||
return array( 'question' => $question, 'answer' => $answer );
|
||||
}
|
||||
|
||||
function getForm( OutputPage $out ) {
|
||||
function getForm( OutputPage $out, $tabIndex = 1 ) {
|
||||
$captcha = $this->getCaptcha();
|
||||
if ( !$captcha ) {
|
||||
die( "No questions found; set some in LocalSettings.php using the format from QuestyCaptcha.php." );
|
||||
|
@ -54,7 +54,7 @@ class QuestyCaptcha extends SimpleCaptcha {
|
|||
'class' => 'mw-ui-input',
|
||||
'required',
|
||||
'autocomplete' => 'off',
|
||||
'tabindex' => 1 ) ) . // tab in before the edit textarea
|
||||
'tabindex' => $tabIndex ) ) . // tab in before the edit textarea
|
||||
"</p>\n" .
|
||||
Xml::element( 'input', array(
|
||||
'type' => 'hidden',
|
||||
|
|
|
@ -9,11 +9,11 @@ class ReCaptcha extends SimpleCaptcha {
|
|||
* If $this->recaptcha_error is set, it will display an error in the widget.
|
||||
* @param OutputPage $out
|
||||
*/
|
||||
function getForm( OutputPage $out ) {
|
||||
function getForm( OutputPage $out, $tabIndex = 1 ) {
|
||||
global $wgReCaptchaPublicKey, $wgReCaptchaTheme;
|
||||
|
||||
$useHttps = ( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] == 'on' );
|
||||
$js = 'var RecaptchaOptions = ' . Xml::encodeJsVar( array( 'theme' => $wgReCaptchaTheme, 'tabindex' => 1 ) );
|
||||
$js = 'var RecaptchaOptions = ' . Xml::encodeJsVar( array( 'theme' => $wgReCaptchaTheme, 'tabindex' => $tabIndex ) );
|
||||
|
||||
return Html::inlineScript( $js ) . recaptcha_get_html( $wgReCaptchaPublicKey, $this->recaptcha_error, $useHttps );
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ class ReCaptchaNoCaptcha extends SimpleCaptcha {
|
|||
* Get the captcha form.
|
||||
* @return string
|
||||
*/
|
||||
function getForm( OutputPage $out ) {
|
||||
function getForm( OutputPage $out, $tabIndex = 1 ) {
|
||||
global $wgReCaptchaSiteKey;
|
||||
|
||||
// Insert reCAPTCHA script.
|
||||
|
|
|
@ -39,7 +39,7 @@ class SimpleCaptcha {
|
|||
*
|
||||
* @return string HTML
|
||||
*/
|
||||
function getForm( OutputPage $out ) {
|
||||
function getForm( OutputPage $out, $tabIndex = 1 ) {
|
||||
$captcha = $this->getCaptcha();
|
||||
$index = $this->storeCaptcha( $captcha );
|
||||
|
||||
|
@ -50,7 +50,7 @@ class SimpleCaptcha {
|
|||
'id' => 'wpCaptchaWord',
|
||||
'size' => 5,
|
||||
'autocomplete' => 'off',
|
||||
'tabindex' => 1 ) ) . // tab in before the edit textarea
|
||||
'tabindex' => $tabIndex ) ) . // tab in before the edit textarea
|
||||
"</p>\n" .
|
||||
Xml::element( 'input', array(
|
||||
'type' => 'hidden',
|
||||
|
@ -152,7 +152,11 @@ class SimpleCaptcha {
|
|||
) );
|
||||
$captcha = "<div class='captcha'>" .
|
||||
$wgOut->parse( $this->getMessage( 'createaccount' ) ) .
|
||||
$this->getForm( $wgOut ) .
|
||||
// FIXME: Hardcoded tab index
|
||||
// Usually, the CAPTCHA is added after the E-Mail address field, which actually has 6 as the tabIndex, but
|
||||
// there may are wikis which allows to mention the "real name", which would have 7 as tabIndex, so increase
|
||||
// 6 by 2 and use it for the CAPTCHA -> 8 (the submit button has a tabIndex of 10)
|
||||
$this->getForm( $wgOut, 8 ) .
|
||||
"</div>\n";
|
||||
// for older MediaWiki versions
|
||||
if ( is_callable( array( $template, 'extend' ) ) ) {
|
||||
|
|
Loading…
Reference in a new issue