From: Timo Tijhof Date: Sat, 14 Feb 2015 07:16:43 +0000 (+0000) Subject: htmlform: Simplify implementation of loadDataFromRequest() X-Git-Tag: 1.31.0-rc.0~12391^2 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=713afe45487e1b70db5fc3a17d096885b087c38c;p=lhc%2Fweb%2Fwiklou.git htmlform: Simplify implementation of loadDataFromRequest() Change-Id: I30d1c186c9e3eb67130b798af987f275316828de --- diff --git a/includes/htmlform/HTMLCheckField.php b/includes/htmlform/HTMLCheckField.php index e54f748362..4942327fc7 100644 --- a/includes/htmlform/HTMLCheckField.php +++ b/includes/htmlform/HTMLCheckField.php @@ -58,23 +58,16 @@ class HTMLCheckField extends HTMLFormField { * @return string */ function loadDataFromRequest( $request ) { - $invert = false; - if ( isset( $this->mParams['invert'] ) && $this->mParams['invert'] ) { - $invert = true; - } + $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) // - checkbox name has a value (false or true), ie is not null if ( $request->getCheck( 'wpEditToken' ) || $request->getVal( $this->mName ) !== null ) { - // XOR has the following truth table, which is what we want - // INVERT VALUE | OUTPUT - // true true | false - // false true | true - // false false | false - // true false | true - return $request->getBool( $this->mName ) xor $invert; + return $invert + ? !$request->getBool( $this->mName ) + : $request->getBool( $this->mName ); } else { return $this->getDefault(); }