Completed
Push — master ( 4b29a6...089279 )
by
unknown
15s
created
SemanticFormsSelect.hooks.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -16,20 +16,20 @@  discard block
 block discarded – undo
16 16
 	 * @param $parser Parser
17 17
 	 * @return bool
18 18
 	 */
19
-	public static function onSemanticFormsSelectSetup ( & $parser ) {
20
-		if ( !defined( 'PF_VERSION' ) ) {
21
-			die( '<b>Error:</b><a href="https://github.com/SemanticMediaWiki/SemanticFormsSelect/">Semantic Forms Select</a> requires the <a href="https://www.mediawiki.org/wiki/Extension:PageForms">Page Forms</a> extension. Please install and activate this extension first.' );
19
+	public static function onSemanticFormsSelectSetup(& $parser) {
20
+		if (!defined('PF_VERSION')) {
21
+			die('<b>Error:</b><a href="https://github.com/SemanticMediaWiki/SemanticFormsSelect/">Semantic Forms Select</a> requires the <a href="https://www.mediawiki.org/wiki/Extension:PageForms">Page Forms</a> extension. Please install and activate this extension first.');
22 22
 		}
23 23
 
24
-		if ( isset( $GLOBALS['wgPageFormsFormPrinter'] ) ) {
25
-			$GLOBALS['wgPageFormsFormPrinter']->registerInputType( \SFS\SemanticFormsSelectInput::class );
24
+		if (isset($GLOBALS['wgPageFormsFormPrinter'])) {
25
+			$GLOBALS['wgPageFormsFormPrinter']->registerInputType(\SFS\SemanticFormsSelectInput::class);
26 26
 		}
27 27
 
28 28
 		return true;
29 29
 	}
30 30
 
31 31
 	public static function onRegistration() {
32
-		if ( isset( $GLOBALS['wgAPIModules'] ) ) {
32
+		if (isset($GLOBALS['wgAPIModules'])) {
33 33
 			$GLOBALS['wgAPIModules']['sformsselect'] = \SFS\ApiSemanticFormsSelect::class;
34 34
 		}
35 35
 	}
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 * Hook: ResourceLoaderTestModules
39 39
 	 * @param array &$modules
40 40
 	 */
41
-	public static function onResourceLoaderTestModules( array &$modules ) {
41
+	public static function onResourceLoaderTestModules(array &$modules) {
42 42
 		$modules['qunit']['ext.sfs.unit'] = [
43 43
 			'scripts' => [
44 44
 				'res/sfs.js',
Please login to merge, or discard this patch.
src/ApiSemanticFormsSelectRequestProcessor.php 2 patches
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	 * @since 1.3
37 37
 	 *
38 38
 	 */
39
-	public function __construct( Parser $parser, $getSmwResultFromFunctionParams = null ) {
39
+	public function __construct(Parser $parser, $getSmwResultFromFunctionParams = null) {
40 40
 		$this->parser = $parser;
41 41
 		$this->getSmwResultFromFunctionParams = $getSmwResultFromFunctionParams
42 42
 			?? '\SFS\ApiSemanticFormsSelectRequestProcessor::defaultGetSmwResultFromFunctionParams';
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 *
48 48
 	 * @param boolean $debugFlag
49 49
 	 */
50
-	public function setDebugFlag( $debugFlag ) {
50
+	public function setDebugFlag($debugFlag) {
51 51
 		$this->debugFlag = $debugFlag;
52 52
 	}
53 53
 
@@ -58,106 +58,106 @@  discard block
 block discarded – undo
58 58
 	 *
59 59
 	 * @return string
60 60
 	 */
61
-	public function getJsonDecodedResultValuesForRequestParameters( array $parameters ) {
61
+	public function getJsonDecodedResultValuesForRequestParameters(array $parameters) {
62 62
 
63
-		if ( !isset( $parameters['query'] ) || !isset( $parameters['sep'] ) ) {
64
-			throw new InvalidArgumentException( 'Missing an query parameter' );
63
+		if (!isset($parameters['query']) || !isset($parameters['sep'])) {
64
+			throw new InvalidArgumentException('Missing an query parameter');
65 65
 		}
66 66
 
67 67
 		$this->parser->firstCallInit();
68 68
 		$json = [];
69 69
 
70
-		if ( isset( $parameters['approach'] ) && $parameters['approach'] == 'smw' ) {
71
-			$json = $this->doProcessQueryFor( $parameters['query'], $parameters['sep'] );
70
+		if (isset($parameters['approach']) && $parameters['approach'] == 'smw') {
71
+			$json = $this->doProcessQueryFor($parameters['query'], $parameters['sep']);
72 72
 		} else {
73
-			$json = $this->doProcessFunctionFor( $parameters['query'], $parameters['sep'] );
73
+			$json = $this->doProcessFunctionFor($parameters['query'], $parameters['sep']);
74 74
 		}
75 75
 
76 76
 		// I have no idea why we first encode and and then decode here??
77 77
 
78
-		return json_decode( $json );
78
+		return json_decode($json);
79 79
 	}
80 80
 
81
-	private function doProcessQueryFor( $querystr, $sep = "," ) {
81
+	private function doProcessQueryFor($querystr, $sep = ",") {
82 82
 
83 83
 		$querystr = str_replace(
84
-			[ "&lt;", "&gt;", "sep=;" ],
85
-			[ "<", ">", "sep={$sep};" ],
84
+			["&lt;", "&gt;", "sep=;"],
85
+			["<", ">", "sep={$sep};"],
86 86
 			$querystr
87 87
 		);
88 88
 
89
-		$rawparams = $this->extractRawParameters( $querystr );
90
-		$f = str_replace( ";", "|", $rawparams[0] );
91
-		$rawparams[0] = $this->parser->replaceVariables( $f );
89
+		$rawparams = $this->extractRawParameters($querystr);
90
+		$f = str_replace(";", "|", $rawparams[0]);
91
+		$rawparams[0] = $this->parser->replaceVariables($f);
92 92
 
93
-		if ( $this->debugFlag ) {
94
-			error_log( implode( "|", $rawparams ) );
93
+		if ($this->debugFlag) {
94
+			error_log(implode("|", $rawparams));
95 95
 		}
96 96
 
97 97
 		$result = ($this->getSmwResultFromFunctionParams)($rawparams);
98 98
 
99
-		$values = $this->getFormattedValuesFrom( $sep, $result );
99
+		$values = $this->getFormattedValuesFrom($sep, $result);
100 100
 
101
-		return json_encode( [
101
+		return json_encode([
102 102
 			"values" => $values,
103
-			"count"  => count( $values )
104
-		] );
103
+			"count"  => count($values)
104
+		]);
105 105
 	}
106 106
 
107
-	private function extractRawParameters( $querystr ) {
107
+	private function extractRawParameters($querystr) {
108 108
 		$ensureParameter = function($name, $value) use (&$rawparams) {
109 109
 			$rawparams = array_filter($rawparams, function($param) use ($name) {
110
-				return substr_compare( $param, "$name=", 0, strlen( "$name=" ) ) !== 0;
110
+				return substr_compare($param, "$name=", 0, strlen("$name=")) !== 0;
111 111
 			});
112 112
 			if ($value !== null)
113 113
 				$rawparams[] = "$name=$value";
114 114
 		};
115 115
 
116
-		$rawparams = explode( ";", $querystr );
116
+		$rawparams = explode(";", $querystr);
117 117
 		// The JavaScript part expects plainlist format for parsing
118 118
 		$ensureParameter('format', 'plainlist');
119 119
 
120 120
 		return $rawparams;
121 121
 	}
122 122
 
123
-	private function doProcessFunctionFor( $query, $sep = "," ) {
123
+	private function doProcessFunctionFor($query, $sep = ",") {
124 124
 
125 125
 		$query = str_replace(
126
-			[ "&lt;", "&gt;", "sep=;" ],
127
-			[ "<", ">", "sep={$sep};" ],
126
+			["&lt;", "&gt;", "sep=;"],
127
+			["<", ">", "sep={$sep};"],
128 128
 			$query
129 129
 		);
130 130
 
131
-		$f = str_replace( ";", "|", $query );
131
+		$f = str_replace(";", "|", $query);
132 132
 
133
-		if ( $this->debugFlag ) {
134
-			error_log( $f );
133
+		if ($this->debugFlag) {
134
+			error_log($f);
135 135
 		}
136 136
 
137 137
 		$values = $this->getFormattedValuesFrom(
138 138
 			$sep,
139
-			$this->parser->replaceVariables( $f )
139
+			$this->parser->replaceVariables($f)
140 140
 		);
141 141
 
142
-		return json_encode( [
142
+		return json_encode([
143 143
 			"values" => $values,
144
-			"count"  => count( $values )
145
-		] );
144
+			"count"  => count($values)
145
+		]);
146 146
 	}
147 147
 
148
-	private function getFormattedValuesFrom( $sep, $values ) {
148
+	private function getFormattedValuesFrom($sep, $values) {
149 149
 
150
-		if ( strpos( $values, $sep ) === false ) {
151
-			return [ $values ];
150
+		if (strpos($values, $sep) === false) {
151
+			return [$values];
152 152
 		}
153 153
 
154
-		$values = explode( $sep, $values );
155
-		$values = array_map( "trim", $values );
156
-		$values = array_unique( $values );
154
+		$values = explode($sep, $values);
155
+		$values = array_map("trim", $values);
156
+		$values = array_unique($values);
157 157
 
158 158
 		// TODO: sorting here will destroy any sort defined in the query, e.g. in case sorting for labels (instead of mainlable)
159 159
 		//sort( $values );
160
-		array_unshift( $values, "" );
160
+		array_unshift($values, "");
161 161
 
162 162
 		return $values;
163 163
 	}
@@ -166,14 +166,14 @@  discard block
 block discarded – undo
166 166
 	 * @param $rawparams
167 167
 	 * @return string
168 168
 	 */
169
-	private static function defaultGetSmwResultFromFunctionParams( $rawparams ): string {
170
-		list( $query, $params ) =
171
-			SMWQueryProcessor::getQueryAndParamsFromFunctionParams( $rawparams, SMW_OUTPUT_WIKI,
172
-				SMWQueryProcessor::INLINE_QUERY, false );
169
+	private static function defaultGetSmwResultFromFunctionParams($rawparams): string {
170
+		list($query, $params) =
171
+			SMWQueryProcessor::getQueryAndParamsFromFunctionParams($rawparams, SMW_OUTPUT_WIKI,
172
+				SMWQueryProcessor::INLINE_QUERY, false);
173 173
 
174 174
 		$result =
175
-			SMWQueryProcessor::getResultFromQuery( $query, $params, SMW_OUTPUT_WIKI,
176
-				SMWQueryProcessor::INLINE_QUERY );
175
+			SMWQueryProcessor::getResultFromQuery($query, $params, SMW_OUTPUT_WIKI,
176
+				SMWQueryProcessor::INLINE_QUERY);
177 177
 
178 178
 		return $result;
179 179
 	}
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -109,8 +109,9 @@
 block discarded – undo
109 109
 			$rawparams = array_filter($rawparams, function($param) use ($name) {
110 110
 				return substr_compare( $param, "$name=", 0, strlen( "$name=" ) ) !== 0;
111 111
 			});
112
-			if ($value !== null)
113
-				$rawparams[] = "$name=$value";
112
+			if ($value !== null) {
113
+							$rawparams[] = "$name=$value";
114
+			}
114 115
 		};
115 116
 
116 117
 		$rawparams = explode( ";", $querystr );
Please login to merge, or discard this patch.
src/ApiSemanticFormsSelect.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -27,17 +27,17 @@  discard block
 block discarded – undo
27 27
 	public function execute() {
28 28
 		$parser = $this->getParser();
29 29
 
30
-		$apiRequestProcessor = new \SFS\ApiSemanticFormsSelectRequestProcessor( $parser );
31
-		$apiRequestProcessor->setDebugFlag( $GLOBALS['wgSF_Select_debug'] );
30
+		$apiRequestProcessor = new \SFS\ApiSemanticFormsSelectRequestProcessor($parser);
31
+		$apiRequestProcessor->setDebugFlag($GLOBALS['wgSF_Select_debug']);
32 32
 
33 33
 		$resultValues = $apiRequestProcessor->getJsonDecodedResultValuesForRequestParameters(
34 34
 			$this->extractRequestParams()
35 35
 		);
36 36
 
37 37
 		$result = $this->getResult();
38
-		$result->setIndexedTagName( $resultValues->values, 'value' );
39
-		$result->addValue( $this->getModuleName(), 'values', $resultValues->values );
40
-		$result->addValue( $this->getModuleName(), 'count', $resultValues->count );
38
+		$result->setIndexedTagName($resultValues->values, 'value');
39
+		$result->addValue($this->getModuleName(), 'values', $resultValues->values);
40
+		$result->addValue($this->getModuleName(), 'count', $resultValues->count);
41 41
 
42 42
 		return true;
43 43
 	}
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 * @see ApiBase::getVersion
86 86
 	 */
87 87
 	public function getVersion() {
88
-		return __CLASS__ . ': 1.1';
88
+		return __CLASS__.': 1.1';
89 89
 	}
90 90
 
91 91
 	/**
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
 	 */
94 94
 	protected function getParser(): Parser {
95 95
 		$parser = MediaWikiServices::getInstance()->getParserFactory()->create();
96
-		$parser->setTitle( Title::newFromText( 'NO TITLE' ) );
97
-		$parser->setOptions( new ParserOptions() );
96
+		$parser->setTitle(Title::newFromText('NO TITLE'));
97
+		$parser->setOptions(new ParserOptions());
98 98
 		$parser->resetOutput();
99 99
 
100 100
 		return $parser;
Please login to merge, or discard this patch.
src/SemanticFormsSelectInput.php 1 patch
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -28,12 +28,12 @@  discard block
 block discarded – undo
28 28
 
29 29
 	private $mSelectField;
30 30
 
31
-	public function __construct( $inputNumber, $curValue, $inputName, $disabled, $otherArgs ) {
32
-		parent::__construct( $inputNumber, $curValue, $inputName, $disabled, $otherArgs );
31
+	public function __construct($inputNumber, $curValue, $inputName, $disabled, $otherArgs) {
32
+		parent::__construct($inputNumber, $curValue, $inputName, $disabled, $otherArgs);
33 33
 
34 34
 		// SelectField is a simple value object - we accept creating it in the constructor
35 35
 		$parser = MediaWikiServices::getInstance()->getParser();
36
-		$this->mSelectField = new SelectField( $parser );
36
+		$this->mSelectField = new SelectField($parser);
37 37
 	}
38 38
 
39 39
 	public static function getName() {
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	}
47 47
 
48 48
 	public function getResourceModuleNames() {
49
-		return [ 'ext.sfs' ];
49
+		return ['ext.sfs'];
50 50
 	}
51 51
 
52 52
 	/**
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
 	 * This is currently just a wrapper for getHTML().
55 55
 	 */
56 56
 	public function getHtmlText() {
57
-		return self::getHTML( $this->mCurrentValue, $this->mInputName, $this->mIsMandatory, $this->mIsDisabled,
58
-			$this->mOtherArgs );
57
+		return self::getHTML($this->mCurrentValue, $this->mInputName, $this->mIsMandatory, $this->mIsDisabled,
58
+			$this->mOtherArgs);
59 59
 	}
60 60
 
61 61
 	/**
@@ -69,35 +69,35 @@  discard block
 block discarded – undo
69 69
 	 * @param    string[] $other_args Array of other field parameters
70 70
 	 * @return string
71 71
 	 */
72
-	public function getHTML( $cur_value = "", $input_name = "", $is_mandatory, $is_disabled, Array $other_args ) {
72
+	public function getHTML($cur_value = "", $input_name = "", $is_mandatory, $is_disabled, Array $other_args) {
73 73
 		global $wgPageFormsFieldNum, $wgUser;
74 74
 
75 75
 		// shortcut to the SelectField object
76 76
 		$selectField = $this->mSelectField;
77 77
 
78 78
 		// get 'delimiter' before 'query' or 'function'
79
-		$selectField->setDelimiter( $other_args );
79
+		$selectField->setDelimiter($other_args);
80 80
 
81
-		if ( array_key_exists( "query", $other_args ) ) {
82
-			$selectField->setQuery( $other_args );
83
-		} elseif ( array_key_exists( "function", $other_args ) ) {
84
-			$selectField->setFunction( $other_args );
81
+		if (array_key_exists("query", $other_args)) {
82
+			$selectField->setQuery($other_args);
83
+		} elseif (array_key_exists("function", $other_args)) {
84
+			$selectField->setFunction($other_args);
85 85
 		}
86 86
 
87
-		if ( array_key_exists( "label", $other_args ) ) {
88
-			$selectField->setLabel( $other_args );
87
+		if (array_key_exists("label", $other_args)) {
88
+			$selectField->setLabel($other_args);
89 89
 		}
90 90
 
91 91
 		// parameters are only required if values needs to be retrieved dynamically
92
-		if ( !$selectField->hasStaticValues() ) {
93
-			$selectField->setSelectIsMultiple( $other_args );
94
-			$selectField->setSelectTemplate( $input_name );
95
-			$selectField->setSelectField( $input_name );
96
-			$selectField->setValueTemplate( $other_args );
97
-			$selectField->setValueField( $other_args );
98
-			$selectField->setSelectRemove( $other_args );
99
-
100
-			$item = Output::addToHeadItem( $selectField->getData() );
92
+		if (!$selectField->hasStaticValues()) {
93
+			$selectField->setSelectIsMultiple($other_args);
94
+			$selectField->setSelectTemplate($input_name);
95
+			$selectField->setSelectField($input_name);
96
+			$selectField->setValueTemplate($other_args);
97
+			$selectField->setValueField($other_args);
98
+			$selectField->setSelectRemove($other_args);
99
+
100
+			$item = Output::addToHeadItem($selectField->getData());
101 101
 		}
102 102
 
103 103
 		Output::commitToParserOutput();
@@ -107,51 +107,51 @@  discard block
 block discarded – undo
107 107
 		$extraatt = "";
108 108
 		$is_list = false;
109 109
 
110
-		if ( array_key_exists( 'is_list', $other_args ) && $other_args['is_list'] == true ) {
110
+		if (array_key_exists('is_list', $other_args) && $other_args['is_list'] == true) {
111 111
 			$is_list = true;
112 112
 		}
113 113
 
114
-		if ( $is_list ) {
114
+		if ($is_list) {
115 115
 			$extraatt = ' multiple="multiple" ';
116 116
 		}
117 117
 
118
-		if ( array_key_exists( "size", $other_args ) ) {
118
+		if (array_key_exists("size", $other_args)) {
119 119
 			$extraatt .= " size=\"{$other_args['size']}\"";
120 120
 		}
121 121
 
122 122
 		$classes = [];
123
-		if ( $is_mandatory ) {
123
+		if ($is_mandatory) {
124 124
 			$classes[] = "mandatoryField";
125 125
 		}
126
-		if ( array_key_exists( "class", $other_args ) ) {
126
+		if (array_key_exists("class", $other_args)) {
127 127
 			$classes[] = $other_args['class'];
128 128
 		}
129
-		if ( $classes ) {
130
-			$cstr = implode( " ", $classes );
129
+		if ($classes) {
130
+			$cstr = implode(" ", $classes);
131 131
 			$extraatt .= " class=\"$cstr\"";
132 132
 		}
133 133
 
134 134
 		$inname = $input_name;
135
-		if ( $is_list ) {
135
+		if ($is_list) {
136 136
 			$inname .= '[]';
137 137
 		}
138 138
 
139 139
 		// TODO Use Html::
140 140
 
141 141
 		$spanextra = $is_mandatory ? 'mandatoryFieldSpan' : '';
142
-		$is_single_select = (!$is_list) ? 'select-sfs-single' : '' ;
142
+		$is_single_select = (!$is_list) ? 'select-sfs-single' : '';
143 143
 		$ret = "<span class=\"inputSpan select-sfs $is_single_select $spanextra\"><select name='$inname' id='input_$wgPageFormsFieldNum' $extraatt>";
144 144
 
145 145
 		$curvalues = null;
146
-		if ( $cur_value ) {
147
-			if ( $cur_value === 'current user' ) {
146
+		if ($cur_value) {
147
+			if ($cur_value === 'current user') {
148 148
 				$cur_value = $wgUser->getName();
149 149
 			}
150
-			if ( is_array( $cur_value ) ) {
150
+			if (is_array($cur_value)) {
151 151
 				$curvalues = $cur_value;
152 152
 			} else {
153 153
 				// delimiter for $cur_value is always ',' - PF seems to ignore $wgPageFormsListSeparator
154
-				$curvalues = array_map( "trim", explode( $selectField->getDelimiter(), $cur_value ) );
154
+				$curvalues = array_map("trim", explode($selectField->getDelimiter(), $cur_value));
155 155
 			}
156 156
 
157 157
 		} else {
@@ -160,38 +160,38 @@  discard block
 block discarded – undo
160 160
 
161 161
 
162 162
 		$labelArray = [];
163
-		if ( array_key_exists( "label", $other_args ) && $curvalues ) {
163
+		if (array_key_exists("label", $other_args) && $curvalues) {
164 164
 			// $labelArray = $this->getLabels( $curvalues );
165 165
 		}
166 166
 
167 167
 		// TODO handle empty value case.
168 168
 		$ret .= "<option></option>";
169 169
 
170
-		if ( $selectField->hasStaticValues() ) {
170
+		if ($selectField->hasStaticValues()) {
171 171
 
172 172
 			$values = $selectField->getValues();
173 173
 
174
-			if ( array_key_exists( "label", $other_args ) && $values ) {
175
-				$labelArray = $this->getLabels( $values );
174
+			if (array_key_exists("label", $other_args) && $values) {
175
+				$labelArray = $this->getLabels($values);
176 176
 			}
177 177
 
178
-			if ( is_array( $values ) ) {
178
+			if (is_array($values)) {
179 179
 
180
-				foreach ( $values as $val ) {
180
+				foreach ($values as $val) {
181 181
 
182 182
 					$selected = "";
183 183
 
184
-					if ( array_key_exists( $val, $labelArray ) ) {
184
+					if (array_key_exists($val, $labelArray)) {
185 185
 
186
-						if ( in_array( $labelArray[ $val ][0], $curvalues ) ) {
186
+						if (in_array($labelArray[$val][0], $curvalues)) {
187 187
 							$selected = " selected='selected'";
188 188
 						}
189 189
 
190
-						$ret.="<option".$selected." value='".$labelArray[ $val ][0]."'>".$labelArray[ $val ][1]."</option>";
190
+						$ret .= "<option".$selected." value='".$labelArray[$val][0]."'>".$labelArray[$val][1]."</option>";
191 191
 
192 192
 					} else {
193 193
 
194
-						if ( in_array( $val, $curvalues ) ) {
194
+						if (in_array($val, $curvalues)) {
195 195
 							$selected = " selected='selected'";
196 196
 						}
197 197
 
@@ -201,22 +201,22 @@  discard block
 block discarded – undo
201 201
 			}
202 202
 		} else {
203 203
 
204
-			foreach ( $curvalues as $cur ) {
204
+			foreach ($curvalues as $cur) {
205 205
 				$selected = "";
206 206
 
207
-				if ( array_key_exists( $cur, $labelArray ) ) {
207
+				if (array_key_exists($cur, $labelArray)) {
208 208
 
209
-					if ( in_array( $labelArray[ $cur ][0], $curvalues ) ) {
209
+					if (in_array($labelArray[$cur][0], $curvalues)) {
210 210
 						$selected = " selected='selected'";
211 211
 					}
212 212
 
213
-					$ret.="<option".$selected." value='".$labelArray[ $cur ][0]."'>".$labelArray[ $cur ][1]."</option>";
213
+					$ret .= "<option".$selected." value='".$labelArray[$cur][0]."'>".$labelArray[$cur][1]."</option>";
214 214
 
215 215
 				} else {
216
-					if ( in_array( $cur, $curvalues ) ) {
216
+					if (in_array($cur, $curvalues)) {
217 217
 						$selected = " selected='selected'";
218 218
 					}
219
-					$ret.="<option".$selected.">$cur</option>";
219
+					$ret .= "<option".$selected.">$cur</option>";
220 220
 				}
221 221
 			}
222 222
 
@@ -225,8 +225,8 @@  discard block
 block discarded – undo
225 225
 		$ret .= "</select></span>";
226 226
 		$ret .= "<span id=\"info_$wgPageFormsFieldNum\" class=\"errorMessage\"></span>";
227 227
 
228
-		if ( $other_args["is_list"] ) {
229
-			$hiddenname = $input_name . '[is_list]';
228
+		if ($other_args["is_list"]) {
229
+			$hiddenname = $input_name.'[is_list]';
230 230
 			$ret .= "<input type='hidden' name='$hiddenname' value='1' />";
231 231
 		}
232 232
 
@@ -234,49 +234,49 @@  discard block
 block discarded – undo
234 234
 	}
235 235
 
236 236
 
237
-	private function getLabels( $labels ) {
237
+	private function getLabels($labels) {
238 238
 
239
-		$labelArray = [ ];
239
+		$labelArray = [];
240 240
 
241
-		if ( is_array( $labels ) ) {
242
-			foreach ( $labels as $label ) {
241
+		if (is_array($labels)) {
242
+			foreach ($labels as $label) {
243 243
 
244 244
 				$labelKey = $label;
245 245
 				$labelValue = $label;
246 246
 
247 247
 				// Tricky thing if ( ) already in name
248
-				if ( strpos( $label, ")" ) && strpos( $label, "(" ) ) {
248
+				if (strpos($label, ")") && strpos($label, "(")) {
249 249
 
250 250
 					// Check Break
251 251
 					$openBr = 0;
252 252
 					$doneBr = 0;
253 253
 					$num = 0;
254 254
 
255
-					$labelArr = str_split ( $label );
255
+					$labelArr = str_split($label);
256 256
 
257
-					$end = count( $labelArr ) - 1;
257
+					$end = count($labelArr) - 1;
258 258
 					$iter = $end;
259 259
 
260 260
 					$endBr = $end;
261 261
 					$startBr = 0;
262 262
 
263
-					while ( $doneBr == 0 && $iter >= 0 ) {
263
+					while ($doneBr == 0 && $iter >= 0) {
264 264
 
265
-						$char = $labelArr[ $iter ];
265
+						$char = $labelArr[$iter];
266 266
 
267
-						if ( $char == ")" ) {
267
+						if ($char == ")") {
268 268
 							$openBr = $openBr - 1;
269 269
 
270
-							if ( $num == 0 ) {
270
+							if ($num == 0) {
271 271
 								$endBr = $iter;
272 272
 								$num = $num + 1;
273 273
 							}
274 274
 						}
275 275
 
276
-						if ( $char == "(" ) {
276
+						if ($char == "(") {
277 277
 							$openBr = $openBr + 1;
278 278
 
279
-							if ( $num > 0 && $openBr == 0 ) {
279
+							if ($num > 0 && $openBr == 0) {
280 280
 								$startBr = $iter;
281 281
 								$doneBr = 1;
282 282
 							}
@@ -286,12 +286,12 @@  discard block
 block discarded – undo
286 286
 
287 287
 					}
288 288
 
289
-					$labelValue = implode( "", array_slice( $labelArr, $startBr+1, $endBr-$startBr-1 ) );
290
-					$labelKey = implode( "", array_slice( $labelArr, 0, $startBr-1 ) );
289
+					$labelValue = implode("", array_slice($labelArr, $startBr + 1, $endBr - $startBr - 1));
290
+					$labelKey = implode("", array_slice($labelArr, 0, $startBr - 1));
291 291
 
292 292
 				}
293 293
 
294
-				$labelArray[ $label ] = [ $labelKey, $labelValue ] ;
294
+				$labelArray[$label] = [$labelKey, $labelValue];
295 295
 			}
296 296
 
297 297
 		}
Please login to merge, or discard this patch.