@@ -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) 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 | const SUBMITTED_FORM_DATA_SSN_KEY = 'submitted_form_data'; |
13 | 13 | |
@@ -71,49 +71,49 @@ discard block |
||
71 | 71 | * } @see EE_Form_Section_Validatable::__construct() |
72 | 72 | * @throws \EE_Error |
73 | 73 | */ |
74 | - public function __construct( $options_array = array() ){ |
|
75 | - $options_array = (array) apply_filters( 'FHEE__EE_Form_Section_Proper___construct__options_array', $options_array, $this ); |
|
74 | + public function __construct($options_array = array()) { |
|
75 | + $options_array = (array) apply_filters('FHEE__EE_Form_Section_Proper___construct__options_array', $options_array, $this); |
|
76 | 76 | //call parent first, as it may be setting the name |
77 | 77 | parent::__construct($options_array); |
78 | 78 | //if they've included subsections in the constructor, add them now |
79 | - if( isset( $options_array['include'] )){ |
|
79 | + if (isset($options_array['include'])) { |
|
80 | 80 | //we are going to make sure we ONLY have those subsections to include |
81 | 81 | //AND we are going to make sure they're in that specified order |
82 | 82 | $reordered_subsections = array(); |
83 | - foreach($options_array['include'] as $input_name){ |
|
84 | - if(isset($this->_subsections[$input_name])){ |
|
83 | + foreach ($options_array['include'] as $input_name) { |
|
84 | + if (isset($this->_subsections[$input_name])) { |
|
85 | 85 | $reordered_subsections[$input_name] = $this->_subsections[$input_name]; |
86 | 86 | } |
87 | 87 | } |
88 | 88 | $this->_subsections = $reordered_subsections; |
89 | 89 | } |
90 | - if(isset($options_array['exclude'])){ |
|
90 | + if (isset($options_array['exclude'])) { |
|
91 | 91 | $exclude = $options_array['exclude']; |
92 | 92 | $this->_subsections = array_diff_key($this->_subsections, array_flip($exclude)); |
93 | 93 | } |
94 | - if(isset($options_array['layout_strategy'])){ |
|
94 | + if (isset($options_array['layout_strategy'])) { |
|
95 | 95 | $this->_layout_strategy = $options_array['layout_strategy']; |
96 | 96 | } |
97 | - if( ! $this->_layout_strategy){ |
|
97 | + if ( ! $this->_layout_strategy) { |
|
98 | 98 | $this->_layout_strategy = is_admin() ? new EE_Admin_Two_Column_Layout() : new EE_Two_Column_Layout(); |
99 | 99 | } |
100 | 100 | $this->_layout_strategy->_construct_finalize($this); |
101 | 101 | |
102 | 102 | //ok so we are definitely going to want the forms JS, |
103 | 103 | //so enqueue it or remember to enqueue it during wp_enqueue_scripts |
104 | - if( did_action( 'wp_enqueue_scripts' ) |
|
105 | - || did_action( 'admin_enqueue_scripts' ) ) { |
|
104 | + if (did_action('wp_enqueue_scripts') |
|
105 | + || did_action('admin_enqueue_scripts')) { |
|
106 | 106 | //ok so they've constructed this object after when they should have. |
107 | 107 | //just enqueue the generic form scripts and initialize the form immediately in the JS |
108 | - \EE_Form_Section_Proper::wp_enqueue_scripts( true ); |
|
108 | + \EE_Form_Section_Proper::wp_enqueue_scripts(true); |
|
109 | 109 | } else { |
110 | - add_action( 'wp_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' )); |
|
111 | - add_action( 'admin_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' )); |
|
110 | + add_action('wp_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts')); |
|
111 | + add_action('admin_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts')); |
|
112 | 112 | } |
113 | - add_action( 'wp_footer', array( $this, 'ensure_scripts_localized' ), 1 ); |
|
113 | + add_action('wp_footer', array($this, 'ensure_scripts_localized'), 1); |
|
114 | 114 | |
115 | - if( isset( $options_array[ 'name' ] ) ) { |
|
116 | - $this->_construct_finalize( null, $options_array[ 'name' ] ); |
|
115 | + if (isset($options_array['name'])) { |
|
116 | + $this->_construct_finalize(null, $options_array['name']); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
@@ -126,25 +126,25 @@ discard block |
||
126 | 126 | * @param string $name |
127 | 127 | * @throws \EE_Error |
128 | 128 | */ |
129 | - public function _construct_finalize( $parent_form_section, $name ) { |
|
129 | + public function _construct_finalize($parent_form_section, $name) { |
|
130 | 130 | parent::_construct_finalize($parent_form_section, $name); |
131 | 131 | $this->_set_default_name_if_empty(); |
132 | 132 | $this->_set_default_html_id_if_empty(); |
133 | - foreach( $this->_subsections as $subsection_name => $subsection ){ |
|
134 | - if ( $subsection instanceof EE_Form_Section_Base ) { |
|
135 | - $subsection->_construct_finalize( $this, $subsection_name ); |
|
133 | + foreach ($this->_subsections as $subsection_name => $subsection) { |
|
134 | + if ($subsection instanceof EE_Form_Section_Base) { |
|
135 | + $subsection->_construct_finalize($this, $subsection_name); |
|
136 | 136 | } else { |
137 | 137 | throw new EE_Error( |
138 | 138 | sprintf( |
139 | - __( 'Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso' ), |
|
139 | + __('Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso'), |
|
140 | 140 | $subsection_name, |
141 | 141 | get_class($this), |
142 | - $subsection ? get_class($subsection) : __( 'NULL', 'event_espresso' ) |
|
142 | + $subsection ? get_class($subsection) : __('NULL', 'event_espresso') |
|
143 | 143 | ) |
144 | 144 | ); |
145 | 145 | } |
146 | 146 | } |
147 | - do_action( 'AHEE__EE_Form_Section_Proper___construct_finalize__end', $this, $parent_form_section, $name ); |
|
147 | + do_action('AHEE__EE_Form_Section_Proper___construct_finalize__end', $this, $parent_form_section, $name); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * Gets the layout strategy for this form section |
154 | 154 | * @return EE_Form_Section_Layout_Base |
155 | 155 | */ |
156 | - public function get_layout_strategy(){ |
|
156 | + public function get_layout_strategy() { |
|
157 | 157 | return $this->_layout_strategy; |
158 | 158 | } |
159 | 159 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * @param EE_Form_Input_Base $input |
166 | 166 | * @return string |
167 | 167 | */ |
168 | - public function get_html_for_input($input){ |
|
168 | + public function get_html_for_input($input) { |
|
169 | 169 | return $this->_layout_strategy->layout_input($input); |
170 | 170 | } |
171 | 171 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | * @param null $form_data |
179 | 179 | * @return boolean |
180 | 180 | */ |
181 | - public function was_submitted($form_data = NULL){ |
|
181 | + public function was_submitted($form_data = NULL) { |
|
182 | 182 | return $this->form_data_present_in($form_data); |
183 | 183 | } |
184 | 184 | |
@@ -203,21 +203,21 @@ discard block |
||
203 | 203 | * (eg you validated the data then stored it in the DB) |
204 | 204 | * you may want to skip this step. |
205 | 205 | */ |
206 | - public function receive_form_submission( $req_data = null, $validate = true ){ |
|
207 | - $req_data = apply_filters( 'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', $req_data, $this, $validate ); |
|
208 | - if( $req_data === null ){ |
|
209 | - $req_data = array_merge( $_GET, $_POST ); |
|
206 | + public function receive_form_submission($req_data = null, $validate = true) { |
|
207 | + $req_data = apply_filters('FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', $req_data, $this, $validate); |
|
208 | + if ($req_data === null) { |
|
209 | + $req_data = array_merge($_GET, $_POST); |
|
210 | 210 | } |
211 | - $req_data = apply_filters( 'FHEE__EE_Form_Section_Proper__receive_form_submission__request_data', $req_data, $this ); |
|
212 | - $this->_normalize( $req_data ); |
|
213 | - if( $validate ){ |
|
211 | + $req_data = apply_filters('FHEE__EE_Form_Section_Proper__receive_form_submission__request_data', $req_data, $this); |
|
212 | + $this->_normalize($req_data); |
|
213 | + if ($validate) { |
|
214 | 214 | $this->_validate(); |
215 | 215 | //if it's invalid, we're going to want to re-display so remember what they submitted |
216 | - if ( ! $this->is_valid() ) { |
|
216 | + if ( ! $this->is_valid()) { |
|
217 | 217 | $this->store_submitted_form_data_in_session(); |
218 | 218 | } |
219 | 219 | } |
220 | - do_action( 'AHEE__EE_Form_Section_Proper__receive_form_submission__end', $req_data, $this, $validate ); |
|
220 | + do_action('AHEE__EE_Form_Section_Proper__receive_form_submission__end', $req_data, $this, $validate); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | protected function store_submitted_form_data_in_session() { |
232 | 232 | return EE_Registry::instance()->SSN->set_session_data( |
233 | 233 | array( |
234 | - \EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY => $this->submitted_values( true ) |
|
234 | + \EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY => $this->submitted_values(true) |
|
235 | 235 | ) |
236 | 236 | ); |
237 | 237 | } |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | */ |
247 | 247 | protected function get_submitted_form_data_from_session() { |
248 | 248 | $session = EE_Registry::instance()->SSN; |
249 | - if( $session instanceof EE_Session ) { |
|
249 | + if ($session instanceof EE_Session) { |
|
250 | 250 | return $session->get_session_data( |
251 | 251 | \EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY |
252 | 252 | ); |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | */ |
265 | 265 | protected function flush_submitted_form_data_from_session() { |
266 | 266 | return EE_Registry::instance()->SSN->reset_data( |
267 | - array( \EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY ) |
|
267 | + array(\EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY) |
|
268 | 268 | ); |
269 | 269 | } |
270 | 270 | |
@@ -280,12 +280,12 @@ discard block |
||
280 | 280 | */ |
281 | 281 | public function populate_from_session() { |
282 | 282 | $form_data_in_session = $this->get_submitted_form_data_from_session(); |
283 | - if ( empty( $form_data_in_session ) ) { |
|
283 | + if (empty($form_data_in_session)) { |
|
284 | 284 | return false; |
285 | 285 | } |
286 | - $this->receive_form_submission( $form_data_in_session ); |
|
286 | + $this->receive_form_submission($form_data_in_session); |
|
287 | 287 | $this->flush_submitted_form_data_from_session(); |
288 | - if ( $this->form_data_present_in( $form_data_in_session ) ) { |
|
288 | + if ($this->form_data_present_in($form_data_in_session)) { |
|
289 | 289 | return true; |
290 | 290 | } else { |
291 | 291 | return false; |
@@ -302,12 +302,12 @@ discard block |
||
302 | 302 | * the value being an array formatted in teh same way |
303 | 303 | * @param array $default_data |
304 | 304 | */ |
305 | - public function populate_defaults($default_data){ |
|
306 | - foreach($this->subsections() as $subsection_name => $subsection){ |
|
307 | - if(isset($default_data[$subsection_name])){ |
|
308 | - if($subsection instanceof EE_Form_Input_Base){ |
|
305 | + public function populate_defaults($default_data) { |
|
306 | + foreach ($this->subsections() as $subsection_name => $subsection) { |
|
307 | + if (isset($default_data[$subsection_name])) { |
|
308 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
309 | 309 | $subsection->set_default($default_data[$subsection_name]); |
310 | - }elseif($subsection instanceof EE_Form_Section_Proper){ |
|
310 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
311 | 311 | $subsection->populate_defaults($default_data[$subsection_name]); |
312 | 312 | } |
313 | 313 | } |
@@ -322,8 +322,8 @@ discard block |
||
322 | 322 | * @param string $name |
323 | 323 | * @return boolean |
324 | 324 | */ |
325 | - public function subsection_exists( $name ){ |
|
326 | - return isset( $this->_subsections[ $name ] ) ? true : false; |
|
325 | + public function subsection_exists($name) { |
|
326 | + return isset($this->_subsections[$name]) ? true : false; |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | |
@@ -341,11 +341,11 @@ discard block |
||
341 | 341 | * @return EE_Form_Section_Base |
342 | 342 | * @throws \EE_Error |
343 | 343 | */ |
344 | - public function get_subsection($name, $require_construction_to_be_finalized = TRUE ){ |
|
345 | - if( $require_construction_to_be_finalized ){ |
|
344 | + public function get_subsection($name, $require_construction_to_be_finalized = TRUE) { |
|
345 | + if ($require_construction_to_be_finalized) { |
|
346 | 346 | $this->ensure_construct_finalized_called(); |
347 | 347 | } |
348 | - return $this->subsection_exists( $name ) ? $this->_subsections[$name] : NULL; |
|
348 | + return $this->subsection_exists($name) ? $this->_subsections[$name] : NULL; |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | |
@@ -354,10 +354,10 @@ discard block |
||
354 | 354 | * Gets all the validatable subsections of this form section |
355 | 355 | * @return EE_Form_Section_Validatable[] |
356 | 356 | */ |
357 | - public function get_validatable_subsections(){ |
|
357 | + public function get_validatable_subsections() { |
|
358 | 358 | $validatable_subsections = array(); |
359 | - foreach($this->subsections() as $name=>$obj){ |
|
360 | - if($obj instanceof EE_Form_Section_Validatable){ |
|
359 | + foreach ($this->subsections() as $name=>$obj) { |
|
360 | + if ($obj instanceof EE_Form_Section_Validatable) { |
|
361 | 361 | $validatable_subsections[$name] = $obj; |
362 | 362 | } |
363 | 363 | } |
@@ -377,9 +377,9 @@ discard block |
||
377 | 377 | * @return EE_Form_Input_Base |
378 | 378 | * @throws EE_Error |
379 | 379 | */ |
380 | - public function get_input($name, $require_construction_to_be_finalized = TRUE ){ |
|
380 | + public function get_input($name, $require_construction_to_be_finalized = TRUE) { |
|
381 | 381 | $subsection = $this->get_subsection($name, $require_construction_to_be_finalized); |
382 | - if( ! $subsection instanceof EE_Form_Input_Base){ |
|
382 | + if ( ! $subsection instanceof EE_Form_Input_Base) { |
|
383 | 383 | throw new EE_Error( |
384 | 384 | sprintf( |
385 | 385 | __( |
@@ -387,8 +387,8 @@ discard block |
||
387 | 387 | 'event_espresso' |
388 | 388 | ), |
389 | 389 | $name, |
390 | - get_class( $this ), |
|
391 | - $subsection ? get_class( $subsection ) : __( "NULL", 'event_espresso' ) |
|
390 | + get_class($this), |
|
391 | + $subsection ? get_class($subsection) : __("NULL", 'event_espresso') |
|
392 | 392 | ) |
393 | 393 | ); |
394 | 394 | } |
@@ -408,14 +408,14 @@ discard block |
||
408 | 408 | * @return EE_Form_Section_Proper |
409 | 409 | * @throws EE_Error |
410 | 410 | */ |
411 | - public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE ){ |
|
412 | - $subsection = $this->get_subsection( $name, $require_construction_to_be_finalized ); |
|
413 | - if( ! $subsection instanceof EE_Form_Section_Proper){ |
|
411 | + public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE) { |
|
412 | + $subsection = $this->get_subsection($name, $require_construction_to_be_finalized); |
|
413 | + if ( ! $subsection instanceof EE_Form_Section_Proper) { |
|
414 | 414 | throw new EE_Error( |
415 | 415 | sprintf( |
416 | - __( "Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso' ), |
|
416 | + __("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'), |
|
417 | 417 | $name, |
418 | - get_class( $this ) |
|
418 | + get_class($this) |
|
419 | 419 | ) |
420 | 420 | ); |
421 | 421 | } |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | * @return mixed depending on the input's type and its normalization strategy |
433 | 433 | * @throws \EE_Error |
434 | 434 | */ |
435 | - public function get_input_value($name){ |
|
435 | + public function get_input_value($name) { |
|
436 | 436 | $input = $this->get_input($name); |
437 | 437 | return $input->normalized_value(); |
438 | 438 | } |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | * @return boolean |
446 | 446 | */ |
447 | 447 | public function is_valid() { |
448 | - if( ! $this->has_received_submission()){ |
|
448 | + if ( ! $this->has_received_submission()) { |
|
449 | 449 | throw new EE_Error( |
450 | 450 | sprintf( |
451 | 451 | __( |
@@ -455,16 +455,16 @@ discard block |
||
455 | 455 | ) |
456 | 456 | ); |
457 | 457 | } |
458 | - if( ! parent::is_valid() ) { |
|
458 | + if ( ! parent::is_valid()) { |
|
459 | 459 | return false; |
460 | 460 | } |
461 | 461 | // ok so no general errors to this entire form section. |
462 | 462 | // so let's check the subsections, but only set errors if that hasn't been done yet |
463 | 463 | $set_submission_errors = $this->submission_error_message() === '' ? true : false; |
464 | - foreach( $this->get_validatable_subsections() as $subsection ){ |
|
465 | - if( ! $subsection->is_valid() || $subsection->get_validation_error_string() !== '' ){ |
|
466 | - if ( $set_submission_errors ) { |
|
467 | - $this->set_submission_error_message( $subsection->get_validation_error_string() ); |
|
464 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
465 | + if ( ! $subsection->is_valid() || $subsection->get_validation_error_string() !== '') { |
|
466 | + if ($set_submission_errors) { |
|
467 | + $this->set_submission_error_message($subsection->get_validation_error_string()); |
|
468 | 468 | } |
469 | 469 | return false; |
470 | 470 | } |
@@ -478,11 +478,11 @@ discard block |
||
478 | 478 | * gets teh default name of this form section if none is specified |
479 | 479 | * @return string |
480 | 480 | */ |
481 | - protected function _set_default_name_if_empty(){ |
|
482 | - if( ! $this->_name ){ |
|
481 | + protected function _set_default_name_if_empty() { |
|
482 | + if ( ! $this->_name) { |
|
483 | 483 | $classname = get_class($this); |
484 | 484 | $default_name = str_replace("EE_", "", $classname); |
485 | - $this->_name = $default_name; |
|
485 | + $this->_name = $default_name; |
|
486 | 486 | } |
487 | 487 | } |
488 | 488 | |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | * and get_html when you are about to display the form. |
499 | 499 | * @throws \EE_Error |
500 | 500 | */ |
501 | - public function get_html_and_js(){ |
|
501 | + public function get_html_and_js() { |
|
502 | 502 | //no doing_it_wrong yet because we ourselves are still doing it wrong... |
503 | 503 | //and theoretically this CAN be used properly, provided its used during "wp_enqueue_scripts" |
504 | 504 | $this->enqueue_js(); |
@@ -513,9 +513,9 @@ discard block |
||
513 | 513 | * @param bool $display_previously_submitted_data |
514 | 514 | * @return string |
515 | 515 | */ |
516 | - public function get_html( $display_previously_submitted_data = true ){ |
|
516 | + public function get_html($display_previously_submitted_data = true) { |
|
517 | 517 | $this->ensure_construct_finalized_called(); |
518 | - if ( $display_previously_submitted_data ) { |
|
518 | + if ($display_previously_submitted_data) { |
|
519 | 519 | $this->populate_from_session(); |
520 | 520 | } |
521 | 521 | return $this->_layout_strategy->layout_form(); |
@@ -529,9 +529,9 @@ discard block |
||
529 | 529 | * @return string |
530 | 530 | * @throws \EE_Error |
531 | 531 | */ |
532 | - public function enqueue_js(){ |
|
532 | + public function enqueue_js() { |
|
533 | 533 | $this->_enqueue_and_localize_form_js(); |
534 | - foreach( $this->subsections() as $subsection ) { |
|
534 | + foreach ($this->subsections() as $subsection) { |
|
535 | 535 | $subsection->enqueue_js(); |
536 | 536 | } |
537 | 537 | } |
@@ -550,19 +550,19 @@ discard block |
||
550 | 550 | * to be triggered automatically or not |
551 | 551 | * @return void |
552 | 552 | */ |
553 | - public static function wp_enqueue_scripts( $init_form_validation_automatically = true ){ |
|
554 | - add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
|
553 | + public static function wp_enqueue_scripts($init_form_validation_automatically = true) { |
|
554 | + add_filter('FHEE_load_jquery_validate', '__return_true'); |
|
555 | 555 | wp_register_script( |
556 | 556 | 'ee_form_section_validation', |
557 | - EE_GLOBAL_ASSETS_URL . 'scripts' . DS . 'form_section_validation.js', |
|
558 | - array( 'jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods' ), |
|
557 | + EE_GLOBAL_ASSETS_URL.'scripts'.DS.'form_section_validation.js', |
|
558 | + array('jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods'), |
|
559 | 559 | EVENT_ESPRESSO_VERSION, |
560 | 560 | true |
561 | 561 | ); |
562 | 562 | wp_localize_script( |
563 | 563 | 'ee_form_section_validation', |
564 | 564 | 'ee_form_section_validation_init', |
565 | - array( 'init' => $init_form_validation_automatically ? true : false ) |
|
565 | + array('init' => $init_form_validation_automatically ? true : false) |
|
566 | 566 | ); |
567 | 567 | } |
568 | 568 | |
@@ -573,14 +573,14 @@ discard block |
||
573 | 573 | * |
574 | 574 | * @throws \EE_Error |
575 | 575 | */ |
576 | - public function _enqueue_and_localize_form_js(){ |
|
576 | + public function _enqueue_and_localize_form_js() { |
|
577 | 577 | $this->ensure_construct_finalized_called(); |
578 | 578 | //actually, we don't want to localize just yet. There may be other forms on the page. |
579 | 579 | //so we need to add our form section data to a static variable accessible by all form sections |
580 | 580 | //and localize it just before the footer |
581 | 581 | $this->localize_validation_rules(); |
582 | - add_action( 'wp_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ), 2 ); |
|
583 | - add_action( 'admin_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ) ); |
|
582 | + add_action('wp_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'), 2); |
|
583 | + add_action('admin_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms')); |
|
584 | 584 | } |
585 | 585 | |
586 | 586 | |
@@ -592,12 +592,12 @@ discard block |
||
592 | 592 | * @return void |
593 | 593 | * @throws \EE_Error |
594 | 594 | */ |
595 | - public function localize_validation_rules( $return_for_subsection = FALSE ){ |
|
595 | + public function localize_validation_rules($return_for_subsection = FALSE) { |
|
596 | 596 | // we only want to localize vars ONCE for the entire form, |
597 | 597 | // so if the form section doesn't have a parent, then it must be the top dog |
598 | - if ( $return_for_subsection || ! $this->parent_section() ) { |
|
599 | - EE_Form_Section_Proper::$_js_localization['form_data'][ $this->html_id() ] = array( |
|
600 | - 'form_section_id'=> $this->html_id( TRUE ), |
|
598 | + if ($return_for_subsection || ! $this->parent_section()) { |
|
599 | + EE_Form_Section_Proper::$_js_localization['form_data'][$this->html_id()] = array( |
|
600 | + 'form_section_id'=> $this->html_id(TRUE), |
|
601 | 601 | 'validation_rules'=> $this->get_jquery_validation_rules(), |
602 | 602 | 'other_data' => $this->get_other_js_data(), |
603 | 603 | 'errors'=> $this->subsection_validation_errors_by_html_name() |
@@ -613,9 +613,9 @@ discard block |
||
613 | 613 | * @param array $form_other_js_data |
614 | 614 | * @return array |
615 | 615 | */ |
616 | - public function get_other_js_data( $form_other_js_data = array() ) { |
|
617 | - foreach( $this->subsections() as $subsection ) { |
|
618 | - $form_other_js_data = $subsection->get_other_js_data( $form_other_js_data ); |
|
616 | + public function get_other_js_data($form_other_js_data = array()) { |
|
617 | + foreach ($this->subsections() as $subsection) { |
|
618 | + $form_other_js_data = $subsection->get_other_js_data($form_other_js_data); |
|
619 | 619 | } |
620 | 620 | return $form_other_js_data; |
621 | 621 | } |
@@ -626,12 +626,12 @@ discard block |
||
626 | 626 | * Keys are their form names, and values are the inputs themselves |
627 | 627 | * @return EE_Form_Input_Base |
628 | 628 | */ |
629 | - public function inputs_in_subsections(){ |
|
629 | + public function inputs_in_subsections() { |
|
630 | 630 | $inputs = array(); |
631 | - foreach($this->subsections() as $subsection){ |
|
632 | - if( $subsection instanceof EE_Form_Input_Base ){ |
|
633 | - $inputs[ $subsection->html_name() ] = $subsection; |
|
634 | - }elseif($subsection instanceof EE_Form_Section_Proper ){ |
|
631 | + foreach ($this->subsections() as $subsection) { |
|
632 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
633 | + $inputs[$subsection->html_name()] = $subsection; |
|
634 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
635 | 635 | $inputs += $subsection->inputs_in_subsections(); |
636 | 636 | } |
637 | 637 | } |
@@ -644,12 +644,12 @@ discard block |
||
644 | 644 | * and values are a string of all their validation errors |
645 | 645 | * @return string[] |
646 | 646 | */ |
647 | - public function subsection_validation_errors_by_html_name(){ |
|
647 | + public function subsection_validation_errors_by_html_name() { |
|
648 | 648 | $inputs = $this->inputs(); |
649 | 649 | $errors = array(); |
650 | - foreach( $inputs as $form_input ){ |
|
651 | - if ( $form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors() ){ |
|
652 | - $errors[ $form_input->html_name() ] = $form_input->get_validation_error_string(); |
|
650 | + foreach ($inputs as $form_input) { |
|
651 | + if ($form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors()) { |
|
652 | + $errors[$form_input->html_name()] = $form_input->get_validation_error_string(); |
|
653 | 653 | } |
654 | 654 | } |
655 | 655 | return $errors; |
@@ -661,15 +661,15 @@ discard block |
||
661 | 661 | * passes all the form data required by the JS to the JS, and enqueues the few required JS files. |
662 | 662 | * Should be setup by each form during the _enqueues_and_localize_form_js |
663 | 663 | */ |
664 | - public static function localize_script_for_all_forms(){ |
|
664 | + public static function localize_script_for_all_forms() { |
|
665 | 665 | //allow inputs and stuff to hook in their JS and stuff here |
666 | - do_action( 'AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin' ); |
|
666 | + do_action('AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin'); |
|
667 | 667 | EE_Form_Section_Proper::$_js_localization['localized_error_messages'] = EE_Form_Section_Proper::_get_localized_error_messages(); |
668 | - $email_validation_level = isset( EE_Registry::instance()->CFG->registration->email_validation_level ) |
|
668 | + $email_validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level) |
|
669 | 669 | ? EE_Registry::instance()->CFG->registration->email_validation_level |
670 | 670 | : 'wp_default'; |
671 | 671 | EE_Form_Section_Proper::$_js_localization['email_validation_level'] = $email_validation_level; |
672 | - wp_enqueue_script( 'ee_form_section_validation' ); |
|
672 | + wp_enqueue_script('ee_form_section_validation'); |
|
673 | 673 | wp_localize_script( |
674 | 674 | 'ee_form_section_validation', |
675 | 675 | 'ee_form_section_vars', |
@@ -682,8 +682,8 @@ discard block |
||
682 | 682 | /** |
683 | 683 | * ensure_scripts_localized |
684 | 684 | */ |
685 | - public function ensure_scripts_localized(){ |
|
686 | - if ( ! EE_Form_Section_Proper::$_scripts_localized ) { |
|
685 | + public function ensure_scripts_localized() { |
|
686 | + if ( ! EE_Form_Section_Proper::$_scripts_localized) { |
|
687 | 687 | $this->_enqueue_and_localize_form_js(); |
688 | 688 | } |
689 | 689 | } |
@@ -695,10 +695,10 @@ discard block |
||
695 | 695 | * is that the key here should be the same as the custom validation rule put in the JS file |
696 | 696 | * @return array keys are custom validation rules, and values are internationalized strings |
697 | 697 | */ |
698 | - private static function _get_localized_error_messages(){ |
|
698 | + private static function _get_localized_error_messages() { |
|
699 | 699 | return array( |
700 | 700 | 'validUrl'=> __("This is not a valid absolute URL. Eg, http://domain.com/monkey.jpg", "event_espresso"), |
701 | - 'regex' => __( 'Please check your input', 'event_espresso' ), |
|
701 | + 'regex' => __('Please check your input', 'event_espresso'), |
|
702 | 702 | ); |
703 | 703 | } |
704 | 704 | |
@@ -728,9 +728,9 @@ discard block |
||
728 | 728 | * |
729 | 729 | * @return array |
730 | 730 | */ |
731 | - public function get_jquery_validation_rules(){ |
|
731 | + public function get_jquery_validation_rules() { |
|
732 | 732 | $jquery_validation_rules = array(); |
733 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
733 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
734 | 734 | $jquery_validation_rules = array_merge( |
735 | 735 | $jquery_validation_rules, |
736 | 736 | $subsection->get_jquery_validation_rules() |
@@ -747,14 +747,14 @@ discard block |
||
747 | 747 | * @param array $req_data like $_POST |
748 | 748 | * @return void |
749 | 749 | */ |
750 | - protected function _normalize( $req_data ) { |
|
750 | + protected function _normalize($req_data) { |
|
751 | 751 | $this->_received_submission = true; |
752 | 752 | $this->_validation_errors = array(); |
753 | - foreach ( $this->get_validatable_subsections() as $subsection ) { |
|
753 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
754 | 754 | try { |
755 | - $subsection->_normalize( $req_data ); |
|
756 | - } catch ( EE_Validation_Error $e ) { |
|
757 | - $subsection->add_validation_error( $e ); |
|
755 | + $subsection->_normalize($req_data); |
|
756 | + } catch (EE_Validation_Error $e) { |
|
757 | + $subsection->add_validation_error($e); |
|
758 | 758 | } |
759 | 759 | } |
760 | 760 | } |
@@ -771,9 +771,9 @@ discard block |
||
771 | 771 | * calling parent::_validate() first. |
772 | 772 | */ |
773 | 773 | protected function _validate() { |
774 | - foreach($this->get_validatable_subsections() as $subsection_name => $subsection){ |
|
775 | - if(method_exists($this,'_validate_'.$subsection_name)){ |
|
776 | - call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection)); |
|
774 | + foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) { |
|
775 | + if (method_exists($this, '_validate_'.$subsection_name)) { |
|
776 | + call_user_func_array(array($this, '_validate_'.$subsection_name), array($subsection)); |
|
777 | 777 | } |
778 | 778 | $subsection->_validate(); |
779 | 779 | } |
@@ -785,13 +785,13 @@ discard block |
||
785 | 785 | * Gets all the validated inputs for the form section |
786 | 786 | * @return array |
787 | 787 | */ |
788 | - public function valid_data(){ |
|
788 | + public function valid_data() { |
|
789 | 789 | $inputs = array(); |
790 | - foreach( $this->subsections() as $subsection_name =>$subsection ){ |
|
791 | - if ( $subsection instanceof EE_Form_Section_Proper ) { |
|
792 | - $inputs[ $subsection_name ] = $subsection->valid_data(); |
|
793 | - } else if ( $subsection instanceof EE_Form_Input_Base ){ |
|
794 | - $inputs[ $subsection_name ] = $subsection->normalized_value(); |
|
790 | + foreach ($this->subsections() as $subsection_name =>$subsection) { |
|
791 | + if ($subsection instanceof EE_Form_Section_Proper) { |
|
792 | + $inputs[$subsection_name] = $subsection->valid_data(); |
|
793 | + } else if ($subsection instanceof EE_Form_Input_Base) { |
|
794 | + $inputs[$subsection_name] = $subsection->normalized_value(); |
|
795 | 795 | } |
796 | 796 | } |
797 | 797 | return $inputs; |
@@ -803,11 +803,11 @@ discard block |
||
803 | 803 | * Gets all the inputs on this form section |
804 | 804 | * @return EE_Form_Input_Base[] |
805 | 805 | */ |
806 | - public function inputs(){ |
|
806 | + public function inputs() { |
|
807 | 807 | $inputs = array(); |
808 | - foreach( $this->subsections() as $subsection_name =>$subsection ){ |
|
809 | - if ( $subsection instanceof EE_Form_Input_Base ){ |
|
810 | - $inputs[ $subsection_name ] = $subsection; |
|
808 | + foreach ($this->subsections() as $subsection_name =>$subsection) { |
|
809 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
810 | + $inputs[$subsection_name] = $subsection; |
|
811 | 811 | } |
812 | 812 | } |
813 | 813 | return $inputs; |
@@ -819,10 +819,10 @@ discard block |
||
819 | 819 | * Gets all the subsections which are a proper form |
820 | 820 | * @return EE_Form_Section_Proper[] |
821 | 821 | */ |
822 | - public function subforms(){ |
|
822 | + public function subforms() { |
|
823 | 823 | $form_sections = array(); |
824 | - foreach($this->subsections() as $name=>$obj){ |
|
825 | - if($obj instanceof EE_Form_Section_Proper){ |
|
824 | + foreach ($this->subsections() as $name=>$obj) { |
|
825 | + if ($obj instanceof EE_Form_Section_Proper) { |
|
826 | 826 | $form_sections[$name] = $obj; |
827 | 827 | } |
828 | 828 | } |
@@ -837,7 +837,7 @@ discard block |
||
837 | 837 | * if you only want form inputs or proper form sections. |
838 | 838 | * @return EE_Form_Section_Proper[] |
839 | 839 | */ |
840 | - public function subsections(){ |
|
840 | + public function subsections() { |
|
841 | 841 | $this->ensure_construct_finalized_called(); |
842 | 842 | return $this->_subsections; |
843 | 843 | } |
@@ -859,8 +859,8 @@ discard block |
||
859 | 859 | * where keys are always subsection names and values are either |
860 | 860 | * the input's normalized value, or an array like the top-level array |
861 | 861 | */ |
862 | - public function input_values( $include_subform_inputs = false, $flatten = false ){ |
|
863 | - return $this->_input_values( false, $include_subform_inputs, $flatten ); |
|
862 | + public function input_values($include_subform_inputs = false, $flatten = false) { |
|
863 | + return $this->_input_values(false, $include_subform_inputs, $flatten); |
|
864 | 864 | } |
865 | 865 | |
866 | 866 | /** |
@@ -880,8 +880,8 @@ discard block |
||
880 | 880 | * where keys are always subsection names and values are either |
881 | 881 | * the input's normalized value, or an array like the top-level array |
882 | 882 | */ |
883 | - public function input_pretty_values( $include_subform_inputs = false, $flatten = false ){ |
|
884 | - return $this->_input_values( true, $include_subform_inputs, $flatten ); |
|
883 | + public function input_pretty_values($include_subform_inputs = false, $flatten = false) { |
|
884 | + return $this->_input_values(true, $include_subform_inputs, $flatten); |
|
885 | 885 | } |
886 | 886 | |
887 | 887 | /** |
@@ -899,19 +899,19 @@ discard block |
||
899 | 899 | * where keys are always subsection names and values are either |
900 | 900 | * the input's normalized value, or an array like the top-level array |
901 | 901 | */ |
902 | - public function _input_values( $pretty = false, $include_subform_inputs = false, $flatten = false ) { |
|
902 | + public function _input_values($pretty = false, $include_subform_inputs = false, $flatten = false) { |
|
903 | 903 | $input_values = array(); |
904 | - foreach( $this->subsections() as $subsection_name => $subsection ) { |
|
905 | - if( $subsection instanceof EE_Form_Input_Base ) { |
|
906 | - $input_values[ $subsection_name ] = $pretty |
|
904 | + foreach ($this->subsections() as $subsection_name => $subsection) { |
|
905 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
906 | + $input_values[$subsection_name] = $pretty |
|
907 | 907 | ? $subsection->pretty_value() |
908 | 908 | : $subsection->normalized_value(); |
909 | - } else if( $subsection instanceof EE_Form_Section_Proper && $include_subform_inputs ) { |
|
910 | - $subform_input_values = $subsection->_input_values( $pretty, $include_subform_inputs, $flatten ); |
|
911 | - if( $flatten ) { |
|
912 | - $input_values = array_merge( $input_values, $subform_input_values ); |
|
909 | + } else if ($subsection instanceof EE_Form_Section_Proper && $include_subform_inputs) { |
|
910 | + $subform_input_values = $subsection->_input_values($pretty, $include_subform_inputs, $flatten); |
|
911 | + if ($flatten) { |
|
912 | + $input_values = array_merge($input_values, $subform_input_values); |
|
913 | 913 | } else { |
914 | - $input_values[ $subsection_name ] = $subform_input_values; |
|
914 | + $input_values[$subsection_name] = $subform_input_values; |
|
915 | 915 | } |
916 | 916 | } |
917 | 917 | } |
@@ -932,23 +932,23 @@ discard block |
||
932 | 932 | * where keys are always subsection names and values are either |
933 | 933 | * the input's normalized value, or an array like the top-level array |
934 | 934 | */ |
935 | - public function submitted_values( $include_subforms = false ) { |
|
935 | + public function submitted_values($include_subforms = false) { |
|
936 | 936 | $submitted_values = array(); |
937 | - foreach( $this->subsections() as $subsection ) { |
|
938 | - if( $subsection instanceof EE_Form_Input_Base ) { |
|
937 | + foreach ($this->subsections() as $subsection) { |
|
938 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
939 | 939 | // is this input part of an array of inputs? |
940 | - if ( strpos( $subsection->html_name(), '[' ) !== false ) { |
|
940 | + if (strpos($subsection->html_name(), '[') !== false) { |
|
941 | 941 | $full_input_name = \EEH_Array::convert_array_values_to_keys( |
942 | - explode( '[', str_replace( ']', '', $subsection->html_name() ) ), |
|
942 | + explode('[', str_replace(']', '', $subsection->html_name())), |
|
943 | 943 | $subsection->raw_value() |
944 | 944 | ); |
945 | - $submitted_values = array_replace_recursive( $submitted_values, $full_input_name ); |
|
945 | + $submitted_values = array_replace_recursive($submitted_values, $full_input_name); |
|
946 | 946 | } else { |
947 | - $submitted_values[ $subsection->html_name() ] = $subsection->raw_value(); |
|
947 | + $submitted_values[$subsection->html_name()] = $subsection->raw_value(); |
|
948 | 948 | } |
949 | - } else if( $subsection instanceof EE_Form_Section_Proper && $include_subforms ) { |
|
950 | - $subform_input_values = $subsection->submitted_values( $include_subforms ); |
|
951 | - $submitted_values = array_replace_recursive( $submitted_values, $subform_input_values ); |
|
949 | + } else if ($subsection instanceof EE_Form_Section_Proper && $include_subforms) { |
|
950 | + $subform_input_values = $subsection->submitted_values($include_subforms); |
|
951 | + $submitted_values = array_replace_recursive($submitted_values, $subform_input_values); |
|
952 | 952 | } |
953 | 953 | } |
954 | 954 | return $submitted_values; |
@@ -963,7 +963,7 @@ discard block |
||
963 | 963 | * @return boolean |
964 | 964 | * @throws \EE_Error |
965 | 965 | */ |
966 | - public function has_received_submission(){ |
|
966 | + public function has_received_submission() { |
|
967 | 967 | $this->ensure_construct_finalized_called(); |
968 | 968 | return $this->_received_submission; |
969 | 969 | } |
@@ -976,8 +976,8 @@ discard block |
||
976 | 976 | * @param array $inputs_to_exclude values are the input names |
977 | 977 | * @return void |
978 | 978 | */ |
979 | - public function exclude($inputs_to_exclude = array()){ |
|
980 | - foreach($inputs_to_exclude as $input_to_exclude_name){ |
|
979 | + public function exclude($inputs_to_exclude = array()) { |
|
980 | + foreach ($inputs_to_exclude as $input_to_exclude_name) { |
|
981 | 981 | unset($this->_subsections[$input_to_exclude_name]); |
982 | 982 | } |
983 | 983 | } |
@@ -988,8 +988,8 @@ discard block |
||
988 | 988 | * @param array $inputs_to_hide |
989 | 989 | * @throws \EE_Error |
990 | 990 | */ |
991 | - public function hide($inputs_to_hide= array()){ |
|
992 | - foreach($inputs_to_hide as $input_to_hide){ |
|
991 | + public function hide($inputs_to_hide = array()) { |
|
992 | + foreach ($inputs_to_hide as $input_to_hide) { |
|
993 | 993 | $input = $this->get_input($input_to_hide); |
994 | 994 | |
995 | 995 | $input->set_display_strategy(new EE_Hidden_Display_Strategy()); |
@@ -1019,21 +1019,21 @@ discard block |
||
1019 | 1019 | * @return void |
1020 | 1020 | * @throws \EE_Error |
1021 | 1021 | */ |
1022 | - public function add_subsections( $new_subsections, $subsection_name_to_target = NULL, $add_before = true ){ |
|
1023 | - foreach( $new_subsections as $subsection_name => $subsection ){ |
|
1024 | - if( ! $subsection instanceof EE_Form_Section_Base ){ |
|
1022 | + public function add_subsections($new_subsections, $subsection_name_to_target = NULL, $add_before = true) { |
|
1023 | + foreach ($new_subsections as $subsection_name => $subsection) { |
|
1024 | + if ( ! $subsection instanceof EE_Form_Section_Base) { |
|
1025 | 1025 | EE_Error::add_error( |
1026 | 1026 | sprintf( |
1027 | 1027 | __( |
1028 | 1028 | "Trying to add a %s as a subsection (it was named '%s') to the form section '%s'. It was removed.", |
1029 | 1029 | "event_espresso" |
1030 | 1030 | ), |
1031 | - get_class( $subsection ), |
|
1031 | + get_class($subsection), |
|
1032 | 1032 | $subsection_name, |
1033 | 1033 | $this->name() |
1034 | 1034 | ) |
1035 | 1035 | ); |
1036 | - unset( $new_subsections[ $subsection_name ] ); |
|
1036 | + unset($new_subsections[$subsection_name]); |
|
1037 | 1037 | } |
1038 | 1038 | } |
1039 | 1039 | $this->_subsections = EEH_Array::insert_into_array( |
@@ -1044,8 +1044,8 @@ discard block |
||
1044 | 1044 | ); |
1045 | 1045 | |
1046 | 1046 | |
1047 | - if( $this->_construction_finalized ){ |
|
1048 | - foreach($this->_subsections as $name => $subsection){ |
|
1047 | + if ($this->_construction_finalized) { |
|
1048 | + foreach ($this->_subsections as $name => $subsection) { |
|
1049 | 1049 | $subsection->_construct_finalize($this, $name); |
1050 | 1050 | } |
1051 | 1051 | } |
@@ -1056,8 +1056,8 @@ discard block |
||
1056 | 1056 | /** |
1057 | 1057 | * Just gets all validatable subsections to clean their sensitive data |
1058 | 1058 | */ |
1059 | - public function clean_sensitive_data(){ |
|
1060 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
1059 | + public function clean_sensitive_data() { |
|
1060 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
1061 | 1061 | $subsection->clean_sensitive_data(); |
1062 | 1062 | } |
1063 | 1063 | } |
@@ -1067,10 +1067,10 @@ discard block |
||
1067 | 1067 | /** |
1068 | 1068 | * @param string $form_submission_error_message |
1069 | 1069 | */ |
1070 | - public function set_submission_error_message( $form_submission_error_message = '' ) { |
|
1071 | - $this->_form_submission_error_message .= ! empty( $form_submission_error_message ) |
|
1070 | + public function set_submission_error_message($form_submission_error_message = '') { |
|
1071 | + $this->_form_submission_error_message .= ! empty($form_submission_error_message) |
|
1072 | 1072 | ? $form_submission_error_message |
1073 | - : __( 'Form submission failed due to errors', 'event_espresso' ); |
|
1073 | + : __('Form submission failed due to errors', 'event_espresso'); |
|
1074 | 1074 | } |
1075 | 1075 | |
1076 | 1076 | |
@@ -1087,10 +1087,10 @@ discard block |
||
1087 | 1087 | /** |
1088 | 1088 | * @param string $form_submission_success_message |
1089 | 1089 | */ |
1090 | - public function set_submission_success_message( $form_submission_success_message ) { |
|
1091 | - $this->_form_submission_success_message .= ! empty( $form_submission_success_message ) |
|
1090 | + public function set_submission_success_message($form_submission_success_message) { |
|
1091 | + $this->_form_submission_success_message .= ! empty($form_submission_success_message) |
|
1092 | 1092 | ? $form_submission_success_message |
1093 | - : __( 'Form submitted successfully', 'event_espresso' ); |
|
1093 | + : __('Form submitted successfully', 'event_espresso'); |
|
1094 | 1094 | } |
1095 | 1095 | |
1096 | 1096 | |
@@ -1113,10 +1113,10 @@ discard block |
||
1113 | 1113 | * @return string |
1114 | 1114 | * @throws \EE_Error |
1115 | 1115 | */ |
1116 | - public function html_name_prefix(){ |
|
1117 | - if( $this->parent_section() instanceof EE_Form_Section_Proper ){ |
|
1118 | - return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']'; |
|
1119 | - }else{ |
|
1116 | + public function html_name_prefix() { |
|
1117 | + if ($this->parent_section() instanceof EE_Form_Section_Proper) { |
|
1118 | + return $this->parent_section()->html_name_prefix().'['.$this->name().']'; |
|
1119 | + } else { |
|
1120 | 1120 | return $this->name(); |
1121 | 1121 | } |
1122 | 1122 | } |
@@ -1131,7 +1131,7 @@ discard block |
||
1131 | 1131 | * @return string |
1132 | 1132 | * @throws \EE_Error |
1133 | 1133 | */ |
1134 | - public function name(){ |
|
1134 | + public function name() { |
|
1135 | 1135 | $this->ensure_construct_finalized_called(); |
1136 | 1136 | return parent::name(); |
1137 | 1137 | } |
@@ -1142,7 +1142,7 @@ discard block |
||
1142 | 1142 | * @return EE_Form_Section_Proper |
1143 | 1143 | * @throws \EE_Error |
1144 | 1144 | */ |
1145 | - public function parent_section(){ |
|
1145 | + public function parent_section() { |
|
1146 | 1146 | $this->ensure_construct_finalized_called(); |
1147 | 1147 | return parent::parent_section(); |
1148 | 1148 | } |
@@ -1155,9 +1155,9 @@ discard block |
||
1155 | 1155 | * @return void |
1156 | 1156 | * @throws \EE_Error |
1157 | 1157 | */ |
1158 | - public function ensure_construct_finalized_called(){ |
|
1159 | - if( ! $this->_construction_finalized ){ |
|
1160 | - $this->_construct_finalize($this->_parent_section, $this->_name ); |
|
1158 | + public function ensure_construct_finalized_called() { |
|
1159 | + if ( ! $this->_construction_finalized) { |
|
1160 | + $this->_construct_finalize($this->_parent_section, $this->_name); |
|
1161 | 1161 | } |
1162 | 1162 | } |
1163 | 1163 | |
@@ -1169,17 +1169,17 @@ discard block |
||
1169 | 1169 | * @param array $req_data |
1170 | 1170 | * @return boolean |
1171 | 1171 | */ |
1172 | - public function form_data_present_in( $req_data = NULL ) { |
|
1173 | - if( $req_data === NULL){ |
|
1172 | + public function form_data_present_in($req_data = NULL) { |
|
1173 | + if ($req_data === NULL) { |
|
1174 | 1174 | $req_data = $_POST; |
1175 | 1175 | } |
1176 | - foreach( $this->subsections() as $subsection ) { |
|
1177 | - if($subsection instanceof EE_Form_Input_Base ) { |
|
1178 | - if( $subsection->form_data_present_in( $req_data ) ) { |
|
1176 | + foreach ($this->subsections() as $subsection) { |
|
1177 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
1178 | + if ($subsection->form_data_present_in($req_data)) { |
|
1179 | 1179 | return TRUE; |
1180 | 1180 | } |
1181 | - }elseif( $subsection instanceof EE_Form_Section_Proper ) { |
|
1182 | - if( $subsection->form_data_present_in( $req_data ) ) { |
|
1181 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
1182 | + if ($subsection->form_data_present_in($req_data)) { |
|
1183 | 1183 | return TRUE; |
1184 | 1184 | } |
1185 | 1185 | } |
@@ -1196,14 +1196,14 @@ discard block |
||
1196 | 1196 | */ |
1197 | 1197 | public function get_validation_errors_accumulated() { |
1198 | 1198 | $validation_errors = $this->get_validation_errors(); |
1199 | - foreach($this->get_validatable_subsections() as $subsection ) { |
|
1200 | - if( $subsection instanceof EE_Form_Section_Proper ) { |
|
1199 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
1200 | + if ($subsection instanceof EE_Form_Section_Proper) { |
|
1201 | 1201 | $validation_errors_on_this_subsection = $subsection->get_validation_errors_accumulated(); |
1202 | 1202 | } else { |
1203 | - $validation_errors_on_this_subsection = $subsection->get_validation_errors(); |
|
1203 | + $validation_errors_on_this_subsection = $subsection->get_validation_errors(); |
|
1204 | 1204 | } |
1205 | - if( $validation_errors_on_this_subsection ){ |
|
1206 | - $validation_errors = array_merge( $validation_errors, $validation_errors_on_this_subsection ); |
|
1205 | + if ($validation_errors_on_this_subsection) { |
|
1206 | + $validation_errors = array_merge($validation_errors, $validation_errors_on_this_subsection); |
|
1207 | 1207 | } |
1208 | 1208 | } |
1209 | 1209 | return $validation_errors; |
@@ -1225,24 +1225,24 @@ discard block |
||
1225 | 1225 | * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false |
1226 | 1226 | * @return EE_Form_Section_Base |
1227 | 1227 | */ |
1228 | - public function find_section_from_path( $form_section_path ) { |
|
1228 | + public function find_section_from_path($form_section_path) { |
|
1229 | 1229 | //check if we can find the input from purely going straight up the tree |
1230 | - $input = parent::find_section_from_path( $form_section_path ); |
|
1231 | - if( $input instanceof EE_Form_Section_Base ) { |
|
1230 | + $input = parent::find_section_from_path($form_section_path); |
|
1231 | + if ($input instanceof EE_Form_Section_Base) { |
|
1232 | 1232 | return $input; |
1233 | 1233 | } |
1234 | 1234 | |
1235 | - $next_slash_pos = strpos( $form_section_path, '/' ); |
|
1236 | - if( $next_slash_pos !== false ) { |
|
1237 | - $child_section_name = substr( $form_section_path, 0, $next_slash_pos ); |
|
1238 | - $subpath = substr( $form_section_path, $next_slash_pos + 1 ); |
|
1235 | + $next_slash_pos = strpos($form_section_path, '/'); |
|
1236 | + if ($next_slash_pos !== false) { |
|
1237 | + $child_section_name = substr($form_section_path, 0, $next_slash_pos); |
|
1238 | + $subpath = substr($form_section_path, $next_slash_pos + 1); |
|
1239 | 1239 | } else { |
1240 | 1240 | $child_section_name = $form_section_path; |
1241 | 1241 | $subpath = ''; |
1242 | 1242 | } |
1243 | - $child_section = $this->get_subsection( $child_section_name ); |
|
1244 | - if ( $child_section instanceof EE_Form_Section_Base ) { |
|
1245 | - return $child_section->find_section_from_path( $subpath ); |
|
1243 | + $child_section = $this->get_subsection($child_section_name); |
|
1244 | + if ($child_section instanceof EE_Form_Section_Base) { |
|
1245 | + return $child_section->find_section_from_path($subpath); |
|
1246 | 1246 | } else { |
1247 | 1247 | return null; |
1248 | 1248 | } |