MediaWiki  1.23.0
HTMLCheckField.php
Go to the documentation of this file.
1 <?php
2 
7  function getInputHTML( $value ) {
8  if ( !empty( $this->mParams['invert'] ) ) {
9  $value = !$value;
10  }
11 
12  $attr = $this->getTooltipAndAccessKey();
13  $attr['id'] = $this->mID;
14 
15  $attr += $this->getAttributes( array( 'disabled', 'tabindex' ) );
16 
17  if ( $this->mClass !== '' ) {
18  $attr['class'] = $this->mClass;
19  }
20 
21  if ( $this->mParent->isVForm() ) {
22  // Nest checkbox inside label.
23  return Html::rawElement( 'label',
24  array(
25  'class' => 'mw-ui-checkbox-label'
26  ),
27  Xml::check( $this->mName, $value, $attr ) . // Html:rawElement doesn't escape contents.
28  htmlspecialchars( $this->mLabel ) );
29  } else {
30  return Xml::check( $this->mName, $value, $attr )
31  . '&#160;'
32  . Html::rawElement( 'label', array( 'for' => $this->mID ), $this->mLabel );
33  }
34  }
35 
41  function getLabel() {
42  return '&#160;';
43  }
44 
48  protected function needsLabel() {
49  return false;
50  }
51 
57  function loadDataFromRequest( $request ) {
58  $invert = false;
59  if ( isset( $this->mParams['invert'] ) && $this->mParams['invert'] ) {
60  $invert = true;
61  }
62 
63  // GetCheck won't work like we want for checks.
64  // Fetch the value in either one of the two following case:
65  // - we have a valid token (form got posted or GET forged by the user)
66  // - checkbox name has a value (false or true), ie is not null
67  if ( $request->getCheck( 'wpEditToken' ) || $request->getVal( $this->mName ) !== null ) {
68  // XOR has the following truth table, which is what we want
69  // INVERT VALUE | OUTPUT
70  // true true | false
71  // false true | true
72  // false false | false
73  // true false | true
74  return $request->getBool( $this->mName ) xor $invert;
75  } else {
76  return $this->getDefault();
77  }
78  }
79 }
HTMLCheckField\getLabel
getLabel()
For a checkbox, the label goes on the right hand side, and is added in getInputHTML(),...
Definition: HTMLCheckField.php:41
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
HTMLCheckField
A checkbox field.
Definition: HTMLCheckField.php:6
HTMLFormField\$mClass
$mClass
Definition: HTMLFormField.php:15
HTMLFormField
The parent class to generate form fields.
Definition: HTMLFormField.php:7
HTMLCheckField\loadDataFromRequest
loadDataFromRequest( $request)
Definition: HTMLCheckField.php:57
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
HTMLCheckField\getInputHTML
getInputHTML( $value)
This function must be implemented to return the HTML to generate the input object itself.
Definition: HTMLCheckField.php:7
HTMLFormField\$mID
$mID
Definition: HTMLFormField.php:14
$value
$value
Definition: styleTest.css.php:45
Xml\check
static check( $name, $checked=false, $attribs=array())
Convenience function to build an HTML checkbox.
Definition: Xml.php:339
HTMLFormField\getDefault
getDefault()
Definition: HTMLFormField.php:466
HTMLCheckField\needsLabel
needsLabel()
checkboxes don't need a label.
Definition: HTMLCheckField.php:48
HTMLFormField\getTooltipAndAccessKey
getTooltipAndAccessKey()
Returns the attributes required for the tooltip and accesskey.
Definition: HTMLFormField.php:479
Html\rawElement
static rawElement( $element, $attribs=array(), $contents='')
Returns an HTML element in a string.
Definition: Html.php:124
HTMLFormField\getAttributes
getAttributes(array $list)
Returns the given attributes from the parameters.
Definition: HTMLFormField.php:493