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