Move MediaHandler defaults out of global scope
[lhc/web/wiklou.git] / includes / htmlform / HTMLCheckField.php
index 5ef4f79..a553839 100644 (file)
@@ -14,13 +14,13 @@ class HTMLCheckField extends HTMLFormField {
                $attr = $this->getTooltipAndAccessKey();
                $attr['id'] = $this->mID;
 
-               $attr += $this->getAttributes( array( 'disabled', 'tabindex' ) );
+               $attr += $this->getAttributes( [ 'disabled', 'tabindex' ] );
 
                if ( $this->mClass !== '' ) {
                        $attr['class'] = $this->mClass;
                }
 
-               $attrLabel = array( 'for' => $this->mID );
+               $attrLabel = [ 'for' => $this->mID ];
                if ( isset( $attr['title'] ) ) {
                        // propagate tooltip to label
                        $attrLabel['title'] = $attr['title'];
@@ -33,7 +33,7 @@ class HTMLCheckField extends HTMLFormField {
                if ( $wgUseMediaWikiUIEverywhere || $this->mParent instanceof VFormHTMLForm ) {
                        $chkLabel = Html::rawElement(
                                'div',
-                               array( 'class' => 'mw-ui-checkbox' ),
+                               [ 'class' => 'mw-ui-checkbox' ],
                                $chkLabel
                        );
                }
@@ -56,13 +56,12 @@ class HTMLCheckField extends HTMLFormField {
                $attr['id'] = $this->mID;
                $attr['name'] = $this->mName;
 
-               $attr += $this->getAttributes(
-                       array( 'disabled', 'tabindex' ),
-                       array( 'tabindex' => 'tabIndex' )
+               $attr += OOUI\Element::configFromHtmlAttributes(
+                       $this->getAttributes( [ 'disabled', 'tabindex' ] )
                );
 
                if ( $this->mClass !== '' ) {
-                       $attr['classes'] = array( $this->mClass );
+                       $attr['classes'] = [ $this->mClass ];
                }
 
                $attr['selected'] = $value;
@@ -112,21 +111,21 @@ class HTMLCheckField extends HTMLFormField {
        /**
         * @param WebRequest $request
         *
-        * @return string
+        * @return bool
         */
        function loadDataFromRequest( $request ) {
                $invert = isset( $this->mParams['invert'] ) && $this->mParams['invert'];
 
                // GetCheck won't work like we want for checks.
                // Fetch the value in either one of the two following case:
-               // - we have a valid token (form got posted or GET forged by the user)
+               // - we have a valid submit attempt (form was just submitted, or a GET URL forged by the user)
                // - checkbox name has a value (false or true), ie is not null
-               if ( $request->getCheck( 'wpEditToken' ) || $request->getVal( $this->mName ) !== null ) {
+               if ( $this->isSubmitAttempt( $request ) || $request->getVal( $this->mName ) !== null ) {
                        return $invert
                                ? !$request->getBool( $this->mName )
                                : $request->getBool( $this->mName );
                } else {
-                       return $this->getDefault();
+                       return (bool)$this->getDefault();
                }
        }
 }