Captcha.php: modified to add captcha to 'extrafields' in Userlogin and Usercreate

Captcha.php inserts captcha in the header of Userlogin and Usercreate template.
This leads to inconsistent view because js,if enabled, moves the captcha before
submit button. Now the captcha is inserted at the 'extrafields' parameter just
before submit button in both the templates,for uniformity of view.

JS functionality in
resources/src/mediawiki.special/mediawiki.special.userlogin.common.js migrated
to backed in FancyCaptcha.class.php, so that the FancyCaptch is already styled
and positioned before 'submit'.
Depends on I82c68814e79cbc5aa250a308862c59fcbb6fd527
Depends on Ie95305b2e6dcbf527a23c92613755092185e6a05

Bug: T85192
Bug: T87190
Change-Id: If9a68aaee2cf98d63647816ccc8fc0bad12ca3d3
This commit is contained in:
Sumit Asthana 2015-01-14 22:04:23 +05:30 committed by Florianschmidtwelzow
parent 2d8804479f
commit 2237e2c4ce
2 changed files with 39 additions and 22 deletions

View file

@ -160,11 +160,16 @@ class SimpleCaptcha {
wfDebug( "ConfirmEdit: user group allows skipping captcha on account creation\n" );
return true;
}
$template->set( 'header',
"<div class='captcha'>" .
$captcha = "<div class='captcha'>" .
$wgOut->parse( $this->getMessage( 'createaccount' ) ) .
$this->getForm() .
"</div>\n" );
"</div>\n";
// for older MediaWiki versions
if ( is_callable( array( $template, 'extend' ) ) ) {
$template->extend( 'extrafields', $captcha );
} else {
$template->set( 'header', $captcha );
}
}
return true;
}
@ -179,11 +184,16 @@ class SimpleCaptcha {
function injectUserLogin( &$template ) {
if ( $this->isBadLoginTriggered() ) {
global $wgOut;
$template->set( 'header',
"<div class='captcha'>" .
$captcha = "<div class='captcha'>" .
$wgOut->parse( $this->getMessage( 'badlogin' ) ) .
$this->getForm() .
"</div>\n" );
"</div>\n";
// for older MediaWiki versions
if ( is_callable( array( $template, 'extend' ) ) ) {
$template->extend( 'extrafields', $captcha );
} else {
$template->set( 'header', $captcha );
}
}
return true;
}

View file

@ -113,21 +113,21 @@ class FancyCaptcha extends SimpleCaptcha {
$captchaReload = '';
}
return "<div class='fancycaptcha-wrapper'><div class='fancycaptcha-image-container'>" .
$form = Html::openElement( 'div' ) .
Html::element( 'label', array(
'for' => 'wpCaptchaWord',
),
parent::getMessage( 'label' ) . ' ' . wfMessage( 'createacct-captcha' )->text()
) .
Html::openElement( 'div', array( 'class' => 'mw-createacct-captcha-container' ) ) .
Html::openElement( 'div', array( 'class' => 'mw-createacct-captcha-and-reload' ) ) .
Html::openElement( 'div', array( 'class' => 'fancycaptcha-image-container' ) ) .
Html::element( 'img', array(
'class' => 'fancycaptcha-image',
'src' => $title->getLocalUrl( 'wpCaptchaId=' . urlencode( $index ) ),
'alt' => ''
)
) .
$captchaReload .
"</div>\n" .
'<p>' .
Html::element( 'label', array(
'for' => 'wpCaptchaWord',
),
parent::getMessage( 'label' ) . wfMessage( 'colon-separator' )->text()
) .
) . $captchaReload . Html::closeElement( 'div' ) . Html::closeElement( 'div' ) . "\n" .
Html::element( 'input', array(
'name' => 'wpCaptchaWord',
'class' => 'mw-ui-input',
@ -138,18 +138,25 @@ class FancyCaptcha extends SimpleCaptcha {
'autocorrect' => 'off',
'autocapitalize' => 'off',
'required' => 'required',
'tabindex' => 1
'tabindex' => 1,
'placeholder' => wfMessage( 'createacct-imgcaptcha-ph' )
)
) . // tab in before the edit textarea
Html::element( 'input', array(
); // tab in before the edit textarea
if ( $this->action == 'usercreate' ) {
$form .= HTML::element( 'small',array(
'class' => 'mw-createacct-captcha-assisted'
), wfMessage( 'createacct-imgcaptcha-help' )
);
}
$form .= Html::element( 'input', array(
'type' => 'hidden',
'name' => 'wpCaptchaId',
'id' => 'wpCaptchaId',
'value' => $index
)
) .
"</p>\n" .
"</div>\n";;
) . Html::closeElement( 'div' ) . Html::closeElement( 'div' ) . "\n";
return $form;
}
/**