Completed
Branch models-cleanup/main (c8075d)
by
unknown
185:05 queued 175:13
created
core/libraries/batch/JobHandlers/AttendeesReport.php 3 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -90,6 +90,10 @@
 block discarded – undo
90 90
         return \EEM_Attendee::instance()->count(array('caps' => \EEM_Base::caps_read_admin));
91 91
     }
92 92
 
93
+    /**
94
+     * @param integer $offset
95
+     * @param integer $limit
96
+     */
93 97
     public function get_csv_data($offset, $limit)
94 98
     {
95 99
         $attendee_rows = \EEM_Attendee::instance()->get_all_wpdb_results(
Please login to merge, or discard this patch.
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -19,106 +19,106 @@
 block discarded – undo
19 19
 class AttendeesReport extends JobHandlerFile
20 20
 {
21 21
 
22
-    // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
23
-    public function create_job(JobParameters $job_parameters)
24
-    {
25
-        if (! \EE_Capabilities::instance()->current_user_can('ee_read_contacts', 'generating_report')) {
26
-            throw new BatchRequestException(
27
-                __('You do not have permission to view contacts', 'event_espresso')
28
-            );
29
-        }
30
-        $filepath = $this->create_file_from_job_with_name(
31
-            $job_parameters->job_id(),
32
-            __('contact-list-report.csv', 'event_espresso')
33
-        );
34
-        $job_parameters->add_extra_data('filepath', $filepath);
35
-        $job_parameters->set_job_size($this->count_units_to_process());
36
-        // we should also set the header columns
37
-        $csv_data_for_row = $this->get_csv_data(0, 1);
38
-        \EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true);
39
-        // if we actually processed a row there, record it
40
-        if ($job_parameters->job_size()) {
41
-            $job_parameters->mark_processed(1);
42
-        }
43
-        return new JobStepResponse(
44
-            $job_parameters,
45
-            __('Contacts report started successfully...', 'event_espresso')
46
-        );
47
-    }
22
+	// phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
23
+	public function create_job(JobParameters $job_parameters)
24
+	{
25
+		if (! \EE_Capabilities::instance()->current_user_can('ee_read_contacts', 'generating_report')) {
26
+			throw new BatchRequestException(
27
+				__('You do not have permission to view contacts', 'event_espresso')
28
+			);
29
+		}
30
+		$filepath = $this->create_file_from_job_with_name(
31
+			$job_parameters->job_id(),
32
+			__('contact-list-report.csv', 'event_espresso')
33
+		);
34
+		$job_parameters->add_extra_data('filepath', $filepath);
35
+		$job_parameters->set_job_size($this->count_units_to_process());
36
+		// we should also set the header columns
37
+		$csv_data_for_row = $this->get_csv_data(0, 1);
38
+		\EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true);
39
+		// if we actually processed a row there, record it
40
+		if ($job_parameters->job_size()) {
41
+			$job_parameters->mark_processed(1);
42
+		}
43
+		return new JobStepResponse(
44
+			$job_parameters,
45
+			__('Contacts report started successfully...', 'event_espresso')
46
+		);
47
+	}
48 48
 
49 49
 
50
-    public function continue_job(JobParameters $job_parameters, $batch_size = 50)
51
-    {
52
-        $csv_data = $this->get_csv_data($job_parameters->units_processed(), $batch_size);
53
-        \EEH_Export::write_data_array_to_csv(
54
-            $job_parameters->extra_datum('filepath'),
55
-            $csv_data,
56
-            false
57
-        );
58
-        $units_processed = count($csv_data);
59
-        $job_parameters->mark_processed($units_processed);
60
-        $extra_response_data = array(
61
-            'file_url' => '',
62
-        );
63
-        if ($units_processed < $batch_size) {
64
-            $job_parameters->set_status(JobParameters::status_complete);
65
-            $extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath'));
66
-        }
67
-        return new JobStepResponse(
68
-            $job_parameters,
69
-            sprintf(
70
-                __('Wrote %1$s rows to report CSV file...', 'event_espresso'),
71
-                count($csv_data)
72
-            ),
73
-            $extra_response_data
74
-        );
75
-    }
50
+	public function continue_job(JobParameters $job_parameters, $batch_size = 50)
51
+	{
52
+		$csv_data = $this->get_csv_data($job_parameters->units_processed(), $batch_size);
53
+		\EEH_Export::write_data_array_to_csv(
54
+			$job_parameters->extra_datum('filepath'),
55
+			$csv_data,
56
+			false
57
+		);
58
+		$units_processed = count($csv_data);
59
+		$job_parameters->mark_processed($units_processed);
60
+		$extra_response_data = array(
61
+			'file_url' => '',
62
+		);
63
+		if ($units_processed < $batch_size) {
64
+			$job_parameters->set_status(JobParameters::status_complete);
65
+			$extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath'));
66
+		}
67
+		return new JobStepResponse(
68
+			$job_parameters,
69
+			sprintf(
70
+				__('Wrote %1$s rows to report CSV file...', 'event_espresso'),
71
+				count($csv_data)
72
+			),
73
+			$extra_response_data
74
+		);
75
+	}
76 76
 
77 77
 
78
-    public function cleanup_job(JobParameters $job_parameters)
79
-    {
80
-        $this->_file_helper->delete(
81
-            \EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')),
82
-            true,
83
-            'd'
84
-        );
85
-        return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso'));
86
-    }
78
+	public function cleanup_job(JobParameters $job_parameters)
79
+	{
80
+		$this->_file_helper->delete(
81
+			\EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')),
82
+			true,
83
+			'd'
84
+		);
85
+		return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso'));
86
+	}
87 87
 
88
-    public function count_units_to_process()
89
-    {
90
-        return \EEM_Attendee::instance()->count(array('caps' => \EEM_Base::caps_read_admin));
91
-    }
88
+	public function count_units_to_process()
89
+	{
90
+		return \EEM_Attendee::instance()->count(array('caps' => \EEM_Base::caps_read_admin));
91
+	}
92 92
 
93
-    public function get_csv_data($offset, $limit)
94
-    {
95
-        $attendee_rows = \EEM_Attendee::instance()->get_all_wpdb_results(
96
-            array(
97
-                'limit'      => array($offset, $limit),
98
-                'force_join' => array('State', 'Country'),
99
-                'caps'       => \EEM_Base::caps_read_admin,
100
-            )
101
-        );
102
-        $csv_data = array();
103
-        foreach ($attendee_rows as $attendee_row) {
104
-            $csv_row = array();
105
-            foreach (\EEM_Attendee::instance()->field_settings() as $field_name => $field_obj) {
106
-                if ($field_name == 'STA_ID') {
107
-                    $state_name_field = \EEM_State::instance()->field_settings_for('STA_name');
108
-                    $csv_row[ __('State', 'event_espresso') ] = $attendee_row[ $state_name_field->get_qualified_column() ];
109
-                } elseif ($field_name == 'CNT_ISO') {
110
-                    $country_name_field = \EEM_Country::instance()->field_settings_for('CNT_name');
111
-                    $csv_row[ __('Country', 'event_espresso') ] = $attendee_row[ $country_name_field->get_qualified_column() ];
112
-                } else {
113
-                    $csv_row[ wp_specialchars_decode($field_obj->get_nicename(), ENT_QUOTES) ] = $attendee_row[ $field_obj->get_qualified_column() ];
114
-                }
115
-            }
116
-            $csv_data[] = apply_filters(
117
-                'FHEE___EventEspresso_core_libraries_batch_JobHandlers_AttendeesReport__get_csv_data__row',
118
-                $csv_row,
119
-                $attendee_row
120
-            );
121
-        }
122
-        return $csv_data;
123
-    }
93
+	public function get_csv_data($offset, $limit)
94
+	{
95
+		$attendee_rows = \EEM_Attendee::instance()->get_all_wpdb_results(
96
+			array(
97
+				'limit'      => array($offset, $limit),
98
+				'force_join' => array('State', 'Country'),
99
+				'caps'       => \EEM_Base::caps_read_admin,
100
+			)
101
+		);
102
+		$csv_data = array();
103
+		foreach ($attendee_rows as $attendee_row) {
104
+			$csv_row = array();
105
+			foreach (\EEM_Attendee::instance()->field_settings() as $field_name => $field_obj) {
106
+				if ($field_name == 'STA_ID') {
107
+					$state_name_field = \EEM_State::instance()->field_settings_for('STA_name');
108
+					$csv_row[ __('State', 'event_espresso') ] = $attendee_row[ $state_name_field->get_qualified_column() ];
109
+				} elseif ($field_name == 'CNT_ISO') {
110
+					$country_name_field = \EEM_Country::instance()->field_settings_for('CNT_name');
111
+					$csv_row[ __('Country', 'event_espresso') ] = $attendee_row[ $country_name_field->get_qualified_column() ];
112
+				} else {
113
+					$csv_row[ wp_specialchars_decode($field_obj->get_nicename(), ENT_QUOTES) ] = $attendee_row[ $field_obj->get_qualified_column() ];
114
+				}
115
+			}
116
+			$csv_data[] = apply_filters(
117
+				'FHEE___EventEspresso_core_libraries_batch_JobHandlers_AttendeesReport__get_csv_data__row',
118
+				$csv_row,
119
+				$attendee_row
120
+			);
121
+		}
122
+		return $csv_data;
123
+	}
124 124
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
23 23
     public function create_job(JobParameters $job_parameters)
24 24
     {
25
-        if (! \EE_Capabilities::instance()->current_user_can('ee_read_contacts', 'generating_report')) {
25
+        if ( ! \EE_Capabilities::instance()->current_user_can('ee_read_contacts', 'generating_report')) {
26 26
             throw new BatchRequestException(
27 27
                 __('You do not have permission to view contacts', 'event_espresso')
28 28
             );
@@ -105,12 +105,12 @@  discard block
 block discarded – undo
105 105
             foreach (\EEM_Attendee::instance()->field_settings() as $field_name => $field_obj) {
106 106
                 if ($field_name == 'STA_ID') {
107 107
                     $state_name_field = \EEM_State::instance()->field_settings_for('STA_name');
108
-                    $csv_row[ __('State', 'event_espresso') ] = $attendee_row[ $state_name_field->get_qualified_column() ];
108
+                    $csv_row[__('State', 'event_espresso')] = $attendee_row[$state_name_field->get_qualified_column()];
109 109
                 } elseif ($field_name == 'CNT_ISO') {
110 110
                     $country_name_field = \EEM_Country::instance()->field_settings_for('CNT_name');
111
-                    $csv_row[ __('Country', 'event_espresso') ] = $attendee_row[ $country_name_field->get_qualified_column() ];
111
+                    $csv_row[__('Country', 'event_espresso')] = $attendee_row[$country_name_field->get_qualified_column()];
112 112
                 } else {
113
-                    $csv_row[ wp_specialchars_decode($field_obj->get_nicename(), ENT_QUOTES) ] = $attendee_row[ $field_obj->get_qualified_column() ];
113
+                    $csv_row[wp_specialchars_decode($field_obj->get_nicename(), ENT_QUOTES)] = $attendee_row[$field_obj->get_qualified_column()];
114 114
                 }
115 115
             }
116 116
             $csv_data[] = apply_filters(
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Form_Input_Base.input.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
      * Sets sensitive_data_removal_strategy
357 357
      *
358 358
      * @param EE_Sensitive_Data_Removal_Base $sensitive_data_removal_strategy
359
-     * @return boolean
359
+     * @return boolean|null
360 360
      */
361 361
     public function set_sensitive_data_removal_strategy($sensitive_data_removal_strategy)
362 362
     {
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
     /**
477 477
      * returns true if input employs any of the validation strategy defined by the supplied array of classnames
478 478
      *
479
-     * @param array $validation_strategy_classnames
479
+     * @param string[] $validation_strategy_classnames
480 480
      * @return bool
481 481
      */
482 482
     public function has_validation_strategy($validation_strategy_classnames)
Please login to merge, or discard this patch.
Indentation   +1255 added lines, -1255 removed lines patch added patch discarded remove patch
@@ -12,1259 +12,1259 @@
 block discarded – undo
12 12
 abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable
13 13
 {
14 14
 
15
-    /**
16
-     * the input's name attribute
17
-     *
18
-     * @var string
19
-     */
20
-    protected $_html_name;
21
-
22
-    /**
23
-     * id for the html label tag
24
-     *
25
-     * @var string
26
-     */
27
-    protected $_html_label_id;
28
-
29
-    /**
30
-     * class for teh html label tag
31
-     *
32
-     * @var string
33
-     */
34
-    protected $_html_label_class;
35
-
36
-    /**
37
-     * style for teh html label tag
38
-     *
39
-     * @var string
40
-     */
41
-    protected $_html_label_style;
42
-
43
-    /**
44
-     * text to be placed in the html label
45
-     *
46
-     * @var string
47
-     */
48
-    protected $_html_label_text;
49
-
50
-    /**
51
-     * the full html label. If used, all other html_label_* properties are invalid
52
-     *
53
-     * @var string
54
-     */
55
-    protected $_html_label;
56
-
57
-    /**
58
-     * HTML to use for help text (normally placed below form input), in a span which normally
59
-     * has a class of 'description'
60
-     *
61
-     * @var string
62
-     */
63
-    protected $_html_help_text;
64
-
65
-    /**
66
-     * CSS classes for displaying the help span
67
-     *
68
-     * @var string
69
-     */
70
-    protected $_html_help_class = 'description';
71
-
72
-    /**
73
-     * CSS to put in the style attribute on the help span
74
-     *
75
-     * @var string
76
-     */
77
-    protected $_html_help_style;
78
-
79
-    /**
80
-     * Stores whether or not this input's response is required.
81
-     * Because certain styling elements may also want to know that this
82
-     * input is required etc.
83
-     *
84
-     * @var boolean
85
-     */
86
-    protected $_required;
87
-
88
-    /**
89
-     * css class added to required inputs
90
-     *
91
-     * @var string
92
-     */
93
-    protected $_required_css_class = 'ee-required';
94
-
95
-    /**
96
-     * css styles applied to button type inputs
97
-     *
98
-     * @var string
99
-     */
100
-    protected $_button_css_attributes;
101
-
102
-    /**
103
-     * The raw data submitted for this, like in the $_POST super global.
104
-     * Generally unsafe for usage in client code
105
-     *
106
-     * @var mixed string or array
107
-     */
108
-    protected $_raw_value;
109
-
110
-    /**
111
-     * Value normalized according to the input's normalization strategy.
112
-     * The normalization strategy dictates whether this is a string, int, float,
113
-     * boolean, or array of any of those.
114
-     *
115
-     * @var mixed
116
-     */
117
-    protected $_normalized_value;
118
-
119
-
120
-    /**
121
-     * Normalized default value either initially set on the input, or provided by calling
122
-     * set_default().
123
-     * @var mixed
124
-     */
125
-    protected $_default;
126
-
127
-    /**
128
-     * Strategy used for displaying this field.
129
-     * Child classes must use _get_display_strategy to access it.
130
-     *
131
-     * @var EE_Display_Strategy_Base
132
-     */
133
-    private $_display_strategy;
134
-
135
-    /**
136
-     * Gets all the validation strategies used on this field
137
-     *
138
-     * @var EE_Validation_Strategy_Base[]
139
-     */
140
-    private $_validation_strategies = array();
141
-
142
-    /**
143
-     * The normalization strategy for this field
144
-     *
145
-     * @var EE_Normalization_Strategy_Base
146
-     */
147
-    private $_normalization_strategy;
148
-
149
-    /**
150
-     * Strategy for removing sensitive data after we're done with the form input
151
-     *
152
-     * @var EE_Sensitive_Data_Removal_Base
153
-     */
154
-    protected $_sensitive_data_removal_strategy;
155
-
156
-    /**
157
-     * Whether this input has been disabled or not.
158
-     * If it's disabled while rendering, an extra hidden input is added that indicates it has been knowingly disabled.
159
-     * (Client-side code that wants to dynamically disable it must also add this hidden input).
160
-     * When the form is submitted, if the input is disabled in the PHP formsection, then input is ignored.
161
-     * If the input is missing from the $_REQUEST data but the hidden input indicating the input is disabled, then the input is again ignored.
162
-     *
163
-     * @var boolean
164
-     */
165
-    protected $disabled = false;
166
-
167
-
168
-
169
-    /**
170
-     * @param array                         $input_args       {
171
-     * @type string                         $html_name        the html name for the input
172
-     * @type string                         $html_label_id    the id attribute to give to the html label tag
173
-     * @type string                         $html_label_class the class attribute to give to the html label tag
174
-     * @type string                         $html_label_style the style attribute to give ot teh label tag
175
-     * @type string                         $html_label_text  the text to put in the label tag
176
-     * @type string                         $html_label       the full html label. If used,
177
-     *                                                        all other html_label_* args are invalid
178
-     * @type string                         $html_help_text   text to put in help element
179
-     * @type string                         $html_help_style  style attribute to give to teh help element
180
-     * @type string                         $html_help_class  class attribute to give to the help element
181
-     * @type string                         $default          default value NORMALIZED (eg, if providing the default
182
-     *       for a Yes_No_Input, you should provide TRUE or FALSE, not '1' or '0')
183
-     * @type EE_Display_Strategy_Base       $display          strategy
184
-     * @type EE_Normalization_Strategy_Base $normalization_strategy
185
-     * @type EE_Validation_Strategy_Base[]  $validation_strategies
186
-     * @type boolean                        $ignore_input special argument which can be used to avoid adding any validation strategies,
187
-     *                                                    and sets the normalization strategy to the Null normalization. This is good
188
-     *                                                    when you want the input to be totally ignored server-side (like when using
189
-     *                                                    React.js form inputs)
190
-     *                                                        }
191
-     */
192
-    public function __construct($input_args = array())
193
-    {
194
-        $input_args = (array) apply_filters('FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this);
195
-        // the following properties must be cast as arrays
196
-        if (isset($input_args['validation_strategies'])) {
197
-            foreach ((array) $input_args['validation_strategies'] as $validation_strategy) {
198
-                if ($validation_strategy instanceof EE_Validation_Strategy_Base && empty($input_args['ignore_input'])) {
199
-                    $this->_validation_strategies[ get_class($validation_strategy) ] = $validation_strategy;
200
-                }
201
-            }
202
-            unset($input_args['validation_strategies']);
203
-        }
204
-        if (isset($input_args['ignore_input'])) {
205
-            $this->_validation_strategies = array();
206
-        }
207
-        // loop thru incoming options
208
-        foreach ($input_args as $key => $value) {
209
-            // add underscore to $key to match property names
210
-            $_key = '_' . $key;
211
-            if (property_exists($this, $_key)) {
212
-                $this->{$_key} = $value;
213
-            }
214
-        }
215
-        // ensure that "required" is set correctly
216
-        $this->set_required(
217
-            $this->_required,
218
-            isset($input_args['required_validation_error_message'])
219
-            ? $input_args['required_validation_error_message']
220
-            : null
221
-        );
222
-        // $this->_html_name_specified = isset( $input_args['html_name'] ) ? TRUE : FALSE;
223
-        $this->_display_strategy->_construct_finalize($this);
224
-        foreach ($this->_validation_strategies as $validation_strategy) {
225
-            $validation_strategy->_construct_finalize($this);
226
-        }
227
-        if (isset($input_args['ignore_input'])) {
228
-            $this->_normalization_strategy = new EE_Null_Normalization();
229
-        }
230
-        if (! $this->_normalization_strategy) {
231
-                $this->_normalization_strategy = new EE_Text_Normalization();
232
-        }
233
-        $this->_normalization_strategy->_construct_finalize($this);
234
-        // at least we can use the normalization strategy to populate the default
235
-        if (isset($input_args['default'])) {
236
-            $this->set_default($input_args['default']);
237
-            unset($input_args['default']);
238
-        }
239
-        if (! $this->_sensitive_data_removal_strategy) {
240
-            $this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal();
241
-        }
242
-        $this->_sensitive_data_removal_strategy->_construct_finalize($this);
243
-        parent::__construct($input_args);
244
-    }
245
-
246
-
247
-
248
-    /**
249
-     * Sets the html_name to its default value, if none was specified in teh constructor.
250
-     * Calculation involves using the name and the parent's html_name
251
-     *
252
-     * @throws \EE_Error
253
-     */
254
-    protected function _set_default_html_name_if_empty()
255
-    {
256
-        if (! $this->_html_name) {
257
-            $this->_html_name = $this->name();
258
-            if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) {
259
-                $this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]";
260
-            }
261
-        }
262
-    }
263
-
264
-
265
-
266
-    /**
267
-     * @param $parent_form_section
268
-     * @param $name
269
-     * @throws \EE_Error
270
-     */
271
-    public function _construct_finalize($parent_form_section, $name)
272
-    {
273
-        parent::_construct_finalize($parent_form_section, $name);
274
-        if ($this->_html_label === null && $this->_html_label_text === null) {
275
-            $this->_html_label_text = ucwords(str_replace("_", " ", $name));
276
-        }
277
-        do_action('AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name);
278
-    }
279
-
280
-
281
-
282
-    /**
283
-     * Returns the strategy for displaying this form input. If none is set, throws an exception.
284
-     *
285
-     * @return EE_Display_Strategy_Base
286
-     * @throws EE_Error
287
-     */
288
-    protected function _get_display_strategy()
289
-    {
290
-        $this->ensure_construct_finalized_called();
291
-        if (! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) {
292
-            throw new EE_Error(
293
-                sprintf(
294
-                    __(
295
-                        "Cannot get display strategy for form input with name %s and id %s, because it has not been set in the constructor",
296
-                        "event_espresso"
297
-                    ),
298
-                    $this->html_name(),
299
-                    $this->html_id()
300
-                )
301
-            );
302
-        } else {
303
-            return $this->_display_strategy;
304
-        }
305
-    }
306
-
307
-
308
-
309
-    /**
310
-     * Sets the display strategy.
311
-     *
312
-     * @param EE_Display_Strategy_Base $strategy
313
-     */
314
-    protected function _set_display_strategy(EE_Display_Strategy_Base $strategy)
315
-    {
316
-        $this->_display_strategy = $strategy;
317
-    }
318
-
319
-
320
-
321
-    /**
322
-     * Sets the sanitization strategy
323
-     *
324
-     * @param EE_Normalization_Strategy_Base $strategy
325
-     */
326
-    protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy)
327
-    {
328
-        $this->_normalization_strategy = $strategy;
329
-    }
330
-
331
-
332
-
333
-    /**
334
-     * Gets sensitive_data_removal_strategy
335
-     *
336
-     * @return EE_Sensitive_Data_Removal_Base
337
-     */
338
-    public function get_sensitive_data_removal_strategy()
339
-    {
340
-        return $this->_sensitive_data_removal_strategy;
341
-    }
342
-
343
-
344
-
345
-    /**
346
-     * Sets sensitive_data_removal_strategy
347
-     *
348
-     * @param EE_Sensitive_Data_Removal_Base $sensitive_data_removal_strategy
349
-     * @return boolean
350
-     */
351
-    public function set_sensitive_data_removal_strategy($sensitive_data_removal_strategy)
352
-    {
353
-        $this->_sensitive_data_removal_strategy = $sensitive_data_removal_strategy;
354
-    }
355
-
356
-
357
-
358
-    /**
359
-     * Gets the display strategy for this input
360
-     *
361
-     * @return EE_Display_Strategy_Base
362
-     */
363
-    public function get_display_strategy()
364
-    {
365
-        return $this->_display_strategy;
366
-    }
367
-
368
-
369
-
370
-    /**
371
-     * Overwrites the display strategy
372
-     *
373
-     * @param EE_Display_Strategy_Base $display_strategy
374
-     */
375
-    public function set_display_strategy($display_strategy)
376
-    {
377
-        $this->_display_strategy = $display_strategy;
378
-        $this->_display_strategy->_construct_finalize($this);
379
-    }
380
-
381
-
382
-
383
-    /**
384
-     * Gets the normalization strategy set on this input
385
-     *
386
-     * @return EE_Normalization_Strategy_Base
387
-     */
388
-    public function get_normalization_strategy()
389
-    {
390
-        return $this->_normalization_strategy;
391
-    }
392
-
393
-
394
-
395
-    /**
396
-     * Overwrites the normalization strategy
397
-     *
398
-     * @param EE_Normalization_Strategy_Base $normalization_strategy
399
-     */
400
-    public function set_normalization_strategy($normalization_strategy)
401
-    {
402
-        $this->_normalization_strategy = $normalization_strategy;
403
-        $this->_normalization_strategy->_construct_finalize($this);
404
-    }
405
-
406
-
407
-
408
-    /**
409
-     * Returns all teh validation strategies which apply to this field, numerically indexed
410
-     *
411
-     * @return EE_Validation_Strategy_Base[]
412
-     */
413
-    public function get_validation_strategies()
414
-    {
415
-        return $this->_validation_strategies;
416
-    }
417
-
418
-
419
-
420
-    /**
421
-     * Adds this strategy to the field so it will be used in both JS validation and server-side validation
422
-     *
423
-     * @param EE_Validation_Strategy_Base $validation_strategy
424
-     * @return void
425
-     */
426
-    protected function _add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy)
427
-    {
428
-        $validation_strategy->_construct_finalize($this);
429
-        $this->_validation_strategies[] = $validation_strategy;
430
-    }
431
-
432
-
433
-
434
-    /**
435
-     * Adds a new validation strategy onto the form input
436
-     *
437
-     * @param EE_Validation_Strategy_Base $validation_strategy
438
-     * @return void
439
-     */
440
-    public function add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy)
441
-    {
442
-        $this->_add_validation_strategy($validation_strategy);
443
-    }
444
-
445
-
446
-
447
-    /**
448
-     * The classname of the validation strategy to remove
449
-     *
450
-     * @param string $validation_strategy_classname
451
-     */
452
-    public function remove_validation_strategy($validation_strategy_classname)
453
-    {
454
-        foreach ($this->_validation_strategies as $key => $validation_strategy) {
455
-            if (
456
-                $validation_strategy instanceof $validation_strategy_classname
457
-                || is_subclass_of($validation_strategy, $validation_strategy_classname)
458
-            ) {
459
-                unset($this->_validation_strategies[ $key ]);
460
-            }
461
-        }
462
-    }
463
-
464
-
465
-
466
-    /**
467
-     * returns true if input employs any of the validation strategy defined by the supplied array of classnames
468
-     *
469
-     * @param array $validation_strategy_classnames
470
-     * @return bool
471
-     */
472
-    public function has_validation_strategy($validation_strategy_classnames)
473
-    {
474
-        $validation_strategy_classnames = is_array($validation_strategy_classnames)
475
-            ? $validation_strategy_classnames
476
-            : array($validation_strategy_classnames);
477
-        foreach ($this->_validation_strategies as $key => $validation_strategy) {
478
-            if (in_array($key, $validation_strategy_classnames)) {
479
-                return true;
480
-            }
481
-        }
482
-        return false;
483
-    }
484
-
485
-
486
-
487
-    /**
488
-     * Gets the HTML
489
-     *
490
-     * @return string
491
-     */
492
-    public function get_html()
493
-    {
494
-        return $this->_parent_section->get_html_for_input($this);
495
-    }
496
-
497
-
498
-
499
-    /**
500
-     * Gets the HTML for the input itself (no label or errors) according to the
501
-     * input's display strategy
502
-     * Makes sure the JS and CSS are enqueued for it
503
-     *
504
-     * @return string
505
-     * @throws \EE_Error
506
-     */
507
-    public function get_html_for_input()
508
-    {
509
-        return $this->_form_html_filter
510
-            ? $this->_form_html_filter->filterHtml(
511
-                $this->_get_display_strategy()->display(),
512
-                $this
513
-            )
514
-            : $this->_get_display_strategy()->display();
515
-    }
516
-
517
-
518
-
519
-    /**
520
-     * @return string
521
-     */
522
-    public function html_other_attributes()
523
-    {
524
-        EE_Error::doing_it_wrong(
525
-            __METHOD__,
526
-            sprintf(
527
-                esc_html__(
528
-                    'This method is no longer in use. You should replace it by %s',
529
-                    'event_espresso'
530
-                ),
531
-                'EE_Form_Section_Base::other_html_attributes()'
532
-            ),
533
-            '4.10.2.p'
534
-        );
535
-
536
-        return $this->other_html_attributes();
537
-    }
538
-
539
-
540
-
541
-    /**
542
-     * @param string $html_other_attributes
543
-     */
544
-    public function set_html_other_attributes($html_other_attributes)
545
-    {
546
-        EE_Error::doing_it_wrong(
547
-            __METHOD__,
548
-            sprintf(
549
-                esc_html__(
550
-                    'This method is no longer in use. You should replace it by %s',
551
-                    'event_espresso'
552
-                ),
553
-                'EE_Form_Section_Base::set_other_html_attributes()'
554
-            ),
555
-            '4.10.2.p'
556
-        );
557
-
558
-        $this->set_other_html_attributes($html_other_attributes);
559
-    }
560
-
561
-
562
-
563
-    /**
564
-     * Gets the HTML for displaying the label for this form input
565
-     * according to the form section's layout strategy
566
-     *
567
-     * @return string
568
-     */
569
-    public function get_html_for_label()
570
-    {
571
-        return $this->_parent_section->get_layout_strategy()->display_label($this);
572
-    }
573
-
574
-
575
-
576
-    /**
577
-     * Gets the HTML for displaying the errors section for this form input
578
-     * according to the form section's layout strategy
579
-     *
580
-     * @return string
581
-     */
582
-    public function get_html_for_errors()
583
-    {
584
-        return $this->_parent_section->get_layout_strategy()->display_errors($this);
585
-    }
586
-
587
-
588
-
589
-    /**
590
-     * Gets the HTML for displaying the help text for this form input
591
-     * according to the form section's layout strategy
592
-     *
593
-     * @return string
594
-     */
595
-    public function get_html_for_help()
596
-    {
597
-        return $this->_parent_section->get_layout_strategy()->display_help_text($this);
598
-    }
599
-
600
-
601
-
602
-    /**
603
-     * Validates the input's sanitized value (assumes _sanitize() has already been called)
604
-     * and returns whether or not the form input's submitted value is value
605
-     *
606
-     * @return boolean
607
-     */
608
-    protected function _validate()
609
-    {
610
-        if ($this->isDisabled()) {
611
-            return true;
612
-        }
613
-        foreach ($this->_validation_strategies as $validation_strategy) {
614
-            if ($validation_strategy instanceof EE_Validation_Strategy_Base) {
615
-                try {
616
-                    $validation_strategy->validate($this->normalized_value());
617
-                } catch (EE_Validation_Error $e) {
618
-                    $this->add_validation_error($e);
619
-                }
620
-            }
621
-        }
622
-        if ($this->get_validation_errors()) {
623
-            return false;
624
-        } else {
625
-            return true;
626
-        }
627
-    }
628
-
629
-
630
-
631
-    /**
632
-     * Performs basic sanitization on this value. But what sanitization can be performed anyways?
633
-     * This value MIGHT be allowed to have tags, so we can't really remove them.
634
-     *
635
-     * @param string $value
636
-     * @return null|string
637
-     */
638
-    protected function _sanitize($value)
639
-    {
640
-        return $value !== null ? stripslashes(html_entity_decode(trim($value))) : null;
641
-    }
642
-
643
-
644
-
645
-    /**
646
-     * Picks out the form value that relates to this form input,
647
-     * and stores it as the sanitized value on the form input, and sets the normalized value.
648
-     * Returns whether or not any validation errors occurred
649
-     *
650
-     * @param array $req_data like $_POST
651
-     * @return boolean whether or not there was an error
652
-     * @throws \EE_Error
653
-     */
654
-    protected function _normalize($req_data)
655
-    {
656
-        // any existing validation errors don't apply so clear them
657
-        $this->_validation_errors = array();
658
-        // if the input is disabled, ignore whatever input was sent in
659
-        if ($this->isDisabled()) {
660
-            $this->_set_raw_value(null);
661
-            $this->_set_normalized_value($this->get_default());
662
-            return false;
663
-        }
664
-        try {
665
-            $raw_input = $this->find_form_data_for_this_section($req_data);
666
-            // super simple sanitization for now
667
-            if (is_array($raw_input)) {
668
-                $raw_value = array();
669
-                foreach ($raw_input as $key => $value) {
670
-                    $raw_value[ $key ] = $this->_sanitize($value);
671
-                }
672
-                $this->_set_raw_value($raw_value);
673
-            } else {
674
-                $this->_set_raw_value($this->_sanitize($raw_input));
675
-            }
676
-            // we want to mostly leave the input alone in case we need to re-display it to the user
677
-            $this->_set_normalized_value($this->_normalization_strategy->normalize($this->raw_value()));
678
-            return false;
679
-        } catch (EE_Validation_Error $e) {
680
-            $this->add_validation_error($e);
681
-            return true;
682
-        }
683
-    }
684
-
685
-
686
-
687
-    /**
688
-     * @return string
689
-     */
690
-    public function html_name()
691
-    {
692
-        $this->_set_default_html_name_if_empty();
693
-        return $this->_html_name;
694
-    }
695
-
696
-
697
-
698
-    /**
699
-     * @return string
700
-     */
701
-    public function html_label_id()
702
-    {
703
-        return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->html_id() . '-lbl';
704
-    }
705
-
706
-
707
-
708
-    /**
709
-     * @return string
710
-     */
711
-    public function html_label_class()
712
-    {
713
-        return $this->_html_label_class;
714
-    }
715
-
716
-
717
-
718
-    /**
719
-     * @return string
720
-     */
721
-    public function html_label_style()
722
-    {
723
-        return $this->_html_label_style;
724
-    }
725
-
726
-
727
-
728
-    /**
729
-     * @return string
730
-     */
731
-    public function html_label_text()
732
-    {
733
-        return $this->_html_label_text;
734
-    }
735
-
736
-
737
-
738
-    /**
739
-     * @return string
740
-     */
741
-    public function html_help_text()
742
-    {
743
-        return $this->_html_help_text;
744
-    }
745
-
746
-
747
-
748
-    /**
749
-     * @return string
750
-     */
751
-    public function html_help_class()
752
-    {
753
-        return $this->_html_help_class;
754
-    }
755
-
756
-
757
-
758
-    /**
759
-     * @return string
760
-     */
761
-    public function html_help_style()
762
-    {
763
-        return $this->_html_style;
764
-    }
765
-
766
-
767
-
768
-    /**
769
-     * returns the raw, UNSAFE, input, almost exactly as the user submitted it.
770
-     * Please note that almost all client code should instead use the normalized_value;
771
-     * or possibly raw_value_in_form (which prepares the string for displaying in an HTML attribute on a tag,
772
-     * mostly by escaping quotes)
773
-     * Note, we do not store the exact original value sent in the user's request because
774
-     * it may have malicious content, and we MIGHT want to store the form input in a transient or something...
775
-     * in which case, we would have stored the malicious content to our database.
776
-     *
777
-     * @return string
778
-     */
779
-    public function raw_value()
780
-    {
781
-        return $this->_raw_value;
782
-    }
783
-
784
-
785
-
786
-    /**
787
-     * Returns a string safe to usage in form inputs when displaying, because
788
-     * it escapes all html entities
789
-     *
790
-     * @return string
791
-     */
792
-    public function raw_value_in_form()
793
-    {
794
-        return htmlentities($this->raw_value(), ENT_QUOTES, 'UTF-8');
795
-    }
796
-
797
-
798
-
799
-    /**
800
-     * returns the value after it's been sanitized, and then converted into it's proper type
801
-     * in PHP. Eg, a string, an int, an array,
802
-     *
803
-     * @return mixed
804
-     */
805
-    public function normalized_value()
806
-    {
807
-        return $this->_normalized_value;
808
-    }
809
-
810
-
811
-
812
-    /**
813
-     * Returns the normalized value is a presentable way. By default this is just
814
-     * the normalized value by itself, but it can be overridden for when that's not
815
-     * the best thing to display
816
-     *
817
-     * @return string
818
-     */
819
-    public function pretty_value()
820
-    {
821
-        return $this->_normalized_value;
822
-    }
823
-
824
-
825
-
826
-    /**
827
-     * When generating the JS for the jquery validation rules like<br>
828
-     * <code>$( "#myform" ).validate({
829
-     * rules: {
830
-     * password: "required",
831
-     * password_again: {
832
-     * equalTo: "#password"
833
-     * }
834
-     * }
835
-     * });</code>
836
-     * if this field had the name 'password_again', it should return
837
-     * <br><code>password_again: {
838
-     * equalTo: "#password"
839
-     * }</code>
840
-     *
841
-     * @return array
842
-     */
843
-    public function get_jquery_validation_rules()
844
-    {
845
-        $jquery_validation_js = array();
846
-        $jquery_validation_rules = array();
847
-        foreach ($this->get_validation_strategies() as $validation_strategy) {
848
-            $jquery_validation_rules = array_replace_recursive(
849
-                $jquery_validation_rules,
850
-                $validation_strategy->get_jquery_validation_rule_array()
851
-            );
852
-        }
853
-        if (! empty($jquery_validation_rules)) {
854
-            foreach ($this->get_display_strategy()->get_html_input_ids(true) as $html_id_with_pound_sign) {
855
-                $jquery_validation_js[ $html_id_with_pound_sign ] = $jquery_validation_rules;
856
-            }
857
-        }
858
-        return $jquery_validation_js;
859
-    }
860
-
861
-
862
-
863
-    /**
864
-     * Sets the input's default value for use in displaying in the form. Note: value should be
865
-     * normalized (Eg, if providing a default of ra Yes_NO_Input you would provide TRUE or FALSE, not '1' or '0')
866
-     *
867
-     * @param mixed $value
868
-     * @return void
869
-     */
870
-    public function set_default($value)
871
-    {
872
-        $this->_default = $value;
873
-        $this->_set_normalized_value($value);
874
-        $this->_set_raw_value($value);
875
-    }
876
-
877
-
878
-
879
-    /**
880
-     * Sets the normalized value on this input
881
-     *
882
-     * @param mixed $value
883
-     */
884
-    protected function _set_normalized_value($value)
885
-    {
886
-        $this->_normalized_value = $value;
887
-    }
888
-
889
-
890
-
891
-    /**
892
-     * Sets the raw value on this input (ie, exactly as the user submitted it)
893
-     *
894
-     * @param mixed $value
895
-     */
896
-    protected function _set_raw_value($value)
897
-    {
898
-        $this->_raw_value = $this->_normalization_strategy->unnormalize($value);
899
-    }
900
-
901
-
902
-
903
-    /**
904
-     * Sets the HTML label text after it has already been defined
905
-     *
906
-     * @param string $label
907
-     * @return void
908
-     */
909
-    public function set_html_label_text($label)
910
-    {
911
-        $this->_html_label_text = $label;
912
-    }
913
-
914
-
915
-
916
-    /**
917
-     * Sets whether or not this field is required, and adjusts the validation strategy.
918
-     * If you want to use the EE_Conditionally_Required_Validation_Strategy,
919
-     * please add it as a validation strategy using add_validation_strategy as normal
920
-     *
921
-     * @param boolean $required boolean
922
-     * @param null    $required_text
923
-     */
924
-    public function set_required($required = true, $required_text = null)
925
-    {
926
-        $required = filter_var($required, FILTER_VALIDATE_BOOLEAN);
927
-        // whether $required is a string or a boolean, we want to add a required validation strategy
928
-        if ($required) {
929
-            $this->_add_validation_strategy(new EE_Required_Validation_Strategy($required_text));
930
-        } else {
931
-            $this->remove_validation_strategy('EE_Required_Validation_Strategy');
932
-        }
933
-        $this->_required = $required;
934
-    }
935
-
936
-
937
-
938
-    /**
939
-     * Returns whether or not this field is required
940
-     *
941
-     * @return boolean
942
-     */
943
-    public function required()
944
-    {
945
-        return $this->_required;
946
-    }
947
-
948
-
949
-
950
-    /**
951
-     * @param string $required_css_class
952
-     */
953
-    public function set_required_css_class($required_css_class)
954
-    {
955
-        $this->_required_css_class = $required_css_class;
956
-    }
957
-
958
-
959
-
960
-    /**
961
-     * @return string
962
-     */
963
-    public function required_css_class()
964
-    {
965
-        return $this->_required_css_class;
966
-    }
967
-
968
-
969
-
970
-    /**
971
-     * @param bool $add_required
972
-     * @return string
973
-     */
974
-    public function html_class($add_required = false)
975
-    {
976
-        return $add_required && $this->required()
977
-            ? $this->required_css_class() . ' ' . $this->_html_class
978
-            : $this->_html_class;
979
-    }
980
-
981
-
982
-    /**
983
-     * Sets the help text, in case
984
-     *
985
-     * @param string $text
986
-     */
987
-    public function set_html_help_text($text)
988
-    {
989
-        $this->_html_help_text = $text;
990
-    }
991
-
992
-
993
-
994
-    /**
995
-     * Uses the sensitive data removal strategy to remove the sensitive data from this
996
-     * input. If there is any kind of sensitive data removal on this input, we clear
997
-     * out the raw value completely
998
-     *
999
-     * @return void
1000
-     */
1001
-    public function clean_sensitive_data()
1002
-    {
1003
-        // if we do ANY kind of sensitive data removal on this, then just clear out the raw value
1004
-        // if we need more logic than this we'll make a strategy for it
1005
-        if (
1006
-            $this->_sensitive_data_removal_strategy
1007
-            && ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal
1008
-        ) {
1009
-            $this->_set_raw_value(null);
1010
-        }
1011
-        // and clean the normalized value according to the appropriate strategy
1012
-        $this->_set_normalized_value(
1013
-            $this->get_sensitive_data_removal_strategy()->remove_sensitive_data(
1014
-                $this->_normalized_value
1015
-            )
1016
-        );
1017
-    }
1018
-
1019
-
1020
-
1021
-    /**
1022
-     * @param bool   $primary
1023
-     * @param string $button_size
1024
-     * @param string $other_attributes
1025
-     */
1026
-    public function set_button_css_attributes($primary = true, $button_size = '', $other_attributes = '')
1027
-    {
1028
-        $button_css_attributes = 'button';
1029
-        $button_css_attributes .= $primary === true ? ' button-primary' : ' button-secondary';
1030
-        switch ($button_size) {
1031
-            case 'xs':
1032
-            case 'extra-small':
1033
-                $button_css_attributes .= ' button-xs';
1034
-                break;
1035
-            case 'sm':
1036
-            case 'small':
1037
-                $button_css_attributes .= ' button-sm';
1038
-                break;
1039
-            case 'lg':
1040
-            case 'large':
1041
-                $button_css_attributes .= ' button-lg';
1042
-                break;
1043
-            case 'block':
1044
-                $button_css_attributes .= ' button-block';
1045
-                break;
1046
-            case 'md':
1047
-            case 'medium':
1048
-            default:
1049
-                $button_css_attributes .= '';
1050
-        }
1051
-        $this->_button_css_attributes .= ! empty($other_attributes)
1052
-            ? $button_css_attributes . ' ' . $other_attributes
1053
-            : $button_css_attributes;
1054
-    }
1055
-
1056
-
1057
-
1058
-    /**
1059
-     * @return string
1060
-     */
1061
-    public function button_css_attributes()
1062
-    {
1063
-        if (empty($this->_button_css_attributes)) {
1064
-            $this->set_button_css_attributes();
1065
-        }
1066
-        return $this->_button_css_attributes;
1067
-    }
1068
-
1069
-
1070
-
1071
-    /**
1072
-     * find_form_data_for_this_section
1073
-     * using this section's name and its parents, finds the value of the form data that corresponds to it.
1074
-     * For example, if this form section's HTML name is my_form[subform][form_input_1],
1075
-     * then it's value should be in $_REQUEST at $_REQUEST['my_form']['subform']['form_input_1'].
1076
-     * (If that doesn't exist, we also check for this subsection's name
1077
-     * at the TOP LEVEL of the request data. Eg $_REQUEST['form_input_1'].)
1078
-     * This function finds its value in the form.
1079
-     *
1080
-     * @param array $req_data
1081
-     * @return mixed whatever the raw value of this form section is in the request data
1082
-     * @throws \EE_Error
1083
-     */
1084
-    public function find_form_data_for_this_section($req_data)
1085
-    {
1086
-        $name_parts = $this->getInputNameParts();
1087
-        // now get the value for the input
1088
-        $value = $this->findRequestForSectionUsingNameParts($name_parts, $req_data);
1089
-        // check if this thing's name is at the TOP level of the request data
1090
-        if ($value === null && isset($req_data[ $this->name() ])) {
1091
-            $value = $req_data[ $this->name() ];
1092
-        }
1093
-        return $value;
1094
-    }
1095
-
1096
-
1097
-
1098
-    /**
1099
-     * If this input's name is something like "foo[bar][baz]"
1100
-     * returns an array like `array('foo','bar',baz')`
1101
-     * @return array
1102
-     */
1103
-    protected function getInputNameParts()
1104
-    {
1105
-        // break up the html name by "[]"
1106
-        if (strpos($this->html_name(), '[') !== false) {
1107
-            $before_any_brackets = substr($this->html_name(), 0, strpos($this->html_name(), '['));
1108
-        } else {
1109
-            $before_any_brackets = $this->html_name();
1110
-        }
1111
-        // grab all of the segments
1112
-        preg_match_all('~\[([^]]*)\]~', $this->html_name(), $matches);
1113
-        if (isset($matches[1]) && is_array($matches[1])) {
1114
-            $name_parts = $matches[1];
1115
-            array_unshift($name_parts, $before_any_brackets);
1116
-        } else {
1117
-            $name_parts = array($before_any_brackets);
1118
-        }
1119
-        return $name_parts;
1120
-    }
1121
-
1122
-
1123
-
1124
-    /**
1125
-     * @param array $html_name_parts
1126
-     * @param array $req_data
1127
-     * @return array | NULL
1128
-     */
1129
-    public function findRequestForSectionUsingNameParts($html_name_parts, $req_data)
1130
-    {
1131
-        $first_part_to_consider = array_shift($html_name_parts);
1132
-        if (isset($req_data[ $first_part_to_consider ])) {
1133
-            if (empty($html_name_parts)) {
1134
-                return $req_data[ $first_part_to_consider ];
1135
-            } else {
1136
-                return $this->findRequestForSectionUsingNameParts(
1137
-                    $html_name_parts,
1138
-                    $req_data[ $first_part_to_consider ]
1139
-                );
1140
-            }
1141
-        } else {
1142
-            return null;
1143
-        }
1144
-    }
1145
-
1146
-
1147
-
1148
-    /**
1149
-     * Checks if this form input's data is in the request data
1150
-     *
1151
-     * @param array $req_data like $_POST
1152
-     * @return boolean
1153
-     * @throws \EE_Error
1154
-     */
1155
-    public function form_data_present_in($req_data = null)
1156
-    {
1157
-        if ($req_data === null) {
1158
-            $req_data = $_POST;
1159
-        }
1160
-        $checked_value = $this->find_form_data_for_this_section($req_data);
1161
-        if ($checked_value !== null) {
1162
-            return true;
1163
-        } else {
1164
-            return false;
1165
-        }
1166
-    }
1167
-
1168
-
1169
-
1170
-    /**
1171
-     * Overrides parent to add js data from validation and display strategies
1172
-     *
1173
-     * @param array $form_other_js_data
1174
-     * @return array
1175
-     */
1176
-    public function get_other_js_data($form_other_js_data = array())
1177
-    {
1178
-        $form_other_js_data = $this->get_other_js_data_from_strategies($form_other_js_data);
1179
-        return $form_other_js_data;
1180
-    }
1181
-
1182
-
1183
-
1184
-    /**
1185
-     * Gets other JS data for localization from this input's strategies, like
1186
-     * the validation strategies and the display strategy
1187
-     *
1188
-     * @param array $form_other_js_data
1189
-     * @return array
1190
-     */
1191
-    public function get_other_js_data_from_strategies($form_other_js_data = array())
1192
-    {
1193
-        $form_other_js_data = $this->get_display_strategy()->get_other_js_data($form_other_js_data);
1194
-        foreach ($this->get_validation_strategies() as $validation_strategy) {
1195
-            $form_other_js_data = $validation_strategy->get_other_js_data($form_other_js_data);
1196
-        }
1197
-        return $form_other_js_data;
1198
-    }
1199
-
1200
-
1201
-
1202
-    /**
1203
-     * Override parent because we want to give our strategies an opportunity to enqueue some js and css
1204
-     *
1205
-     * @return void
1206
-     */
1207
-    public function enqueue_js()
1208
-    {
1209
-        // ask our display strategy and validation strategies if they have js to enqueue
1210
-        $this->enqueue_js_from_strategies();
1211
-    }
1212
-
1213
-
1214
-
1215
-    /**
1216
-     * Tells strategies when its ok to enqueue their js and css
1217
-     *
1218
-     * @return void
1219
-     */
1220
-    public function enqueue_js_from_strategies()
1221
-    {
1222
-        $this->get_display_strategy()->enqueue_js();
1223
-        foreach ($this->get_validation_strategies() as $validation_strategy) {
1224
-            $validation_strategy->enqueue_js();
1225
-        }
1226
-    }
1227
-
1228
-
1229
-
1230
-    /**
1231
-     * Gets the default value set on the input (not the current value, which may have been
1232
-     * changed because of a form submission). If no default was set, this us null.
1233
-     * @return mixed
1234
-     */
1235
-    public function get_default()
1236
-    {
1237
-        return $this->_default;
1238
-    }
1239
-
1240
-
1241
-
1242
-    /**
1243
-     * Makes this input disabled. That means it will have the HTML attribute 'disabled="disabled"',
1244
-     * and server-side if any input was received it will be ignored
1245
-     */
1246
-    public function disable($disable = true)
1247
-    {
1248
-        $disabled_attribute = ' disabled="disabled"';
1249
-        $this->disabled = filter_var($disable, FILTER_VALIDATE_BOOLEAN);
1250
-        if ($this->disabled) {
1251
-            if (strpos($this->_other_html_attributes, $disabled_attribute) === false) {
1252
-                $this->_other_html_attributes .= $disabled_attribute;
1253
-            }
1254
-            $this->_set_normalized_value($this->get_default());
1255
-        } else {
1256
-            $this->_other_html_attributes = str_replace($disabled_attribute, '', $this->_other_html_attributes);
1257
-        }
1258
-    }
1259
-
1260
-
1261
-
1262
-    /**
1263
-     * Returns whether or not this input is currently disabled.
1264
-     * @return bool
1265
-     */
1266
-    public function isDisabled()
1267
-    {
1268
-        return $this->disabled;
1269
-    }
15
+	/**
16
+	 * the input's name attribute
17
+	 *
18
+	 * @var string
19
+	 */
20
+	protected $_html_name;
21
+
22
+	/**
23
+	 * id for the html label tag
24
+	 *
25
+	 * @var string
26
+	 */
27
+	protected $_html_label_id;
28
+
29
+	/**
30
+	 * class for teh html label tag
31
+	 *
32
+	 * @var string
33
+	 */
34
+	protected $_html_label_class;
35
+
36
+	/**
37
+	 * style for teh html label tag
38
+	 *
39
+	 * @var string
40
+	 */
41
+	protected $_html_label_style;
42
+
43
+	/**
44
+	 * text to be placed in the html label
45
+	 *
46
+	 * @var string
47
+	 */
48
+	protected $_html_label_text;
49
+
50
+	/**
51
+	 * the full html label. If used, all other html_label_* properties are invalid
52
+	 *
53
+	 * @var string
54
+	 */
55
+	protected $_html_label;
56
+
57
+	/**
58
+	 * HTML to use for help text (normally placed below form input), in a span which normally
59
+	 * has a class of 'description'
60
+	 *
61
+	 * @var string
62
+	 */
63
+	protected $_html_help_text;
64
+
65
+	/**
66
+	 * CSS classes for displaying the help span
67
+	 *
68
+	 * @var string
69
+	 */
70
+	protected $_html_help_class = 'description';
71
+
72
+	/**
73
+	 * CSS to put in the style attribute on the help span
74
+	 *
75
+	 * @var string
76
+	 */
77
+	protected $_html_help_style;
78
+
79
+	/**
80
+	 * Stores whether or not this input's response is required.
81
+	 * Because certain styling elements may also want to know that this
82
+	 * input is required etc.
83
+	 *
84
+	 * @var boolean
85
+	 */
86
+	protected $_required;
87
+
88
+	/**
89
+	 * css class added to required inputs
90
+	 *
91
+	 * @var string
92
+	 */
93
+	protected $_required_css_class = 'ee-required';
94
+
95
+	/**
96
+	 * css styles applied to button type inputs
97
+	 *
98
+	 * @var string
99
+	 */
100
+	protected $_button_css_attributes;
101
+
102
+	/**
103
+	 * The raw data submitted for this, like in the $_POST super global.
104
+	 * Generally unsafe for usage in client code
105
+	 *
106
+	 * @var mixed string or array
107
+	 */
108
+	protected $_raw_value;
109
+
110
+	/**
111
+	 * Value normalized according to the input's normalization strategy.
112
+	 * The normalization strategy dictates whether this is a string, int, float,
113
+	 * boolean, or array of any of those.
114
+	 *
115
+	 * @var mixed
116
+	 */
117
+	protected $_normalized_value;
118
+
119
+
120
+	/**
121
+	 * Normalized default value either initially set on the input, or provided by calling
122
+	 * set_default().
123
+	 * @var mixed
124
+	 */
125
+	protected $_default;
126
+
127
+	/**
128
+	 * Strategy used for displaying this field.
129
+	 * Child classes must use _get_display_strategy to access it.
130
+	 *
131
+	 * @var EE_Display_Strategy_Base
132
+	 */
133
+	private $_display_strategy;
134
+
135
+	/**
136
+	 * Gets all the validation strategies used on this field
137
+	 *
138
+	 * @var EE_Validation_Strategy_Base[]
139
+	 */
140
+	private $_validation_strategies = array();
141
+
142
+	/**
143
+	 * The normalization strategy for this field
144
+	 *
145
+	 * @var EE_Normalization_Strategy_Base
146
+	 */
147
+	private $_normalization_strategy;
148
+
149
+	/**
150
+	 * Strategy for removing sensitive data after we're done with the form input
151
+	 *
152
+	 * @var EE_Sensitive_Data_Removal_Base
153
+	 */
154
+	protected $_sensitive_data_removal_strategy;
155
+
156
+	/**
157
+	 * Whether this input has been disabled or not.
158
+	 * If it's disabled while rendering, an extra hidden input is added that indicates it has been knowingly disabled.
159
+	 * (Client-side code that wants to dynamically disable it must also add this hidden input).
160
+	 * When the form is submitted, if the input is disabled in the PHP formsection, then input is ignored.
161
+	 * If the input is missing from the $_REQUEST data but the hidden input indicating the input is disabled, then the input is again ignored.
162
+	 *
163
+	 * @var boolean
164
+	 */
165
+	protected $disabled = false;
166
+
167
+
168
+
169
+	/**
170
+	 * @param array                         $input_args       {
171
+	 * @type string                         $html_name        the html name for the input
172
+	 * @type string                         $html_label_id    the id attribute to give to the html label tag
173
+	 * @type string                         $html_label_class the class attribute to give to the html label tag
174
+	 * @type string                         $html_label_style the style attribute to give ot teh label tag
175
+	 * @type string                         $html_label_text  the text to put in the label tag
176
+	 * @type string                         $html_label       the full html label. If used,
177
+	 *                                                        all other html_label_* args are invalid
178
+	 * @type string                         $html_help_text   text to put in help element
179
+	 * @type string                         $html_help_style  style attribute to give to teh help element
180
+	 * @type string                         $html_help_class  class attribute to give to the help element
181
+	 * @type string                         $default          default value NORMALIZED (eg, if providing the default
182
+	 *       for a Yes_No_Input, you should provide TRUE or FALSE, not '1' or '0')
183
+	 * @type EE_Display_Strategy_Base       $display          strategy
184
+	 * @type EE_Normalization_Strategy_Base $normalization_strategy
185
+	 * @type EE_Validation_Strategy_Base[]  $validation_strategies
186
+	 * @type boolean                        $ignore_input special argument which can be used to avoid adding any validation strategies,
187
+	 *                                                    and sets the normalization strategy to the Null normalization. This is good
188
+	 *                                                    when you want the input to be totally ignored server-side (like when using
189
+	 *                                                    React.js form inputs)
190
+	 *                                                        }
191
+	 */
192
+	public function __construct($input_args = array())
193
+	{
194
+		$input_args = (array) apply_filters('FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this);
195
+		// the following properties must be cast as arrays
196
+		if (isset($input_args['validation_strategies'])) {
197
+			foreach ((array) $input_args['validation_strategies'] as $validation_strategy) {
198
+				if ($validation_strategy instanceof EE_Validation_Strategy_Base && empty($input_args['ignore_input'])) {
199
+					$this->_validation_strategies[ get_class($validation_strategy) ] = $validation_strategy;
200
+				}
201
+			}
202
+			unset($input_args['validation_strategies']);
203
+		}
204
+		if (isset($input_args['ignore_input'])) {
205
+			$this->_validation_strategies = array();
206
+		}
207
+		// loop thru incoming options
208
+		foreach ($input_args as $key => $value) {
209
+			// add underscore to $key to match property names
210
+			$_key = '_' . $key;
211
+			if (property_exists($this, $_key)) {
212
+				$this->{$_key} = $value;
213
+			}
214
+		}
215
+		// ensure that "required" is set correctly
216
+		$this->set_required(
217
+			$this->_required,
218
+			isset($input_args['required_validation_error_message'])
219
+			? $input_args['required_validation_error_message']
220
+			: null
221
+		);
222
+		// $this->_html_name_specified = isset( $input_args['html_name'] ) ? TRUE : FALSE;
223
+		$this->_display_strategy->_construct_finalize($this);
224
+		foreach ($this->_validation_strategies as $validation_strategy) {
225
+			$validation_strategy->_construct_finalize($this);
226
+		}
227
+		if (isset($input_args['ignore_input'])) {
228
+			$this->_normalization_strategy = new EE_Null_Normalization();
229
+		}
230
+		if (! $this->_normalization_strategy) {
231
+				$this->_normalization_strategy = new EE_Text_Normalization();
232
+		}
233
+		$this->_normalization_strategy->_construct_finalize($this);
234
+		// at least we can use the normalization strategy to populate the default
235
+		if (isset($input_args['default'])) {
236
+			$this->set_default($input_args['default']);
237
+			unset($input_args['default']);
238
+		}
239
+		if (! $this->_sensitive_data_removal_strategy) {
240
+			$this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal();
241
+		}
242
+		$this->_sensitive_data_removal_strategy->_construct_finalize($this);
243
+		parent::__construct($input_args);
244
+	}
245
+
246
+
247
+
248
+	/**
249
+	 * Sets the html_name to its default value, if none was specified in teh constructor.
250
+	 * Calculation involves using the name and the parent's html_name
251
+	 *
252
+	 * @throws \EE_Error
253
+	 */
254
+	protected function _set_default_html_name_if_empty()
255
+	{
256
+		if (! $this->_html_name) {
257
+			$this->_html_name = $this->name();
258
+			if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) {
259
+				$this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]";
260
+			}
261
+		}
262
+	}
263
+
264
+
265
+
266
+	/**
267
+	 * @param $parent_form_section
268
+	 * @param $name
269
+	 * @throws \EE_Error
270
+	 */
271
+	public function _construct_finalize($parent_form_section, $name)
272
+	{
273
+		parent::_construct_finalize($parent_form_section, $name);
274
+		if ($this->_html_label === null && $this->_html_label_text === null) {
275
+			$this->_html_label_text = ucwords(str_replace("_", " ", $name));
276
+		}
277
+		do_action('AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name);
278
+	}
279
+
280
+
281
+
282
+	/**
283
+	 * Returns the strategy for displaying this form input. If none is set, throws an exception.
284
+	 *
285
+	 * @return EE_Display_Strategy_Base
286
+	 * @throws EE_Error
287
+	 */
288
+	protected function _get_display_strategy()
289
+	{
290
+		$this->ensure_construct_finalized_called();
291
+		if (! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) {
292
+			throw new EE_Error(
293
+				sprintf(
294
+					__(
295
+						"Cannot get display strategy for form input with name %s and id %s, because it has not been set in the constructor",
296
+						"event_espresso"
297
+					),
298
+					$this->html_name(),
299
+					$this->html_id()
300
+				)
301
+			);
302
+		} else {
303
+			return $this->_display_strategy;
304
+		}
305
+	}
306
+
307
+
308
+
309
+	/**
310
+	 * Sets the display strategy.
311
+	 *
312
+	 * @param EE_Display_Strategy_Base $strategy
313
+	 */
314
+	protected function _set_display_strategy(EE_Display_Strategy_Base $strategy)
315
+	{
316
+		$this->_display_strategy = $strategy;
317
+	}
318
+
319
+
320
+
321
+	/**
322
+	 * Sets the sanitization strategy
323
+	 *
324
+	 * @param EE_Normalization_Strategy_Base $strategy
325
+	 */
326
+	protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy)
327
+	{
328
+		$this->_normalization_strategy = $strategy;
329
+	}
330
+
331
+
332
+
333
+	/**
334
+	 * Gets sensitive_data_removal_strategy
335
+	 *
336
+	 * @return EE_Sensitive_Data_Removal_Base
337
+	 */
338
+	public function get_sensitive_data_removal_strategy()
339
+	{
340
+		return $this->_sensitive_data_removal_strategy;
341
+	}
342
+
343
+
344
+
345
+	/**
346
+	 * Sets sensitive_data_removal_strategy
347
+	 *
348
+	 * @param EE_Sensitive_Data_Removal_Base $sensitive_data_removal_strategy
349
+	 * @return boolean
350
+	 */
351
+	public function set_sensitive_data_removal_strategy($sensitive_data_removal_strategy)
352
+	{
353
+		$this->_sensitive_data_removal_strategy = $sensitive_data_removal_strategy;
354
+	}
355
+
356
+
357
+
358
+	/**
359
+	 * Gets the display strategy for this input
360
+	 *
361
+	 * @return EE_Display_Strategy_Base
362
+	 */
363
+	public function get_display_strategy()
364
+	{
365
+		return $this->_display_strategy;
366
+	}
367
+
368
+
369
+
370
+	/**
371
+	 * Overwrites the display strategy
372
+	 *
373
+	 * @param EE_Display_Strategy_Base $display_strategy
374
+	 */
375
+	public function set_display_strategy($display_strategy)
376
+	{
377
+		$this->_display_strategy = $display_strategy;
378
+		$this->_display_strategy->_construct_finalize($this);
379
+	}
380
+
381
+
382
+
383
+	/**
384
+	 * Gets the normalization strategy set on this input
385
+	 *
386
+	 * @return EE_Normalization_Strategy_Base
387
+	 */
388
+	public function get_normalization_strategy()
389
+	{
390
+		return $this->_normalization_strategy;
391
+	}
392
+
393
+
394
+
395
+	/**
396
+	 * Overwrites the normalization strategy
397
+	 *
398
+	 * @param EE_Normalization_Strategy_Base $normalization_strategy
399
+	 */
400
+	public function set_normalization_strategy($normalization_strategy)
401
+	{
402
+		$this->_normalization_strategy = $normalization_strategy;
403
+		$this->_normalization_strategy->_construct_finalize($this);
404
+	}
405
+
406
+
407
+
408
+	/**
409
+	 * Returns all teh validation strategies which apply to this field, numerically indexed
410
+	 *
411
+	 * @return EE_Validation_Strategy_Base[]
412
+	 */
413
+	public function get_validation_strategies()
414
+	{
415
+		return $this->_validation_strategies;
416
+	}
417
+
418
+
419
+
420
+	/**
421
+	 * Adds this strategy to the field so it will be used in both JS validation and server-side validation
422
+	 *
423
+	 * @param EE_Validation_Strategy_Base $validation_strategy
424
+	 * @return void
425
+	 */
426
+	protected function _add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy)
427
+	{
428
+		$validation_strategy->_construct_finalize($this);
429
+		$this->_validation_strategies[] = $validation_strategy;
430
+	}
431
+
432
+
433
+
434
+	/**
435
+	 * Adds a new validation strategy onto the form input
436
+	 *
437
+	 * @param EE_Validation_Strategy_Base $validation_strategy
438
+	 * @return void
439
+	 */
440
+	public function add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy)
441
+	{
442
+		$this->_add_validation_strategy($validation_strategy);
443
+	}
444
+
445
+
446
+
447
+	/**
448
+	 * The classname of the validation strategy to remove
449
+	 *
450
+	 * @param string $validation_strategy_classname
451
+	 */
452
+	public function remove_validation_strategy($validation_strategy_classname)
453
+	{
454
+		foreach ($this->_validation_strategies as $key => $validation_strategy) {
455
+			if (
456
+				$validation_strategy instanceof $validation_strategy_classname
457
+				|| is_subclass_of($validation_strategy, $validation_strategy_classname)
458
+			) {
459
+				unset($this->_validation_strategies[ $key ]);
460
+			}
461
+		}
462
+	}
463
+
464
+
465
+
466
+	/**
467
+	 * returns true if input employs any of the validation strategy defined by the supplied array of classnames
468
+	 *
469
+	 * @param array $validation_strategy_classnames
470
+	 * @return bool
471
+	 */
472
+	public function has_validation_strategy($validation_strategy_classnames)
473
+	{
474
+		$validation_strategy_classnames = is_array($validation_strategy_classnames)
475
+			? $validation_strategy_classnames
476
+			: array($validation_strategy_classnames);
477
+		foreach ($this->_validation_strategies as $key => $validation_strategy) {
478
+			if (in_array($key, $validation_strategy_classnames)) {
479
+				return true;
480
+			}
481
+		}
482
+		return false;
483
+	}
484
+
485
+
486
+
487
+	/**
488
+	 * Gets the HTML
489
+	 *
490
+	 * @return string
491
+	 */
492
+	public function get_html()
493
+	{
494
+		return $this->_parent_section->get_html_for_input($this);
495
+	}
496
+
497
+
498
+
499
+	/**
500
+	 * Gets the HTML for the input itself (no label or errors) according to the
501
+	 * input's display strategy
502
+	 * Makes sure the JS and CSS are enqueued for it
503
+	 *
504
+	 * @return string
505
+	 * @throws \EE_Error
506
+	 */
507
+	public function get_html_for_input()
508
+	{
509
+		return $this->_form_html_filter
510
+			? $this->_form_html_filter->filterHtml(
511
+				$this->_get_display_strategy()->display(),
512
+				$this
513
+			)
514
+			: $this->_get_display_strategy()->display();
515
+	}
516
+
517
+
518
+
519
+	/**
520
+	 * @return string
521
+	 */
522
+	public function html_other_attributes()
523
+	{
524
+		EE_Error::doing_it_wrong(
525
+			__METHOD__,
526
+			sprintf(
527
+				esc_html__(
528
+					'This method is no longer in use. You should replace it by %s',
529
+					'event_espresso'
530
+				),
531
+				'EE_Form_Section_Base::other_html_attributes()'
532
+			),
533
+			'4.10.2.p'
534
+		);
535
+
536
+		return $this->other_html_attributes();
537
+	}
538
+
539
+
540
+
541
+	/**
542
+	 * @param string $html_other_attributes
543
+	 */
544
+	public function set_html_other_attributes($html_other_attributes)
545
+	{
546
+		EE_Error::doing_it_wrong(
547
+			__METHOD__,
548
+			sprintf(
549
+				esc_html__(
550
+					'This method is no longer in use. You should replace it by %s',
551
+					'event_espresso'
552
+				),
553
+				'EE_Form_Section_Base::set_other_html_attributes()'
554
+			),
555
+			'4.10.2.p'
556
+		);
557
+
558
+		$this->set_other_html_attributes($html_other_attributes);
559
+	}
560
+
561
+
562
+
563
+	/**
564
+	 * Gets the HTML for displaying the label for this form input
565
+	 * according to the form section's layout strategy
566
+	 *
567
+	 * @return string
568
+	 */
569
+	public function get_html_for_label()
570
+	{
571
+		return $this->_parent_section->get_layout_strategy()->display_label($this);
572
+	}
573
+
574
+
575
+
576
+	/**
577
+	 * Gets the HTML for displaying the errors section for this form input
578
+	 * according to the form section's layout strategy
579
+	 *
580
+	 * @return string
581
+	 */
582
+	public function get_html_for_errors()
583
+	{
584
+		return $this->_parent_section->get_layout_strategy()->display_errors($this);
585
+	}
586
+
587
+
588
+
589
+	/**
590
+	 * Gets the HTML for displaying the help text for this form input
591
+	 * according to the form section's layout strategy
592
+	 *
593
+	 * @return string
594
+	 */
595
+	public function get_html_for_help()
596
+	{
597
+		return $this->_parent_section->get_layout_strategy()->display_help_text($this);
598
+	}
599
+
600
+
601
+
602
+	/**
603
+	 * Validates the input's sanitized value (assumes _sanitize() has already been called)
604
+	 * and returns whether or not the form input's submitted value is value
605
+	 *
606
+	 * @return boolean
607
+	 */
608
+	protected function _validate()
609
+	{
610
+		if ($this->isDisabled()) {
611
+			return true;
612
+		}
613
+		foreach ($this->_validation_strategies as $validation_strategy) {
614
+			if ($validation_strategy instanceof EE_Validation_Strategy_Base) {
615
+				try {
616
+					$validation_strategy->validate($this->normalized_value());
617
+				} catch (EE_Validation_Error $e) {
618
+					$this->add_validation_error($e);
619
+				}
620
+			}
621
+		}
622
+		if ($this->get_validation_errors()) {
623
+			return false;
624
+		} else {
625
+			return true;
626
+		}
627
+	}
628
+
629
+
630
+
631
+	/**
632
+	 * Performs basic sanitization on this value. But what sanitization can be performed anyways?
633
+	 * This value MIGHT be allowed to have tags, so we can't really remove them.
634
+	 *
635
+	 * @param string $value
636
+	 * @return null|string
637
+	 */
638
+	protected function _sanitize($value)
639
+	{
640
+		return $value !== null ? stripslashes(html_entity_decode(trim($value))) : null;
641
+	}
642
+
643
+
644
+
645
+	/**
646
+	 * Picks out the form value that relates to this form input,
647
+	 * and stores it as the sanitized value on the form input, and sets the normalized value.
648
+	 * Returns whether or not any validation errors occurred
649
+	 *
650
+	 * @param array $req_data like $_POST
651
+	 * @return boolean whether or not there was an error
652
+	 * @throws \EE_Error
653
+	 */
654
+	protected function _normalize($req_data)
655
+	{
656
+		// any existing validation errors don't apply so clear them
657
+		$this->_validation_errors = array();
658
+		// if the input is disabled, ignore whatever input was sent in
659
+		if ($this->isDisabled()) {
660
+			$this->_set_raw_value(null);
661
+			$this->_set_normalized_value($this->get_default());
662
+			return false;
663
+		}
664
+		try {
665
+			$raw_input = $this->find_form_data_for_this_section($req_data);
666
+			// super simple sanitization for now
667
+			if (is_array($raw_input)) {
668
+				$raw_value = array();
669
+				foreach ($raw_input as $key => $value) {
670
+					$raw_value[ $key ] = $this->_sanitize($value);
671
+				}
672
+				$this->_set_raw_value($raw_value);
673
+			} else {
674
+				$this->_set_raw_value($this->_sanitize($raw_input));
675
+			}
676
+			// we want to mostly leave the input alone in case we need to re-display it to the user
677
+			$this->_set_normalized_value($this->_normalization_strategy->normalize($this->raw_value()));
678
+			return false;
679
+		} catch (EE_Validation_Error $e) {
680
+			$this->add_validation_error($e);
681
+			return true;
682
+		}
683
+	}
684
+
685
+
686
+
687
+	/**
688
+	 * @return string
689
+	 */
690
+	public function html_name()
691
+	{
692
+		$this->_set_default_html_name_if_empty();
693
+		return $this->_html_name;
694
+	}
695
+
696
+
697
+
698
+	/**
699
+	 * @return string
700
+	 */
701
+	public function html_label_id()
702
+	{
703
+		return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->html_id() . '-lbl';
704
+	}
705
+
706
+
707
+
708
+	/**
709
+	 * @return string
710
+	 */
711
+	public function html_label_class()
712
+	{
713
+		return $this->_html_label_class;
714
+	}
715
+
716
+
717
+
718
+	/**
719
+	 * @return string
720
+	 */
721
+	public function html_label_style()
722
+	{
723
+		return $this->_html_label_style;
724
+	}
725
+
726
+
727
+
728
+	/**
729
+	 * @return string
730
+	 */
731
+	public function html_label_text()
732
+	{
733
+		return $this->_html_label_text;
734
+	}
735
+
736
+
737
+
738
+	/**
739
+	 * @return string
740
+	 */
741
+	public function html_help_text()
742
+	{
743
+		return $this->_html_help_text;
744
+	}
745
+
746
+
747
+
748
+	/**
749
+	 * @return string
750
+	 */
751
+	public function html_help_class()
752
+	{
753
+		return $this->_html_help_class;
754
+	}
755
+
756
+
757
+
758
+	/**
759
+	 * @return string
760
+	 */
761
+	public function html_help_style()
762
+	{
763
+		return $this->_html_style;
764
+	}
765
+
766
+
767
+
768
+	/**
769
+	 * returns the raw, UNSAFE, input, almost exactly as the user submitted it.
770
+	 * Please note that almost all client code should instead use the normalized_value;
771
+	 * or possibly raw_value_in_form (which prepares the string for displaying in an HTML attribute on a tag,
772
+	 * mostly by escaping quotes)
773
+	 * Note, we do not store the exact original value sent in the user's request because
774
+	 * it may have malicious content, and we MIGHT want to store the form input in a transient or something...
775
+	 * in which case, we would have stored the malicious content to our database.
776
+	 *
777
+	 * @return string
778
+	 */
779
+	public function raw_value()
780
+	{
781
+		return $this->_raw_value;
782
+	}
783
+
784
+
785
+
786
+	/**
787
+	 * Returns a string safe to usage in form inputs when displaying, because
788
+	 * it escapes all html entities
789
+	 *
790
+	 * @return string
791
+	 */
792
+	public function raw_value_in_form()
793
+	{
794
+		return htmlentities($this->raw_value(), ENT_QUOTES, 'UTF-8');
795
+	}
796
+
797
+
798
+
799
+	/**
800
+	 * returns the value after it's been sanitized, and then converted into it's proper type
801
+	 * in PHP. Eg, a string, an int, an array,
802
+	 *
803
+	 * @return mixed
804
+	 */
805
+	public function normalized_value()
806
+	{
807
+		return $this->_normalized_value;
808
+	}
809
+
810
+
811
+
812
+	/**
813
+	 * Returns the normalized value is a presentable way. By default this is just
814
+	 * the normalized value by itself, but it can be overridden for when that's not
815
+	 * the best thing to display
816
+	 *
817
+	 * @return string
818
+	 */
819
+	public function pretty_value()
820
+	{
821
+		return $this->_normalized_value;
822
+	}
823
+
824
+
825
+
826
+	/**
827
+	 * When generating the JS for the jquery validation rules like<br>
828
+	 * <code>$( "#myform" ).validate({
829
+	 * rules: {
830
+	 * password: "required",
831
+	 * password_again: {
832
+	 * equalTo: "#password"
833
+	 * }
834
+	 * }
835
+	 * });</code>
836
+	 * if this field had the name 'password_again', it should return
837
+	 * <br><code>password_again: {
838
+	 * equalTo: "#password"
839
+	 * }</code>
840
+	 *
841
+	 * @return array
842
+	 */
843
+	public function get_jquery_validation_rules()
844
+	{
845
+		$jquery_validation_js = array();
846
+		$jquery_validation_rules = array();
847
+		foreach ($this->get_validation_strategies() as $validation_strategy) {
848
+			$jquery_validation_rules = array_replace_recursive(
849
+				$jquery_validation_rules,
850
+				$validation_strategy->get_jquery_validation_rule_array()
851
+			);
852
+		}
853
+		if (! empty($jquery_validation_rules)) {
854
+			foreach ($this->get_display_strategy()->get_html_input_ids(true) as $html_id_with_pound_sign) {
855
+				$jquery_validation_js[ $html_id_with_pound_sign ] = $jquery_validation_rules;
856
+			}
857
+		}
858
+		return $jquery_validation_js;
859
+	}
860
+
861
+
862
+
863
+	/**
864
+	 * Sets the input's default value for use in displaying in the form. Note: value should be
865
+	 * normalized (Eg, if providing a default of ra Yes_NO_Input you would provide TRUE or FALSE, not '1' or '0')
866
+	 *
867
+	 * @param mixed $value
868
+	 * @return void
869
+	 */
870
+	public function set_default($value)
871
+	{
872
+		$this->_default = $value;
873
+		$this->_set_normalized_value($value);
874
+		$this->_set_raw_value($value);
875
+	}
876
+
877
+
878
+
879
+	/**
880
+	 * Sets the normalized value on this input
881
+	 *
882
+	 * @param mixed $value
883
+	 */
884
+	protected function _set_normalized_value($value)
885
+	{
886
+		$this->_normalized_value = $value;
887
+	}
888
+
889
+
890
+
891
+	/**
892
+	 * Sets the raw value on this input (ie, exactly as the user submitted it)
893
+	 *
894
+	 * @param mixed $value
895
+	 */
896
+	protected function _set_raw_value($value)
897
+	{
898
+		$this->_raw_value = $this->_normalization_strategy->unnormalize($value);
899
+	}
900
+
901
+
902
+
903
+	/**
904
+	 * Sets the HTML label text after it has already been defined
905
+	 *
906
+	 * @param string $label
907
+	 * @return void
908
+	 */
909
+	public function set_html_label_text($label)
910
+	{
911
+		$this->_html_label_text = $label;
912
+	}
913
+
914
+
915
+
916
+	/**
917
+	 * Sets whether or not this field is required, and adjusts the validation strategy.
918
+	 * If you want to use the EE_Conditionally_Required_Validation_Strategy,
919
+	 * please add it as a validation strategy using add_validation_strategy as normal
920
+	 *
921
+	 * @param boolean $required boolean
922
+	 * @param null    $required_text
923
+	 */
924
+	public function set_required($required = true, $required_text = null)
925
+	{
926
+		$required = filter_var($required, FILTER_VALIDATE_BOOLEAN);
927
+		// whether $required is a string or a boolean, we want to add a required validation strategy
928
+		if ($required) {
929
+			$this->_add_validation_strategy(new EE_Required_Validation_Strategy($required_text));
930
+		} else {
931
+			$this->remove_validation_strategy('EE_Required_Validation_Strategy');
932
+		}
933
+		$this->_required = $required;
934
+	}
935
+
936
+
937
+
938
+	/**
939
+	 * Returns whether or not this field is required
940
+	 *
941
+	 * @return boolean
942
+	 */
943
+	public function required()
944
+	{
945
+		return $this->_required;
946
+	}
947
+
948
+
949
+
950
+	/**
951
+	 * @param string $required_css_class
952
+	 */
953
+	public function set_required_css_class($required_css_class)
954
+	{
955
+		$this->_required_css_class = $required_css_class;
956
+	}
957
+
958
+
959
+
960
+	/**
961
+	 * @return string
962
+	 */
963
+	public function required_css_class()
964
+	{
965
+		return $this->_required_css_class;
966
+	}
967
+
968
+
969
+
970
+	/**
971
+	 * @param bool $add_required
972
+	 * @return string
973
+	 */
974
+	public function html_class($add_required = false)
975
+	{
976
+		return $add_required && $this->required()
977
+			? $this->required_css_class() . ' ' . $this->_html_class
978
+			: $this->_html_class;
979
+	}
980
+
981
+
982
+	/**
983
+	 * Sets the help text, in case
984
+	 *
985
+	 * @param string $text
986
+	 */
987
+	public function set_html_help_text($text)
988
+	{
989
+		$this->_html_help_text = $text;
990
+	}
991
+
992
+
993
+
994
+	/**
995
+	 * Uses the sensitive data removal strategy to remove the sensitive data from this
996
+	 * input. If there is any kind of sensitive data removal on this input, we clear
997
+	 * out the raw value completely
998
+	 *
999
+	 * @return void
1000
+	 */
1001
+	public function clean_sensitive_data()
1002
+	{
1003
+		// if we do ANY kind of sensitive data removal on this, then just clear out the raw value
1004
+		// if we need more logic than this we'll make a strategy for it
1005
+		if (
1006
+			$this->_sensitive_data_removal_strategy
1007
+			&& ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal
1008
+		) {
1009
+			$this->_set_raw_value(null);
1010
+		}
1011
+		// and clean the normalized value according to the appropriate strategy
1012
+		$this->_set_normalized_value(
1013
+			$this->get_sensitive_data_removal_strategy()->remove_sensitive_data(
1014
+				$this->_normalized_value
1015
+			)
1016
+		);
1017
+	}
1018
+
1019
+
1020
+
1021
+	/**
1022
+	 * @param bool   $primary
1023
+	 * @param string $button_size
1024
+	 * @param string $other_attributes
1025
+	 */
1026
+	public function set_button_css_attributes($primary = true, $button_size = '', $other_attributes = '')
1027
+	{
1028
+		$button_css_attributes = 'button';
1029
+		$button_css_attributes .= $primary === true ? ' button-primary' : ' button-secondary';
1030
+		switch ($button_size) {
1031
+			case 'xs':
1032
+			case 'extra-small':
1033
+				$button_css_attributes .= ' button-xs';
1034
+				break;
1035
+			case 'sm':
1036
+			case 'small':
1037
+				$button_css_attributes .= ' button-sm';
1038
+				break;
1039
+			case 'lg':
1040
+			case 'large':
1041
+				$button_css_attributes .= ' button-lg';
1042
+				break;
1043
+			case 'block':
1044
+				$button_css_attributes .= ' button-block';
1045
+				break;
1046
+			case 'md':
1047
+			case 'medium':
1048
+			default:
1049
+				$button_css_attributes .= '';
1050
+		}
1051
+		$this->_button_css_attributes .= ! empty($other_attributes)
1052
+			? $button_css_attributes . ' ' . $other_attributes
1053
+			: $button_css_attributes;
1054
+	}
1055
+
1056
+
1057
+
1058
+	/**
1059
+	 * @return string
1060
+	 */
1061
+	public function button_css_attributes()
1062
+	{
1063
+		if (empty($this->_button_css_attributes)) {
1064
+			$this->set_button_css_attributes();
1065
+		}
1066
+		return $this->_button_css_attributes;
1067
+	}
1068
+
1069
+
1070
+
1071
+	/**
1072
+	 * find_form_data_for_this_section
1073
+	 * using this section's name and its parents, finds the value of the form data that corresponds to it.
1074
+	 * For example, if this form section's HTML name is my_form[subform][form_input_1],
1075
+	 * then it's value should be in $_REQUEST at $_REQUEST['my_form']['subform']['form_input_1'].
1076
+	 * (If that doesn't exist, we also check for this subsection's name
1077
+	 * at the TOP LEVEL of the request data. Eg $_REQUEST['form_input_1'].)
1078
+	 * This function finds its value in the form.
1079
+	 *
1080
+	 * @param array $req_data
1081
+	 * @return mixed whatever the raw value of this form section is in the request data
1082
+	 * @throws \EE_Error
1083
+	 */
1084
+	public function find_form_data_for_this_section($req_data)
1085
+	{
1086
+		$name_parts = $this->getInputNameParts();
1087
+		// now get the value for the input
1088
+		$value = $this->findRequestForSectionUsingNameParts($name_parts, $req_data);
1089
+		// check if this thing's name is at the TOP level of the request data
1090
+		if ($value === null && isset($req_data[ $this->name() ])) {
1091
+			$value = $req_data[ $this->name() ];
1092
+		}
1093
+		return $value;
1094
+	}
1095
+
1096
+
1097
+
1098
+	/**
1099
+	 * If this input's name is something like "foo[bar][baz]"
1100
+	 * returns an array like `array('foo','bar',baz')`
1101
+	 * @return array
1102
+	 */
1103
+	protected function getInputNameParts()
1104
+	{
1105
+		// break up the html name by "[]"
1106
+		if (strpos($this->html_name(), '[') !== false) {
1107
+			$before_any_brackets = substr($this->html_name(), 0, strpos($this->html_name(), '['));
1108
+		} else {
1109
+			$before_any_brackets = $this->html_name();
1110
+		}
1111
+		// grab all of the segments
1112
+		preg_match_all('~\[([^]]*)\]~', $this->html_name(), $matches);
1113
+		if (isset($matches[1]) && is_array($matches[1])) {
1114
+			$name_parts = $matches[1];
1115
+			array_unshift($name_parts, $before_any_brackets);
1116
+		} else {
1117
+			$name_parts = array($before_any_brackets);
1118
+		}
1119
+		return $name_parts;
1120
+	}
1121
+
1122
+
1123
+
1124
+	/**
1125
+	 * @param array $html_name_parts
1126
+	 * @param array $req_data
1127
+	 * @return array | NULL
1128
+	 */
1129
+	public function findRequestForSectionUsingNameParts($html_name_parts, $req_data)
1130
+	{
1131
+		$first_part_to_consider = array_shift($html_name_parts);
1132
+		if (isset($req_data[ $first_part_to_consider ])) {
1133
+			if (empty($html_name_parts)) {
1134
+				return $req_data[ $first_part_to_consider ];
1135
+			} else {
1136
+				return $this->findRequestForSectionUsingNameParts(
1137
+					$html_name_parts,
1138
+					$req_data[ $first_part_to_consider ]
1139
+				);
1140
+			}
1141
+		} else {
1142
+			return null;
1143
+		}
1144
+	}
1145
+
1146
+
1147
+
1148
+	/**
1149
+	 * Checks if this form input's data is in the request data
1150
+	 *
1151
+	 * @param array $req_data like $_POST
1152
+	 * @return boolean
1153
+	 * @throws \EE_Error
1154
+	 */
1155
+	public function form_data_present_in($req_data = null)
1156
+	{
1157
+		if ($req_data === null) {
1158
+			$req_data = $_POST;
1159
+		}
1160
+		$checked_value = $this->find_form_data_for_this_section($req_data);
1161
+		if ($checked_value !== null) {
1162
+			return true;
1163
+		} else {
1164
+			return false;
1165
+		}
1166
+	}
1167
+
1168
+
1169
+
1170
+	/**
1171
+	 * Overrides parent to add js data from validation and display strategies
1172
+	 *
1173
+	 * @param array $form_other_js_data
1174
+	 * @return array
1175
+	 */
1176
+	public function get_other_js_data($form_other_js_data = array())
1177
+	{
1178
+		$form_other_js_data = $this->get_other_js_data_from_strategies($form_other_js_data);
1179
+		return $form_other_js_data;
1180
+	}
1181
+
1182
+
1183
+
1184
+	/**
1185
+	 * Gets other JS data for localization from this input's strategies, like
1186
+	 * the validation strategies and the display strategy
1187
+	 *
1188
+	 * @param array $form_other_js_data
1189
+	 * @return array
1190
+	 */
1191
+	public function get_other_js_data_from_strategies($form_other_js_data = array())
1192
+	{
1193
+		$form_other_js_data = $this->get_display_strategy()->get_other_js_data($form_other_js_data);
1194
+		foreach ($this->get_validation_strategies() as $validation_strategy) {
1195
+			$form_other_js_data = $validation_strategy->get_other_js_data($form_other_js_data);
1196
+		}
1197
+		return $form_other_js_data;
1198
+	}
1199
+
1200
+
1201
+
1202
+	/**
1203
+	 * Override parent because we want to give our strategies an opportunity to enqueue some js and css
1204
+	 *
1205
+	 * @return void
1206
+	 */
1207
+	public function enqueue_js()
1208
+	{
1209
+		// ask our display strategy and validation strategies if they have js to enqueue
1210
+		$this->enqueue_js_from_strategies();
1211
+	}
1212
+
1213
+
1214
+
1215
+	/**
1216
+	 * Tells strategies when its ok to enqueue their js and css
1217
+	 *
1218
+	 * @return void
1219
+	 */
1220
+	public function enqueue_js_from_strategies()
1221
+	{
1222
+		$this->get_display_strategy()->enqueue_js();
1223
+		foreach ($this->get_validation_strategies() as $validation_strategy) {
1224
+			$validation_strategy->enqueue_js();
1225
+		}
1226
+	}
1227
+
1228
+
1229
+
1230
+	/**
1231
+	 * Gets the default value set on the input (not the current value, which may have been
1232
+	 * changed because of a form submission). If no default was set, this us null.
1233
+	 * @return mixed
1234
+	 */
1235
+	public function get_default()
1236
+	{
1237
+		return $this->_default;
1238
+	}
1239
+
1240
+
1241
+
1242
+	/**
1243
+	 * Makes this input disabled. That means it will have the HTML attribute 'disabled="disabled"',
1244
+	 * and server-side if any input was received it will be ignored
1245
+	 */
1246
+	public function disable($disable = true)
1247
+	{
1248
+		$disabled_attribute = ' disabled="disabled"';
1249
+		$this->disabled = filter_var($disable, FILTER_VALIDATE_BOOLEAN);
1250
+		if ($this->disabled) {
1251
+			if (strpos($this->_other_html_attributes, $disabled_attribute) === false) {
1252
+				$this->_other_html_attributes .= $disabled_attribute;
1253
+			}
1254
+			$this->_set_normalized_value($this->get_default());
1255
+		} else {
1256
+			$this->_other_html_attributes = str_replace($disabled_attribute, '', $this->_other_html_attributes);
1257
+		}
1258
+	}
1259
+
1260
+
1261
+
1262
+	/**
1263
+	 * Returns whether or not this input is currently disabled.
1264
+	 * @return bool
1265
+	 */
1266
+	public function isDisabled()
1267
+	{
1268
+		return $this->disabled;
1269
+	}
1270 1270
 }
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
         if (isset($input_args['validation_strategies'])) {
197 197
             foreach ((array) $input_args['validation_strategies'] as $validation_strategy) {
198 198
                 if ($validation_strategy instanceof EE_Validation_Strategy_Base && empty($input_args['ignore_input'])) {
199
-                    $this->_validation_strategies[ get_class($validation_strategy) ] = $validation_strategy;
199
+                    $this->_validation_strategies[get_class($validation_strategy)] = $validation_strategy;
200 200
                 }
201 201
             }
202 202
             unset($input_args['validation_strategies']);
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
         // loop thru incoming options
208 208
         foreach ($input_args as $key => $value) {
209 209
             // add underscore to $key to match property names
210
-            $_key = '_' . $key;
210
+            $_key = '_'.$key;
211 211
             if (property_exists($this, $_key)) {
212 212
                 $this->{$_key} = $value;
213 213
             }
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
         if (isset($input_args['ignore_input'])) {
228 228
             $this->_normalization_strategy = new EE_Null_Normalization();
229 229
         }
230
-        if (! $this->_normalization_strategy) {
230
+        if ( ! $this->_normalization_strategy) {
231 231
                 $this->_normalization_strategy = new EE_Text_Normalization();
232 232
         }
233 233
         $this->_normalization_strategy->_construct_finalize($this);
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
             $this->set_default($input_args['default']);
237 237
             unset($input_args['default']);
238 238
         }
239
-        if (! $this->_sensitive_data_removal_strategy) {
239
+        if ( ! $this->_sensitive_data_removal_strategy) {
240 240
             $this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal();
241 241
         }
242 242
         $this->_sensitive_data_removal_strategy->_construct_finalize($this);
@@ -253,10 +253,10 @@  discard block
 block discarded – undo
253 253
      */
254 254
     protected function _set_default_html_name_if_empty()
255 255
     {
256
-        if (! $this->_html_name) {
256
+        if ( ! $this->_html_name) {
257 257
             $this->_html_name = $this->name();
258 258
             if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) {
259
-                $this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]";
259
+                $this->_html_name = $this->_parent_section->html_name_prefix()."[{$this->name()}]";
260 260
             }
261 261
         }
262 262
     }
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
     protected function _get_display_strategy()
289 289
     {
290 290
         $this->ensure_construct_finalized_called();
291
-        if (! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) {
291
+        if ( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) {
292 292
             throw new EE_Error(
293 293
                 sprintf(
294 294
                     __(
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
                 $validation_strategy instanceof $validation_strategy_classname
457 457
                 || is_subclass_of($validation_strategy, $validation_strategy_classname)
458 458
             ) {
459
-                unset($this->_validation_strategies[ $key ]);
459
+                unset($this->_validation_strategies[$key]);
460 460
             }
461 461
         }
462 462
     }
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
             if (is_array($raw_input)) {
668 668
                 $raw_value = array();
669 669
                 foreach ($raw_input as $key => $value) {
670
-                    $raw_value[ $key ] = $this->_sanitize($value);
670
+                    $raw_value[$key] = $this->_sanitize($value);
671 671
                 }
672 672
                 $this->_set_raw_value($raw_value);
673 673
             } else {
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
      */
701 701
     public function html_label_id()
702 702
     {
703
-        return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->html_id() . '-lbl';
703
+        return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->html_id().'-lbl';
704 704
     }
705 705
 
706 706
 
@@ -850,9 +850,9 @@  discard block
 block discarded – undo
850 850
                 $validation_strategy->get_jquery_validation_rule_array()
851 851
             );
852 852
         }
853
-        if (! empty($jquery_validation_rules)) {
853
+        if ( ! empty($jquery_validation_rules)) {
854 854
             foreach ($this->get_display_strategy()->get_html_input_ids(true) as $html_id_with_pound_sign) {
855
-                $jquery_validation_js[ $html_id_with_pound_sign ] = $jquery_validation_rules;
855
+                $jquery_validation_js[$html_id_with_pound_sign] = $jquery_validation_rules;
856 856
             }
857 857
         }
858 858
         return $jquery_validation_js;
@@ -974,7 +974,7 @@  discard block
 block discarded – undo
974 974
     public function html_class($add_required = false)
975 975
     {
976 976
         return $add_required && $this->required()
977
-            ? $this->required_css_class() . ' ' . $this->_html_class
977
+            ? $this->required_css_class().' '.$this->_html_class
978 978
             : $this->_html_class;
979 979
     }
980 980
 
@@ -1049,7 +1049,7 @@  discard block
 block discarded – undo
1049 1049
                 $button_css_attributes .= '';
1050 1050
         }
1051 1051
         $this->_button_css_attributes .= ! empty($other_attributes)
1052
-            ? $button_css_attributes . ' ' . $other_attributes
1052
+            ? $button_css_attributes.' '.$other_attributes
1053 1053
             : $button_css_attributes;
1054 1054
     }
1055 1055
 
@@ -1087,8 +1087,8 @@  discard block
 block discarded – undo
1087 1087
         // now get the value for the input
1088 1088
         $value = $this->findRequestForSectionUsingNameParts($name_parts, $req_data);
1089 1089
         // check if this thing's name is at the TOP level of the request data
1090
-        if ($value === null && isset($req_data[ $this->name() ])) {
1091
-            $value = $req_data[ $this->name() ];
1090
+        if ($value === null && isset($req_data[$this->name()])) {
1091
+            $value = $req_data[$this->name()];
1092 1092
         }
1093 1093
         return $value;
1094 1094
     }
@@ -1129,13 +1129,13 @@  discard block
 block discarded – undo
1129 1129
     public function findRequestForSectionUsingNameParts($html_name_parts, $req_data)
1130 1130
     {
1131 1131
         $first_part_to_consider = array_shift($html_name_parts);
1132
-        if (isset($req_data[ $first_part_to_consider ])) {
1132
+        if (isset($req_data[$first_part_to_consider])) {
1133 1133
             if (empty($html_name_parts)) {
1134
-                return $req_data[ $first_part_to_consider ];
1134
+                return $req_data[$first_part_to_consider];
1135 1135
             } else {
1136 1136
                 return $this->findRequestForSectionUsingNameParts(
1137 1137
                     $html_name_parts,
1138
-                    $req_data[ $first_part_to_consider ]
1138
+                    $req_data[$first_part_to_consider]
1139 1139
                 );
1140 1140
             }
1141 1141
         } else {
Please login to merge, or discard this patch.
core/services/container/SharedCoffeeMaker.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
     /**
31 31
      * @param RecipeInterface $recipe
32 32
      * @param array           $arguments
33
-     * @return mixed
33
+     * @return boolean
34 34
      */
35 35
     public function brew(RecipeInterface $recipe, $arguments = array())
36 36
     {
Please login to merge, or discard this patch.
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -18,43 +18,43 @@
 block discarded – undo
18 18
 {
19 19
 
20 20
 
21
-    /**
22
-     * @return string
23
-     */
24
-    public function type()
25
-    {
26
-        return CoffeeMaker::BREW_SHARED;
27
-    }
21
+	/**
22
+	 * @return string
23
+	 */
24
+	public function type()
25
+	{
26
+		return CoffeeMaker::BREW_SHARED;
27
+	}
28 28
 
29 29
 
30
-    /**
31
-     * @param RecipeInterface $recipe
32
-     * @param array           $arguments
33
-     * @return mixed
34
-     */
35
-    public function brew(RecipeInterface $recipe, $arguments = array())
36
-    {
37
-        $this->resolveClassAndFilepath($recipe);
38
-        $reflector = $this->injector()->getReflectionClass($recipe->fqcn());
39
-        $method = $this->resolveInstantiationMethod($reflector);
40
-        switch ($method) {
41
-            case 'instance':
42
-            case 'new_instance':
43
-            case 'new_instance_from_db':
44
-                $service = call_user_func_array(
45
-                    array($reflector->getName(), $method),
46
-                    $this->injector()->resolveDependencies($recipe, $reflector, $arguments)
47
-                );
48
-                break;
49
-            case 'newInstance':
50
-                $service = $reflector->newInstance();
51
-                break;
52
-            case 'newInstanceArgs':
53
-            default:
54
-                $service = $reflector->newInstanceArgs(
55
-                    $this->injector()->resolveDependencies($recipe, $reflector, $arguments)
56
-                );
57
-        }
58
-        return $this->coffeePot()->addService($recipe->identifier(), $service);
59
-    }
30
+	/**
31
+	 * @param RecipeInterface $recipe
32
+	 * @param array           $arguments
33
+	 * @return mixed
34
+	 */
35
+	public function brew(RecipeInterface $recipe, $arguments = array())
36
+	{
37
+		$this->resolveClassAndFilepath($recipe);
38
+		$reflector = $this->injector()->getReflectionClass($recipe->fqcn());
39
+		$method = $this->resolveInstantiationMethod($reflector);
40
+		switch ($method) {
41
+			case 'instance':
42
+			case 'new_instance':
43
+			case 'new_instance_from_db':
44
+				$service = call_user_func_array(
45
+					array($reflector->getName(), $method),
46
+					$this->injector()->resolveDependencies($recipe, $reflector, $arguments)
47
+				);
48
+				break;
49
+			case 'newInstance':
50
+				$service = $reflector->newInstance();
51
+				break;
52
+			case 'newInstanceArgs':
53
+			default:
54
+				$service = $reflector->newInstanceArgs(
55
+					$this->injector()->resolveDependencies($recipe, $reflector, $arguments)
56
+				);
57
+		}
58
+		return $this->coffeePot()->addService($recipe->identifier(), $service);
59
+	}
60 60
 }
Please login to merge, or discard this patch.
core/services/formatters/AsciiOnly.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
     /**
34 34
      * Taken from https://gist.github.com/jaywilliams/119517
35 35
      *
36
-     * @param $string
36
+     * @param string $string
37 37
      * @return string
38 38
      */
39 39
     protected function convertAscii($string)
Please login to merge, or discard this patch.
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -2,8 +2,6 @@
 block discarded – undo
2 2
 
3 3
 namespace EventEspresso\core\services\formatters;
4 4
 
5
-use EventEspresso\core\exceptions\InvalidDataTypeException;
6
-
7 5
 /**
8 6
  * Class AsciiOnly
9 7
  * Removes all non-ascii characters from the string
Please login to merge, or discard this patch.
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -15,58 +15,58 @@
 block discarded – undo
15 15
 class AsciiOnly extends FormatterBase
16 16
 {
17 17
 
18
-    /**
19
-     * Removes all non Ascii characters from string
20
-     *
21
-     * @param string|int|float $input anything easily cast into a string
22
-     * @return string
23
-     */
24
-    public function format($input)
25
-    {
26
-        // in case an int or float etc was passed in
27
-        $input = (string) $input;
28
-        $input = $this->convertAscii($input);
29
-        return $input;
30
-    }
18
+	/**
19
+	 * Removes all non Ascii characters from string
20
+	 *
21
+	 * @param string|int|float $input anything easily cast into a string
22
+	 * @return string
23
+	 */
24
+	public function format($input)
25
+	{
26
+		// in case an int or float etc was passed in
27
+		$input = (string) $input;
28
+		$input = $this->convertAscii($input);
29
+		return $input;
30
+	}
31 31
 
32 32
 
33
-    /**
34
-     * Taken from https://gist.github.com/jaywilliams/119517
35
-     *
36
-     * @param $string
37
-     * @return string
38
-     */
39
-    protected function convertAscii($string)
40
-    {
41
-        // Replace Single Curly Quotes
42
-        $search[] = chr(226) . chr(128) . chr(152);
43
-        $replace[] = "'";
44
-        $search[] = chr(226) . chr(128) . chr(153);
45
-        $replace[] = "'";
46
-        // Replace Smart Double Curly Quotes
47
-        $search[] = chr(226) . chr(128) . chr(156);
48
-        $replace[] = '"';
49
-        $search[] = chr(226) . chr(128) . chr(157);
50
-        $replace[] = '"';
51
-        // Replace En Dash
52
-        $search[] = chr(226) . chr(128) . chr(147);
53
-        $replace[] = '--';
54
-        // Replace Em Dash
55
-        $search[] = chr(226) . chr(128) . chr(148);
56
-        $replace[] = '---';
57
-        // Replace Bullet
58
-        $search[] = chr(226) . chr(128) . chr(162);
59
-        $replace[] = '*';
60
-        // Replace Middle Dot
61
-        $search[] = chr(194) . chr(183);
62
-        $replace[] = '*';
63
-        // Replace Ellipsis with three consecutive dots
64
-        $search[] = chr(226) . chr(128) . chr(166);
65
-        $replace[] = '...';
66
-        // Apply Replacements
67
-        $string = str_replace($search, $replace, $string);
68
-        // Remove any non-ASCII Characters
69
-        $string = preg_replace("/[^\x01-\x7F]/", "", $string);
70
-        return $string;
71
-    }
33
+	/**
34
+	 * Taken from https://gist.github.com/jaywilliams/119517
35
+	 *
36
+	 * @param $string
37
+	 * @return string
38
+	 */
39
+	protected function convertAscii($string)
40
+	{
41
+		// Replace Single Curly Quotes
42
+		$search[] = chr(226) . chr(128) . chr(152);
43
+		$replace[] = "'";
44
+		$search[] = chr(226) . chr(128) . chr(153);
45
+		$replace[] = "'";
46
+		// Replace Smart Double Curly Quotes
47
+		$search[] = chr(226) . chr(128) . chr(156);
48
+		$replace[] = '"';
49
+		$search[] = chr(226) . chr(128) . chr(157);
50
+		$replace[] = '"';
51
+		// Replace En Dash
52
+		$search[] = chr(226) . chr(128) . chr(147);
53
+		$replace[] = '--';
54
+		// Replace Em Dash
55
+		$search[] = chr(226) . chr(128) . chr(148);
56
+		$replace[] = '---';
57
+		// Replace Bullet
58
+		$search[] = chr(226) . chr(128) . chr(162);
59
+		$replace[] = '*';
60
+		// Replace Middle Dot
61
+		$search[] = chr(194) . chr(183);
62
+		$replace[] = '*';
63
+		// Replace Ellipsis with three consecutive dots
64
+		$search[] = chr(226) . chr(128) . chr(166);
65
+		$replace[] = '...';
66
+		// Apply Replacements
67
+		$string = str_replace($search, $replace, $string);
68
+		// Remove any non-ASCII Characters
69
+		$string = preg_replace("/[^\x01-\x7F]/", "", $string);
70
+		return $string;
71
+	}
72 72
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -39,29 +39,29 @@
 block discarded – undo
39 39
     protected function convertAscii($string)
40 40
     {
41 41
         // Replace Single Curly Quotes
42
-        $search[] = chr(226) . chr(128) . chr(152);
42
+        $search[] = chr(226).chr(128).chr(152);
43 43
         $replace[] = "'";
44
-        $search[] = chr(226) . chr(128) . chr(153);
44
+        $search[] = chr(226).chr(128).chr(153);
45 45
         $replace[] = "'";
46 46
         // Replace Smart Double Curly Quotes
47
-        $search[] = chr(226) . chr(128) . chr(156);
47
+        $search[] = chr(226).chr(128).chr(156);
48 48
         $replace[] = '"';
49
-        $search[] = chr(226) . chr(128) . chr(157);
49
+        $search[] = chr(226).chr(128).chr(157);
50 50
         $replace[] = '"';
51 51
         // Replace En Dash
52
-        $search[] = chr(226) . chr(128) . chr(147);
52
+        $search[] = chr(226).chr(128).chr(147);
53 53
         $replace[] = '--';
54 54
         // Replace Em Dash
55
-        $search[] = chr(226) . chr(128) . chr(148);
55
+        $search[] = chr(226).chr(128).chr(148);
56 56
         $replace[] = '---';
57 57
         // Replace Bullet
58
-        $search[] = chr(226) . chr(128) . chr(162);
58
+        $search[] = chr(226).chr(128).chr(162);
59 59
         $replace[] = '*';
60 60
         // Replace Middle Dot
61
-        $search[] = chr(194) . chr(183);
61
+        $search[] = chr(194).chr(183);
62 62
         $replace[] = '*';
63 63
         // Replace Ellipsis with three consecutive dots
64
-        $search[] = chr(226) . chr(128) . chr(166);
64
+        $search[] = chr(226).chr(128).chr(166);
65 65
         $replace[] = '...';
66 66
         // Apply Replacements
67 67
         $string = str_replace($search, $replace, $string);
Please login to merge, or discard this patch.
modules/ticket_selector/ProcessTicketSelector.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -473,7 +473,7 @@
 block discarded – undo
473 473
      *
474 474
      * @param EE_Ticket $ticket
475 475
      * @param int       $qty
476
-     * @return TRUE on success, FALSE on fail
476
+     * @return boolean on success, FALSE on fail
477 477
      * @throws InvalidArgumentException
478 478
      * @throws InvalidInterfaceException
479 479
      * @throws InvalidDataTypeException
Please login to merge, or discard this patch.
Indentation   +500 added lines, -500 removed lines patch added patch discarded remove patch
@@ -33,529 +33,529 @@
 block discarded – undo
33 33
 class ProcessTicketSelector
34 34
 {
35 35
 
36
-    /**
37
-     * @var EE_Cart $cart
38
-     */
39
-    private $cart;
36
+	/**
37
+	 * @var EE_Cart $cart
38
+	 */
39
+	private $cart;
40 40
 
41
-    /**
42
-     * @var EE_Core_Config $core_config
43
-     */
44
-    private $core_config;
41
+	/**
42
+	 * @var EE_Core_Config $core_config
43
+	 */
44
+	private $core_config;
45 45
 
46
-    /**
47
-     * @var Request $request
48
-     */
49
-    private $request;
46
+	/**
47
+	 * @var Request $request
48
+	 */
49
+	private $request;
50 50
 
51
-    /**
52
-     * @var EE_Session $session
53
-     */
54
-    private $session;
51
+	/**
52
+	 * @var EE_Session $session
53
+	 */
54
+	private $session;
55 55
 
56
-    /**
57
-     * @var EEM_Ticket $ticket_model
58
-     */
59
-    private $ticket_model;
56
+	/**
57
+	 * @var EEM_Ticket $ticket_model
58
+	 */
59
+	private $ticket_model;
60 60
 
61
-    /**
62
-     * @var TicketDatetimeAvailabilityTracker $tracker
63
-     */
64
-    private $tracker;
61
+	/**
62
+	 * @var TicketDatetimeAvailabilityTracker $tracker
63
+	 */
64
+	private $tracker;
65 65
 
66 66
 
67
-    /**
68
-     * ProcessTicketSelector constructor.
69
-     * NOTE: PLZ use the Loader to instantiate this class if need be
70
-     * so that all dependencies get injected correctly (which will happen automatically)
71
-     * Null values for parameters are only for backwards compatibility but will be removed later on.
72
-     *
73
-     * @param EE_Core_Config                    $core_config
74
-     * @param Request                           $request
75
-     * @param EE_Session                        $session
76
-     * @param EEM_Ticket                        $ticket_model
77
-     * @param TicketDatetimeAvailabilityTracker $tracker
78
-     * @throws InvalidArgumentException
79
-     * @throws InvalidDataTypeException
80
-     * @throws InvalidInterfaceException
81
-     */
82
-    public function __construct(
83
-        EE_Core_Config $core_config = null,
84
-        Request $request = null,
85
-        EE_Session $session = null,
86
-        EEM_Ticket $ticket_model = null,
87
-        TicketDatetimeAvailabilityTracker $tracker = null
88
-    ) {
89
-        /** @var LoaderInterface $loader */
90
-        $loader = LoaderFactory::getLoader();
91
-        $this->core_config = $core_config instanceof EE_Core_Config
92
-            ? $core_config
93
-            : $loader->getShared('EE_Core_Config');
94
-        $this->request = $request instanceof Request
95
-            ? $request
96
-            : $loader->getShared('EventEspresso\core\services\request\Request');
97
-        $this->session = $session instanceof EE_Session
98
-            ? $session
99
-            : $loader->getShared('EE_Session');
100
-        $this->ticket_model = $ticket_model instanceof EEM_Ticket
101
-            ? $ticket_model
102
-            : $loader->getShared('EEM_Ticket');
103
-        $this->tracker = $tracker instanceof TicketDatetimeAvailabilityTracker
104
-            ? $tracker
105
-            : $loader->getShared('EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker');
106
-    }
67
+	/**
68
+	 * ProcessTicketSelector constructor.
69
+	 * NOTE: PLZ use the Loader to instantiate this class if need be
70
+	 * so that all dependencies get injected correctly (which will happen automatically)
71
+	 * Null values for parameters are only for backwards compatibility but will be removed later on.
72
+	 *
73
+	 * @param EE_Core_Config                    $core_config
74
+	 * @param Request                           $request
75
+	 * @param EE_Session                        $session
76
+	 * @param EEM_Ticket                        $ticket_model
77
+	 * @param TicketDatetimeAvailabilityTracker $tracker
78
+	 * @throws InvalidArgumentException
79
+	 * @throws InvalidDataTypeException
80
+	 * @throws InvalidInterfaceException
81
+	 */
82
+	public function __construct(
83
+		EE_Core_Config $core_config = null,
84
+		Request $request = null,
85
+		EE_Session $session = null,
86
+		EEM_Ticket $ticket_model = null,
87
+		TicketDatetimeAvailabilityTracker $tracker = null
88
+	) {
89
+		/** @var LoaderInterface $loader */
90
+		$loader = LoaderFactory::getLoader();
91
+		$this->core_config = $core_config instanceof EE_Core_Config
92
+			? $core_config
93
+			: $loader->getShared('EE_Core_Config');
94
+		$this->request = $request instanceof Request
95
+			? $request
96
+			: $loader->getShared('EventEspresso\core\services\request\Request');
97
+		$this->session = $session instanceof EE_Session
98
+			? $session
99
+			: $loader->getShared('EE_Session');
100
+		$this->ticket_model = $ticket_model instanceof EEM_Ticket
101
+			? $ticket_model
102
+			: $loader->getShared('EEM_Ticket');
103
+		$this->tracker = $tracker instanceof TicketDatetimeAvailabilityTracker
104
+			? $tracker
105
+			: $loader->getShared('EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker');
106
+	}
107 107
 
108 108
 
109
-    /**
110
-     * cancelTicketSelections
111
-     *
112
-     * @return bool
113
-     * @throws EE_Error
114
-     * @throws InvalidArgumentException
115
-     * @throws InvalidInterfaceException
116
-     * @throws InvalidDataTypeException
117
-     */
118
-    public function cancelTicketSelections()
119
-    {
120
-        // check nonce
121
-        if (! $this->processTicketSelectorNonce('cancel_ticket_selections')) {
122
-            return false;
123
-        }
124
-        $this->session->clear_session(__CLASS__, __FUNCTION__);
125
-        if ($this->request->requestParamIsSet('event_id')) {
126
-            EEH_URL::safeRedirectAndExit(
127
-                EEH_Event_View::event_link_url(
128
-                    $this->request->getRequestParam('event_id')
129
-                )
130
-            );
131
-        }
132
-        EEH_URL::safeRedirectAndExit(
133
-            site_url('/' . $this->core_config->event_cpt_slug . '/')
134
-        );
135
-        return true;
136
-    }
109
+	/**
110
+	 * cancelTicketSelections
111
+	 *
112
+	 * @return bool
113
+	 * @throws EE_Error
114
+	 * @throws InvalidArgumentException
115
+	 * @throws InvalidInterfaceException
116
+	 * @throws InvalidDataTypeException
117
+	 */
118
+	public function cancelTicketSelections()
119
+	{
120
+		// check nonce
121
+		if (! $this->processTicketSelectorNonce('cancel_ticket_selections')) {
122
+			return false;
123
+		}
124
+		$this->session->clear_session(__CLASS__, __FUNCTION__);
125
+		if ($this->request->requestParamIsSet('event_id')) {
126
+			EEH_URL::safeRedirectAndExit(
127
+				EEH_Event_View::event_link_url(
128
+					$this->request->getRequestParam('event_id')
129
+				)
130
+			);
131
+		}
132
+		EEH_URL::safeRedirectAndExit(
133
+			site_url('/' . $this->core_config->event_cpt_slug . '/')
134
+		);
135
+		return true;
136
+	}
137 137
 
138 138
 
139
-    /**
140
-     * processTicketSelectorNonce
141
-     *
142
-     * @param  string $nonce_name
143
-     * @param string  $id
144
-     * @return bool
145
-     */
146
-    private function processTicketSelectorNonce($nonce_name, $id = '')
147
-    {
148
-        $nonce_name_with_id = ! empty($id) ? "{$nonce_name}_nonce_{$id}" : "{$nonce_name}_nonce";
149
-        if (
150
-            ! $this->request->isAdmin()
151
-            && (
152
-                ! $this->request->is_set($nonce_name_with_id)
153
-                || ! wp_verify_nonce(
154
-                    $this->request->get($nonce_name_with_id),
155
-                    $nonce_name
156
-                )
157
-            )
158
-        ) {
159
-            EE_Error::add_error(
160
-                sprintf(
161
-                    esc_html__(
162
-                        'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.',
163
-                        'event_espresso'
164
-                    ),
165
-                    '<br/>'
166
-                ),
167
-                __FILE__,
168
-                __FUNCTION__,
169
-                __LINE__
170
-            );
171
-            return false;
172
-        }
173
-        return true;
174
-    }
139
+	/**
140
+	 * processTicketSelectorNonce
141
+	 *
142
+	 * @param  string $nonce_name
143
+	 * @param string  $id
144
+	 * @return bool
145
+	 */
146
+	private function processTicketSelectorNonce($nonce_name, $id = '')
147
+	{
148
+		$nonce_name_with_id = ! empty($id) ? "{$nonce_name}_nonce_{$id}" : "{$nonce_name}_nonce";
149
+		if (
150
+			! $this->request->isAdmin()
151
+			&& (
152
+				! $this->request->is_set($nonce_name_with_id)
153
+				|| ! wp_verify_nonce(
154
+					$this->request->get($nonce_name_with_id),
155
+					$nonce_name
156
+				)
157
+			)
158
+		) {
159
+			EE_Error::add_error(
160
+				sprintf(
161
+					esc_html__(
162
+						'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.',
163
+						'event_espresso'
164
+					),
165
+					'<br/>'
166
+				),
167
+				__FILE__,
168
+				__FUNCTION__,
169
+				__LINE__
170
+			);
171
+			return false;
172
+		}
173
+		return true;
174
+	}
175 175
 
176 176
 
177
-    /**
178
-     * process_ticket_selections
179
-     *
180
-     * @return array|bool
181
-     * @throws EE_Error
182
-     * @throws InvalidArgumentException
183
-     * @throws InvalidDataTypeException
184
-     * @throws InvalidInterfaceException
185
-     */
186
-    public function processTicketSelections()
187
-    {
188
-        do_action('EED_Ticket_Selector__process_ticket_selections__before');
189
-        if ($this->request->isBot()) {
190
-            EEH_URL::safeRedirectAndExit(
191
-                apply_filters(
192
-                    'FHEE__EE_Ticket_Selector__process_ticket_selections__bot_redirect_url',
193
-                    site_url()
194
-                )
195
-            );
196
-        }
197
-        // do we have an event id?
198
-        $id = $this->getEventId();
199
-        // we should really only have 1 registration in the works now
200
-        // (ie, no MER) so unless otherwise requested, clear the session
201
-        if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', true)) {
202
-            $this->session->clear_session(__CLASS__, __FUNCTION__);
203
-        }
204
-        // validate/sanitize/filter data
205
-        $valid = apply_filters(
206
-            'FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data',
207
-            $this->validatePostData($id)
208
-        );
209
-        // check total tickets ordered vs max number of attendees that can register
210
-        if (! empty($valid) && $valid['total_tickets'] > $valid['max_atndz']) {
211
-            $this->maxAttendeesViolation($valid);
212
-        } else {
213
-            // all data appears to be valid
214
-            if ($this->processSuccessfulCart($this->addTicketsToCart($valid))) {
215
-                return true;
216
-            }
217
-        }
218
-        // die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT
219
-        // at this point, just return if registration is being made from admin
220
-        if ($this->request->isAdmin() || $this->request->isFrontAjax()) {
221
-            return false;
222
-        }
223
-        if ($valid['return_url']) {
224
-            EEH_URL::safeRedirectAndExit($valid['return_url']);
225
-        }
226
-        if ($id) {
227
-            EEH_URL::safeRedirectAndExit(get_permalink($id));
228
-        }
229
-        echo EE_Error::get_notices();
230
-        return false;
231
-    }
177
+	/**
178
+	 * process_ticket_selections
179
+	 *
180
+	 * @return array|bool
181
+	 * @throws EE_Error
182
+	 * @throws InvalidArgumentException
183
+	 * @throws InvalidDataTypeException
184
+	 * @throws InvalidInterfaceException
185
+	 */
186
+	public function processTicketSelections()
187
+	{
188
+		do_action('EED_Ticket_Selector__process_ticket_selections__before');
189
+		if ($this->request->isBot()) {
190
+			EEH_URL::safeRedirectAndExit(
191
+				apply_filters(
192
+					'FHEE__EE_Ticket_Selector__process_ticket_selections__bot_redirect_url',
193
+					site_url()
194
+				)
195
+			);
196
+		}
197
+		// do we have an event id?
198
+		$id = $this->getEventId();
199
+		// we should really only have 1 registration in the works now
200
+		// (ie, no MER) so unless otherwise requested, clear the session
201
+		if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', true)) {
202
+			$this->session->clear_session(__CLASS__, __FUNCTION__);
203
+		}
204
+		// validate/sanitize/filter data
205
+		$valid = apply_filters(
206
+			'FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data',
207
+			$this->validatePostData($id)
208
+		);
209
+		// check total tickets ordered vs max number of attendees that can register
210
+		if (! empty($valid) && $valid['total_tickets'] > $valid['max_atndz']) {
211
+			$this->maxAttendeesViolation($valid);
212
+		} else {
213
+			// all data appears to be valid
214
+			if ($this->processSuccessfulCart($this->addTicketsToCart($valid))) {
215
+				return true;
216
+			}
217
+		}
218
+		// die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT
219
+		// at this point, just return if registration is being made from admin
220
+		if ($this->request->isAdmin() || $this->request->isFrontAjax()) {
221
+			return false;
222
+		}
223
+		if ($valid['return_url']) {
224
+			EEH_URL::safeRedirectAndExit($valid['return_url']);
225
+		}
226
+		if ($id) {
227
+			EEH_URL::safeRedirectAndExit(get_permalink($id));
228
+		}
229
+		echo EE_Error::get_notices();
230
+		return false;
231
+	}
232 232
 
233 233
 
234
-    /**
235
-     * @return int
236
-     */
237
-    private function getEventId()
238
-    {
239
-        // do we have an event id?
240
-        if (! $this->request->requestParamIsSet('tkt-slctr-event-id')) {
241
-            // $_POST['tkt-slctr-event-id'] was not set ?!?!?!?
242
-            EE_Error::add_error(
243
-                sprintf(
244
-                    esc_html__(
245
-                        'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.',
246
-                        'event_espresso'
247
-                    ),
248
-                    '<br/>'
249
-                ),
250
-                __FILE__,
251
-                __FUNCTION__,
252
-                __LINE__
253
-            );
254
-        }
255
-        // if event id is valid
256
-        return absint($this->request->getRequestParam('tkt-slctr-event-id'));
257
-    }
234
+	/**
235
+	 * @return int
236
+	 */
237
+	private function getEventId()
238
+	{
239
+		// do we have an event id?
240
+		if (! $this->request->requestParamIsSet('tkt-slctr-event-id')) {
241
+			// $_POST['tkt-slctr-event-id'] was not set ?!?!?!?
242
+			EE_Error::add_error(
243
+				sprintf(
244
+					esc_html__(
245
+						'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.',
246
+						'event_espresso'
247
+					),
248
+					'<br/>'
249
+				),
250
+				__FILE__,
251
+				__FUNCTION__,
252
+				__LINE__
253
+			);
254
+		}
255
+		// if event id is valid
256
+		return absint($this->request->getRequestParam('tkt-slctr-event-id'));
257
+	}
258 258
 
259 259
 
260
-    /**
261
-     * validate_post_data
262
-     *
263
-     * @param int $id
264
-     * @return array
265
-     */
266
-    private function validatePostData($id = 0)
267
-    {
268
-        if (! $id) {
269
-            EE_Error::add_error(
270
-                esc_html__('The event id provided was not valid.', 'event_espresso'),
271
-                __FILE__,
272
-                __FUNCTION__,
273
-                __LINE__
274
-            );
275
-            return array();
276
-        }
277
-        // start with an empty array()
278
-        $valid_data = array();
279
-        // grab valid id
280
-        $valid_data['id'] = $id;
281
-        // array of other form names
282
-        $inputs_to_clean = array(
283
-            'event_id'   => 'tkt-slctr-event-id',
284
-            'max_atndz'  => 'tkt-slctr-max-atndz-',
285
-            'rows'       => 'tkt-slctr-rows-',
286
-            'qty'        => 'tkt-slctr-qty-',
287
-            'ticket_id'  => 'tkt-slctr-ticket-id-',
288
-            'return_url' => 'tkt-slctr-return-url-',
289
-        );
290
-        // let's track the total number of tickets ordered.'
291
-        $valid_data['total_tickets'] = 0;
292
-        // cycle through $inputs_to_clean array
293
-        foreach ($inputs_to_clean as $what => $input_to_clean) {
294
-            // check for POST data
295
-            if ($this->request->requestParamIsSet($input_to_clean . $id)) {
296
-                // grab value
297
-                $input_value = $this->request->getRequestParam($input_to_clean . $id);
298
-                switch ($what) {
299
-                    // integers
300
-                    case 'event_id':
301
-                        $valid_data[ $what ] = absint($input_value);
302
-                        // get event via the event id we put in the form
303
-                        break;
304
-                    case 'rows':
305
-                    case 'max_atndz':
306
-                        $valid_data[ $what ] = absint($input_value);
307
-                        break;
308
-                    // arrays of integers
309
-                    case 'qty':
310
-                        /** @var array $row_qty */
311
-                        $row_qty = $input_value;
312
-                        // if qty is coming from a radio button input, then we need to assemble an array of rows
313
-                        if (! is_array($row_qty)) {
314
-                            /** @var string $row_qty */
315
-                            // get number of rows
316
-                            $rows = $this->request->requestParamIsSet('tkt-slctr-rows-' . $id)
317
-                                ? absint($this->request->getRequestParam('tkt-slctr-rows-' . $id))
318
-                                : 1;
319
-                            // explode integers by the dash
320
-                            $row_qty = explode('-', $row_qty);
321
-                            $row = isset($row_qty[0]) ? absint($row_qty[0]) : 1;
322
-                            $qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0;
323
-                            $row_qty = array($row => $qty);
324
-                            for ($x = 1; $x <= $rows; $x++) {
325
-                                if (! isset($row_qty[ $x ])) {
326
-                                    $row_qty[ $x ] = 0;
327
-                                }
328
-                            }
329
-                        }
330
-                        ksort($row_qty);
331
-                        // cycle thru values
332
-                        foreach ($row_qty as $qty) {
333
-                            $qty = absint($qty);
334
-                            // sanitize as integers
335
-                            $valid_data[ $what ][] = $qty;
336
-                            $valid_data['total_tickets'] += $qty;
337
-                        }
338
-                        break;
339
-                    // array of integers
340
-                    case 'ticket_id':
341
-                        // cycle thru values
342
-                        foreach ((array) $input_value as $key => $value) {
343
-                            // allow only integers
344
-                            $valid_data[ $what ][ $key ] = absint($value);
345
-                        }
346
-                        break;
347
-                    case 'return_url':
348
-                        // grab and sanitize return-url
349
-                        $input_value = esc_url_raw($input_value);
350
-                        // was the request coming from an iframe ? if so, then:
351
-                        if (strpos($input_value, 'event_list=iframe')) {
352
-                            // get anchor fragment
353
-                            $input_value = explode('#', $input_value);
354
-                            $input_value = end($input_value);
355
-                            // use event list url instead, but append anchor
356
-                            $input_value = EEH_Event_View::event_archive_url() . '#' . $input_value;
357
-                        }
358
-                        $valid_data[ $what ] = $input_value;
359
-                        break;
360
-                }    // end switch $what
361
-            }
362
-        }    // end foreach $inputs_to_clean
363
-        return $valid_data;
364
-    }
260
+	/**
261
+	 * validate_post_data
262
+	 *
263
+	 * @param int $id
264
+	 * @return array
265
+	 */
266
+	private function validatePostData($id = 0)
267
+	{
268
+		if (! $id) {
269
+			EE_Error::add_error(
270
+				esc_html__('The event id provided was not valid.', 'event_espresso'),
271
+				__FILE__,
272
+				__FUNCTION__,
273
+				__LINE__
274
+			);
275
+			return array();
276
+		}
277
+		// start with an empty array()
278
+		$valid_data = array();
279
+		// grab valid id
280
+		$valid_data['id'] = $id;
281
+		// array of other form names
282
+		$inputs_to_clean = array(
283
+			'event_id'   => 'tkt-slctr-event-id',
284
+			'max_atndz'  => 'tkt-slctr-max-atndz-',
285
+			'rows'       => 'tkt-slctr-rows-',
286
+			'qty'        => 'tkt-slctr-qty-',
287
+			'ticket_id'  => 'tkt-slctr-ticket-id-',
288
+			'return_url' => 'tkt-slctr-return-url-',
289
+		);
290
+		// let's track the total number of tickets ordered.'
291
+		$valid_data['total_tickets'] = 0;
292
+		// cycle through $inputs_to_clean array
293
+		foreach ($inputs_to_clean as $what => $input_to_clean) {
294
+			// check for POST data
295
+			if ($this->request->requestParamIsSet($input_to_clean . $id)) {
296
+				// grab value
297
+				$input_value = $this->request->getRequestParam($input_to_clean . $id);
298
+				switch ($what) {
299
+					// integers
300
+					case 'event_id':
301
+						$valid_data[ $what ] = absint($input_value);
302
+						// get event via the event id we put in the form
303
+						break;
304
+					case 'rows':
305
+					case 'max_atndz':
306
+						$valid_data[ $what ] = absint($input_value);
307
+						break;
308
+					// arrays of integers
309
+					case 'qty':
310
+						/** @var array $row_qty */
311
+						$row_qty = $input_value;
312
+						// if qty is coming from a radio button input, then we need to assemble an array of rows
313
+						if (! is_array($row_qty)) {
314
+							/** @var string $row_qty */
315
+							// get number of rows
316
+							$rows = $this->request->requestParamIsSet('tkt-slctr-rows-' . $id)
317
+								? absint($this->request->getRequestParam('tkt-slctr-rows-' . $id))
318
+								: 1;
319
+							// explode integers by the dash
320
+							$row_qty = explode('-', $row_qty);
321
+							$row = isset($row_qty[0]) ? absint($row_qty[0]) : 1;
322
+							$qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0;
323
+							$row_qty = array($row => $qty);
324
+							for ($x = 1; $x <= $rows; $x++) {
325
+								if (! isset($row_qty[ $x ])) {
326
+									$row_qty[ $x ] = 0;
327
+								}
328
+							}
329
+						}
330
+						ksort($row_qty);
331
+						// cycle thru values
332
+						foreach ($row_qty as $qty) {
333
+							$qty = absint($qty);
334
+							// sanitize as integers
335
+							$valid_data[ $what ][] = $qty;
336
+							$valid_data['total_tickets'] += $qty;
337
+						}
338
+						break;
339
+					// array of integers
340
+					case 'ticket_id':
341
+						// cycle thru values
342
+						foreach ((array) $input_value as $key => $value) {
343
+							// allow only integers
344
+							$valid_data[ $what ][ $key ] = absint($value);
345
+						}
346
+						break;
347
+					case 'return_url':
348
+						// grab and sanitize return-url
349
+						$input_value = esc_url_raw($input_value);
350
+						// was the request coming from an iframe ? if so, then:
351
+						if (strpos($input_value, 'event_list=iframe')) {
352
+							// get anchor fragment
353
+							$input_value = explode('#', $input_value);
354
+							$input_value = end($input_value);
355
+							// use event list url instead, but append anchor
356
+							$input_value = EEH_Event_View::event_archive_url() . '#' . $input_value;
357
+						}
358
+						$valid_data[ $what ] = $input_value;
359
+						break;
360
+				}    // end switch $what
361
+			}
362
+		}    // end foreach $inputs_to_clean
363
+		return $valid_data;
364
+	}
365 365
 
366 366
 
367
-    /**
368
-     * @param array $valid
369
-     */
370
-    private function maxAttendeesViolation(array $valid)
371
-    {
372
-        // ordering too many tickets !!!
373
-        $total_tickets_string = esc_html(
374
-            _n(
375
-                'You have attempted to purchase %s ticket.',
376
-                'You have attempted to purchase %s tickets.',
377
-                $valid['total_tickets'],
378
-                'event_espresso'
379
-            )
380
-        );
381
-        $limit_error_1 = sprintf($total_tickets_string, $valid['total_tickets']);
382
-        // dev only message
383
-        $max_attendees_string = esc_html(
384
-            _n(
385
-                'The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
386
-                'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
387
-                $valid['max_atndz'],
388
-                'event_espresso'
389
-            )
390
-        );
391
-        $limit_error_2 = sprintf($max_attendees_string, $valid['max_atndz'], $valid['max_atndz']);
392
-        EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__);
393
-    }
367
+	/**
368
+	 * @param array $valid
369
+	 */
370
+	private function maxAttendeesViolation(array $valid)
371
+	{
372
+		// ordering too many tickets !!!
373
+		$total_tickets_string = esc_html(
374
+			_n(
375
+				'You have attempted to purchase %s ticket.',
376
+				'You have attempted to purchase %s tickets.',
377
+				$valid['total_tickets'],
378
+				'event_espresso'
379
+			)
380
+		);
381
+		$limit_error_1 = sprintf($total_tickets_string, $valid['total_tickets']);
382
+		// dev only message
383
+		$max_attendees_string = esc_html(
384
+			_n(
385
+				'The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
386
+				'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
387
+				$valid['max_atndz'],
388
+				'event_espresso'
389
+			)
390
+		);
391
+		$limit_error_2 = sprintf($max_attendees_string, $valid['max_atndz'], $valid['max_atndz']);
392
+		EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__);
393
+	}
394 394
 
395 395
 
396
-    /**
397
-     * @param array $valid
398
-     * @return int
399
-     * @throws EE_Error
400
-     * @throws InvalidArgumentException
401
-     * @throws InvalidDataTypeException
402
-     * @throws InvalidInterfaceException
403
-     */
404
-    private function addTicketsToCart(array $valid)
405
-    {
406
-        $tickets_added = 0;
407
-        $tickets_selected = false;
408
-        if (! empty($valid) && $valid['total_tickets'] > 0) {
409
-            // load cart using factory because we don't want to do so until actually needed
410
-            $this->cart = CartFactory::getCart();
411
-            // cycle thru the number of data rows sent from the event listing
412
-            for ($x = 0; $x < $valid['rows']; $x++) {
413
-                // does this row actually contain a ticket quantity?
414
-                if (isset($valid['qty'][ $x ]) && $valid['qty'][ $x ] > 0) {
415
-                    // YES we have a ticket quantity
416
-                    $tickets_selected = true;
417
-                    $valid_ticket = false;
418
-                    // \EEH_Debug_Tools::printr(
419
-                    //     $valid['ticket_id'][ $x ],
420
-                    //     '$valid[\'ticket_id\'][ $x ]',
421
-                    //     __FILE__, __LINE__
422
-                    // );
423
-                    if (isset($valid['ticket_id'][ $x ])) {
424
-                        // get ticket via the ticket id we put in the form
425
-                        $ticket = $this->ticket_model->get_one_by_ID($valid['ticket_id'][ $x ]);
426
-                        if ($ticket instanceof EE_Ticket) {
427
-                            $valid_ticket = true;
428
-                            $tickets_added += $this->addTicketToCart(
429
-                                $ticket,
430
-                                $valid['qty'][ $x ]
431
-                            );
432
-                        }
433
-                    }
434
-                    if ($valid_ticket !== true) {
435
-                        // nothing added to cart retrieved
436
-                        EE_Error::add_error(
437
-                            sprintf(
438
-                                esc_html__(
439
-                                    'A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.',
440
-                                    'event_espresso'
441
-                                ),
442
-                                '<br/>'
443
-                            ),
444
-                            __FILE__,
445
-                            __FUNCTION__,
446
-                            __LINE__
447
-                        );
448
-                    }
449
-                    if (EE_Error::has_error()) {
450
-                        break;
451
-                    }
452
-                }
453
-            }
454
-        }
455
-        do_action(
456
-            'AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart',
457
-            $this->cart,
458
-            $this
459
-        );
460
-        if (! apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tickets_selected)) {
461
-            // no ticket quantities were selected
462
-            EE_Error::add_error(
463
-                esc_html__('You need to select a ticket quantity before you can proceed.', 'event_espresso'),
464
-                __FILE__,
465
-                __FUNCTION__,
466
-                __LINE__
467
-            );
468
-        }
469
-        return $tickets_added;
470
-    }
396
+	/**
397
+	 * @param array $valid
398
+	 * @return int
399
+	 * @throws EE_Error
400
+	 * @throws InvalidArgumentException
401
+	 * @throws InvalidDataTypeException
402
+	 * @throws InvalidInterfaceException
403
+	 */
404
+	private function addTicketsToCart(array $valid)
405
+	{
406
+		$tickets_added = 0;
407
+		$tickets_selected = false;
408
+		if (! empty($valid) && $valid['total_tickets'] > 0) {
409
+			// load cart using factory because we don't want to do so until actually needed
410
+			$this->cart = CartFactory::getCart();
411
+			// cycle thru the number of data rows sent from the event listing
412
+			for ($x = 0; $x < $valid['rows']; $x++) {
413
+				// does this row actually contain a ticket quantity?
414
+				if (isset($valid['qty'][ $x ]) && $valid['qty'][ $x ] > 0) {
415
+					// YES we have a ticket quantity
416
+					$tickets_selected = true;
417
+					$valid_ticket = false;
418
+					// \EEH_Debug_Tools::printr(
419
+					//     $valid['ticket_id'][ $x ],
420
+					//     '$valid[\'ticket_id\'][ $x ]',
421
+					//     __FILE__, __LINE__
422
+					// );
423
+					if (isset($valid['ticket_id'][ $x ])) {
424
+						// get ticket via the ticket id we put in the form
425
+						$ticket = $this->ticket_model->get_one_by_ID($valid['ticket_id'][ $x ]);
426
+						if ($ticket instanceof EE_Ticket) {
427
+							$valid_ticket = true;
428
+							$tickets_added += $this->addTicketToCart(
429
+								$ticket,
430
+								$valid['qty'][ $x ]
431
+							);
432
+						}
433
+					}
434
+					if ($valid_ticket !== true) {
435
+						// nothing added to cart retrieved
436
+						EE_Error::add_error(
437
+							sprintf(
438
+								esc_html__(
439
+									'A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.',
440
+									'event_espresso'
441
+								),
442
+								'<br/>'
443
+							),
444
+							__FILE__,
445
+							__FUNCTION__,
446
+							__LINE__
447
+						);
448
+					}
449
+					if (EE_Error::has_error()) {
450
+						break;
451
+					}
452
+				}
453
+			}
454
+		}
455
+		do_action(
456
+			'AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart',
457
+			$this->cart,
458
+			$this
459
+		);
460
+		if (! apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tickets_selected)) {
461
+			// no ticket quantities were selected
462
+			EE_Error::add_error(
463
+				esc_html__('You need to select a ticket quantity before you can proceed.', 'event_espresso'),
464
+				__FILE__,
465
+				__FUNCTION__,
466
+				__LINE__
467
+			);
468
+		}
469
+		return $tickets_added;
470
+	}
471 471
 
472 472
 
473
-    /**
474
-     * adds a ticket to the cart
475
-     *
476
-     * @param EE_Ticket $ticket
477
-     * @param int       $qty
478
-     * @return TRUE on success, FALSE on fail
479
-     * @throws InvalidArgumentException
480
-     * @throws InvalidInterfaceException
481
-     * @throws InvalidDataTypeException
482
-     * @throws EE_Error
483
-     */
484
-    private function addTicketToCart(EE_Ticket $ticket, $qty = 1)
485
-    {
486
-        // get the number of spaces left for this datetime ticket
487
-        $available_spaces = $this->tracker->ticketDatetimeAvailability($ticket);
488
-        // compare available spaces against the number of tickets being purchased
489
-        if ($available_spaces >= $qty) {
490
-            // allow addons to prevent a ticket from being added to cart
491
-            if (
492
-                ! apply_filters(
493
-                    'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart',
494
-                    true,
495
-                    $ticket,
496
-                    $qty,
497
-                    $available_spaces
498
-                )
499
-            ) {
500
-                return false;
501
-            }
502
-            $qty = absint(apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', $qty, $ticket));
503
-            // add event to cart
504
-            if ($this->cart->add_ticket_to_cart($ticket, $qty)) {
505
-                $this->tracker->recalculateTicketDatetimeAvailability($ticket, $qty);
506
-                return true;
507
-            }
508
-            return false;
509
-        }
510
-        $this->tracker->processAvailabilityError($ticket, $qty, $this->cart->all_ticket_quantity_count());
511
-        return false;
512
-    }
473
+	/**
474
+	 * adds a ticket to the cart
475
+	 *
476
+	 * @param EE_Ticket $ticket
477
+	 * @param int       $qty
478
+	 * @return TRUE on success, FALSE on fail
479
+	 * @throws InvalidArgumentException
480
+	 * @throws InvalidInterfaceException
481
+	 * @throws InvalidDataTypeException
482
+	 * @throws EE_Error
483
+	 */
484
+	private function addTicketToCart(EE_Ticket $ticket, $qty = 1)
485
+	{
486
+		// get the number of spaces left for this datetime ticket
487
+		$available_spaces = $this->tracker->ticketDatetimeAvailability($ticket);
488
+		// compare available spaces against the number of tickets being purchased
489
+		if ($available_spaces >= $qty) {
490
+			// allow addons to prevent a ticket from being added to cart
491
+			if (
492
+				! apply_filters(
493
+					'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart',
494
+					true,
495
+					$ticket,
496
+					$qty,
497
+					$available_spaces
498
+				)
499
+			) {
500
+				return false;
501
+			}
502
+			$qty = absint(apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', $qty, $ticket));
503
+			// add event to cart
504
+			if ($this->cart->add_ticket_to_cart($ticket, $qty)) {
505
+				$this->tracker->recalculateTicketDatetimeAvailability($ticket, $qty);
506
+				return true;
507
+			}
508
+			return false;
509
+		}
510
+		$this->tracker->processAvailabilityError($ticket, $qty, $this->cart->all_ticket_quantity_count());
511
+		return false;
512
+	}
513 513
 
514 514
 
515
-    /**
516
-     * @param $tickets_added
517
-     * @return bool
518
-     * @throws InvalidInterfaceException
519
-     * @throws InvalidDataTypeException
520
-     * @throws EE_Error
521
-     * @throws InvalidArgumentException
522
-     */
523
-    private function processSuccessfulCart($tickets_added)
524
-    {
525
-        // exit('KILL REDIRECT BEFORE CART UPDATE'); // <<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE
526
-        if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) {
527
-            // make sure cart is loaded
528
-            if (! $this->cart instanceof EE_Cart) {
529
-                $this->cart = CartFactory::getCart();
530
-            }
531
-            do_action(
532
-                'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout',
533
-                $this->cart,
534
-                $this
535
-            );
536
-            $this->cart->recalculate_all_cart_totals();
537
-            $this->cart->save_cart(false);
538
-            // exit('KILL REDIRECT AFTER CART UPDATE'); // <<<<<<<<  OR HERE TO KILL REDIRECT AFTER CART UPDATE
539
-            // just return TRUE for registrations being made from admin
540
-            if ($this->request->isAdmin() || $this->request->isFrontAjax()) {
541
-                return true;
542
-            }
543
-            EEH_URL::safeRedirectAndExit(
544
-                apply_filters(
545
-                    'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url',
546
-                    $this->core_config->reg_page_url()
547
-                )
548
-            );
549
-        }
550
-        if (! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) {
551
-            // nothing added to cart
552
-            EE_Error::add_attention(
553
-                esc_html__('No tickets were added for the event', 'event_espresso'),
554
-                __FILE__,
555
-                __FUNCTION__,
556
-                __LINE__
557
-            );
558
-        }
559
-        return false;
560
-    }
515
+	/**
516
+	 * @param $tickets_added
517
+	 * @return bool
518
+	 * @throws InvalidInterfaceException
519
+	 * @throws InvalidDataTypeException
520
+	 * @throws EE_Error
521
+	 * @throws InvalidArgumentException
522
+	 */
523
+	private function processSuccessfulCart($tickets_added)
524
+	{
525
+		// exit('KILL REDIRECT BEFORE CART UPDATE'); // <<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE
526
+		if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) {
527
+			// make sure cart is loaded
528
+			if (! $this->cart instanceof EE_Cart) {
529
+				$this->cart = CartFactory::getCart();
530
+			}
531
+			do_action(
532
+				'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout',
533
+				$this->cart,
534
+				$this
535
+			);
536
+			$this->cart->recalculate_all_cart_totals();
537
+			$this->cart->save_cart(false);
538
+			// exit('KILL REDIRECT AFTER CART UPDATE'); // <<<<<<<<  OR HERE TO KILL REDIRECT AFTER CART UPDATE
539
+			// just return TRUE for registrations being made from admin
540
+			if ($this->request->isAdmin() || $this->request->isFrontAjax()) {
541
+				return true;
542
+			}
543
+			EEH_URL::safeRedirectAndExit(
544
+				apply_filters(
545
+					'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url',
546
+					$this->core_config->reg_page_url()
547
+				)
548
+			);
549
+		}
550
+		if (! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) {
551
+			// nothing added to cart
552
+			EE_Error::add_attention(
553
+				esc_html__('No tickets were added for the event', 'event_espresso'),
554
+				__FILE__,
555
+				__FUNCTION__,
556
+				__LINE__
557
+			);
558
+		}
559
+		return false;
560
+	}
561 561
 }
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
     public function cancelTicketSelections()
119 119
     {
120 120
         // check nonce
121
-        if (! $this->processTicketSelectorNonce('cancel_ticket_selections')) {
121
+        if ( ! $this->processTicketSelectorNonce('cancel_ticket_selections')) {
122 122
             return false;
123 123
         }
124 124
         $this->session->clear_session(__CLASS__, __FUNCTION__);
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
             );
131 131
         }
132 132
         EEH_URL::safeRedirectAndExit(
133
-            site_url('/' . $this->core_config->event_cpt_slug . '/')
133
+            site_url('/'.$this->core_config->event_cpt_slug.'/')
134 134
         );
135 135
         return true;
136 136
     }
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
             $this->validatePostData($id)
208 208
         );
