6 class HTMLCheckField
extends HTMLFormField
{
7 function getInputHTML( $value ) {
8 global $wgUseMediaWikiUIEverywhere;
10 if ( !empty( $this->mParams
['invert'] ) ) {
14 $attr = $this->getTooltipAndAccessKey();
15 $attr['id'] = $this->mID
;
17 $attr +
= $this->getAttributes( array( 'disabled', 'tabindex' ) );
19 if ( $this->mClass
!== '' ) {
20 $attr['class'] = $this->mClass
;
23 if ( $this->mParent
->isVForm() ) {
24 // Nest checkbox inside label.
25 return Html
::rawElement( 'label',
27 'class' => 'mw-ui-checkbox-label'
29 Xml
::check( $this->mName
, $value, $attr ) . $this->mLabel
);
31 $chkLabel = Xml
::check( $this->mName
, $value, $attr )
33 . Html
::rawElement( 'label', array( 'for' => $this->mID
), $this->mLabel
);
35 if ( $wgUseMediaWikiUIEverywhere ) {
36 $chkLabel = Html
::rawElement(
38 array( 'class' => 'mw-ui-checkbox' ),
48 * For a checkbox, the label goes on the right hand side, and is
49 * added in getInputHTML(), rather than HTMLFormField::getRow()
57 * checkboxes don't need a label.
60 protected function needsLabel() {
65 * @param WebRequest $request
69 function loadDataFromRequest( $request ) {
71 if ( isset( $this->mParams
['invert'] ) && $this->mParams
['invert'] ) {
75 // GetCheck won't work like we want for checks.
76 // Fetch the value in either one of the two following case:
77 // - we have a valid token (form got posted or GET forged by the user)
78 // - checkbox name has a value (false or true), ie is not null
79 if ( $request->getCheck( 'wpEditToken' ) ||
$request->getVal( $this->mName
) !== null ) {
80 // XOR has the following truth table, which is what we want
81 // INVERT VALUE | OUTPUT
84 // false false | false
86 return $request->getBool( $this->mName
) xor $invert;
88 return $this->getDefault();