Completed
Branch FIX/fix-datetime-picker-styles (49553a)
by
unknown
43:56 queued 35:31
created
libraries/form_sections/inputs/EE_Form_Input_With_Options_Base.input.php 2 patches
Indentation   +317 added lines, -317 removed lines patch added patch discarded remove patch
@@ -11,321 +11,321 @@
 block discarded – undo
11 11
 class EE_Form_Input_With_Options_Base extends EE_Form_Input_Base
12 12
 {
13 13
 
14
-    /**
15
-     * array of available options to choose as an answer
16
-     *
17
-     * @var array
18
-     */
19
-    protected $_options = array();
20
-
21
-    /**
22
-     * whether to display the html_label_text above the checkbox/radio button options
23
-     *
24
-     * @var boolean
25
-     */
26
-    protected $_display_html_label_text = true;
27
-
28
-    /**
29
-     * whether to display an question option description as part of the input label
30
-     *
31
-     * @var boolean
32
-     */
33
-    protected $_use_desc_in_label = true;
34
-
35
-    /**
36
-     * strlen() result for the longest input value (what gets displayed in the label)
37
-     * this is used to apply a css class to the input label
38
-     *
39
-     * @var int
40
-     */
41
-    protected $_label_size = 0;
42
-
43
-    /**
44
-     * whether to enforce the label size value passed in the constructor
45
-     *
46
-     * @var boolean
47
-     */
48
-    protected $_enforce_label_size = false;
49
-
50
-    /**
51
-     * whether to allow multiple selections (ie, the value of this input should be an array)
52
-     * or not (ie, the value should be a simple int, string, etc)
53
-     *
54
-     * @var boolean
55
-     */
56
-    protected $_multiple_selections = false;
57
-
58
-
59
-
60
-    /**
61
-     * @param array     $answer_options
62
-     * @param array     $input_settings {
63
-     * @type int|string $label_size
64
-     * @type boolean    $display_html_label_text
65
-     *                                  }
66
-     *                                  And all the options accepted by EE_Form_Input_Base
67
-     */
68
-    public function __construct($answer_options = array(), $input_settings = array())
69
-    {
70
-        if (isset($input_settings['label_size'])) {
71
-            $this->_set_label_size($input_settings['label_size']);
72
-            if (isset($input_settings['enforce_label_size']) && $input_settings['enforce_label_size']) {
73
-                $this->_enforce_label_size = true;
74
-            }
75
-        }
76
-        if (isset($input_settings['display_html_label_text'])) {
77
-            $this->set_display_html_label_text($input_settings['display_html_label_text']);
78
-        }
79
-        $this->set_select_options($answer_options);
80
-        parent::__construct($input_settings);
81
-    }
82
-
83
-
84
-
85
-    /**
86
-     * Sets the allowed options for this input. Also has the side-effect of
87
-     * updating the normalization strategy to match the keys provided in the array
88
-     *
89
-     * @param array $answer_options
90
-     * @return void  just has the side-effect of setting the options for this input
91
-     */
92
-    public function set_select_options($answer_options = array())
93
-    {
94
-        $answer_options = is_array($answer_options) ? $answer_options : array($answer_options);
95
-        // get the first item in the select options and check it's type
96
-        $this->_options = reset($answer_options) instanceof EE_Question_Option
97
-            ? $this->_process_question_options($answer_options)
98
-            : $answer_options;
99
-        // d( $this->_options );
100
-        $select_option_keys = array_keys($this->_options);
101
-        // attempt to determine data type for values in order to set normalization type
102
-        // purposefully only
103
-        if (count($this->_options) === 2
104
-            && (
105
-                (in_array(true, $select_option_keys, true) && in_array(false, $select_option_keys, true))
106
-                || (in_array(1, $select_option_keys, true) && in_array(0, $select_option_keys, true))
107
-            )
108
-        ) {
109
-            // values appear to be boolean, like TRUE, FALSE, 1, 0
110
-            $normalization = new EE_Boolean_Normalization();
111
-        } else {
112
-            // are ALL the options ints (even if we're using a multi-dimensional array)? If so use int validation
113
-            $all_ints = true;
114
-            array_walk_recursive(
115
-                $this->_options,
116
-                function ($value, $key) use (&$all_ints) {
117
-                    // is this a top-level key? ignore it
118
-                    if (! is_array($value)
119
-                        && ! is_int($key)
120
-                       && $key !== ''
121
-                       && $key !== null) {
122
-                        $all_ints = false;
123
-                    }
124
-                }
125
-            );
126
-            if ($all_ints) {
127
-                $normalization = new EE_Int_Normalization();
128
-            } else {
129
-                $normalization = new EE_Text_Normalization();
130
-            }
131
-        }
132
-        // does input type have multiple options ?
133
-        if ($this->_multiple_selections) {
134
-            $this->_set_normalization_strategy(new EE_Many_Valued_Normalization($normalization));
135
-        } else {
136
-            $this->_set_normalization_strategy($normalization);
137
-        }
138
-    }
139
-
140
-
141
-
142
-    /**
143
-     * @return array
144
-     */
145
-    public function options()
146
-    {
147
-        return $this->_options;
148
-    }
149
-
150
-
151
-
152
-    /**
153
-     * Returns an array which is guaranteed to not be multidimensional
154
-     *
155
-     * @return array
156
-     */
157
-    public function flat_options()
158
-    {
159
-        return $this->_flatten_select_options($this->options());
160
-    }
161
-
162
-
163
-
164
-    /**
165
-     * Makes sure $arr is a flat array, not a multidimensional one
166
-     *
167
-     * @param array $arr
168
-     * @return array
169
-     */
170
-    protected function _flatten_select_options($arr)
171
-    {
172
-        $flat_array = array();
173
-        if (EEH_Array::is_multi_dimensional_array($arr)) {
174
-            foreach ($arr as $sub_array) {
175
-                foreach ((array) $sub_array as $key => $value) {
176
-                    $flat_array[ $key ] = $value;
177
-                    $this->_set_label_size($value);
178
-                }
179
-            }
180
-        } else {
181
-            foreach ($arr as $key => $value) {
182
-                $flat_array[ $key ] = $value;
183
-                $this->_set_label_size($value);
184
-            }
185
-        }
186
-        return $flat_array;
187
-    }
188
-
189
-
190
-
191
-    /**
192
-     * @param EE_Question_Option[] $question_options_array
193
-     * @return array
194
-     */
195
-    protected function _process_question_options($question_options_array = array())
196
-    {
197
-        $flat_array = array();
198
-        foreach ($question_options_array as $question_option) {
199
-            if ($question_option instanceof EE_Question_Option) {
200
-                $desc = '';
201
-                if ($this->_use_desc_in_label) {
202
-                    $desc = $question_option->desc();
203
-                    $desc = ! empty($desc) ? '<span class="ee-question-option-desc">' . $desc . '</span>' : '';
204
-                }
205
-                $value = $question_option->value();
206
-                // add value even if it's empty
207
-                $flat_array[ $value ] = $value;
208
-                // if both value and desc are not empty, then separate with a dash
209
-                if (! empty($value) && ! empty($desc)) {
210
-                    $flat_array[ $value ] .= ' - ' . $desc;
211
-                } else {
212
-                    // otherwise, just add desc, since either or both of the vars is empty, and no dash is necessary
213
-                    $flat_array[ $value ] .= $desc;
214
-                }
215
-            } elseif (is_array($question_option)) {
216
-                $flat_array += $this->_flatten_select_options($question_option);
217
-            }
218
-        }
219
-        return $flat_array;
220
-    }
221
-
222
-
223
-
224
-    /**
225
-     *    set_label_sizes
226
-     *
227
-     * @return void
228
-     */
229
-    public function set_label_sizes()
230
-    {
231
-        // did the input settings specifically say to NOT set the label size dynamically ?
232
-        if (! $this->_enforce_label_size) {
233
-            foreach ($this->_options as $option) {
234
-                // calculate the strlen of the label
235
-                $this->_set_label_size($option);
236
-            }
237
-        }
238
-    }
239
-
240
-
241
-
242
-    /**
243
-     *    _set_label_size_class
244
-     *
245
-     * @param int|string $value
246
-     * @return void
247
-     */
248
-    private function _set_label_size($value = '')
249
-    {
250
-        // don't change label size if it has already been set and is being enforced
251
-        if ($this->_enforce_label_size && $this->_label_size >  0) {
252
-            return;
253
-        }
254
-        // determine length of option value
255
-        $val_size = is_int($value) ? $value : strlen($value);
256
-        // use new value if bigger than existing
257
-        $this->_label_size = $val_size > $this->_label_size ? $val_size : $this->_label_size;
258
-    }
259
-
260
-
261
-
262
-    /**
263
-     *    get_label_size_class
264
-     *
265
-     * @return string
266
-     */
267
-    public function get_label_size_class()
268
-    {
269
-        $size = ' medium-lbl';
270
-        // use maximum option value length to determine label size
271
-        if ($this->_label_size < 3) {
272
-            $size = ' nano-lbl';
273
-        } elseif ($this->_label_size < 6) {
274
-            $size = ' micro-lbl';
275
-        } elseif ($this->_label_size < 12) {
276
-            $size = ' tiny-lbl';
277
-        } elseif ($this->_label_size < 25) {
278
-            $size = ' small-lbl';
279
-        } elseif ($this->_label_size < 50) {
280
-            $size = ' medium-lbl';
281
-        } elseif ($this->_label_size >= 100) {
282
-            $size = ' big-lbl';
283
-        }
284
-        return $size;
285
-    }
286
-
287
-
288
-
289
-    /**
290
-     * Returns the pretty value for the normalized value
291
-     *
292
-     * @return string
293
-     */
294
-    public function pretty_value()
295
-    {
296
-        $options = $this->flat_options();
297
-        $unnormalized_value_choices = $this->get_normalization_strategy()->unnormalize($this->_normalized_value);
298
-        if (! $this->_multiple_selections) {
299
-            $unnormalized_value_choices = array($unnormalized_value_choices);
300
-        }
301
-        $pretty_strings = array();
302
-        foreach ((array) $unnormalized_value_choices as $unnormalized_value_choice) {
303
-            if (isset($options[ $unnormalized_value_choice ])) {
304
-                $pretty_strings[] = $options[ $unnormalized_value_choice ];
305
-            } else {
306
-                $pretty_strings[] = $this->normalized_value();
307
-            }
308
-        }
309
-        return implode(', ', $pretty_strings);
310
-    }
311
-
312
-
313
-
314
-    /**
315
-     * @return boolean
316
-     */
317
-    public function display_html_label_text()
318
-    {
319
-        return $this->_display_html_label_text;
320
-    }
321
-
322
-
323
-
324
-    /**
325
-     * @param boolean $display_html_label_text
326
-     */
327
-    public function set_display_html_label_text($display_html_label_text)
328
-    {
329
-        $this->_display_html_label_text = filter_var($display_html_label_text, FILTER_VALIDATE_BOOLEAN);
330
-    }
14
+	/**
15
+	 * array of available options to choose as an answer
16
+	 *
17
+	 * @var array
18
+	 */
19
+	protected $_options = array();
20
+
21
+	/**
22
+	 * whether to display the html_label_text above the checkbox/radio button options
23
+	 *
24
+	 * @var boolean
25
+	 */
26
+	protected $_display_html_label_text = true;
27
+
28
+	/**
29
+	 * whether to display an question option description as part of the input label
30
+	 *
31
+	 * @var boolean
32
+	 */
33
+	protected $_use_desc_in_label = true;
34
+
35
+	/**
36
+	 * strlen() result for the longest input value (what gets displayed in the label)
37
+	 * this is used to apply a css class to the input label
38
+	 *
39
+	 * @var int
40
+	 */
41
+	protected $_label_size = 0;
42
+
43
+	/**
44
+	 * whether to enforce the label size value passed in the constructor
45
+	 *
46
+	 * @var boolean
47
+	 */
48
+	protected $_enforce_label_size = false;
49
+
50
+	/**
51
+	 * whether to allow multiple selections (ie, the value of this input should be an array)
52
+	 * or not (ie, the value should be a simple int, string, etc)
53
+	 *
54
+	 * @var boolean
55
+	 */
56
+	protected $_multiple_selections = false;
57
+
58
+
59
+
60
+	/**
61
+	 * @param array     $answer_options
62
+	 * @param array     $input_settings {
63
+	 * @type int|string $label_size
64
+	 * @type boolean    $display_html_label_text
65
+	 *                                  }
66
+	 *                                  And all the options accepted by EE_Form_Input_Base
67
+	 */
68
+	public function __construct($answer_options = array(), $input_settings = array())
69
+	{
70
+		if (isset($input_settings['label_size'])) {
71
+			$this->_set_label_size($input_settings['label_size']);
72
+			if (isset($input_settings['enforce_label_size']) && $input_settings['enforce_label_size']) {
73
+				$this->_enforce_label_size = true;
74
+			}
75
+		}
76
+		if (isset($input_settings['display_html_label_text'])) {
77
+			$this->set_display_html_label_text($input_settings['display_html_label_text']);
78
+		}
79
+		$this->set_select_options($answer_options);
80
+		parent::__construct($input_settings);
81
+	}
82
+
83
+
84
+
85
+	/**
86
+	 * Sets the allowed options for this input. Also has the side-effect of
87
+	 * updating the normalization strategy to match the keys provided in the array
88
+	 *
89
+	 * @param array $answer_options
90
+	 * @return void  just has the side-effect of setting the options for this input
91
+	 */
92
+	public function set_select_options($answer_options = array())
93
+	{
94
+		$answer_options = is_array($answer_options) ? $answer_options : array($answer_options);
95
+		// get the first item in the select options and check it's type
96
+		$this->_options = reset($answer_options) instanceof EE_Question_Option
97
+			? $this->_process_question_options($answer_options)
98
+			: $answer_options;
99
+		// d( $this->_options );
100
+		$select_option_keys = array_keys($this->_options);
101
+		// attempt to determine data type for values in order to set normalization type
102
+		// purposefully only
103
+		if (count($this->_options) === 2
104
+			&& (
105
+				(in_array(true, $select_option_keys, true) && in_array(false, $select_option_keys, true))
106
+				|| (in_array(1, $select_option_keys, true) && in_array(0, $select_option_keys, true))
107
+			)
108
+		) {
109
+			// values appear to be boolean, like TRUE, FALSE, 1, 0
110
+			$normalization = new EE_Boolean_Normalization();
111
+		} else {
112
+			// are ALL the options ints (even if we're using a multi-dimensional array)? If so use int validation
113
+			$all_ints = true;
114
+			array_walk_recursive(
115
+				$this->_options,
116
+				function ($value, $key) use (&$all_ints) {
117
+					// is this a top-level key? ignore it
118
+					if (! is_array($value)
119
+						&& ! is_int($key)
120
+					   && $key !== ''
121
+					   && $key !== null) {
122
+						$all_ints = false;
123
+					}
124
+				}
125
+			);
126
+			if ($all_ints) {
127
+				$normalization = new EE_Int_Normalization();
128
+			} else {
129
+				$normalization = new EE_Text_Normalization();
130
+			}
131
+		}
132
+		// does input type have multiple options ?
133
+		if ($this->_multiple_selections) {
134
+			$this->_set_normalization_strategy(new EE_Many_Valued_Normalization($normalization));
135
+		} else {
136
+			$this->_set_normalization_strategy($normalization);
137
+		}
138
+	}
139
+
140
+
141
+
142
+	/**
143
+	 * @return array
144
+	 */
145
+	public function options()
146
+	{
147
+		return $this->_options;
148
+	}
149
+
150
+
151
+
152
+	/**
153
+	 * Returns an array which is guaranteed to not be multidimensional
154
+	 *
155
+	 * @return array
156
+	 */
157
+	public function flat_options()
158
+	{
159
+		return $this->_flatten_select_options($this->options());
160
+	}
161
+
162
+
163
+
164
+	/**
165
+	 * Makes sure $arr is a flat array, not a multidimensional one
166
+	 *
167
+	 * @param array $arr
168
+	 * @return array
169
+	 */
170
+	protected function _flatten_select_options($arr)
171
+	{
172
+		$flat_array = array();
173
+		if (EEH_Array::is_multi_dimensional_array($arr)) {
174
+			foreach ($arr as $sub_array) {
175
+				foreach ((array) $sub_array as $key => $value) {
176
+					$flat_array[ $key ] = $value;
177
+					$this->_set_label_size($value);
178
+				}
179
+			}
180
+		} else {
181
+			foreach ($arr as $key => $value) {
182
+				$flat_array[ $key ] = $value;
183
+				$this->_set_label_size($value);
184
+			}
185
+		}
186
+		return $flat_array;
187
+	}
188
+
189
+
190
+
191
+	/**
192
+	 * @param EE_Question_Option[] $question_options_array
193
+	 * @return array
194
+	 */
195
+	protected function _process_question_options($question_options_array = array())
196
+	{
197
+		$flat_array = array();
198
+		foreach ($question_options_array as $question_option) {
199
+			if ($question_option instanceof EE_Question_Option) {
200
+				$desc = '';
201
+				if ($this->_use_desc_in_label) {
202
+					$desc = $question_option->desc();
203
+					$desc = ! empty($desc) ? '<span class="ee-question-option-desc">' . $desc . '</span>' : '';
204
+				}
205
+				$value = $question_option->value();
206
+				// add value even if it's empty
207
+				$flat_array[ $value ] = $value;
208
+				// if both value and desc are not empty, then separate with a dash
209
+				if (! empty($value) && ! empty($desc)) {
210
+					$flat_array[ $value ] .= ' - ' . $desc;
211
+				} else {
212
+					// otherwise, just add desc, since either or both of the vars is empty, and no dash is necessary
213
+					$flat_array[ $value ] .= $desc;
214
+				}
215
+			} elseif (is_array($question_option)) {
216
+				$flat_array += $this->_flatten_select_options($question_option);
217
+			}
218
+		}
219
+		return $flat_array;
220
+	}
221
+
222
+
223
+
224
+	/**
225
+	 *    set_label_sizes
226
+	 *
227
+	 * @return void
228
+	 */
229
+	public function set_label_sizes()
230
+	{
231
+		// did the input settings specifically say to NOT set the label size dynamically ?
232
+		if (! $this->_enforce_label_size) {
233
+			foreach ($this->_options as $option) {
234
+				// calculate the strlen of the label
235
+				$this->_set_label_size($option);
236
+			}
237
+		}
238
+	}
239
+
240
+
241
+
242
+	/**
243
+	 *    _set_label_size_class
244
+	 *
245
+	 * @param int|string $value
246
+	 * @return void
247
+	 */
248
+	private function _set_label_size($value = '')
249
+	{
250
+		// don't change label size if it has already been set and is being enforced
251
+		if ($this->_enforce_label_size && $this->_label_size >  0) {
252
+			return;
253
+		}
254
+		// determine length of option value
255
+		$val_size = is_int($value) ? $value : strlen($value);
256
+		// use new value if bigger than existing
257
+		$this->_label_size = $val_size > $this->_label_size ? $val_size : $this->_label_size;
258
+	}
259
+
260
+
261
+
262
+	/**
263
+	 *    get_label_size_class
264
+	 *
265
+	 * @return string
266
+	 */
267
+	public function get_label_size_class()
268
+	{
269
+		$size = ' medium-lbl';
270
+		// use maximum option value length to determine label size
271
+		if ($this->_label_size < 3) {
272
+			$size = ' nano-lbl';
273
+		} elseif ($this->_label_size < 6) {
274
+			$size = ' micro-lbl';
275
+		} elseif ($this->_label_size < 12) {
276
+			$size = ' tiny-lbl';
277
+		} elseif ($this->_label_size < 25) {
278
+			$size = ' small-lbl';
279
+		} elseif ($this->_label_size < 50) {
280
+			$size = ' medium-lbl';
281
+		} elseif ($this->_label_size >= 100) {
282
+			$size = ' big-lbl';
283
+		}
284
+		return $size;
285
+	}
286
+
287
+
288
+
289
+	/**
290
+	 * Returns the pretty value for the normalized value
291
+	 *
292
+	 * @return string
293
+	 */
294
+	public function pretty_value()
295
+	{
296
+		$options = $this->flat_options();
297
+		$unnormalized_value_choices = $this->get_normalization_strategy()->unnormalize($this->_normalized_value);
298
+		if (! $this->_multiple_selections) {
299
+			$unnormalized_value_choices = array($unnormalized_value_choices);
300
+		}
301
+		$pretty_strings = array();
302
+		foreach ((array) $unnormalized_value_choices as $unnormalized_value_choice) {
303
+			if (isset($options[ $unnormalized_value_choice ])) {
304
+				$pretty_strings[] = $options[ $unnormalized_value_choice ];
305
+			} else {
306
+				$pretty_strings[] = $this->normalized_value();
307
+			}
308
+		}
309
+		return implode(', ', $pretty_strings);
310
+	}
311
+
312
+
313
+
314
+	/**
315
+	 * @return boolean
316
+	 */
317
+	public function display_html_label_text()
318
+	{
319
+		return $this->_display_html_label_text;
320
+	}
321
+
322
+
323
+
324
+	/**
325
+	 * @param boolean $display_html_label_text
326
+	 */
327
+	public function set_display_html_label_text($display_html_label_text)
328
+	{
329
+		$this->_display_html_label_text = filter_var($display_html_label_text, FILTER_VALIDATE_BOOLEAN);
330
+	}
331 331
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
             $all_ints = true;
114 114
             array_walk_recursive(
115 115
                 $this->_options,
116
-                function ($value, $key) use (&$all_ints) {
116
+                function($value, $key) use (&$all_ints) {
117 117
                     // is this a top-level key? ignore it
118
-                    if (! is_array($value)
118
+                    if ( ! is_array($value)
119 119
                         && ! is_int($key)
120 120
                        && $key !== ''
121 121
                        && $key !== null) {
@@ -173,13 +173,13 @@  discard block
 block discarded – undo
173 173
         if (EEH_Array::is_multi_dimensional_array($arr)) {
174 174
             foreach ($arr as $sub_array) {
175 175
                 foreach ((array) $sub_array as $key => $value) {
176
-                    $flat_array[ $key ] = $value;
176
+                    $flat_array[$key] = $value;
177 177
                     $this->_set_label_size($value);
178 178
                 }
179 179
             }
180 180
         } else {
181 181
             foreach ($arr as $key => $value) {
182
-                $flat_array[ $key ] = $value;
182
+                $flat_array[$key] = $value;
183 183
                 $this->_set_label_size($value);
184 184
             }
185 185
         }
@@ -200,17 +200,17 @@  discard block
 block discarded – undo
200 200
                 $desc = '';
201 201
                 if ($this->_use_desc_in_label) {
202 202
                     $desc = $question_option->desc();
203
-                    $desc = ! empty($desc) ? '<span class="ee-question-option-desc">' . $desc . '</span>' : '';
203
+                    $desc = ! empty($desc) ? '<span class="ee-question-option-desc">'.$desc.'</span>' : '';
204 204
                 }
205 205
                 $value = $question_option->value();
206 206
                 // add value even if it's empty
207
-                $flat_array[ $value ] = $value;
207
+                $flat_array[$value] = $value;
208 208
                 // if both value and desc are not empty, then separate with a dash
209
-                if (! empty($value) && ! empty($desc)) {
210
-                    $flat_array[ $value ] .= ' - ' . $desc;
209
+                if ( ! empty($value) && ! empty($desc)) {
210
+                    $flat_array[$value] .= ' - '.$desc;
211 211
                 } else {
212 212
                     // otherwise, just add desc, since either or both of the vars is empty, and no dash is necessary
213
-                    $flat_array[ $value ] .= $desc;
213
+                    $flat_array[$value] .= $desc;
214 214
                 }
215 215
             } elseif (is_array($question_option)) {
216 216
                 $flat_array += $this->_flatten_select_options($question_option);
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
     public function set_label_sizes()
230 230
     {
231 231
         // did the input settings specifically say to NOT set the label size dynamically ?
232
-        if (! $this->_enforce_label_size) {
232
+        if ( ! $this->_enforce_label_size) {
233 233
             foreach ($this->_options as $option) {
234 234
                 // calculate the strlen of the label
235 235
                 $this->_set_label_size($option);
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
     private function _set_label_size($value = '')
249 249
     {
250 250
         // don't change label size if it has already been set and is being enforced
251
-        if ($this->_enforce_label_size && $this->_label_size >  0) {
251
+        if ($this->_enforce_label_size && $this->_label_size > 0) {
252 252
             return;
253 253
         }
254 254
         // determine length of option value
@@ -295,13 +295,13 @@  discard block
 block discarded – undo
295 295
     {
296 296
         $options = $this->flat_options();
297 297
         $unnormalized_value_choices = $this->get_normalization_strategy()->unnormalize($this->_normalized_value);
298
-        if (! $this->_multiple_selections) {
298
+        if ( ! $this->_multiple_selections) {
299 299
             $unnormalized_value_choices = array($unnormalized_value_choices);
300 300
         }
301 301
         $pretty_strings = array();
302 302
         foreach ((array) $unnormalized_value_choices as $unnormalized_value_choice) {
303
-            if (isset($options[ $unnormalized_value_choice ])) {
304
-                $pretty_strings[] = $options[ $unnormalized_value_choice ];
303
+            if (isset($options[$unnormalized_value_choice])) {
304
+                $pretty_strings[] = $options[$unnormalized_value_choice];
305 305
             } else {
306 306
                 $pretty_strings[] = $this->normalized_value();
307 307
             }
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Integer_Input.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -12,35 +12,35 @@
 block discarded – undo
12 12
 {
13 13
 
14 14
 
15
-    /**
16
-     * @param array $input_settings
17
-     */
18
-    public function __construct($input_settings = array())
19
-    {
20
-        $this->_set_display_strategy(
21
-            new EE_Number_Input_Display_Strategy(
22
-                isset($input_settings['min_value'])
23
-                    ? $input_settings['min_value']
24
-                    : null,
25
-                isset($input_settings['max_value'])
26
-                    ? $input_settings['max_value']
27
-                    : null
28
-            )
29
-        );
30
-        $this->_set_normalization_strategy(
31
-            new EE_Int_Normalization(
32
-                isset($input_settings['validation_error_message'])
33
-                    ? $input_settings['validation_error_message']
34
-                    : null
35
-            )
36
-        );
37
-        $this->_add_validation_strategy(
38
-            new EE_Int_Validation_Strategy(
39
-                isset($input_settings['validation_error_message'])
40
-                    ? $input_settings['validation_error_message']
41
-                    : null
42
-            )
43
-        );
44
-        parent::__construct($input_settings);
45
-    }
15
+	/**
16
+	 * @param array $input_settings
17
+	 */
18
+	public function __construct($input_settings = array())
19
+	{
20
+		$this->_set_display_strategy(
21
+			new EE_Number_Input_Display_Strategy(
22
+				isset($input_settings['min_value'])
23
+					? $input_settings['min_value']
24
+					: null,
25
+				isset($input_settings['max_value'])
26
+					? $input_settings['max_value']
27
+					: null
28
+			)
29
+		);
30
+		$this->_set_normalization_strategy(
31
+			new EE_Int_Normalization(
32
+				isset($input_settings['validation_error_message'])
33
+					? $input_settings['validation_error_message']
34
+					: null
35
+			)
36
+		);
37
+		$this->_add_validation_strategy(
38
+			new EE_Int_Validation_Strategy(
39
+				isset($input_settings['validation_error_message'])
40
+					? $input_settings['validation_error_message']
41
+					: null
42
+			)
43
+		);
44
+		parent::__construct($input_settings);
45
+	}
46 46
 }
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Hidden_Input.input.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -9,28 +9,28 @@
 block discarded – undo
9 9
 class EE_Hidden_Input extends EE_Form_Input_Base
10 10
 {
11 11
 
12
-    /**
13
-     * @param array $input_settings
14
-     */
15
-    public function __construct($input_settings = array())
16
-    {
17
-        // require_once('strategies/display_strategies/EE_Text_Input_Display_Strategy.strategy.php');
18
-        $this->_set_display_strategy(new EE_Hidden_Display_Strategy());
19
-        if (isset($input_settings['normalization_strategy']) && $input_settings['normalization_strategy'] instanceof EE_Normalization_Strategy_Base) {
20
-            $this->_set_normalization_strategy($input_settings['normalization_strategy']);
21
-        } else {
22
-            $this->_set_normalization_strategy(new EE_Text_Normalization());
23
-        }
24
-        parent::__construct($input_settings);
25
-    }
12
+	/**
13
+	 * @param array $input_settings
14
+	 */
15
+	public function __construct($input_settings = array())
16
+	{
17
+		// require_once('strategies/display_strategies/EE_Text_Input_Display_Strategy.strategy.php');
18
+		$this->_set_display_strategy(new EE_Hidden_Display_Strategy());
19
+		if (isset($input_settings['normalization_strategy']) && $input_settings['normalization_strategy'] instanceof EE_Normalization_Strategy_Base) {
20
+			$this->_set_normalization_strategy($input_settings['normalization_strategy']);
21
+		} else {
22
+			$this->_set_normalization_strategy(new EE_Text_Normalization());
23
+		}
24
+		parent::__construct($input_settings);
25
+	}
26 26
 
27 27
 
28 28
 
29
-    /**
30
-     * @return string
31
-     */
32
-    public function get_html_for_label()
33
-    {
34
-        return '';
35
-    }
29
+	/**
30
+	 * @return string
31
+	 */
32
+	public function get_html_for_label()
33
+	{
34
+		return '';
35
+	}
36 36
 }
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Select_Multi_Model_Input.input.php 2 patches
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -12,75 +12,75 @@
 block discarded – undo
12 12
 {
13 13
 
14 14
 
15
-    protected $_naming_method;
15
+	protected $_naming_method;
16 16
 
17 17
 
18 18
 
19
-    /**
20
-     *
21
-     * @param EE_Base_Class[] $answer_options
22
-     * @param array $input_settings {
23
-     *      @var EE_Base_Class[] or array $default
24
-     *      @var string $naming_method function name on the class which will be used for getting the displayed-name.
25
-     *     example:     if the class were an EE_Event, this could be slug(), description(), name() (default)
26
-     * }
27
-     */
28
-    public function __construct($answer_options = array(), $input_settings = array())
29
-    {
30
-        if (isset($input_settings['naming_method'])) {
31
-            $this->set_option_naming_method($input_settings['naming_method']);
32
-        }
33
-        parent::__construct($answer_options, $input_settings);
34
-    }
19
+	/**
20
+	 *
21
+	 * @param EE_Base_Class[] $answer_options
22
+	 * @param array $input_settings {
23
+	 *      @var EE_Base_Class[] or array $default
24
+	 *      @var string $naming_method function name on the class which will be used for getting the displayed-name.
25
+	 *     example:     if the class were an EE_Event, this could be slug(), description(), name() (default)
26
+	 * }
27
+	 */
28
+	public function __construct($answer_options = array(), $input_settings = array())
29
+	{
30
+		if (isset($input_settings['naming_method'])) {
31
+			$this->set_option_naming_method($input_settings['naming_method']);
32
+		}
33
+		parent::__construct($answer_options, $input_settings);
34
+	}
35 35
 
36
-    /**
37
-     * Sets the method name which will be called when outputting the options list
38
-     * @param string $method
39
-     */
40
-    public function set_option_naming_method($method)
41
-    {
42
-        $this->_naming_method = $method;
43
-    }
36
+	/**
37
+	 * Sets the method name which will be called when outputting the options list
38
+	 * @param string $method
39
+	 */
40
+	public function set_option_naming_method($method)
41
+	{
42
+		$this->_naming_method = $method;
43
+	}
44 44
 
45 45
 
46 46
 
47
-    /**
48
-     * You CAN pass an array of model objects instead of simple values for teh options
49
-     * @param EE_Base_Class[] $answer_options
50
-     * @return null|void
51
-     */
52
-    public function set_select_options($answer_options = array())
53
-    {
54
-        // convert the model objects to select from into normal select options
55
-        $select_options = array();
56
-        foreach ($answer_options as $model_obj) {
57
-            if ($this->_naming_method) {
58
-                $display_value = call_user_func(array( $model_obj, $this->_naming_method ));
59
-            } else {
60
-                $display_value = $model_obj->name();
61
-            }
62
-            $select_options[ $model_obj->ID() ] = $display_value;
63
-        }
64
-        parent::set_select_options($select_options);
65
-    }
47
+	/**
48
+	 * You CAN pass an array of model objects instead of simple values for teh options
49
+	 * @param EE_Base_Class[] $answer_options
50
+	 * @return null|void
51
+	 */
52
+	public function set_select_options($answer_options = array())
53
+	{
54
+		// convert the model objects to select from into normal select options
55
+		$select_options = array();
56
+		foreach ($answer_options as $model_obj) {
57
+			if ($this->_naming_method) {
58
+				$display_value = call_user_func(array( $model_obj, $this->_naming_method ));
59
+			} else {
60
+				$display_value = $model_obj->name();
61
+			}
62
+			$select_options[ $model_obj->ID() ] = $display_value;
63
+		}
64
+		parent::set_select_options($select_options);
65
+	}
66 66
 
67 67
 
68 68
 
69
-    /**
70
-     * if they passed in an array of model objects for the default, convert it
71
-     * into the format EE_Select_Multiple expects
72
-     * @param EE_Base_Class[]|array $values
73
-     */
74
-    public function set_default($values)
75
-    {
76
-        $defaults_as_simple_ids = array();
77
-        foreach ($values as $key => $value) {
78
-            if ($value instanceof EE_Base_Class) {
79
-                $defaults_as_simple_ids[] = $value->ID();
80
-            } else {
81
-                $defaults_as_simple_ids[] = $value;
82
-            }
83
-        }
84
-        parent::set_default($defaults_as_simple_ids);
85
-    }
69
+	/**
70
+	 * if they passed in an array of model objects for the default, convert it
71
+	 * into the format EE_Select_Multiple expects
72
+	 * @param EE_Base_Class[]|array $values
73
+	 */
74
+	public function set_default($values)
75
+	{
76
+		$defaults_as_simple_ids = array();
77
+		foreach ($values as $key => $value) {
78
+			if ($value instanceof EE_Base_Class) {
79
+				$defaults_as_simple_ids[] = $value->ID();
80
+			} else {
81
+				$defaults_as_simple_ids[] = $value;
82
+			}
83
+		}
84
+		parent::set_default($defaults_as_simple_ids);
85
+	}
86 86
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,11 +55,11 @@
 block discarded – undo
55 55
         $select_options = array();
56 56
         foreach ($answer_options as $model_obj) {
57 57
             if ($this->_naming_method) {
58
-                $display_value = call_user_func(array( $model_obj, $this->_naming_method ));
58
+                $display_value = call_user_func(array($model_obj, $this->_naming_method));
59 59
             } else {
60 60
                 $display_value = $model_obj->name();
61 61
             }
62
-            $select_options[ $model_obj->ID() ] = $display_value;
62
+            $select_options[$model_obj->ID()] = $display_value;
63 63
         }
64 64
         parent::set_select_options($select_options);
65 65
     }
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Invisible_Recaptcha_Input.input.php 2 patches
Indentation   +217 added lines, -217 removed lines patch added patch discarded remove patch
@@ -15,221 +15,221 @@
 block discarded – undo
15 15
 class EE_Invisible_Recaptcha_Input extends EE_Form_Input_Base
16 16
 {
17 17
 
18
-    const SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA   = 'google_invisible_recaptcha';
19
-
20
-    const SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA = 'espresso_invisible_recaptcha';
21
-
22
-    /**
23
-     * @var EE_Registration_Config $config
24
-     */
25
-    private $config;
26
-
27
-    /**
28
-     * @var string $recaptcha_id
29
-     */
30
-    private $recaptcha_id;
31
-
32
-    /**
33
-     * @var string $submit_button_id
34
-     */
35
-    private $submit_button_id;
36
-
37
-
38
-    /**
39
-     * @param array                  $input_settings
40
-     * @param EE_Registration_Config $registration_config
41
-     * @throws InvalidArgumentException
42
-     * @throws InvalidDataTypeException
43
-     * @throws InvalidInterfaceException
44
-     * @throws DomainException
45
-     */
46
-    public function __construct(array $input_settings = array(), EE_Registration_Config $registration_config = null)
47
-    {
48
-        $this->_set_display_strategy(new EE_Invisible_Recaptcha_Display_Strategy());
49
-        parent::__construct($input_settings);
50
-        $registration_config    = $registration_config instanceof EE_Registration_Config
51
-            ? $registration_config
52
-            : EE_Registry::instance()->CFG->registration;
53
-        $this->config           = $registration_config;
54
-        $this->recaptcha_id     = isset($input_settings['recaptcha_id'])
55
-            ? $input_settings['recaptcha_id']
56
-            : substr(spl_object_hash($this), 8, 8);
57
-        $this->submit_button_id = isset($input_settings['submit_button_id'])
58
-            ? $input_settings['submit_button_id']
59
-            : '';
60
-        if (isset($input_settings['localized_vars'])
61
-            && filter_var($input_settings['iframe'], FILTER_VALIDATE_BOOLEAN)
62
-        ) {
63
-            $this->addIframeAssets($input_settings['localized_vars']);
64
-        } else {
65
-            $this->registerScripts();
66
-        }
67
-    }
68
-
69
-
70
-    /**
71
-     * @return bool
72
-     */
73
-    public function useCaptcha()
74
-    {
75
-        return $this->config->use_captcha && $this->config->recaptcha_theme === 'invisible';
76
-    }
77
-
78
-
79
-    /**
80
-     * @return string
81
-     */
82
-    public function badge()
83
-    {
84
-        return $this->config->recaptcha_badge;
85
-    }
86
-
87
-
88
-    /**
89
-     * @return string
90
-     */
91
-    public function language()
92
-    {
93
-        return $this->config->recaptcha_language;
94
-    }
95
-
96
-
97
-    /**
98
-     * @return string
99
-     */
100
-    public function siteKey()
101
-    {
102
-        return $this->config->recaptcha_publickey;
103
-    }
104
-
105
-
106
-    /**
107
-     * @return string
108
-     */
109
-    public function secretKey()
110
-    {
111
-        return $this->config->recaptcha_privatekey;
112
-    }
113
-
114
-
115
-    /**
116
-     * @return string
117
-     */
118
-    public function recaptchaId()
119
-    {
120
-        return $this->recaptcha_id;
121
-    }
122
-
123
-
124
-    /**
125
-     * @return string
126
-     */
127
-    public function submitButtonId()
128
-    {
129
-        return $this->submit_button_id;
130
-    }
131
-
132
-
133
-    /**
134
-     * @param array $localized_vars
135
-     * @throws DomainException
136
-     */
137
-    private function addIframeAssets(array $localized_vars)
138
-    {
139
-        if (! $this->useCaptcha()) {
140
-            return;
141
-        }
142
-        add_filter(
143
-            'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
144
-            function (array $iframe_assets) {
145
-                $iframe_assets[ EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA ] =
146
-                    EED_Recaptcha_Invisible::assetsUrl()
147
-                    . 'espresso_invisible_recaptcha.js?ver='
148
-                    . EVENT_ESPRESSO_VERSION;
149
-                $iframe_assets[ EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA ] =
150
-                    add_query_arg(
151
-                        array(
152
-                            'onload' => 'espressoLoadRecaptcha',
153
-                            'render' => 'explicit',
154
-                            'hl'     => $this->language(),
155
-                        ),
156
-                        'https://www.google.com/recaptcha/api.js?'
157
-                    );
158
-                return $iframe_assets;
159
-            }
160
-        );
161
-        add_filter(
162
-            'FHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__js_attributes',
163
-            function (array $iframe_asset_attributes) {
164
-                $iframe_asset_attributes[ EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA ]
165
-                    = ' async="async" defer="defer"';
166
-                return $iframe_asset_attributes;
167
-            }
168
-        );
169
-        add_action(
170
-            'AHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__complete',
171
-            function (EventEspresso\modules\ticket_selector\TicketSelectorIframe $ticket_selector_iframe) use ($localized_vars) {
172
-                $ticket_selector_iframe->addLocalizedVars($localized_vars, 'eeRecaptcha');
173
-            }
174
-        );
175
-    }
176
-
177
-
178
-    /**
179
-     * @return void
180
-     */
181
-    private function registerScripts()
182
-    {
183
-        if (! $this->useCaptcha()) {
184
-            return;
185
-        }
186
-        add_filter('script_loader_tag', array($this, 'addScriptAttributes'), 10, 2);
187
-        wp_register_script(
188
-            EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA,
189
-            EED_Recaptcha_Invisible::assetsUrl() . 'espresso_invisible_recaptcha.js',
190
-            array('espresso_core'),
191
-            EVENT_ESPRESSO_VERSION,
192
-            true
193
-        );
194
-        wp_register_script(
195
-            EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA,
196
-            add_query_arg(
197
-                array(
198
-                    'onload' => 'espressoLoadRecaptcha',
199
-                    'render' => 'explicit',
200
-                    'hl'     => $this->language(),
201
-                ),
202
-                'https://www.google.com/recaptcha/api.js?'
203
-            ),
204
-            array(EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA),
205
-            false,
206
-            true
207
-        );
208
-    }
209
-
210
-
211
-    /**
212
-     * @param string $tag
213
-     * @param string $handle
214
-     * @return string
215
-     */
216
-    public function addScriptAttributes($tag, $handle)
217
-    {
218
-        if ($handle === EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA) {
219
-            $tag = str_replace('></script>', ' async="async" defer="defer"></script>', $tag);
220
-        }
221
-        return $tag;
222
-    }
223
-
224
-
225
-    /**
226
-     * Gets the HTML for displaying the label for this form input
227
-     * according to the form section's layout strategy
228
-     *
229
-     * @return string
230
-     */
231
-    public function get_html_for_label()
232
-    {
233
-        return '';
234
-    }
18
+	const SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA   = 'google_invisible_recaptcha';
19
+
20
+	const SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA = 'espresso_invisible_recaptcha';
21
+
22
+	/**
23
+	 * @var EE_Registration_Config $config
24
+	 */
25
+	private $config;
26
+
27
+	/**
28
+	 * @var string $recaptcha_id
29
+	 */
30
+	private $recaptcha_id;
31
+
32
+	/**
33
+	 * @var string $submit_button_id
34
+	 */
35
+	private $submit_button_id;
36
+
37
+
38
+	/**
39
+	 * @param array                  $input_settings
40
+	 * @param EE_Registration_Config $registration_config
41
+	 * @throws InvalidArgumentException
42
+	 * @throws InvalidDataTypeException
43
+	 * @throws InvalidInterfaceException
44
+	 * @throws DomainException
45
+	 */
46
+	public function __construct(array $input_settings = array(), EE_Registration_Config $registration_config = null)
47
+	{
48
+		$this->_set_display_strategy(new EE_Invisible_Recaptcha_Display_Strategy());
49
+		parent::__construct($input_settings);
50
+		$registration_config    = $registration_config instanceof EE_Registration_Config
51
+			? $registration_config
52
+			: EE_Registry::instance()->CFG->registration;
53
+		$this->config           = $registration_config;
54
+		$this->recaptcha_id     = isset($input_settings['recaptcha_id'])
55
+			? $input_settings['recaptcha_id']
56
+			: substr(spl_object_hash($this), 8, 8);
57
+		$this->submit_button_id = isset($input_settings['submit_button_id'])
58
+			? $input_settings['submit_button_id']
59
+			: '';
60
+		if (isset($input_settings['localized_vars'])
61
+			&& filter_var($input_settings['iframe'], FILTER_VALIDATE_BOOLEAN)
62
+		) {
63
+			$this->addIframeAssets($input_settings['localized_vars']);
64
+		} else {
65
+			$this->registerScripts();
66
+		}
67
+	}
68
+
69
+
70
+	/**
71
+	 * @return bool
72
+	 */
73
+	public function useCaptcha()
74
+	{
75
+		return $this->config->use_captcha && $this->config->recaptcha_theme === 'invisible';
76
+	}
77
+
78
+
79
+	/**
80
+	 * @return string
81
+	 */
82
+	public function badge()
83
+	{
84
+		return $this->config->recaptcha_badge;
85
+	}
86
+
87
+
88
+	/**
89
+	 * @return string
90
+	 */
91
+	public function language()
92
+	{
93
+		return $this->config->recaptcha_language;
94
+	}
95
+
96
+
97
+	/**
98
+	 * @return string
99
+	 */
100
+	public function siteKey()
101
+	{
102
+		return $this->config->recaptcha_publickey;
103
+	}
104
+
105
+
106
+	/**
107
+	 * @return string
108
+	 */
109
+	public function secretKey()
110
+	{
111
+		return $this->config->recaptcha_privatekey;
112
+	}
113
+
114
+
115
+	/**
116
+	 * @return string
117
+	 */
118
+	public function recaptchaId()
119
+	{
120
+		return $this->recaptcha_id;
121
+	}
122
+
123
+
124
+	/**
125
+	 * @return string
126
+	 */
127
+	public function submitButtonId()
128
+	{
129
+		return $this->submit_button_id;
130
+	}
131
+
132
+
133
+	/**
134
+	 * @param array $localized_vars
135
+	 * @throws DomainException
136
+	 */
137
+	private function addIframeAssets(array $localized_vars)
138
+	{
139
+		if (! $this->useCaptcha()) {
140
+			return;
141
+		}
142
+		add_filter(
143
+			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
144
+			function (array $iframe_assets) {
145
+				$iframe_assets[ EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA ] =
146
+					EED_Recaptcha_Invisible::assetsUrl()
147
+					. 'espresso_invisible_recaptcha.js?ver='
148
+					. EVENT_ESPRESSO_VERSION;
149
+				$iframe_assets[ EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA ] =
150
+					add_query_arg(
151
+						array(
152
+							'onload' => 'espressoLoadRecaptcha',
153
+							'render' => 'explicit',
154
+							'hl'     => $this->language(),
155
+						),
156
+						'https://www.google.com/recaptcha/api.js?'
157
+					);
158
+				return $iframe_assets;
159
+			}
160
+		);
161
+		add_filter(
162
+			'FHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__js_attributes',
163
+			function (array $iframe_asset_attributes) {
164
+				$iframe_asset_attributes[ EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA ]
165
+					= ' async="async" defer="defer"';
166
+				return $iframe_asset_attributes;
167
+			}
168
+		);
169
+		add_action(
170
+			'AHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__complete',
171
+			function (EventEspresso\modules\ticket_selector\TicketSelectorIframe $ticket_selector_iframe) use ($localized_vars) {
172
+				$ticket_selector_iframe->addLocalizedVars($localized_vars, 'eeRecaptcha');
173
+			}
174
+		);
175
+	}
176
+
177
+
178
+	/**
179
+	 * @return void
180
+	 */
181
+	private function registerScripts()
182
+	{
183
+		if (! $this->useCaptcha()) {
184
+			return;
185
+		}
186
+		add_filter('script_loader_tag', array($this, 'addScriptAttributes'), 10, 2);
187
+		wp_register_script(
188
+			EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA,
189
+			EED_Recaptcha_Invisible::assetsUrl() . 'espresso_invisible_recaptcha.js',
190
+			array('espresso_core'),
191
+			EVENT_ESPRESSO_VERSION,
192
+			true
193
+		);
194
+		wp_register_script(
195
+			EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA,
196
+			add_query_arg(
197
+				array(
198
+					'onload' => 'espressoLoadRecaptcha',
199
+					'render' => 'explicit',
200
+					'hl'     => $this->language(),
201
+				),
202
+				'https://www.google.com/recaptcha/api.js?'
203
+			),
204
+			array(EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA),
205
+			false,
206
+			true
207
+		);
208
+	}
209
+
210
+
211
+	/**
212
+	 * @param string $tag
213
+	 * @param string $handle
214
+	 * @return string
215
+	 */
216
+	public function addScriptAttributes($tag, $handle)
217
+	{
218
+		if ($handle === EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA) {
219
+			$tag = str_replace('></script>', ' async="async" defer="defer"></script>', $tag);
220
+		}
221
+		return $tag;
222
+	}
223
+
224
+
225
+	/**
226
+	 * Gets the HTML for displaying the label for this form input
227
+	 * according to the form section's layout strategy
228
+	 *
229
+	 * @return string
230
+	 */
231
+	public function get_html_for_label()
232
+	{
233
+		return '';
234
+	}
235 235
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -136,17 +136,17 @@  discard block
 block discarded – undo
136 136
      */
137 137
     private function addIframeAssets(array $localized_vars)
138 138
     {
139
-        if (! $this->useCaptcha()) {
139
+        if ( ! $this->useCaptcha()) {
140 140
             return;
141 141
         }
142 142
         add_filter(
143 143
             'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
144
-            function (array $iframe_assets) {
145
-                $iframe_assets[ EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA ] =
144
+            function(array $iframe_assets) {
145
+                $iframe_assets[EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA] =
146 146
                     EED_Recaptcha_Invisible::assetsUrl()
147 147
                     . 'espresso_invisible_recaptcha.js?ver='
148 148
                     . EVENT_ESPRESSO_VERSION;
149
-                $iframe_assets[ EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA ] =
149
+                $iframe_assets[EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA] =
150 150
                     add_query_arg(
151 151
                         array(
152 152
                             'onload' => 'espressoLoadRecaptcha',
@@ -160,15 +160,15 @@  discard block
 block discarded – undo
160 160
         );
161 161
         add_filter(
162 162
             'FHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__js_attributes',
163
-            function (array $iframe_asset_attributes) {
164
-                $iframe_asset_attributes[ EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA ]
163
+            function(array $iframe_asset_attributes) {
164
+                $iframe_asset_attributes[EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA]
165 165
                     = ' async="async" defer="defer"';
166 166
                 return $iframe_asset_attributes;
167 167
             }
168 168
         );
169 169
         add_action(
170 170
             'AHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__complete',
171
-            function (EventEspresso\modules\ticket_selector\TicketSelectorIframe $ticket_selector_iframe) use ($localized_vars) {
171
+            function(EventEspresso\modules\ticket_selector\TicketSelectorIframe $ticket_selector_iframe) use ($localized_vars) {
172 172
                 $ticket_selector_iframe->addLocalizedVars($localized_vars, 'eeRecaptcha');
173 173
             }
174 174
         );
@@ -180,13 +180,13 @@  discard block
 block discarded – undo
180 180
      */
181 181
     private function registerScripts()
182 182
     {
183
-        if (! $this->useCaptcha()) {
183
+        if ( ! $this->useCaptcha()) {
184 184
             return;
185 185
         }
186 186
         add_filter('script_loader_tag', array($this, 'addScriptAttributes'), 10, 2);
187 187
         wp_register_script(
188 188
             EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA,
189
-            EED_Recaptcha_Invisible::assetsUrl() . 'espresso_invisible_recaptcha.js',
189
+            EED_Recaptcha_Invisible::assetsUrl().'espresso_invisible_recaptcha.js',
190 190
             array('espresso_core'),
191 191
             EVENT_ESPRESSO_VERSION,
192 192
             true
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Phone_Input.input.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -14,17 +14,17 @@
 block discarded – undo
14 14
  */
15 15
 class EE_Phone_Input extends EE_Text_Input
16 16
 {
17
-    /**
18
-     * @param array $options
19
-     */
20
-    public function __construct($options = array())
21
-    {
22
-        $this->_add_validation_strategy(
23
-            new EE_Text_Validation_Strategy(
24
-                __('Please enter a valid phone number. Eg 123-456-7890 or 1234567890', 'event_espresso'),
25
-                '~^(([\d]{10})|(^[\d]{3}-[\d]{3}-[\d]{4}))$~'
26
-            )
27
-        );
28
-        parent::__construct($options);
29
-    }
17
+	/**
18
+	 * @param array $options
19
+	 */
20
+	public function __construct($options = array())
21
+	{
22
+		$this->_add_validation_strategy(
23
+			new EE_Text_Validation_Strategy(
24
+				__('Please enter a valid phone number. Eg 123-456-7890 or 1234567890', 'event_espresso'),
25
+				'~^(([\d]{10})|(^[\d]{3}-[\d]{3}-[\d]{4}))$~'
26
+			)
27
+		);
28
+		parent::__construct($options);
29
+	}
30 30
 }
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Select_Multiple_Input.input.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -9,15 +9,15 @@
 block discarded – undo
9 9
 class EE_Select_Multiple_Input extends EE_Form_Input_With_Options_Base
10 10
 {
11 11
 
12
-    /**
13
-     * @param array | EE_Question_Option[] $answer_options
14
-     * @param array $input_settings
15
-     */
16
-    public function __construct($answer_options, $input_settings = array())
17
-    {
18
-        $this->_set_display_strategy(new EE_Select_Multiple_Display_Strategy());
19
-        $this->_add_validation_strategy(new EE_Many_Valued_Validation_Strategy(array( new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : null) )));
20
-        $this->_multiple_selections = true;
21
-        parent::__construct($answer_options, $input_settings);
22
-    }
12
+	/**
13
+	 * @param array | EE_Question_Option[] $answer_options
14
+	 * @param array $input_settings
15
+	 */
16
+	public function __construct($answer_options, $input_settings = array())
17
+	{
18
+		$this->_set_display_strategy(new EE_Select_Multiple_Display_Strategy());
19
+		$this->_add_validation_strategy(new EE_Many_Valued_Validation_Strategy(array( new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : null) )));
20
+		$this->_multiple_selections = true;
21
+		parent::__construct($answer_options, $input_settings);
22
+	}
23 23
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
     public function __construct($answer_options, $input_settings = array())
17 17
     {
18 18
         $this->_set_display_strategy(new EE_Select_Multiple_Display_Strategy());
19
-        $this->_add_validation_strategy(new EE_Many_Valued_Validation_Strategy(array( new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : null) )));
19
+        $this->_add_validation_strategy(new EE_Many_Valued_Validation_Strategy(array(new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : null))));
20 20
         $this->_multiple_selections = true;
21 21
         parent::__construct($answer_options, $input_settings);
22 22
     }
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Select_Reveal_Input.input.php 2 patches
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -14,64 +14,64 @@
 block discarded – undo
14 14
 class EE_Select_Reveal_Input extends EE_Select_Input
15 15
 {
16 16
 
17
-    /**
18
-     * @param array $answer_options Array keys which match a sibling section's name
19
-     *              will show/unhide that sibling subsection. Otherwise, siblings whose names
20
-     *              match array keys of $answer_options are hidden.
21
-     *              Note: internally each array key is considered a relative form input path
22
-     *              (see EE_Form_Section_Base::find_section_from_path) but relative
23
-     *              to THIS INPUT's PARENT section, not this input itself. ie,
24
-     *              a '../' is automatically added onto each each array key, to produce
25
-     *              the relative form input path.
26
-     *              Note however: array keys which are an EMPTY STRING are left as-is
27
-     *
28
-     * @param array $input_settings
29
-     */
30
-    public function __construct($answer_options, $input_settings = array())
31
-    {
32
-        parent::__construct($answer_options, $input_settings);
33
-    }
17
+	/**
18
+	 * @param array $answer_options Array keys which match a sibling section's name
19
+	 *              will show/unhide that sibling subsection. Otherwise, siblings whose names
20
+	 *              match array keys of $answer_options are hidden.
21
+	 *              Note: internally each array key is considered a relative form input path
22
+	 *              (see EE_Form_Section_Base::find_section_from_path) but relative
23
+	 *              to THIS INPUT's PARENT section, not this input itself. ie,
24
+	 *              a '../' is automatically added onto each each array key, to produce
25
+	 *              the relative form input path.
26
+	 *              Note however: array keys which are an EMPTY STRING are left as-is
27
+	 *
28
+	 * @param array $input_settings
29
+	 */
30
+	public function __construct($answer_options, $input_settings = array())
31
+	{
32
+		parent::__construct($answer_options, $input_settings);
33
+	}
34 34
 
35
-    /**
36
-     * Gets all the sibling sections controlled by this reveal select input
37
-     * @return \EE_Form_Section_Base[] keys are their form section paths
38
-     */
39
-    public function sibling_sections_controlled()
40
-    {
41
-        $sibling_sections = array();
42
-        foreach ($this->options() as $sibling_section_name => $sibling_section) {
43
-            // if it's an empty string just leave it alone
44
-            if (empty($sibling_section_name)) {
45
-                continue;
46
-            }
47
-            $sibling_section = $this->find_section_from_path('../' . $sibling_section_name);
48
-            if ($sibling_section instanceof EE_Form_Section_Base
49
-                && ! empty($sibling_section_name)
50
-            ) {
51
-                $sibling_sections[ $sibling_section_name ] = $sibling_section;
52
-            }
53
-        }
54
-        return $sibling_sections;
55
-    }
35
+	/**
36
+	 * Gets all the sibling sections controlled by this reveal select input
37
+	 * @return \EE_Form_Section_Base[] keys are their form section paths
38
+	 */
39
+	public function sibling_sections_controlled()
40
+	{
41
+		$sibling_sections = array();
42
+		foreach ($this->options() as $sibling_section_name => $sibling_section) {
43
+			// if it's an empty string just leave it alone
44
+			if (empty($sibling_section_name)) {
45
+				continue;
46
+			}
47
+			$sibling_section = $this->find_section_from_path('../' . $sibling_section_name);
48
+			if ($sibling_section instanceof EE_Form_Section_Base
49
+				&& ! empty($sibling_section_name)
50
+			) {
51
+				$sibling_sections[ $sibling_section_name ] = $sibling_section;
52
+			}
53
+		}
54
+		return $sibling_sections;
55
+	}
56 56
 
57
-    /**
58
-     * Adds an entry of 'select_reveal_inputs' to the js data, which is an array
59
-     * whose top-level keys are select reveal input html ids; values are arrays
60
-     * whose keys are select option values and values are the sections they reveal
61
-     * @param array $form_other_js_data
62
-     * @return array
63
-     */
64
-    public function get_other_js_data($form_other_js_data = array())
65
-    {
66
-        $form_other_js_data = parent::get_other_js_data($form_other_js_data);
67
-        if (! isset($form_other_js_data['select_reveal_inputs'])) {
68
-            $form_other_js_data['select_reveal_inputs'] = array();
69
-        }
70
-        $sibling_input_to_html_id_map = array();
71
-        foreach ($this->sibling_sections_controlled() as $sibling_section_path => $sibling_section) {
72
-            $sibling_input_to_html_id_map[ $sibling_section_path ] = $sibling_section->html_id();
73
-        }
74
-        $form_other_js_data['select_reveal_inputs'][ $this->html_id() ] = $sibling_input_to_html_id_map;
75
-        return $form_other_js_data;
76
-    }
57
+	/**
58
+	 * Adds an entry of 'select_reveal_inputs' to the js data, which is an array
59
+	 * whose top-level keys are select reveal input html ids; values are arrays
60
+	 * whose keys are select option values and values are the sections they reveal
61
+	 * @param array $form_other_js_data
62
+	 * @return array
63
+	 */
64
+	public function get_other_js_data($form_other_js_data = array())
65
+	{
66
+		$form_other_js_data = parent::get_other_js_data($form_other_js_data);
67
+		if (! isset($form_other_js_data['select_reveal_inputs'])) {
68
+			$form_other_js_data['select_reveal_inputs'] = array();
69
+		}
70
+		$sibling_input_to_html_id_map = array();
71
+		foreach ($this->sibling_sections_controlled() as $sibling_section_path => $sibling_section) {
72
+			$sibling_input_to_html_id_map[ $sibling_section_path ] = $sibling_section->html_id();
73
+		}
74
+		$form_other_js_data['select_reveal_inputs'][ $this->html_id() ] = $sibling_input_to_html_id_map;
75
+		return $form_other_js_data;
76
+	}
77 77
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -44,11 +44,11 @@  discard block
 block discarded – undo
44 44
             if (empty($sibling_section_name)) {
45 45
                 continue;
46 46
             }
47
-            $sibling_section = $this->find_section_from_path('../' . $sibling_section_name);
47
+            $sibling_section = $this->find_section_from_path('../'.$sibling_section_name);
48 48
             if ($sibling_section instanceof EE_Form_Section_Base
49 49
                 && ! empty($sibling_section_name)
50 50
             ) {
51
-                $sibling_sections[ $sibling_section_name ] = $sibling_section;
51
+                $sibling_sections[$sibling_section_name] = $sibling_section;
52 52
             }
53 53
         }
54 54
         return $sibling_sections;
@@ -64,14 +64,14 @@  discard block
 block discarded – undo
64 64
     public function get_other_js_data($form_other_js_data = array())
65 65
     {
66 66
         $form_other_js_data = parent::get_other_js_data($form_other_js_data);
67
-        if (! isset($form_other_js_data['select_reveal_inputs'])) {
67
+        if ( ! isset($form_other_js_data['select_reveal_inputs'])) {
68 68
             $form_other_js_data['select_reveal_inputs'] = array();
69 69
         }
70 70
         $sibling_input_to_html_id_map = array();
71 71
         foreach ($this->sibling_sections_controlled() as $sibling_section_path => $sibling_section) {
72
-            $sibling_input_to_html_id_map[ $sibling_section_path ] = $sibling_section->html_id();
72
+            $sibling_input_to_html_id_map[$sibling_section_path] = $sibling_section->html_id();
73 73
         }
74
-        $form_other_js_data['select_reveal_inputs'][ $this->html_id() ] = $sibling_input_to_html_id_map;
74
+        $form_other_js_data['select_reveal_inputs'][$this->html_id()] = $sibling_input_to_html_id_map;
75 75
         return $form_other_js_data;
76 76
     }
77 77
 }
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Year_Input.input.php 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -12,17 +12,17 @@
 block discarded – undo
12 12
 class EE_Year_Input extends EE_Select_Input
13 13
 {
14 14
 
15
-    public function __construct($input_settings = array(), $four_digit_year = true, $years_behind = 100, $years_ahead = 0)
16
-    {
17
-        if ($four_digit_year) {
18
-            $current_year_int = intval(date('Y'));
19
-        } else {
20
-            $current_year_int = intval(date('y'));
21
-        }
22
-        $answer_options = array();
23
-        for ($start = $current_year_int - $years_behind; $start <= ($current_year_int + $years_ahead); $start++) {
24
-            $answer_options[ $start ] = $start;
25
-        }
26
-        parent::__construct($answer_options, $input_settings);
27
-    }
15
+	public function __construct($input_settings = array(), $four_digit_year = true, $years_behind = 100, $years_ahead = 0)
16
+	{
17
+		if ($four_digit_year) {
18
+			$current_year_int = intval(date('Y'));
19
+		} else {
20
+			$current_year_int = intval(date('y'));
21
+		}
22
+		$answer_options = array();
23
+		for ($start = $current_year_int - $years_behind; $start <= ($current_year_int + $years_ahead); $start++) {
24
+			$answer_options[ $start ] = $start;
25
+		}
26
+		parent::__construct($answer_options, $input_settings);
27
+	}
28 28
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
         }
22 22
         $answer_options = array();
23 23
         for ($start = $current_year_int - $years_behind; $start <= ($current_year_int + $years_ahead); $start++) {
24
-            $answer_options[ $start ] = $start;
24
+            $answer_options[$start] = $start;
25 25
         }
26 26
         parent::__construct($answer_options, $input_settings);
27 27
     }
Please login to merge, or discard this patch.