209 209
         // check total tickets ordered vs max number of attendees that can register
210
-        if (! empty($valid) && $valid['total_tickets'] > $valid['max_atndz']) {
210
+        if ( ! empty($valid) && $valid['total_tickets'] > $valid['max_atndz']) {
211 211
             $this->maxAttendeesViolation($valid);
212 212
         } else {
213 213
             // all data appears to be valid
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
     private function getEventId()
238 238
     {
239 239
         // do we have an event id?
240
-        if (! $this->request->requestParamIsSet('tkt-slctr-event-id')) {
240
+        if ( ! $this->request->requestParamIsSet('tkt-slctr-event-id')) {
241 241
             // $_POST['tkt-slctr-event-id'] was not set ?!?!?!?
242 242
             EE_Error::add_error(
243 243
                 sprintf(
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
      */
266 266
     private function validatePostData($id = 0)
267 267
     {
268
-        if (! $id) {
268
+        if ( ! $id) {
269 269
             EE_Error::add_error(
270 270
                 esc_html__('The event id provided was not valid.', 'event_espresso'),
271 271
                 __FILE__,
@@ -292,29 +292,29 @@  discard block
 block discarded – undo
292 292
         // cycle through $inputs_to_clean array
293 293
         foreach ($inputs_to_clean as $what => $input_to_clean) {
294 294
             // check for POST data
295
-            if ($this->request->requestParamIsSet($input_to_clean . $id)) {
295
+            if ($this->request->requestParamIsSet($input_to_clean.$id)) {
296 296
                 // grab value
297
-                $input_value = $this->request->getRequestParam($input_to_clean . $id);
297
+                $input_value = $this->request->getRequestParam($input_to_clean.$id);
298 298
                 switch ($what) {
299 299
                     // integers
300 300
                     case 'event_id':
301
-                        $valid_data[ $what ] = absint($input_value);
301
+                        $valid_data[$what] = absint($input_value);
302 302
                         // get event via the event id we put in the form
303 303
                         break;
304 304
                     case 'rows':
305 305
                     case 'max_atndz':
306
-                        $valid_data[ $what ] = absint($input_value);
306
+                        $valid_data[$what] = absint($input_value);
307 307
                         break;
308 308
                     // arrays of integers
309 309
                     case 'qty':
310 310
                         /** @var array $row_qty */
311 311
                         $row_qty = $input_value;
312 312
                         // if qty is coming from a radio button input, then we need to assemble an array of rows
313
-                        if (! is_array($row_qty)) {
313
+                        if ( ! is_array($row_qty)) {
314 314
                             /** @var string $row_qty */
315 315
                             // get number of rows
316
-                            $rows = $this->request->requestParamIsSet('tkt-slctr-rows-' . $id)
317
-                                ? absint($this->request->getRequestParam('tkt-slctr-rows-' . $id))
316
+                            $rows = $this->request->requestParamIsSet('tkt-slctr-rows-'.$id)
317
+                                ? absint($this->request->getRequestParam('tkt-slctr-rows-'.$id))
318 318
                                 : 1;
319 319
                             // explode integers by the dash
320 320
                             $row_qty = explode('-', $row_qty);
@@ -322,8 +322,8 @@  discard block
 block discarded – undo
322 322
                             $qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0;
323 323
                             $row_qty = array($row => $qty);
324 324
                             for ($x = 1; $x <= $rows; $x++) {
325
-                                if (! isset($row_qty[ $x ])) {
326
-                                    $row_qty[ $x ] = 0;
325
+                                if ( ! isset($row_qty[$x])) {
326
+                                    $row_qty[$x] = 0;
327 327
                                 }
328 328
                             }
329 329
                         }
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
                         foreach ($row_qty as $qty) {
333 333
                             $qty = absint($qty);
334 334
                             // sanitize as integers
335
-                            $valid_data[ $what ][] = $qty;
335
+                            $valid_data[$what][] = $qty;
336 336
                             $valid_data['total_tickets'] += $qty;
337 337
                         }
338 338
                         break;
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
                         // cycle thru values
342 342
                         foreach ((array) $input_value as $key => $value) {
343 343
                             // allow only integers
344
-                            $valid_data[ $what ][ $key ] = absint($value);
344
+                            $valid_data[$what][$key] = absint($value);
345 345
                         }
346 346
                         break;
347 347
                     case 'return_url':
@@ -353,9 +353,9 @@  discard block
 block discarded – undo
353 353
                             $input_value = explode('#', $input_value);
354 354
                             $input_value = end($input_value);
355 355
                             // use event list url instead, but append anchor
356
-                            $input_value = EEH_Event_View::event_archive_url() . '#' . $input_value;
356
+                            $input_value = EEH_Event_View::event_archive_url().'#'.$input_value;
357 357
                         }
358
-                        $valid_data[ $what ] = $input_value;
358
+                        $valid_data[$what] = $input_value;
359 359
                         break;
360 360
                 }    // end switch $what
361 361
             }
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
             )
390 390
         );
391 391
         $limit_error_2 = sprintf($max_attendees_string, $valid['max_atndz'], $valid['max_atndz']);
392
-        EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__);
392
+        EE_Error::add_error($limit_error_1.'<br/>'.$limit_error_2, __FILE__, __FUNCTION__, __LINE__);
393 393
     }
394 394
 
395 395
 
@@ -405,13 +405,13 @@  discard block
 block discarded – undo
405 405
     {
406 406
         $tickets_added = 0;
407 407
         $tickets_selected = false;
408
-        if (! empty($valid) && $valid['total_tickets'] > 0) {
408
+        if ( ! empty($valid) && $valid['total_tickets'] > 0) {
409 409
             // load cart using factory because we don't want to do so until actually needed
410 410
             $this->cart = CartFactory::getCart();
411 411
             // cycle thru the number of data rows sent from the event listing
412 412
             for ($x = 0; $x < $valid['rows']; $x++) {
413 413
                 // does this row actually contain a ticket quantity?
414
-                if (isset($valid['qty'][ $x ]) && $valid['qty'][ $x ] > 0) {
414
+                if (isset($valid['qty'][$x]) && $valid['qty'][$x] > 0) {
415 415
                     // YES we have a ticket quantity
416 416
                     $tickets_selected = true;
417 417
                     $valid_ticket = false;
@@ -420,14 +420,14 @@  discard block
 block discarded – undo
420 420
                     //     '$valid[\'ticket_id\'][ $x ]',
421 421
                     //     __FILE__, __LINE__
422 422
                     // );
423
-                    if (isset($valid['ticket_id'][ $x ])) {
423
+                    if (isset($valid['ticket_id'][$x])) {
424 424
                         // get ticket via the ticket id we put in the form
425
-                        $ticket = $this->ticket_model->get_one_by_ID($valid['ticket_id'][ $x ]);
425
+                        $ticket = $this->ticket_model->get_one_by_ID($valid['ticket_id'][$x]);
426 426
                         if ($ticket instanceof EE_Ticket) {
427 427
                             $valid_ticket = true;
428 428
                             $tickets_added += $this->addTicketToCart(
429 429
                                 $ticket,
430
-                                $valid['qty'][ $x ]
430
+                                $valid['qty'][$x]
431 431
                             );
432 432
                         }
433 433
                     }
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
             $this->cart,
458 458
             $this
459 459
         );
460
-        if (! apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tickets_selected)) {
460
+        if ( ! apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tickets_selected)) {
461 461
             // no ticket quantities were selected
462 462
             EE_Error::add_error(
463 463
                 esc_html__('You need to select a ticket quantity before you can proceed.', 'event_espresso'),
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
         // exit('KILL REDIRECT BEFORE CART UPDATE'); // <<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE
526 526
         if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) {
527 527
             // make sure cart is loaded
528
-            if (! $this->cart instanceof EE_Cart) {
528
+            if ( ! $this->cart instanceof EE_Cart) {
529 529
                 $this->cart = CartFactory::getCart();
530 530
             }
531 531
             do_action(
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
                 )
548 548
             );
549 549
         }
550
-        if (! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) {
550
+        if ( ! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) {
551 551
             // nothing added to cart
552 552
             EE_Error::add_attention(
553 553
                 esc_html__('No tickets were added for the event', 'event_espresso'),
Please login to merge, or discard this patch.
widgets/EspressoWidget.php 2 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -13,28 +13,28 @@
 block discarded – undo
13 13
 {
14 14
 
15 15
 
16
-    /**
17
-     * @param string $name
18
-     * @param array  $widget_options
19
-     * @param array  $control_options
20
-     */
21
-    public function __construct($name = '', array $widget_options = array(), array $control_options = array())
22
-    {
23
-        $id_base = EspressoWidget::getIdBase(get_class($this));
24
-        $control_options['id_base'] = $id_base;
25
-        $control_options['height'] = isset($control_options['height']) ? $control_options['height'] : 300;
26
-        $control_options['width'] = isset($control_options['width']) ? $control_options['width'] : 350;
27
-        // Register widget with WordPress
28
-        parent::__construct($id_base, $name, $widget_options, $control_options);
29
-    }
16
+	/**
17
+	 * @param string $name
18
+	 * @param array  $widget_options
19
+	 * @param array  $control_options
20
+	 */
21
+	public function __construct($name = '', array $widget_options = array(), array $control_options = array())
22
+	{
23
+		$id_base = EspressoWidget::getIdBase(get_class($this));
24
+		$control_options['id_base'] = $id_base;
25
+		$control_options['height'] = isset($control_options['height']) ? $control_options['height'] : 300;
26
+		$control_options['width'] = isset($control_options['width']) ? $control_options['width'] : 350;
27
+		// Register widget with WordPress
28
+		parent::__construct($id_base, $name, $widget_options, $control_options);
29
+	}
30 30
 
31 31
 
32
-    /**
33
-     * @param string $widget_class
34
-     * @return string
35
-     */
36
-    public static function getIdBase($widget_class)
37
-    {
38
-        return sanitize_title(str_replace(array('EEW_', '_'), array('EE_', '-'), $widget_class)) . '-widget';
39
-    }
32
+	/**
33
+	 * @param string $widget_class
34
+	 * @return string
35
+	 */
36
+	public static function getIdBase($widget_class)
37
+	{
38
+		return sanitize_title(str_replace(array('EEW_', '_'), array('EE_', '-'), $widget_class)) . '-widget';
39
+	}
40 40
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,6 +35,6 @@
 block discarded – undo
35 35
      */
36 36
     public static function getIdBase($widget_class)
37 37
     {
38
-        return sanitize_title(str_replace(array('EEW_', '_'), array('EE_', '-'), $widget_class)) . '-widget';
38
+        return sanitize_title(str_replace(array('EEW_', '_'), array('EE_', '-'), $widget_class)).'-widget';
39 39
     }
40 40
 }
Please login to merge, or discard this patch.
modules/ticket_selector/TicketSelectorRowStandard.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
             '',
175 175
             'tckt-slctr-tbl-td-qty cntr',
176 176
             '',
177
-            'headers="quantity-' . $this->EVT_ID . '"'
177
+            'headers="quantity-'.$this->EVT_ID.'"'
178 178
         );
179 179
         $this->setTicketStatusDisplay($remaining);
180 180
         if (empty($this->ticket_status_display)) {
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
             '',
241 241
             'tckt-slctr-tbl-td-name',
242 242
             '',
243
-            'headers="details-' . $this->EVT_ID . '"'
243
+            'headers="details-'.$this->EVT_ID.'"'
244 244
         );
245 245
         $html .= EEH_HTML::strong($this->ticket->get_pretty('TKT_name'));
246 246
         $html .= $this->ticket_details->getShowHideLinks();
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
                 '',
275 275
                 'tckt-slctr-tbl-td-price jst-rght',
276 276
                 '',
277
-                'headers="price-' . $this->EVT_ID . '"'
277
+                'headers="price-'.$this->EVT_ID.'"'
278 278
             );
279 279
             $html .= \EEH_Template::format_currency($this->ticket_price);
280 280
             $html .= $this->ticket->taxable()
@@ -313,12 +313,12 @@  discard block
 block discarded – undo
313 313
         // display submit button since we have tickets available
314 314
         add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
315 315
         $this->hidden_input_qty = false;
316
-        $id = 'ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row;
317
-        $html = '<label class="ee-a11y-screen-reader-text" for="' . $id . '">';
318
-        $html .= esc_html__('Select this ticket', 'event_espresso') . '</label>';
319
-        $html .= '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"';
320
-        $html .= ' id="' . $id . '"';
321
-        $html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"';
316
+        $id = 'ticket-selector-tbl-qty-slct-'.$this->EVT_ID.'-'.$this->row;
317
+        $html = '<label class="ee-a11y-screen-reader-text" for="'.$id.'">';
318
+        $html .= esc_html__('Select this ticket', 'event_espresso').'</label>';
319
+        $html .= '<input type="radio" name="tkt-slctr-qty-'.$this->EVT_ID.'"';
320
+        $html .= ' id="'.$id.'"';
321
+        $html .= ' class="ticket-selector-tbl-qty-slct" value="'.$this->row.'-1"';
322 322
         $html .= $this->total_tickets === 1 ? ' checked="checked"' : '';
323 323
         $html .= ' title=""/>';
324 324
         return $html;
@@ -336,11 +336,11 @@  discard block
 block discarded – undo
336 336
         // display submit button since we have tickets available
337 337
         add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
338 338
         $this->hidden_input_qty = false;
339
-        $id = 'ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row;
340
-        $html = '<label class="ee-a11y-screen-reader-text" for="' . $id . '">';
341
-        $html .= esc_html__('Quantity', 'event_espresso') . '</label>';
342
-        $html .= '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"';
343
-        $html .= ' id="' . $id . '"';
339
+        $id = 'ticket-selector-tbl-qty-slct-'.$this->EVT_ID.'-'.$this->row;
340
+        $html = '<label class="ee-a11y-screen-reader-text" for="'.$id.'">';
341
+        $html .= esc_html__('Quantity', 'event_espresso').'</label>';
342
+        $html .= '<select name="tkt-slctr-qty-'.$this->EVT_ID.'[]"';
343
+        $html .= ' id="'.$id.'"';
344 344
         $html .= ' class="ticket-selector-tbl-qty-slct">';
345 345
         // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased
346 346
         if ($this->min !== 0 && ! $this->ticket->required()) {
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
         }
349 349
         // offer ticket quantities from the min to the max
350 350
         for ($i = $this->min; $i <= $this->max; $i++) {
351
-            $html .= '<option value="' . $i . '">&nbsp;' . $i . '&nbsp;</option>';
351
+            $html .= '<option value="'.$i.'">&nbsp;'.$i.'&nbsp;</option>';
352 352
         }
353 353
         $html .= '</select>';
354 354
         return $html;
@@ -366,10 +366,10 @@  discard block
 block discarded – undo
366 366
         $html = '';
367 367
         // depending on group reg we need to change the format for qty
368 368
         if ($this->hidden_input_qty) {
369
-            $html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>';
369
+            $html .= '<input type="hidden" name="tkt-slctr-qty-'.$this->EVT_ID.'[]" value="0"/>';
370 370
         }
371
-        $html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"';
372
-        $html .= ' value="' . $this->ticket->ID() . '"/>';
371
+        $html .= '<input type="hidden" name="tkt-slctr-ticket-id-'.$this->EVT_ID.'[]"';
372
+        $html .= ' value="'.$this->ticket->ID().'"/>';
373 373
         return $html;
374 374
     }
375 375
 }
Please login to merge, or discard this patch.
Indentation   +352 added lines, -352 removed lines patch added patch discarded remove patch
@@ -17,356 +17,356 @@
 block discarded – undo
17 17
 class TicketSelectorRowStandard extends TicketSelectorRow
18 18
 {
19 19
 
20
-    /**
21
-     * @var TicketDetails $ticket_details
22
-     */
23
-    protected $ticket_details;
24
-
25
-    /**
26
-     * @var \EE_Ticket_Selector_Config $template_settings
27
-     */
28
-    protected $template_settings;
29
-
30
-    /**
31
-     * @var EE_Tax_Config $tax_settings
32
-     */
33
-    protected $tax_settings;
34
-
35
-    /**
36
-     * @var boolean $prices_displayed_including_taxes
37
-     */
38
-    protected $prices_displayed_including_taxes;
39
-
40
-    /**
41
-     * @var int $row
42
-     */
43
-    protected $row;
44
-
45
-    /**
46
-     * @var int $cols
47
-     */
48
-    protected $cols;
49
-
50
-    /**
51
-     * @var boolean $hidden_input_qty
52
-     */
53
-    protected $hidden_input_qty;
54
-
55
-    /**
56
-     * @var string $ticket_datetime_classes
57
-     */
58
-    protected $ticket_datetime_classes;
59
-
60
-
61
-    /**
62
-     * TicketDetails constructor.
63
-     *
64
-     * @param TicketDetails $ticket_details
65
-     * @param EE_Tax_Config $tax_settings
66
-     * @param int           $total_tickets
67
-     * @param int           $max_attendees
68
-     * @param int           $row
69
-     * @param int           $cols
70
-     * @param boolean       $required_ticket_sold_out
71
-     * @param string        $event_status
72
-     * @param string        $ticket_datetime_classes
73
-     * @throws EE_Error
74
-     * @throws UnexpectedEntityException
75
-     */
76
-    public function __construct(
77
-        TicketDetails $ticket_details,
78
-        EE_Tax_Config $tax_settings,
79
-        $total_tickets,
80
-        $max_attendees,
81
-        $row,
82
-        $cols,
83
-        $required_ticket_sold_out,
84
-        $event_status,
85
-        $ticket_datetime_classes
86
-    ) {
87
-        $this->ticket_details = $ticket_details;
88
-        $this->template_settings = $ticket_details->getTemplateSettings();
89
-        $this->tax_settings = $tax_settings;
90
-        $this->row = $row;
91
-        $this->cols = $cols;
92
-        $this->ticket_datetime_classes = $ticket_datetime_classes;
93
-        parent::__construct(
94
-            $ticket_details->getTicket(),
95
-            $max_attendees,
96
-            $ticket_details->getDateFormat(),
97
-            $event_status,
98
-            $required_ticket_sold_out,
99
-            $total_tickets
100
-        );
101
-    }
102
-
103
-
104
-    /**
105
-     * other ticket rows will need to know if a required ticket is sold out,
106
-     * so that they are not offered for sale
107
-     *
108
-     * @return boolean
109
-     */
110
-    public function getRequiredTicketSoldOut()
111
-    {
112
-        return $this->required_ticket_sold_out;
113
-    }
114
-
115
-
116
-    /**
117
-     * @return int
118
-     */
119
-    public function getCols()
120
-    {
121
-        return $this->cols;
122
-    }
123
-
124
-
125
-    /**
126
-     * getHtml
127
-     *
128
-     * @return string
129
-     * @throws EE_Error
130
-     */
131
-    public function getHtml()
132
-    {
133
-        $this->min = 0;
134
-        $this->max = $this->ticket->max();
135
-        $remaining = $this->ticket->remaining();
136
-        $this->setTicketMinAndMax($remaining);
137
-        // set flag if ticket is required (flag is set to start date so that future tickets are not blocked)
138
-        $this->required_ticket_sold_out = $this->ticket->required() && ! $remaining
139
-            ? $this->ticket->start_date()
140
-            : $this->required_ticket_sold_out;
141
-        $this->setTicketPriceDetails();
142
-        $this->setTicketStatusClasses($remaining);
143
-        $filtered_row_html = $this->getFilteredRowHtml();
144
-        if ($filtered_row_html !== false) {
145
-            return $filtered_row_html;
146
-        }
147
-        $ticket_selector_row_html = EEH_HTML::tr(
148
-            '',
149
-            '',
150
-            "tckt-slctr-tbl-tr {$this->status_class}{$this->ticket_datetime_classes} "
151
-            . espresso_get_object_css_class($this->ticket)
152
-        );
153
-        $filtered_row_content = $this->getFilteredRowContents();
154
-        if ($filtered_row_content !== false && $this->max_attendees === 1) {
155
-            return $ticket_selector_row_html
156
-                   . $filtered_row_content
157
-                   . $this->ticketQtyAndIdHiddenInputs()
158
-                   . EEH_HTML::trx();
159
-        }
160
-        if ($filtered_row_content !== false) {
161
-            return $ticket_selector_row_html
162
-                   . $filtered_row_content
163
-                   . EEH_HTML::trx();
164
-        }
165
-        $this->hidden_input_qty = $this->max_attendees > 1;
166
-
167
-        $ticket_selector_row_html .= $this->ticketNameTableCell();
168
-        $ticket_selector_row_html .= $this->ticketPriceTableCell();
169
-        $ticket_selector_row_html .= EEH_HTML::td(
170
-            '',
171
-            '',
172
-            'tckt-slctr-tbl-td-qty cntr',
173
-            '',
174
-            'headers="quantity-' . $this->EVT_ID . '"'
175
-        );
176
-        $this->setTicketStatusDisplay($remaining);
177
-        if (empty($this->ticket_status_display)) {
178
-            if ($this->max_attendees === 1) {
179
-                // only ONE attendee is allowed to register at a time
180
-                $ticket_selector_row_html .= $this->onlyOneAttendeeCanRegister();
181
-            } elseif ($this->max > 0) {
182
-                $ticket_selector_row_html .= $this->ticketQuantitySelector();
183
-            }
184
-        }
185
-        $ticket_selector_row_html .= $this->ticket_status_display;
186
-        $ticket_selector_row_html .= $this->ticketQtyAndIdHiddenInputs();
187
-        $ticket_selector_row_html .= $this->ticket_details->display(
188
-            $this->ticket_price,
189
-            $remaining,
190
-            $this->cols
191
-        );
192
-        $ticket_selector_row_html .= EEH_HTML::tdx();
193
-        $ticket_selector_row_html .= EEH_HTML::trx();
194
-
195
-
196
-        $this->row++;
197
-        return $ticket_selector_row_html;
198
-    }
199
-
200
-
201
-    /**
202
-     * getTicketPriceDetails
203
-     *
204
-     * @return void
205
-     * @throws EE_Error
206
-     */
207
-    protected function setTicketPriceDetails()
208
-    {
209
-        $this->ticket_price = $this->tax_settings->prices_displayed_including_taxes
210
-            ? $this->ticket->get_ticket_total_with_taxes()
211
-            : $this->ticket->get_ticket_subtotal();
212
-        $this->ticket_bundle = false;
213
-        $ticket_min = $this->ticket->min();
214
-        // for ticket bundles, set min and max qty the same
215
-        if ($ticket_min !== 0 && $ticket_min === $this->ticket->max()) {
216
-            $this->ticket_price *= $ticket_min;
217
-            $this->ticket_bundle = true;
218
-        }
219
-        $this->ticket_price = apply_filters(
220
-            'FHEE__ticket_selector_chart_template__ticket_price',
221
-            $this->ticket_price,
222
-            $this->ticket
223
-        );
224
-    }
225
-
226
-
227
-    /**
228
-     * ticketNameTableCell
229
-     *
230
-     * @return string
231
-     * @throws EE_Error
232
-     */
233
-    protected function ticketNameTableCell()
234
-    {
235
-        $html = EEH_HTML::td(
236
-            '',
237
-            '',
238
-            'tckt-slctr-tbl-td-name',
239
-            '',
240
-            'headers="details-' . $this->EVT_ID . '"'
241
-        );
242
-        $html .= EEH_HTML::strong($this->ticket->get_pretty('TKT_name'));
243
-        $html .= $this->ticket_details->getShowHideLinks();
244
-        if ($this->ticket->required()) {
245
-            $html .= EEH_HTML::p(
246
-                apply_filters(
247
-                    'FHEE__ticket_selector_chart_template__ticket_required_message',
248
-                    esc_html__('This ticket is required and must be purchased.', 'event_espresso')
249
-                ),
250
-                '',
251
-                'ticket-required-pg'
252
-            );
253
-        }
254
-        $html .= EEH_HTML::tdx();
255
-        return $html;
256
-    }
257
-
258
-
259
-    /**
260
-     * ticketPriceTableCell
261
-     *
262
-     * @return string
263
-     * @throws EE_Error
264
-     */
265
-    protected function ticketPriceTableCell()
266
-    {
267
-        $html = '';
268
-        if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) {
269
-            $html .= EEH_HTML::td(
270
-                '',
271
-                '',
272
-                'tckt-slctr-tbl-td-price jst-rght',
273
-                '',
274
-                'headers="price-' . $this->EVT_ID . '"'
275
-            );
276
-            $html .= \EEH_Template::format_currency($this->ticket_price);
277
-            $html .= $this->ticket->taxable()
278
-                ? EEH_HTML::span('*', '', 'taxable-tickets-asterisk grey-text')
279
-                : '';
280
-            $html .= '&nbsp;';
281
-            // phpcs:disable WordPress.WP.I18n.NoEmptyStrings
282
-            $html .= EEH_HTML::span(
283
-                $this->ticket_bundle
284
-                    ? apply_filters(
285
-                        'FHEE__ticket_selector_chart_template__per_ticket_bundle_text',
286
-                        __(' / bundle', 'event_espresso')
287
-                    )
288
-                    : apply_filters(
289
-                        'FHEE__ticket_selector_chart_template__per_ticket_text',
290
-                        __('', 'event_espresso')
291
-                    ),
292
-                '',
293
-                'smaller-text no-bold'
294
-            );
295
-            $html .= '&nbsp;';
296
-            $html .= EEH_HTML::tdx();
297
-            $this->cols++;
298
-        }
299
-        return $html;
300
-    }
301
-
302
-
303
-    /**
304
-     * onlyOneAttendeeCanRegister
305
-     *
306
-     * @return string
307
-     */
308
-    protected function onlyOneAttendeeCanRegister()
309
-    {
310
-        // display submit button since we have tickets available
311
-        add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
312
-        $this->hidden_input_qty = false;
313
-        $id = 'ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row;
314
-        $html = '<label class="ee-a11y-screen-reader-text" for="' . $id . '">';
315
-        $html .= esc_html__('Select this ticket', 'event_espresso') . '</label>';
316
-        $html .= '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"';
317
-        $html .= ' id="' . $id . '"';
318
-        $html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"';
319
-        $html .= $this->total_tickets === 1 ? ' checked="checked"' : '';
320
-        $html .= ' title=""/>';
321
-        return $html;
322
-    }
323
-
324
-
325
-    /**
326
-     * ticketQuantitySelector
327
-     *
328
-     * @return string
329
-     * @throws EE_Error
330
-     */
331
-    protected function ticketQuantitySelector()
332
-    {
333
-        // display submit button since we have tickets available
334
-        add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
335
-        $this->hidden_input_qty = false;
336
-        $id = 'ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row;
337
-        $html = '<label class="ee-a11y-screen-reader-text" for="' . $id . '">';
338
-        $html .= esc_html__('Quantity', 'event_espresso') . '</label>';
339
-        $html .= '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"';
340
-        $html .= ' id="' . $id . '"';
341
-        $html .= ' class="ticket-selector-tbl-qty-slct">';
342
-        // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased
343
-        if ($this->min !== 0 && ! $this->ticket->required()) {
344
-            $html .= '<option value="0">&nbsp;0&nbsp;</option>';
345
-        }
346
-        // offer ticket quantities from the min to the max
347
-        for ($i = $this->min; $i <= $this->max; $i++) {
348
-            $html .= '<option value="' . $i . '">&nbsp;' . $i . '&nbsp;</option>';
349
-        }
350
-        $html .= '</select>';
351
-        return $html;
352
-    }
353
-
354
-
355
-    /**
356
-     * getHiddenInputs
357
-     *
358
-     * @return string
359
-     * @throws EE_Error
360
-     */
361
-    protected function ticketQtyAndIdHiddenInputs()
362
-    {
363
-        $html = '';
364
-        // depending on group reg we need to change the format for qty
365
-        if ($this->hidden_input_qty) {
366
-            $html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>';
367
-        }
368
-        $html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"';
369
-        $html .= ' value="' . $this->ticket->ID() . '"/>';
370
-        return $html;
371
-    }
20
+	/**
21
+	 * @var TicketDetails $ticket_details
22
+	 */
23
+	protected $ticket_details;
24
+
25
+	/**
26
+	 * @var \EE_Ticket_Selector_Config $template_settings
27
+	 */
28
+	protected $template_settings;
29
+
30
+	/**
31
+	 * @var EE_Tax_Config $tax_settings
32
+	 */
33
+	protected $tax_settings;
34
+
35
+	/**
36
+	 * @var boolean $prices_displayed_including_taxes
37
+	 */
38
+	protected $prices_displayed_including_taxes;
39
+
40
+	/**
41
+	 * @var int $row
42
+	 */
43
+	protected $row;
44
+
45
+	/**
46
+	 * @var int $cols
47
+	 */
48
+	protected $cols;
49
+
50
+	/**
51
+	 * @var boolean $hidden_input_qty
52
+	 */
53
+	protected $hidden_input_qty;
54
+
55
+	/**
56
+	 * @var string $ticket_datetime_classes
57
+	 */
58
+	protected $ticket_datetime_classes;
59
+
60
+
61
+	/**
62
+	 * TicketDetails constructor.
63
+	 *
64
+	 * @param TicketDetails $ticket_details
65
+	 * @param EE_Tax_Config $tax_settings
66
+	 * @param int           $total_tickets
67
+	 * @param int           $max_attendees
68
+	 * @param int           $row
69
+	 * @param int           $cols
70
+	 * @param boolean       $required_ticket_sold_out
71
+	 * @param string        $event_status
72
+	 * @param string        $ticket_datetime_classes
73
+	 * @throws EE_Error
74
+	 * @throws UnexpectedEntityException
75
+	 */
76
+	public function __construct(
77
+		TicketDetails $ticket_details,
78
+		EE_Tax_Config $tax_settings,
79
+		$total_tickets,
80
+		$max_attendees,
81
+		$row,
82
+		$cols,
83
+		$required_ticket_sold_out,
84
+		$event_status,
85
+		$ticket_datetime_classes
86
+	) {
87
+		$this->ticket_details = $ticket_details;
88
+		$this->template_settings = $ticket_details->getTemplateSettings();
89
+		$this->tax_settings = $tax_settings;
90
+		$this->row = $row;
91
+		$this->cols = $cols;
92
+		$this->ticket_datetime_classes = $ticket_datetime_classes;
93
+		parent::__construct(
94
+			$ticket_details->getTicket(),
95
+			$max_attendees,
96
+			$ticket_details->getDateFormat(),
97
+			$event_status,
98
+			$required_ticket_sold_out,
99
+			$total_tickets
100
+		);
101
+	}
102
+
103
+
104
+	/**
105
+	 * other ticket rows will need to know if a required ticket is sold out,
106
+	 * so that they are not offered for sale
107
+	 *
108
+	 * @return boolean
109
+	 */
110
+	public function getRequiredTicketSoldOut()
111
+	{
112
+		return $this->required_ticket_sold_out;
113
+	}
114
+
115
+
116
+	/**
117
+	 * @return int
118
+	 */
119
+	public function getCols()
120
+	{
121
+		return $this->cols;
122
+	}
123
+
124
+
125
+	/**
126
+	 * getHtml
127
+	 *
128
+	 * @return string
129
+	 * @throws EE_Error
130
+	 */
131
+	public function getHtml()
132
+	{
133
+		$this->min = 0;
134
+		$this->max = $this->ticket->max();
135
+		$remaining = $this->ticket->remaining();
136
+		$this->setTicketMinAndMax($remaining);
137
+		// set flag if ticket is required (flag is set to start date so that future tickets are not blocked)
138
+		$this->required_ticket_sold_out = $this->ticket->required() && ! $remaining
139
+			? $this->ticket->start_date()
140
+			: $this->required_ticket_sold_out;
141
+		$this->setTicketPriceDetails();
142
+		$this->setTicketStatusClasses($remaining);
143
+		$filtered_row_html = $this->getFilteredRowHtml();
144
+		if ($filtered_row_html !== false) {
145
+			return $filtered_row_html;
146
+		}
147
+		$ticket_selector_row_html = EEH_HTML::tr(
148
+			'',
149
+			'',
150
+			"tckt-slctr-tbl-tr {$this->status_class}{$this->ticket_datetime_classes} "
151
+			. espresso_get_object_css_class($this->ticket)
152
+		);
153
+		$filtered_row_content = $this->getFilteredRowContents();
154
+		if ($filtered_row_content !== false && $this->max_attendees === 1) {
155
+			return $ticket_selector_row_html
156
+				   . $filtered_row_content
157
+				   . $this->ticketQtyAndIdHiddenInputs()
158
+				   . EEH_HTML::trx();
159
+		}
160
+		if ($filtered_row_content !== false) {
161
+			return $ticket_selector_row_html
162
+				   . $filtered_row_content
163
+				   . EEH_HTML::trx();
164
+		}
165
+		$this->hidden_input_qty = $this->max_attendees > 1;
166
+
167
+		$ticket_selector_row_html .= $this->ticketNameTableCell();
168
+		$ticket_selector_row_html .= $this->ticketPriceTableCell();
169
+		$ticket_selector_row_html .= EEH_HTML::td(
170
+			'',
171
+			'',
172
+			'tckt-slctr-tbl-td-qty cntr',
173
+			'',
174
+			'headers="quantity-' . $this->EVT_ID . '"'
175
+		);
176
+		$this->setTicketStatusDisplay($remaining);
177
+		if (empty($this->ticket_status_display)) {
178
+			if ($this->max_attendees === 1) {
179
+				// only ONE attendee is allowed to register at a time
180
+				$ticket_selector_row_html .= $this->onlyOneAttendeeCanRegister();
181
+			} elseif ($this->max > 0) {
182
+				$ticket_selector_row_html .= $this->ticketQuantitySelector();
183
+			}
184
+		}
185
+		$ticket_selector_row_html .= $this->ticket_status_display;
186
+		$ticket_selector_row_html .= $this->ticketQtyAndIdHiddenInputs();
187
+		$ticket_selector_row_html .= $this->ticket_details->display(
188
+			$this->ticket_price,
189
+			$remaining,
190
+			$this->cols
191
+		);
192
+		$ticket_selector_row_html .= EEH_HTML::tdx();
193
+		$ticket_selector_row_html .= EEH_HTML::trx();
194
+
195
+
196
+		$this->row++;
197
+		return $ticket_selector_row_html;
198
+	}
199
+
200
+
201
+	/**
202
+	 * getTicketPriceDetails
203
+	 *
204
+	 * @return void
205
+	 * @throws EE_Error
206
+	 */
207
+	protected function setTicketPriceDetails()
208
+	{
209
+		$this->ticket_price = $this->tax_settings->prices_displayed_including_taxes
210
+			? $this->ticket->get_ticket_total_with_taxes()
211
+			: $this->ticket->get_ticket_subtotal();
212
+		$this->ticket_bundle = false;
213
+		$ticket_min = $this->ticket->min();
214
+		// for ticket bundles, set min and max qty the same
215
+		if ($ticket_min !== 0 && $ticket_min === $this->ticket->max()) {
216
+			$this->ticket_price *= $ticket_min;
217
+			$this->ticket_bundle = true;
218
+		}
219
+		$this->ticket_price = apply_filters(
220
+			'FHEE__ticket_selector_chart_template__ticket_price',
221
+			$this->ticket_price,
222
+			$this->ticket
223
+		);
224
+	}
225
+
226
+
227
+	/**
228
+	 * ticketNameTableCell
229
+	 *
230
+	 * @return string
231
+	 * @throws EE_Error
232
+	 */
233
+	protected function ticketNameTableCell()
234
+	{
235
+		$html = EEH_HTML::td(
236
+			'',
237
+			'',
238
+			'tckt-slctr-tbl-td-name',
239
+			'',
240
+			'headers="details-' . $this->EVT_ID . '"'
241
+		);
242
+		$html .= EEH_HTML::strong($this->ticket->get_pretty('TKT_name'));
243
+		$html .= $this->ticket_details->getShowHideLinks();
244
+		if ($this->ticket->required()) {
245
+			$html .= EEH_HTML::p(
246
+				apply_filters(
247
+					'FHEE__ticket_selector_chart_template__ticket_required_message',
248
+					esc_html__('This ticket is required and must be purchased.', 'event_espresso')
249
+				),
250
+				'',
251
+				'ticket-required-pg'
252
+			);
253
+		}
254
+		$html .= EEH_HTML::tdx();
255
+		return $html;
256
+	}
257
+
258
+
259
+	/**
260
+	 * ticketPriceTableCell
261
+	 *
262
+	 * @return string
263
+	 * @throws EE_Error
264
+	 */
265
+	protected function ticketPriceTableCell()
266
+	{
267
+		$html = '';
268
+		if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) {
269
+			$html .= EEH_HTML::td(
270
+				'',
271
+				'',
272
+				'tckt-slctr-tbl-td-price jst-rght',
273
+				'',
274
+				'headers="price-' . $this->EVT_ID . '"'
275
+			);
276
+			$html .= \EEH_Template::format_currency($this->ticket_price);
277
+			$html .= $this->ticket->taxable()
278
+				? EEH_HTML::span('*', '', 'taxable-tickets-asterisk grey-text')
279
+				: '';
280
+			$html .= '&nbsp;';
281
+			// phpcs:disable WordPress.WP.I18n.NoEmptyStrings
282
+			$html .= EEH_HTML::span(
283
+				$this->ticket_bundle
284
+					? apply_filters(
285
+						'FHEE__ticket_selector_chart_template__per_ticket_bundle_text',
286
+						__(' / bundle', 'event_espresso')
287
+					)
288
+					: apply_filters(
289
+						'FHEE__ticket_selector_chart_template__per_ticket_text',
290
+						__('', 'event_espresso')
291
+					),
292
+				'',
293
+				'smaller-text no-bold'
294
+			);
295
+			$html .= '&nbsp;';
296
+			$html .= EEH_HTML::tdx();
297
+			$this->cols++;
298
+		}
299
+		return $html;
300
+	}
301
+
302
+
303
+	/**
304
+	 * onlyOneAttendeeCanRegister
305
+	 *
306
+	 * @return string
307
+	 */
308
+	protected function onlyOneAttendeeCanRegister()
309
+	{
310
+		// display submit button since we have tickets available
311
+		add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
312
+		$this->hidden_input_qty = false;
313
+		$id = 'ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row;
314
+		$html = '<label class="ee-a11y-screen-reader-text" for="' . $id . '">';
315
+		$html .= esc_html__('Select this ticket', 'event_espresso') . '</label>';
316
+		$html .= '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"';
317
+		$html .= ' id="' . $id . '"';
318
+		$html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"';
319
+		$html .= $this->total_tickets === 1 ? ' checked="checked"' : '';
320
+		$html .= ' title=""/>';
321
+		return $html;
322
+	}
323
+
324
+
325
+	/**
326
+	 * ticketQuantitySelector
327
+	 *
328
+	 * @return string
329
+	 * @throws EE_Error
330
+	 */
331
+	protected function ticketQuantitySelector()
332
+	{
333
+		// display submit button since we have tickets available
334
+		add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
335
+		$this->hidden_input_qty = false;
336
+		$id = 'ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row;
337
+		$html = '<label class="ee-a11y-screen-reader-text" for="' . $id . '">';
338
+		$html .= esc_html__('Quantity', 'event_espresso') . '</label>';
339
+		$html .= '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"';
340
+		$html .= ' id="' . $id . '"';
341
+		$html .= ' class="ticket-selector-tbl-qty-slct">';
342
+		// this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased
343
+		if ($this->min !== 0 && ! $this->ticket->required()) {
344
+			$html .= '<option value="0">&nbsp;0&nbsp;</option>';
345
+		}
346
+		// offer ticket quantities from the min to the max
347
+		for ($i = $this->min; $i <= $this->max; $i++) {
348
+			$html .= '<option value="' . $i . '">&nbsp;' . $i . '&nbsp;</option>';
349
+		}
350
+		$html .= '</select>';
351
+		return $html;
352
+	}
353
+
354
+
355
+	/**
356
+	 * getHiddenInputs
357
+	 *
358
+	 * @return string
359
+	 * @throws EE_Error
360
+	 */
361
+	protected function ticketQtyAndIdHiddenInputs()
362
+	{
363
+		$html = '';
364
+		// depending on group reg we need to change the format for qty
365
+		if ($this->hidden_input_qty) {
366
+			$html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>';
367
+		}
368
+		$html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"';
369
+		$html .= ' value="' . $this->ticket->ID() . '"/>';
370
+		return $html;
371
+	}
372 372
 }
Please login to merge, or discard this patch.
modules/ticket_selector/TicketSelectorIframeEmbedButton.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -14,24 +14,24 @@
 block discarded – undo
14 14
 class TicketSelectorIframeEmbedButton extends IframeEmbedButton
15 15
 {
16 16
 
17
-    /**
18
-     * TicketSelectorIframeEmbedButton constructor.
19
-     */
20
-    public function __construct()
21
-    {
22
-        parent::__construct(
23
-            esc_html__('Ticket Selector', 'event_espresso'),
24
-            'ticket_selector'
25
-        );
26
-    }
17
+	/**
18
+	 * TicketSelectorIframeEmbedButton constructor.
19
+	 */
20
+	public function __construct()
21
+	{
22
+		parent::__construct(
23
+			esc_html__('Ticket Selector', 'event_espresso'),
24
+			'ticket_selector'
25
+		);
26
+	}
27 27
 
28 28
 
29
-    /**
30
-     * Adds an iframe embed code button to the Event editor.
31
-     */
32
-    public function addEventEditorIframeEmbedButton()
33
-    {
34
-        // add button for iframe code to event editor.
35
-        $this->addEventEditorIframeEmbedButtonFilter();
36
-    }
29
+	/**
30
+	 * Adds an iframe embed code button to the Event editor.
31
+	 */
32
+	public function addEventEditorIframeEmbedButton()
33
+	{
34
+		// add button for iframe code to event editor.
35
+		$this->addEventEditorIframeEmbedButtonFilter();
36
+	}
37 37
 }
Please login to merge, or discard this patch.
modules/ticket_selector/TicketSelectorRowSimple.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -14,26 +14,26 @@
 block discarded – undo
14 14
 class TicketSelectorRowSimple extends TicketSelectorRow
15 15
 {
16 16
 
17
-    /**
18
-     * @throws EE_Error
19
-     */
20
-    public function setupTicketStatusDisplay()
21
-    {
22
-        $remaining = $this->ticket->remaining();
23
-        $this->setTicketMinAndMax($remaining);
24
-        $this->setTicketStatusClasses($remaining);
25
-        $this->setTicketStatusDisplay($remaining);
26
-    }
17
+	/**
18
+	 * @throws EE_Error
19
+	 */
20
+	public function setupTicketStatusDisplay()
21
+	{
22
+		$remaining = $this->ticket->remaining();
23
+		$this->setTicketMinAndMax($remaining);
24
+		$this->setTicketStatusClasses($remaining);
25
+		$this->setTicketStatusDisplay($remaining);
26
+	}
27 27
 
28 28
 
29
-    public function getTicketDescription()
30
-    {
31
-        $filtered_row_content = $this->getFilteredRowContents();
32
-        if ($filtered_row_content !== false) {
33
-            remove_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
34
-            add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_false');
35
-            return $filtered_row_content;
36
-        }
37
-        return $this->ticket->description();
38
-    }
29
+	public function getTicketDescription()
30
+	{
31
+		$filtered_row_content = $this->getFilteredRowContents();
32
+		if ($filtered_row_content !== false) {
33
+			remove_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
34
+			add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_false');
35
+			return $filtered_row_content;
36
+		}
37
+		return $this->ticket->description();
38
+	}
39 39
 }
Please login to merge, or discard this patch.