@@ -2,16 +2,16 @@ |
||
2 | 2 | if (!defined('EVENT_ESPRESSO_VERSION')) |
3 | 3 | exit('No direct script access allowed'); |
4 | 4 | /** |
5 | - * EE_Form_Section_HTML |
|
6 | - * HTML to be laid out like a proper subsection |
|
7 | - * |
|
8 | - * |
|
9 | - * @package Event Espresso |
|
10 | - * @subpackage |
|
11 | - * @author Mike Nelson |
|
12 | - * |
|
13 | - * ------------------------------------------------------------------------ |
|
14 | - */ |
|
5 | + * EE_Form_Section_HTML |
|
6 | + * HTML to be laid out like a proper subsection |
|
7 | + * |
|
8 | + * |
|
9 | + * @package Event Espresso |
|
10 | + * @subpackage |
|
11 | + * @author Mike Nelson |
|
12 | + * |
|
13 | + * ------------------------------------------------------------------------ |
|
14 | + */ |
|
15 | 15 | class EE_Form_Section_HTML extends EE_Form_Section_Base{ |
16 | 16 | |
17 | 17 | protected $_html = ''; |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('No direct script access allowed'); |
4 | 4 | /** |
5 | 5 | * EE_Form_Section_HTML |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * |
13 | 13 | * ------------------------------------------------------------------------ |
14 | 14 | */ |
15 | -class EE_Form_Section_HTML extends EE_Form_Section_Base{ |
|
15 | +class EE_Form_Section_HTML extends EE_Form_Section_Base { |
|
16 | 16 | |
17 | 17 | protected $_html = ''; |
18 | 18 | |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | * @param string $html |
23 | 23 | * @param array $options_array |
24 | 24 | */ |
25 | - public function __construct( $html = '', $options_array = array() ) { |
|
25 | + public function __construct($html = '', $options_array = array()) { |
|
26 | 26 | $this->_html = $html; |
27 | - parent::__construct( $options_array ); |
|
27 | + parent::__construct($options_array); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 |
@@ -1,7 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | 4 | exit('No direct script access allowed'); |
5 | +} |
|
5 | 6 | /** |
6 | 7 | * Event Espresso |
7 | 8 | * |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('No direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -25,10 +25,10 @@ discard block |
||
25 | 25 | * |
26 | 26 | * ------------------------------------------------------------------------ |
27 | 27 | */ |
28 | -class EE_Form_Section_HTML_From_Template extends EE_Form_Section_HTML{ |
|
29 | - public function __construct($template_file,$args = array(), $options_array = array()) { |
|
28 | +class EE_Form_Section_HTML_From_Template extends EE_Form_Section_HTML { |
|
29 | + public function __construct($template_file, $args = array(), $options_array = array()) { |
|
30 | 30 | EE_Registry::instance()->load_helper('Template'); |
31 | - $html = EEH_Template::locate_template( $template_file, $args ); |
|
31 | + $html = EEH_Template::locate_template($template_file, $args); |
|
32 | 32 | |
33 | 33 | // echo " filepath:$template_file html $html"; |
34 | 34 | parent::__construct($html, $options_array); |
@@ -1,7 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | 4 | exit('No direct script access allowed'); |
5 | +} |
|
5 | 6 | /** |
6 | 7 | * Event Espresso |
7 | 8 | * |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | if(isset($default_data[$subsection_name])){ |
210 | 210 | if($subsection instanceof EE_Form_Input_Base){ |
211 | 211 | $subsection->set_default($default_data[$subsection_name]); |
212 | - }elseif($subsection instanceof EE_Form_Section_Proper){ |
|
212 | + } elseif($subsection instanceof EE_Form_Section_Proper){ |
|
213 | 213 | $subsection->populate_defaults($default_data[$subsection_name]); |
214 | 214 | } |
215 | 215 | } |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | foreach($this->subsections() as $subsection){ |
441 | 441 | if( $subsection instanceof EE_Form_Input_Base ){ |
442 | 442 | $inputs[ $subsection->html_name() ] = $subsection; |
443 | - }elseif($subsection instanceof EE_Form_Section_Proper ){ |
|
443 | + } elseif($subsection instanceof EE_Form_Section_Proper ){ |
|
444 | 444 | $inputs += $subsection->inputs_in_subsections(); |
445 | 445 | } |
446 | 446 | } |
@@ -548,7 +548,7 @@ discard block |
||
548 | 548 | foreach($this->get_validatable_subsections() as $subsection){ |
549 | 549 | try{ |
550 | 550 | $subsection->_normalize($req_data); |
551 | - }catch( EE_Validation_Error $e ){ |
|
551 | + } catch( EE_Validation_Error $e ){ |
|
552 | 552 | $subsection->add_validation_error( $e ); |
553 | 553 | } |
554 | 554 | } |
@@ -866,7 +866,7 @@ discard block |
||
866 | 866 | public function html_name_prefix(){ |
867 | 867 | if( $this->parent_section() instanceof EE_Form_Section_Proper ){ |
868 | 868 | return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']'; |
869 | - }else{ |
|
869 | + } else{ |
|
870 | 870 | return $this->name(); |
871 | 871 | } |
872 | 872 | } |
@@ -918,7 +918,7 @@ discard block |
||
918 | 918 | if( $subsection->form_data_present_in( $req_data ) ) { |
919 | 919 | return TRUE; |
920 | 920 | } |
921 | - }elseif( $subsection instanceof EE_Form_Section_Proper ) { |
|
921 | + } elseif( $subsection instanceof EE_Form_Section_Proper ) { |
|
922 | 922 | if( $subsection->form_data_present_in( $req_data ) ) { |
923 | 923 | return TRUE; |
924 | 924 | } |
@@ -225,7 +225,7 @@ |
||
225 | 225 | * leave this as TRUE so that the inputs will be properly configured. However, |
226 | 226 | * some client code may be ok with construction finalize being called later |
227 | 227 | * (realizing that the subsections' html names might not be set yet, etc.) |
228 | - * @return EE_Form_Section_Base |
|
228 | + * @return EE_Form_Section_Validatable|null |
|
229 | 229 | */ |
230 | 230 | public function get_subsection($name, $require_construction_to_be_finalized = TRUE ){ |
231 | 231 | if( $require_construction_to_be_finalized ){ |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * before the hook wp_enqueue_scripts is called (so that the form section can enqueue its needed scripts). |
8 | 8 | * However, you may output the form (usually by calling get_html_and_js) anywhere you like. |
9 | 9 | */ |
10 | -class EE_Form_Section_Proper extends EE_Form_Section_Validatable{ |
|
10 | +class EE_Form_Section_Proper extends EE_Form_Section_Validatable { |
|
11 | 11 | |
12 | 12 | /** |
13 | 13 | * Subsections |
@@ -68,38 +68,38 @@ discard block |
||
68 | 68 | * } @see EE_Form_Section_Validatable::__construct() |
69 | 69 | * |
70 | 70 | */ |
71 | - public function __construct( $options_array = array() ){ |
|
71 | + public function __construct($options_array = array()) { |
|
72 | 72 | EE_Registry::instance()->load_helper('Formatter'); |
73 | - $options_array = apply_filters( 'FHEE__EE_Form_Section_Proper___construct__options_array', $options_array, $this ); |
|
73 | + $options_array = apply_filters('FHEE__EE_Form_Section_Proper___construct__options_array', $options_array, $this); |
|
74 | 74 | //call parent first, as it may be setting the name |
75 | 75 | parent::__construct($options_array); |
76 | 76 | //if they've included subsections in the constructor, add them now |
77 | - if( isset( $options_array['include'] )){ |
|
77 | + if (isset($options_array['include'])) { |
|
78 | 78 | //we are going to make sure we ONLY have those subsections to include |
79 | 79 | //AND we are going to make sure they're in that specified order |
80 | 80 | $reordered_subsections = array(); |
81 | - foreach($options_array['include'] as $input_name){ |
|
82 | - if(isset($this->_subsections[$input_name])){ |
|
81 | + foreach ($options_array['include'] as $input_name) { |
|
82 | + if (isset($this->_subsections[$input_name])) { |
|
83 | 83 | $reordered_subsections[$input_name] = $this->_subsections[$input_name]; |
84 | 84 | } |
85 | 85 | } |
86 | 86 | $this->_subsections = $reordered_subsections; |
87 | 87 | } |
88 | - if(isset($options_array['exclude'])){ |
|
88 | + if (isset($options_array['exclude'])) { |
|
89 | 89 | $exclude = $options_array['exclude']; |
90 | 90 | $this->_subsections = array_diff_key($this->_subsections, array_flip($exclude)); |
91 | 91 | } |
92 | - if(isset($options_array['layout_strategy'])){ |
|
92 | + if (isset($options_array['layout_strategy'])) { |
|
93 | 93 | $this->_layout_strategy = $options_array['layout_strategy']; |
94 | 94 | } |
95 | - if( ! $this->_layout_strategy){ |
|
95 | + if ( ! $this->_layout_strategy) { |
|
96 | 96 | $this->_layout_strategy = new EE_Two_Column_Layout(); |
97 | 97 | } |
98 | 98 | $this->_layout_strategy->_construct_finalize($this); |
99 | 99 | |
100 | - add_action( 'wp_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' )); |
|
101 | - add_action( 'admin_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' )); |
|
102 | - add_action( 'wp_footer', array( $this, 'ensure_scripts_localized' ), 1 ); |
|
100 | + add_action('wp_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts')); |
|
101 | + add_action('admin_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts')); |
|
102 | + add_action('wp_footer', array($this, 'ensure_scripts_localized'), 1); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -111,25 +111,25 @@ discard block |
||
111 | 111 | * @param string $name |
112 | 112 | * @throws \EE_Error |
113 | 113 | */ |
114 | - public function _construct_finalize( $parent_form_section, $name ) { |
|
114 | + public function _construct_finalize($parent_form_section, $name) { |
|
115 | 115 | parent::_construct_finalize($parent_form_section, $name); |
116 | 116 | $this->_set_default_name_if_empty(); |
117 | 117 | $this->_set_default_html_id_if_empty(); |
118 | - foreach( $this->_subsections as $subsection_name => $subsection ){ |
|
119 | - if ( $subsection instanceof EE_Form_Section_Base ) { |
|
120 | - $subsection->_construct_finalize( $this, $subsection_name ); |
|
118 | + foreach ($this->_subsections as $subsection_name => $subsection) { |
|
119 | + if ($subsection instanceof EE_Form_Section_Base) { |
|
120 | + $subsection->_construct_finalize($this, $subsection_name); |
|
121 | 121 | } else { |
122 | 122 | throw new EE_Error( |
123 | 123 | sprintf( |
124 | - __( 'Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso' ), |
|
124 | + __('Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso'), |
|
125 | 125 | $subsection_name, |
126 | 126 | get_class($this), |
127 | - $subsection ? get_class($subsection) : __( 'NULL', 'event_espresso' ) |
|
127 | + $subsection ? get_class($subsection) : __('NULL', 'event_espresso') |
|
128 | 128 | ) |
129 | 129 | ); |
130 | 130 | } |
131 | 131 | } |
132 | - do_action( 'AHEE__EE_Form_Section_Proper___construct_finalize__end', $this, $parent_form_section, $name ); |
|
132 | + do_action('AHEE__EE_Form_Section_Proper___construct_finalize__end', $this, $parent_form_section, $name); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * Gets the layout strategy for this form section |
139 | 139 | * @return EE_Form_Section_Layout_Base |
140 | 140 | */ |
141 | - public function get_layout_strategy(){ |
|
141 | + public function get_layout_strategy() { |
|
142 | 142 | return $this->_layout_strategy; |
143 | 143 | } |
144 | 144 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * @param EE_Form_Input_Base $input |
151 | 151 | * @return string |
152 | 152 | */ |
153 | - public function get_html_for_input($input){ |
|
153 | + public function get_html_for_input($input) { |
|
154 | 154 | return $this->_layout_strategy->layout_input($input); |
155 | 155 | } |
156 | 156 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * @param null $form_data |
164 | 164 | * @return boolean |
165 | 165 | */ |
166 | - public function was_submitted($form_data = NULL){ |
|
166 | + public function was_submitted($form_data = NULL) { |
|
167 | 167 | return $this->form_data_present_in($form_data); |
168 | 168 | } |
169 | 169 | |
@@ -184,13 +184,13 @@ discard block |
||
184 | 184 | * to skip this step. |
185 | 185 | * @return void |
186 | 186 | */ |
187 | - public function receive_form_submission($req_data = NULL, $validate = TRUE){ |
|
188 | - if( $req_data === NULL){ |
|
187 | + public function receive_form_submission($req_data = NULL, $validate = TRUE) { |
|
188 | + if ($req_data === NULL) { |
|
189 | 189 | $req_data = $_REQUEST; |
190 | 190 | } |
191 | - $req_data = apply_filters( 'FHEE__EE_Form_Section_Proper__receive_form_submission__request_data', $req_data, $this ); |
|
191 | + $req_data = apply_filters('FHEE__EE_Form_Section_Proper__receive_form_submission__request_data', $req_data, $this); |
|
192 | 192 | $this->_normalize($req_data); |
193 | - if( $validate ){ |
|
193 | + if ($validate) { |
|
194 | 194 | $this->_validate(); |
195 | 195 | } |
196 | 196 | } |
@@ -205,12 +205,12 @@ discard block |
||
205 | 205 | * the value being an array formatted in teh same way |
206 | 206 | * @param array $default_data |
207 | 207 | */ |
208 | - public function populate_defaults($default_data){ |
|
209 | - foreach($this->subsections() as $subsection_name => $subsection){ |
|
210 | - if(isset($default_data[$subsection_name])){ |
|
211 | - if($subsection instanceof EE_Form_Input_Base){ |
|
208 | + public function populate_defaults($default_data) { |
|
209 | + foreach ($this->subsections() as $subsection_name => $subsection) { |
|
210 | + if (isset($default_data[$subsection_name])) { |
|
211 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
212 | 212 | $subsection->set_default($default_data[$subsection_name]); |
213 | - }elseif($subsection instanceof EE_Form_Section_Proper){ |
|
213 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
214 | 214 | $subsection->populate_defaults($default_data[$subsection_name]); |
215 | 215 | } |
216 | 216 | } |
@@ -228,8 +228,8 @@ discard block |
||
228 | 228 | * (realizing that the subsections' html names might not be set yet, etc.) |
229 | 229 | * @return EE_Form_Section_Base |
230 | 230 | */ |
231 | - public function get_subsection($name, $require_construction_to_be_finalized = TRUE ){ |
|
232 | - if( $require_construction_to_be_finalized ){ |
|
231 | + public function get_subsection($name, $require_construction_to_be_finalized = TRUE) { |
|
232 | + if ($require_construction_to_be_finalized) { |
|
233 | 233 | $this->ensure_construct_finalized_called(); |
234 | 234 | } |
235 | 235 | return isset($this->_subsections[$name]) ? $this->_subsections[$name] : NULL; |
@@ -241,10 +241,10 @@ discard block |
||
241 | 241 | * Gets all the validatable subsections of this form section |
242 | 242 | * @return EE_Form_Section_Validatable[] |
243 | 243 | */ |
244 | - public function get_validatable_subsections(){ |
|
244 | + public function get_validatable_subsections() { |
|
245 | 245 | $validatable_subsections = array(); |
246 | - foreach($this->subsections() as $name=>$obj){ |
|
247 | - if($obj instanceof EE_Form_Section_Validatable){ |
|
246 | + foreach ($this->subsections() as $name=>$obj) { |
|
247 | + if ($obj instanceof EE_Form_Section_Validatable) { |
|
248 | 248 | $validatable_subsections[$name] = $obj; |
249 | 249 | } |
250 | 250 | } |
@@ -264,10 +264,10 @@ discard block |
||
264 | 264 | * @return EE_Form_Input_Base |
265 | 265 | * @throws EE_Error |
266 | 266 | */ |
267 | - public function get_input($name, $require_construction_to_be_finalized = TRUE ){ |
|
267 | + public function get_input($name, $require_construction_to_be_finalized = TRUE) { |
|
268 | 268 | $subsection = $this->get_subsection($name, $require_construction_to_be_finalized); |
269 | - if( ! $subsection instanceof EE_Form_Input_Base){ |
|
270 | - throw new EE_Error(sprintf(__("Subsection '%s' is not an instanceof EE_Form_Input_Base on form '%s'. It is a '%s'", 'event_espresso'),$name, get_class($this),$subsection ? get_class($subsection) : __("NULL", 'event_espresso'))); |
|
269 | + if ( ! $subsection instanceof EE_Form_Input_Base) { |
|
270 | + throw new EE_Error(sprintf(__("Subsection '%s' is not an instanceof EE_Form_Input_Base on form '%s'. It is a '%s'", 'event_espresso'), $name, get_class($this), $subsection ? get_class($subsection) : __("NULL", 'event_espresso'))); |
|
271 | 271 | } |
272 | 272 | return $subsection; |
273 | 273 | } |
@@ -285,10 +285,10 @@ discard block |
||
285 | 285 | * @return EE_Form_Section_Proper |
286 | 286 | * @throws EE_Error |
287 | 287 | */ |
288 | - public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE ){ |
|
289 | - $subsection = $this->get_subsection( $name, $require_construction_to_be_finalized ); |
|
290 | - if( ! $subsection instanceof EE_Form_Section_Proper){ |
|
291 | - throw new EE_Error(sprintf(__("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'),$name, get_class($this))); |
|
288 | + public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE) { |
|
289 | + $subsection = $this->get_subsection($name, $require_construction_to_be_finalized); |
|
290 | + if ( ! $subsection instanceof EE_Form_Section_Proper) { |
|
291 | + throw new EE_Error(sprintf(__("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'), $name, get_class($this))); |
|
292 | 292 | } |
293 | 293 | return $subsection; |
294 | 294 | } |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * @param string $name |
302 | 302 | * @return mixed depending on the input's type and its normalization strategy |
303 | 303 | */ |
304 | - public function get_input_value($name){ |
|
304 | + public function get_input_value($name) { |
|
305 | 305 | $input = $this->get_input($name); |
306 | 306 | return $input->normalized_value(); |
307 | 307 | } |
@@ -314,16 +314,16 @@ discard block |
||
314 | 314 | * @return boolean |
315 | 315 | */ |
316 | 316 | public function is_valid() { |
317 | - if( ! $this->has_received_submission()){ |
|
317 | + if ( ! $this->has_received_submission()) { |
|
318 | 318 | throw new EE_Error(sprintf(__("You cannot check if a form is valid before receiving the form submission using receive_form_submission", "event_espresso"))); |
319 | 319 | } |
320 | - if( ! parent::is_valid()){ |
|
320 | + if ( ! parent::is_valid()) { |
|
321 | 321 | return false; |
322 | 322 | } |
323 | 323 | //ok so no errors general to this entire form section. so let's check the subsections |
324 | - foreach( $this->get_validatable_subsections() as $subsection ){ |
|
325 | - if( ! $subsection->is_valid() || $subsection->get_validation_error_string() != '' ){ |
|
326 | - $this->set_submission_error_message( $subsection->get_validation_error_string() ); |
|
324 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
325 | + if ( ! $subsection->is_valid() || $subsection->get_validation_error_string() != '') { |
|
326 | + $this->set_submission_error_message($subsection->get_validation_error_string()); |
|
327 | 327 | return false; |
328 | 328 | } |
329 | 329 | } |
@@ -336,11 +336,11 @@ discard block |
||
336 | 336 | * gets teh default name of this form section if none is specified |
337 | 337 | * @return string |
338 | 338 | */ |
339 | - protected function _set_default_name_if_empty(){ |
|
340 | - if( ! $this->_name ){ |
|
339 | + protected function _set_default_name_if_empty() { |
|
340 | + if ( ! $this->_name) { |
|
341 | 341 | $classname = get_class($this); |
342 | 342 | $default_name = str_replace("EE_", "", $classname); |
343 | - $this->_name = $default_name; |
|
343 | + $this->_name = $default_name; |
|
344 | 344 | } |
345 | 345 | } |
346 | 346 | |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | * Also returns the HTML for the form, except for the form opening and closing tags |
352 | 352 | * (as the form section doesn't know where you necessarily want to send the information to), and except for a submit button. |
353 | 353 | */ |
354 | - public function get_html_and_js(){ |
|
354 | + public function get_html_and_js() { |
|
355 | 355 | $this->enqueue_js(); |
356 | 356 | return $this->get_html(); |
357 | 357 | } |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | * returns HTML for displaying this form section. recursively calls display_section() on all subsections |
363 | 363 | * @return string |
364 | 364 | */ |
365 | - public function get_html(){ |
|
365 | + public function get_html() { |
|
366 | 366 | $this->ensure_construct_finalized_called(); |
367 | 367 | return $this->_layout_strategy->layout_form(); |
368 | 368 | } |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | * enqueues JS for the form |
374 | 374 | * @return string |
375 | 375 | */ |
376 | - public function enqueue_js(){ |
|
376 | + public function enqueue_js() { |
|
377 | 377 | $this->_enqueue_and_localize_form_js(); |
378 | 378 | } |
379 | 379 | |
@@ -388,9 +388,9 @@ discard block |
||
388 | 388 | * could change until it's actually outputted) |
389 | 389 | * @return void |
390 | 390 | */ |
391 | - public static function wp_enqueue_scripts(){ |
|
392 | - add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
|
393 | - wp_register_script( 'ee_form_section_validation', EE_GLOBAL_ASSETS_URL . 'scripts' . DS . 'form_section_validation.js', array( 'jquery-validate', 'jquery-ui-datepicker' ), EVENT_ESPRESSO_VERSION, TRUE ); |
|
391 | + public static function wp_enqueue_scripts() { |
|
392 | + add_filter('FHEE_load_jquery_validate', '__return_true'); |
|
393 | + wp_register_script('ee_form_section_validation', EE_GLOBAL_ASSETS_URL.'scripts'.DS.'form_section_validation.js', array('jquery-validate', 'jquery-ui-datepicker'), EVENT_ESPRESSO_VERSION, TRUE); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | |
@@ -400,14 +400,14 @@ discard block |
||
400 | 400 | * This needs to be called AFTER we've called $this->_enqueue_jquery_validate_script, |
401 | 401 | * but before the wordpress hook wp_loaded |
402 | 402 | */ |
403 | - public function _enqueue_and_localize_form_js(){ |
|
403 | + public function _enqueue_and_localize_form_js() { |
|
404 | 404 | $this->ensure_construct_finalized_called(); |
405 | 405 | //actually, we don't want to localize just yet. There may be other forms on the page. |
406 | 406 | //so we need to add our form section data to a static variable accessible by all form sections |
407 | 407 | //and localize it just before the footer |
408 | 408 | $this->localize_validation_rules(); |
409 | - add_action( 'wp_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ), 2 ); |
|
410 | - add_action( 'admin_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ) ); |
|
409 | + add_action('wp_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'), 2); |
|
410 | + add_action('admin_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms')); |
|
411 | 411 | } |
412 | 412 | |
413 | 413 | |
@@ -417,11 +417,11 @@ discard block |
||
417 | 417 | * @param bool $return_for_subsection |
418 | 418 | * @return void |
419 | 419 | */ |
420 | - public function localize_validation_rules( $return_for_subsection = FALSE ){ |
|
420 | + public function localize_validation_rules($return_for_subsection = FALSE) { |
|
421 | 421 | // we only want to localize vars ONCE for the entire form, so if the form section doesn't have a parent, then it must be the top dog |
422 | - if ( ! $this->parent_section() || $return_for_subsection ) { |
|
423 | - EE_Form_Section_Proper::$_js_localization['form_data'][ $this->html_id() ] = array( |
|
424 | - 'form_section_id'=> $this->html_id( TRUE ), |
|
422 | + if ( ! $this->parent_section() || $return_for_subsection) { |
|
423 | + EE_Form_Section_Proper::$_js_localization['form_data'][$this->html_id()] = array( |
|
424 | + 'form_section_id'=> $this->html_id(TRUE), |
|
425 | 425 | 'validation_rules'=> $this->get_jquery_validation_rules(), |
426 | 426 | 'errors'=> $this->subsection_validation_errors_by_html_name() |
427 | 427 | ); |
@@ -436,12 +436,12 @@ discard block |
||
436 | 436 | * Keys are their form names, and values are the inputs themselves |
437 | 437 | * @return EE_Form_Input_Base |
438 | 438 | */ |
439 | - public function inputs_in_subsections(){ |
|
439 | + public function inputs_in_subsections() { |
|
440 | 440 | $inputs = array(); |
441 | - foreach($this->subsections() as $subsection){ |
|
442 | - if( $subsection instanceof EE_Form_Input_Base ){ |
|
443 | - $inputs[ $subsection->html_name() ] = $subsection; |
|
444 | - }elseif($subsection instanceof EE_Form_Section_Proper ){ |
|
441 | + foreach ($this->subsections() as $subsection) { |
|
442 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
443 | + $inputs[$subsection->html_name()] = $subsection; |
|
444 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
445 | 445 | $inputs += $subsection->inputs_in_subsections(); |
446 | 446 | } |
447 | 447 | } |
@@ -454,12 +454,12 @@ discard block |
||
454 | 454 | * and values are a string of all their validation errors |
455 | 455 | * @return string[] |
456 | 456 | */ |
457 | - public function subsection_validation_errors_by_html_name(){ |
|
457 | + public function subsection_validation_errors_by_html_name() { |
|
458 | 458 | $inputs = $this->inputs(); |
459 | 459 | $errors = array(); |
460 | - foreach( $inputs as $form_input ){ |
|
461 | - if ( $form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors() ){ |
|
462 | - $errors[ $form_input->html_name() ] = $form_input->get_validation_error_string(); |
|
460 | + foreach ($inputs as $form_input) { |
|
461 | + if ($form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors()) { |
|
462 | + $errors[$form_input->html_name()] = $form_input->get_validation_error_string(); |
|
463 | 463 | } |
464 | 464 | } |
465 | 465 | return $errors; |
@@ -471,12 +471,12 @@ discard block |
||
471 | 471 | * passes all the form data required by the JS to the JS, and enqueues the few required JS files. |
472 | 472 | * Should be setup by each form during the _enqueues_and_localize_form_js |
473 | 473 | */ |
474 | - public static function localize_script_for_all_forms(){ |
|
474 | + public static function localize_script_for_all_forms() { |
|
475 | 475 | //allow inputs and stuff to hook in their JS and stuff here |
476 | 476 | do_action('AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin'); |
477 | 477 | EE_Form_Section_Proper::$_js_localization['localized_error_messages'] = EE_Form_Section_Proper::_get_localized_error_messages(); |
478 | - wp_enqueue_script( 'ee_form_section_validation' ); |
|
479 | - wp_localize_script( 'ee_form_section_validation', 'ee_form_section_vars', EE_Form_Section_Proper::$_js_localization ); |
|
478 | + wp_enqueue_script('ee_form_section_validation'); |
|
479 | + wp_localize_script('ee_form_section_validation', 'ee_form_section_vars', EE_Form_Section_Proper::$_js_localization); |
|
480 | 480 | } |
481 | 481 | |
482 | 482 | |
@@ -484,8 +484,8 @@ discard block |
||
484 | 484 | /** |
485 | 485 | * ensure_scripts_localized |
486 | 486 | */ |
487 | - public function ensure_scripts_localized(){ |
|
488 | - if ( ! EE_Form_Section_Proper::$_scripts_localized ) { |
|
487 | + public function ensure_scripts_localized() { |
|
488 | + if ( ! EE_Form_Section_Proper::$_scripts_localized) { |
|
489 | 489 | $this->_enqueue_and_localize_form_js(); |
490 | 490 | } |
491 | 491 | } |
@@ -497,10 +497,10 @@ discard block |
||
497 | 497 | * is that the key here should be the same as the custom validation rule put in the JS file |
498 | 498 | * @return array keys are custom validation rules, and values are internationalized strings |
499 | 499 | */ |
500 | - private static function _get_localized_error_messages(){ |
|
500 | + private static function _get_localized_error_messages() { |
|
501 | 501 | return array( |
502 | 502 | 'validUrl'=> __("This is not a valid absolute URL. Eg, http://domain.com/monkey.jpg", "event_espresso"), |
503 | - 'regex' => __( 'Please check your input', 'event_espresso' ), |
|
503 | + 'regex' => __('Please check your input', 'event_espresso'), |
|
504 | 504 | ); |
505 | 505 | } |
506 | 506 | |
@@ -528,10 +528,10 @@ discard block |
||
528 | 528 | * Gets the JS to put inside the jquery validation rules for subsection of this form section. See parent function for more... |
529 | 529 | * @return array |
530 | 530 | */ |
531 | - function get_jquery_validation_rules(){ |
|
531 | + function get_jquery_validation_rules() { |
|
532 | 532 | $jquery_validation_rules = array(); |
533 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
534 | - $jquery_validation_rules = array_merge( $jquery_validation_rules, $subsection->get_jquery_validation_rules() ); |
|
533 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
534 | + $jquery_validation_rules = array_merge($jquery_validation_rules, $subsection->get_jquery_validation_rules()); |
|
535 | 535 | } |
536 | 536 | return $jquery_validation_rules; |
537 | 537 | } |
@@ -546,11 +546,11 @@ discard block |
||
546 | 546 | protected function _normalize($req_data) { |
547 | 547 | $this->_received_submission = TRUE; |
548 | 548 | $this->_validation_errors = array(); |
549 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
550 | - try{ |
|
549 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
550 | + try { |
|
551 | 551 | $subsection->_normalize($req_data); |
552 | - }catch( EE_Validation_Error $e ){ |
|
553 | - $subsection->add_validation_error( $e ); |
|
552 | + } catch (EE_Validation_Error $e) { |
|
553 | + $subsection->add_validation_error($e); |
|
554 | 554 | } |
555 | 555 | } |
556 | 556 | } |
@@ -564,9 +564,9 @@ discard block |
||
564 | 564 | * calling parent::_validate() first. |
565 | 565 | */ |
566 | 566 | protected function _validate() { |
567 | - foreach($this->get_validatable_subsections() as $subsection_name => $subsection){ |
|
568 | - if(method_exists($this,'_validate_'.$subsection_name)){ |
|
569 | - call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection)); |
|
567 | + foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) { |
|
568 | + if (method_exists($this, '_validate_'.$subsection_name)) { |
|
569 | + call_user_func_array(array($this, '_validate_'.$subsection_name), array($subsection)); |
|
570 | 570 | } |
571 | 571 | $subsection->_validate(); |
572 | 572 | } |
@@ -578,13 +578,13 @@ discard block |
||
578 | 578 | * Gets all the validated inputs for the form section |
579 | 579 | * @return array |
580 | 580 | */ |
581 | - public function valid_data(){ |
|
581 | + public function valid_data() { |
|
582 | 582 | $inputs = array(); |
583 | - foreach( $this->subsections() as $subsection_name =>$subsection ){ |
|
584 | - if ( $subsection instanceof EE_Form_Section_Proper ) { |
|
585 | - $inputs[ $subsection_name ] = $subsection->valid_data(); |
|
586 | - } else if ( $subsection instanceof EE_Form_Input_Base ){ |
|
587 | - $inputs[ $subsection_name ] = $subsection->normalized_value(); |
|
583 | + foreach ($this->subsections() as $subsection_name =>$subsection) { |
|
584 | + if ($subsection instanceof EE_Form_Section_Proper) { |
|
585 | + $inputs[$subsection_name] = $subsection->valid_data(); |
|
586 | + } else if ($subsection instanceof EE_Form_Input_Base) { |
|
587 | + $inputs[$subsection_name] = $subsection->normalized_value(); |
|
588 | 588 | } |
589 | 589 | } |
590 | 590 | return $inputs; |
@@ -596,11 +596,11 @@ discard block |
||
596 | 596 | * Gets all the inputs on this form section |
597 | 597 | * @return EE_Form_Input_Base[] |
598 | 598 | */ |
599 | - public function inputs(){ |
|
599 | + public function inputs() { |
|
600 | 600 | $inputs = array(); |
601 | - foreach( $this->subsections() as $subsection_name =>$subsection ){ |
|
602 | - if ( $subsection instanceof EE_Form_Input_Base ){ |
|
603 | - $inputs[ $subsection_name ] = $subsection; |
|
601 | + foreach ($this->subsections() as $subsection_name =>$subsection) { |
|
602 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
603 | + $inputs[$subsection_name] = $subsection; |
|
604 | 604 | } |
605 | 605 | } |
606 | 606 | return $inputs; |
@@ -612,10 +612,10 @@ discard block |
||
612 | 612 | * Gets all the subsections which are a proper form |
613 | 613 | * @return EE_Form_Section_Proper[] |
614 | 614 | */ |
615 | - public function subforms(){ |
|
615 | + public function subforms() { |
|
616 | 616 | $form_sections = array(); |
617 | - foreach($this->subsections() as $name=>$obj){ |
|
618 | - if($obj instanceof EE_Form_Section_Proper){ |
|
617 | + foreach ($this->subsections() as $name=>$obj) { |
|
618 | + if ($obj instanceof EE_Form_Section_Proper) { |
|
619 | 619 | $form_sections[$name] = $obj; |
620 | 620 | } |
621 | 621 | } |
@@ -630,7 +630,7 @@ discard block |
||
630 | 630 | * if you only want form inputs or proper form sections. |
631 | 631 | * @return EE_Form_Section_Proper[] |
632 | 632 | */ |
633 | - public function subsections(){ |
|
633 | + public function subsections() { |
|
634 | 634 | $this->ensure_construct_finalized_called(); |
635 | 635 | return $this->_subsections; |
636 | 636 | } |
@@ -648,8 +648,8 @@ discard block |
||
648 | 648 | * it can be a multidimensional array where keys are always subsection names and values are either the |
649 | 649 | * input's normalized value, or an array like the top-level array |
650 | 650 | */ |
651 | - public function input_values( $include_subform_inputs = false, $flatten = false ){ |
|
652 | - return $this->_input_values( false, $include_subform_inputs, $flatten ); |
|
651 | + public function input_values($include_subform_inputs = false, $flatten = false) { |
|
652 | + return $this->_input_values(false, $include_subform_inputs, $flatten); |
|
653 | 653 | } |
654 | 654 | |
655 | 655 | /** |
@@ -665,8 +665,8 @@ discard block |
||
665 | 665 | * it can be a multidimensional array where keys are always subsection names and values are either the |
666 | 666 | * input's normalized value, or an array like the top-level array |
667 | 667 | */ |
668 | - public function input_pretty_values( $include_subform_inputs = false, $flatten = false ){ |
|
669 | - return $this->_input_values( true, $include_subform_inputs, $flatten ); |
|
668 | + public function input_pretty_values($include_subform_inputs = false, $flatten = false) { |
|
669 | + return $this->_input_values(true, $include_subform_inputs, $flatten); |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | /** |
@@ -679,17 +679,17 @@ discard block |
||
679 | 679 | * it can be a multidimensional array where keys are always subsection names and values are either the |
680 | 680 | * input's normalized value, or an array like the top-level array |
681 | 681 | */ |
682 | - public function _input_values( $pretty = false, $include_subform_inputs = false, $flatten = false ) { |
|
682 | + public function _input_values($pretty = false, $include_subform_inputs = false, $flatten = false) { |
|
683 | 683 | $input_values = array(); |
684 | - foreach( $this->subsections() as $subsection_name => $subsection ) { |
|
685 | - if( $subsection instanceof EE_Form_Input_Base ) { |
|
686 | - $input_values[ $subsection_name ] = $pretty ? $subsection->pretty_value() : $subsection->normalized_value(); |
|
687 | - } else if( $subsection instanceof EE_Form_Section_Proper && $include_subform_inputs ) { |
|
688 | - $subform_input_values = $subsection->_input_values( $pretty, $include_subform_inputs, $flatten ); |
|
689 | - if( $flatten ) { |
|
690 | - $input_values = array_merge( $input_values, $subform_input_values ); |
|
684 | + foreach ($this->subsections() as $subsection_name => $subsection) { |
|
685 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
686 | + $input_values[$subsection_name] = $pretty ? $subsection->pretty_value() : $subsection->normalized_value(); |
|
687 | + } else if ($subsection instanceof EE_Form_Section_Proper && $include_subform_inputs) { |
|
688 | + $subform_input_values = $subsection->_input_values($pretty, $include_subform_inputs, $flatten); |
|
689 | + if ($flatten) { |
|
690 | + $input_values = array_merge($input_values, $subform_input_values); |
|
691 | 691 | } else { |
692 | - $input_values[ $subsection_name ] = $subform_input_values; |
|
692 | + $input_values[$subsection_name] = $subform_input_values; |
|
693 | 693 | } |
694 | 694 | } |
695 | 695 | } |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | * (ie, had receive_form_submission called on it yet) |
704 | 704 | * @return boolean |
705 | 705 | */ |
706 | - public function has_received_submission(){ |
|
706 | + public function has_received_submission() { |
|
707 | 707 | $this->ensure_construct_finalized_called(); |
708 | 708 | return $this->_received_submission; |
709 | 709 | } |
@@ -716,8 +716,8 @@ discard block |
||
716 | 716 | * @param array $inputs_to_exclude values are the input names |
717 | 717 | * @return void |
718 | 718 | */ |
719 | - public function exclude($inputs_to_exclude = array()){ |
|
720 | - foreach($inputs_to_exclude as $input_to_exclude_name){ |
|
719 | + public function exclude($inputs_to_exclude = array()) { |
|
720 | + foreach ($inputs_to_exclude as $input_to_exclude_name) { |
|
721 | 721 | unset($this->_subsections[$input_to_exclude_name]); |
722 | 722 | } |
723 | 723 | } |
@@ -727,8 +727,8 @@ discard block |
||
727 | 727 | /** |
728 | 728 | * @param array $inputs_to_hide |
729 | 729 | */ |
730 | - public function hide($inputs_to_hide= array()){ |
|
731 | - foreach($inputs_to_hide as $input_to_hide){ |
|
730 | + public function hide($inputs_to_hide = array()) { |
|
731 | + foreach ($inputs_to_hide as $input_to_hide) { |
|
732 | 732 | $input = $this->get_input($input_to_hide); |
733 | 733 | |
734 | 734 | $input->set_display_strategy(new EE_Hidden_Display_Strategy()); |
@@ -753,13 +753,13 @@ discard block |
||
753 | 753 | * or if $subsection_name_to_target is null, before or after entire subsections array |
754 | 754 | * @return void |
755 | 755 | */ |
756 | - public function add_subsections( $new_subsections, $subsection_name_to_target = NULL, $add_before = true ){ |
|
757 | - foreach($new_subsections as $subsection_name => $subsection){ |
|
758 | - if( ! $subsection instanceof EE_Form_Section_Base){ |
|
756 | + public function add_subsections($new_subsections, $subsection_name_to_target = NULL, $add_before = true) { |
|
757 | + foreach ($new_subsections as $subsection_name => $subsection) { |
|
758 | + if ( ! $subsection instanceof EE_Form_Section_Base) { |
|
759 | 759 | EE_Error::add_error( |
760 | 760 | sprintf( |
761 | 761 | __("Trying to add a %s as a subsection (it was named '%s') to the form section '%s'. It was removed.", "event_espresso"), |
762 | - get_class( $subsection ), |
|
762 | + get_class($subsection), |
|
763 | 763 | $subsection_name, |
764 | 764 | $this->name() |
765 | 765 | ) |
@@ -768,8 +768,8 @@ discard block |
||
768 | 768 | } |
769 | 769 | } |
770 | 770 | |
771 | - EE_Registry::instance()->load_helper( 'Array' ); |
|
772 | - $this->_subsections = EEH_Array::insert_into_array( $this->_subsections, $new_subsections, $subsection_name_to_target, $add_before ); |
|
771 | + EE_Registry::instance()->load_helper('Array'); |
|
772 | + $this->_subsections = EEH_Array::insert_into_array($this->_subsections, $new_subsections, $subsection_name_to_target, $add_before); |
|
773 | 773 | |
774 | 774 | /*$subsections_before = array(); |
775 | 775 | if( $subsection_name_to_target ){ |
@@ -800,8 +800,8 @@ discard block |
||
800 | 800 | $this->_subsections = $new_subsections; |
801 | 801 | } |
802 | 802 | }*/ |
803 | - if( $this->_construction_finalized ){ |
|
804 | - foreach($this->_subsections as $name => $subsection){ |
|
803 | + if ($this->_construction_finalized) { |
|
804 | + foreach ($this->_subsections as $name => $subsection) { |
|
805 | 805 | $subsection->_construct_finalize($this, $name); |
806 | 806 | } |
807 | 807 | } |
@@ -812,8 +812,8 @@ discard block |
||
812 | 812 | /** |
813 | 813 | * Just gets all validatable subsections to clean their sensitive data |
814 | 814 | */ |
815 | - public function clean_sensitive_data(){ |
|
816 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
815 | + public function clean_sensitive_data() { |
|
816 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
817 | 817 | $subsection->clean_sensitive_data(); |
818 | 818 | } |
819 | 819 | } |
@@ -823,8 +823,8 @@ discard block |
||
823 | 823 | /** |
824 | 824 | * @param string $form_submission_error_message |
825 | 825 | */ |
826 | - public function set_submission_error_message( $form_submission_error_message = '' ) { |
|
827 | - $this->_form_submission_error_message .= ! empty( $form_submission_error_message ) ? $form_submission_error_message : __( 'Form submission failed due to errors', 'event_espresso' ); |
|
826 | + public function set_submission_error_message($form_submission_error_message = '') { |
|
827 | + $this->_form_submission_error_message .= ! empty($form_submission_error_message) ? $form_submission_error_message : __('Form submission failed due to errors', 'event_espresso'); |
|
828 | 828 | } |
829 | 829 | |
830 | 830 | |
@@ -841,8 +841,8 @@ discard block |
||
841 | 841 | /** |
842 | 842 | * @param string $form_submission_success_message |
843 | 843 | */ |
844 | - public function set_submission_success_message( $form_submission_success_message ) { |
|
845 | - $this->_form_submission_success_message .= ! empty( $form_submission_success_message ) ? $form_submission_success_message : __( 'Form submitted successfully', 'event_espresso' ); |
|
844 | + public function set_submission_success_message($form_submission_success_message) { |
|
845 | + $this->_form_submission_success_message .= ! empty($form_submission_success_message) ? $form_submission_success_message : __('Form submitted successfully', 'event_espresso'); |
|
846 | 846 | } |
847 | 847 | |
848 | 848 | |
@@ -864,10 +864,10 @@ discard block |
||
864 | 864 | * EE_Form_Input_Base::_set_default_html_name_if_empty |
865 | 865 | * @return string |
866 | 866 | */ |
867 | - public function html_name_prefix(){ |
|
868 | - if( $this->parent_section() instanceof EE_Form_Section_Proper ){ |
|
869 | - return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']'; |
|
870 | - }else{ |
|
867 | + public function html_name_prefix() { |
|
868 | + if ($this->parent_section() instanceof EE_Form_Section_Proper) { |
|
869 | + return $this->parent_section()->html_name_prefix().'['.$this->name().']'; |
|
870 | + } else { |
|
871 | 871 | return $this->name(); |
872 | 872 | } |
873 | 873 | } |
@@ -878,7 +878,7 @@ discard block |
||
878 | 878 | * was set, which is probably nothing, or the classname) |
879 | 879 | * @return string |
880 | 880 | */ |
881 | - public function name(){ |
|
881 | + public function name() { |
|
882 | 882 | $this->ensure_construct_finalized_called(); |
883 | 883 | return parent::name(); |
884 | 884 | } |
@@ -887,7 +887,7 @@ discard block |
||
887 | 887 | * |
888 | 888 | * @return EE_Form_Section_Proper |
889 | 889 | */ |
890 | - public function parent_section(){ |
|
890 | + public function parent_section() { |
|
891 | 891 | $this->ensure_construct_finalized_called(); |
892 | 892 | return parent::parent_section(); |
893 | 893 | } |
@@ -896,9 +896,9 @@ discard block |
||
896 | 896 | * make sure construction finalized was called, otherwise children might not be ready |
897 | 897 | * @return void |
898 | 898 | */ |
899 | - public function ensure_construct_finalized_called(){ |
|
900 | - if( ! $this->_construction_finalized ){ |
|
901 | - $this->_construct_finalize($this->_parent_section, $this->_name ); |
|
899 | + public function ensure_construct_finalized_called() { |
|
900 | + if ( ! $this->_construction_finalized) { |
|
901 | + $this->_construct_finalize($this->_parent_section, $this->_name); |
|
902 | 902 | } |
903 | 903 | } |
904 | 904 | |
@@ -910,17 +910,17 @@ discard block |
||
910 | 910 | * @param array $req_data |
911 | 911 | * @return boolean |
912 | 912 | */ |
913 | - public function form_data_present_in( $req_data = NULL ) { |
|
914 | - if( $req_data === NULL){ |
|
913 | + public function form_data_present_in($req_data = NULL) { |
|
914 | + if ($req_data === NULL) { |
|
915 | 915 | $req_data = $_POST; |
916 | 916 | } |
917 | - foreach( $this->subsections() as $subsection ) { |
|
918 | - if($subsection instanceof EE_Form_Input_Base ) { |
|
919 | - if( $subsection->form_data_present_in( $req_data ) ) { |
|
917 | + foreach ($this->subsections() as $subsection) { |
|
918 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
919 | + if ($subsection->form_data_present_in($req_data)) { |
|
920 | 920 | return TRUE; |
921 | 921 | } |
922 | - }elseif( $subsection instanceof EE_Form_Section_Proper ) { |
|
923 | - if( $subsection->form_data_present_in( $req_data ) ) { |
|
922 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
923 | + if ($subsection->form_data_present_in($req_data)) { |
|
924 | 924 | return TRUE; |
925 | 925 | } |
926 | 926 | } |
@@ -937,14 +937,14 @@ discard block |
||
937 | 937 | */ |
938 | 938 | public function get_validation_errors_accumulated() { |
939 | 939 | $validation_errors = $this->get_validation_errors(); |
940 | - foreach($this->get_validatable_subsections() as $subsection ) { |
|
941 | - if( $subsection instanceof EE_Form_Section_Proper ) { |
|
940 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
941 | + if ($subsection instanceof EE_Form_Section_Proper) { |
|
942 | 942 | $validation_errors_on_this_subsection = $subsection->get_validation_errors_accumulated(); |
943 | 943 | } else { |
944 | - $validation_errors_on_this_subsection = $subsection->get_validation_errors(); |
|
944 | + $validation_errors_on_this_subsection = $subsection->get_validation_errors(); |
|
945 | 945 | } |
946 | - if( $validation_errors_on_this_subsection ){ |
|
947 | - $validation_errors = array_merge( $validation_errors, $validation_errors_on_this_subsection ); |
|
946 | + if ($validation_errors_on_this_subsection) { |
|
947 | + $validation_errors = array_merge($validation_errors, $validation_errors_on_this_subsection); |
|
948 | 948 | } |
949 | 949 | } |
950 | 950 | return $validation_errors; |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('No direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * |
35 | 35 | * ------------------------------------------------------------------------ |
36 | 36 | */ |
37 | -abstract class EE_Form_Section_Validatable extends EE_Form_Section_Base{ |
|
37 | +abstract class EE_Form_Section_Validatable extends EE_Form_Section_Base { |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * Array of validation errors in this section. Does not contain validation errors in subsections, however. |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * called get_validation_errors_accumulated |
50 | 50 | * @return EE_Validation_Error[] |
51 | 51 | */ |
52 | - public function get_validation_errors(){ |
|
52 | + public function get_validation_errors() { |
|
53 | 53 | return $this->_validation_errors; |
54 | 54 | } |
55 | 55 | /** |
@@ -57,16 +57,16 @@ discard block |
||
57 | 57 | * If we want this to be customizable, we may decide to create a strategy for displaying it. |
58 | 58 | * @return string |
59 | 59 | */ |
60 | - public function get_validation_error_string(){ |
|
60 | + public function get_validation_error_string() { |
|
61 | 61 | $validation_error_messages = array(); |
62 | - if($this->get_validation_errors()){ |
|
63 | - foreach($this->get_validation_errors() as $validation_error){ |
|
64 | - if ( $validation_error instanceof EE_Validation_Error ) { |
|
65 | - $validation_error_messages[] =$validation_error->getMessage(); |
|
62 | + if ($this->get_validation_errors()) { |
|
63 | + foreach ($this->get_validation_errors() as $validation_error) { |
|
64 | + if ($validation_error instanceof EE_Validation_Error) { |
|
65 | + $validation_error_messages[] = $validation_error->getMessage(); |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | } |
69 | - return implode(", ",$validation_error_messages); |
|
69 | + return implode(", ", $validation_error_messages); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | * @return boolean |
83 | 83 | */ |
84 | 84 | public function is_valid() { |
85 | - if(count($this->_validation_errors)){ |
|
85 | + if (count($this->_validation_errors)) { |
|
86 | 86 | return false; |
87 | - }else{ |
|
87 | + } else { |
|
88 | 88 | return true; |
89 | 89 | } |
90 | 90 | } |
@@ -109,11 +109,11 @@ discard block |
||
109 | 109 | * @param Exception $previous_exception if there was an exception that caused the error, that exception |
110 | 110 | * @return void |
111 | 111 | */ |
112 | - function add_validation_error( $message_or_object, $error_code = NULL, $previous_exception = NULL ){ |
|
113 | - if($message_or_object instanceof EE_Validation_Error){ |
|
114 | - $validation_error= $message_or_object; |
|
112 | + function add_validation_error($message_or_object, $error_code = NULL, $previous_exception = NULL) { |
|
113 | + if ($message_or_object instanceof EE_Validation_Error) { |
|
114 | + $validation_error = $message_or_object; |
|
115 | 115 | $validation_error->set_form_section($this); |
116 | - }else{ |
|
116 | + } else { |
|
117 | 117 | $validation_error = new EE_Validation_Error($message_or_object, $error_code, $this, $previous_exception); |
118 | 118 | } |
119 | 119 | $this->_validation_errors[] = $validation_error; |
@@ -1,6 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
2 | +if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | 3 | exit('No direct script access allowed'); |
4 | +} |
|
4 | 5 | |
5 | 6 | /** |
6 | 7 | * Event Espresso |
@@ -84,7 +85,7 @@ discard block |
||
84 | 85 | public function is_valid() { |
85 | 86 | if(count($this->_validation_errors)){ |
86 | 87 | return false; |
87 | - }else{ |
|
88 | + } else{ |
|
88 | 89 | return true; |
89 | 90 | } |
90 | 91 | } |
@@ -113,7 +114,7 @@ discard block |
||
113 | 114 | if($message_or_object instanceof EE_Validation_Error){ |
114 | 115 | $validation_error= $message_or_object; |
115 | 116 | $validation_error->set_form_section($this); |
116 | - }else{ |
|
117 | + } else{ |
|
117 | 118 | $validation_error = new EE_Validation_Error($message_or_object, $error_code, $this, $previous_exception); |
118 | 119 | } |
119 | 120 | $this->_validation_errors[] = $validation_error; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -class EE_Validation_Error extends Exception{ |
|
3 | +class EE_Validation_Error extends Exception { |
|
4 | 4 | /** |
5 | 5 | * Form Section from which this error originated. |
6 | 6 | * @var EE_Form_Section |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @param EE_Form_Section_Validatable $form_section |
21 | 21 | * @param Exception $previous if there was an exception that caused this exception |
22 | 22 | */ |
23 | - function __construct( $message = null, $string_code = null,$form_section = null, $previous = null){ |
|
23 | + function __construct($message = null, $string_code = null, $form_section = null, $previous = null) { |
|
24 | 24 | $this->_form_section = $form_section; |
25 | 25 | $this->_string_code = $string_code; |
26 | 26 | parent::__construct($message, 500, $previous); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * returns teh form section which caused the error. |
31 | 31 | * @return EE_Form_Section_Validatable |
32 | 32 | */ |
33 | - public function get_form_section(){ |
|
33 | + public function get_form_section() { |
|
34 | 34 | return $this->_form_section; |
35 | 35 | } |
36 | 36 | /** |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * @param EE_Form_Section_Validatable $form_section |
39 | 39 | * @return void |
40 | 40 | */ |
41 | - public function set_form_section($form_section){ |
|
41 | + public function set_form_section($form_section) { |
|
42 | 42 | $this->_form_section = $form_section; |
43 | 43 | } |
44 | 44 |
@@ -8,15 +8,15 @@ |
||
8 | 8 | * @since 4.6 |
9 | 9 | * |
10 | 10 | */ |
11 | -class EE_Admin_File_Uploader_Input extends EE_Form_Input_Base{ |
|
11 | +class EE_Admin_File_Uploader_Input extends EE_Form_Input_Base { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * @param array $input_settings |
15 | 15 | */ |
16 | - function __construct($input_settings = array()){ |
|
16 | + function __construct($input_settings = array()) { |
|
17 | 17 | $this->_set_display_strategy(new EE_Admin_File_Uploader_Display_Strategy()); |
18 | 18 | $this->_set_normalization_strategy(new EE_Text_Normalization()); |
19 | - $this->_add_validation_strategy(new EE_URL_Validation_Strategy( isset( $input_settings[ 'validation_error_message' ] ) ? $input_settings[ 'validation_error_message' ] : NULL ) ); |
|
19 | + $this->_add_validation_strategy(new EE_URL_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : NULL)); |
|
20 | 20 | parent::__construct($input_settings); |
21 | 21 | } |
22 | 22 | } |
23 | 23 | \ No newline at end of file |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
2 | 2 | /** |
3 | 3 | * |
4 | 4 | * Class EE_Checkbox_Multi_Input |
@@ -11,16 +11,16 @@ discard block |
||
11 | 11 | * @since $VID:$ |
12 | 12 | * |
13 | 13 | */ |
14 | -class EE_Checkbox_Multi_Input extends EE_Form_Input_With_Options_Base{ |
|
14 | +class EE_Checkbox_Multi_Input extends EE_Form_Input_With_Options_Base { |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * @param array $input_settings |
18 | 18 | * @param array | EE_Question_Option[] $answer_options |
19 | 19 | */ |
20 | - public function __construct( $answer_options, $input_settings = array() ) { |
|
21 | - $this->_set_display_strategy( new EE_Checkbox_Display_Strategy() ); |
|
22 | - $this->_add_validation_strategy( new EE_Many_Valued_Validation_Strategy( array( new EE_Enum_Validation_Strategy( isset( $input_settings[ 'validation_error_message' ] ) ? $input_settings[ 'validation_error_message' ] : NULL ) ))); |
|
20 | + public function __construct($answer_options, $input_settings = array()) { |
|
21 | + $this->_set_display_strategy(new EE_Checkbox_Display_Strategy()); |
|
22 | + $this->_add_validation_strategy(new EE_Many_Valued_Validation_Strategy(array(new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : NULL)))); |
|
23 | 23 | $this->_multiple_selections = TRUE; |
24 | - parent::__construct( $answer_options, $input_settings ); |
|
24 | + parent::__construct($answer_options, $input_settings); |
|
25 | 25 | } |
26 | 26 | } |
27 | 27 | \ No newline at end of file |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' )) { exit( 'No direct script access allowed' ); } |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
2 | 2 | /** |
3 | 3 | * Class EE_Country_Select_Input |
4 | 4 | * |
@@ -11,20 +11,20 @@ discard block |
||
11 | 11 | * @since $VID:$ |
12 | 12 | * |
13 | 13 | */ |
14 | -class EE_Country_Select_Input extends EE_Select_Input{ |
|
14 | +class EE_Country_Select_Input extends EE_Select_Input { |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * @param array $country_options |
18 | 18 | * @param array $input_settings |
19 | 19 | * @return EE_Country_Select_Input |
20 | 20 | */ |
21 | - public function __construct( $country_options = NULL, $input_settings = array() ){ |
|
21 | + public function __construct($country_options = NULL, $input_settings = array()) { |
|
22 | 22 | $country_options = apply_filters( |
23 | 23 | 'FHEE__EE_Country_Select_Input____construct__country_options', |
24 | - $this->get_country_answer_options( $country_options ), |
|
24 | + $this->get_country_answer_options($country_options), |
|
25 | 25 | $this |
26 | 26 | ); |
27 | - parent::__construct( $country_options, $input_settings ); |
|
27 | + parent::__construct($country_options, $input_settings); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | |
@@ -35,16 +35,16 @@ discard block |
||
35 | 35 | * @param array $country_options |
36 | 36 | * @return array |
37 | 37 | */ |
38 | - public function get_country_answer_options( $country_options = NULL ){ |
|
38 | + public function get_country_answer_options($country_options = NULL) { |
|
39 | 39 | // if passed something that is NOT an array |
40 | - if ( ! is_array( $country_options )) { |
|
40 | + if ( ! is_array($country_options)) { |
|
41 | 41 | // get possibly cached list of countries |
42 | 42 | $countries = EEM_Country::instance()->get_all_active_countries(); |
43 | - if ( ! empty( $countries )) { |
|
44 | - $country_options[ '' ] = ''; |
|
45 | - foreach( $countries as $country ){ |
|
46 | - if ( $country instanceof EE_Country ) { |
|
47 | - $country_options[ $country->ID() ] = $country->name(); |
|
43 | + if ( ! empty($countries)) { |
|
44 | + $country_options[''] = ''; |
|
45 | + foreach ($countries as $country) { |
|
46 | + if ($country instanceof EE_Country) { |
|
47 | + $country_options[$country->ID()] = $country->name(); |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | } else { |
@@ -7,16 +7,16 @@ |
||
7 | 7 | * @subpackage |
8 | 8 | * @author Mike Nelson |
9 | 9 | */ |
10 | -class EE_Credit_Card_Input extends EE_Form_Input_Base{ |
|
10 | +class EE_Credit_Card_Input extends EE_Form_Input_Base { |
|
11 | 11 | |
12 | 12 | /** |
13 | 13 | * @param array $input_settings |
14 | 14 | */ |
15 | - function __construct($input_settings = array()){ |
|
16 | - $input_settings['required'] = isset( $input_settings['required'] ) ? $input_settings['required'] : TRUE; |
|
15 | + function __construct($input_settings = array()) { |
|
16 | + $input_settings['required'] = isset($input_settings['required']) ? $input_settings['required'] : TRUE; |
|
17 | 17 | $this->_set_display_strategy(new EE_Text_Input_Display_Strategy()); |
18 | 18 | $this->_set_normalization_strategy(new EE_Text_Normalization()); |
19 | - $this->_add_validation_strategy(new EE_Credit_Card_Validation_Strategy( isset( $input_settings[ 'validation_error_message' ] ) ? $input_settings[ 'validation_error_message' ] : NULL )); |
|
19 | + $this->_add_validation_strategy(new EE_Credit_Card_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : NULL)); |
|
20 | 20 | $this->set_sensitive_data_removal_strategy(new EE_Credit_Card_Sensitive_Data_Removal()); |
21 | 21 | parent::__construct($input_settings); |
22 | 22 | } |