@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @param \EEI_Line_Item $line_item |
27 | 27 | * @return \EEI_Line_Item |
28 | 28 | */ |
29 | - public function process( EEI_Line_Item $line_item ); |
|
29 | + public function process(EEI_Line_Item $line_item); |
|
30 | 30 | |
31 | 31 | |
32 | 32 |
@@ -1,20 +1,20 @@ discard block |
||
1 | 1 | <?php |
2 | -class EE_Sample_Form extends EE_Form_Section_Proper{ |
|
3 | - function __construct(){ |
|
2 | +class EE_Sample_Form extends EE_Form_Section_Proper { |
|
3 | + function __construct() { |
|
4 | 4 | $this->_subsections = array( |
5 | 5 | 'h1'=>new EE_Form_Section_HTML('hello wordl'), |
6 | - 'name'=>new EE_Text_Input(array('required'=>true,'default'=>'your name here')), |
|
6 | + 'name'=>new EE_Text_Input(array('required'=>true, 'default'=>'your name here')), |
|
7 | 7 | 'email'=>new EE_Email_Input(array('required'=>false)), |
8 | - 'shirt_size'=>new EE_Select_Input(array(''=>'Please select...', 's'=> __("Small", "event_espresso"),'m'=> __("Medium", "event_espresso"),'l'=> __("Large", "event_espresso")),array('required'=>true,'default'=>'s')), |
|
8 | + 'shirt_size'=>new EE_Select_Input(array(''=>'Please select...', 's'=> __("Small", "event_espresso"), 'm'=> __("Medium", "event_espresso"), 'l'=> __("Large", "event_espresso")), array('required'=>true, 'default'=>'s')), |
|
9 | 9 | 'month_normal'=>new EE_Month_Input(), |
10 | 10 | 'month_leading_zero'=>new EE_Month_Input(true), |
11 | 11 | 'year_2'=>new EE_Year_Input(false, 1, 1), |
12 | - 'year_4'=>new EE_Year_Input(true, 0,10,array('default'=>'2017')), |
|
12 | + 'year_4'=>new EE_Year_Input(true, 0, 10, array('default'=>'2017')), |
|
13 | 13 | 'yes_no'=>new EE_Yes_No_Input(array('html_label_text'=> __("Yes or No", "event_espresso"))), |
14 | 14 | 'credit_card'=>new EE_Credit_Card_Input(), |
15 | 15 | 'image_1'=>new EE_Admin_File_Uploader_Input(), |
16 | 16 | 'image_2'=>new EE_Admin_File_Uploader_Input(), |
17 | - 'skillz'=>new EE_Checkbox_Multi_Input(array('php'=>'PHP','mysql'=>'MYSQL'),array('default'=>array('php'))), |
|
17 | + 'skillz'=>new EE_Checkbox_Multi_Input(array('php'=>'PHP', 'mysql'=>'MYSQL'), array('default'=>array('php'))), |
|
18 | 18 | 'float'=>new EE_Float_Input(), |
19 | 19 | 'essay'=>new EE_Text_Area_Input(), |
20 | 20 | 'amenities'=>new EE_Select_Multiple_Input( |
@@ -40,16 +40,16 @@ discard block |
||
40 | 40 | * Extra validation for the 'name' input. |
41 | 41 | * @param EE_Text_Input $form_input |
42 | 42 | */ |
43 | - function _validate_name($form_input){ |
|
44 | - if($form_input->raw_value() != 'Mike'){ |
|
43 | + function _validate_name($form_input) { |
|
44 | + if ($form_input->raw_value() != 'Mike') { |
|
45 | 45 | $form_input->add_validation_error(__("You are not mike. You must be brent or darren. Thats ok, I guess", 'event_espresso'), 'not-mike'); |
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
49 | - function _validate(){ |
|
49 | + function _validate() { |
|
50 | 50 | parent::_validate(); |
51 | - if($this->_subsections['shirt_size']->normalized_value() =='s' |
|
52 | - && $this->_subsections['year_4']->normalized_value() < 2010){ |
|
51 | + if ($this->_subsections['shirt_size']->normalized_value() == 's' |
|
52 | + && $this->_subsections['year_4']->normalized_value() < 2010) { |
|
53 | 53 | $this->add_validation_error(__("If you want a small shirt, you should be born after 2010. Otherwise theyre just too big", 'event_espresso'), 'too-old'); |
54 | 54 | } |
55 | 55 | } |
@@ -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 ){ |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * For containing info about a non-field form section, which contains other form sections/fields. |
|
4 | - * Relies heavily on the script form_section_validation.js for client-side validation, mostly |
|
5 | - * the php code just provides form_section_validation.js with teh variables to use. |
|
6 | - * Important: in order for the JS to be loaded properly, you must construct a form section |
|
7 | - * before the hook wp_enqueue_scripts is called (so that the form section can enqueue its needed scripts). |
|
8 | - * However, you may output the form (usually by calling get_html_and_js) anywhere you like. |
|
9 | - */ |
|
3 | + * For containing info about a non-field form section, which contains other form sections/fields. |
|
4 | + * Relies heavily on the script form_section_validation.js for client-side validation, mostly |
|
5 | + * the php code just provides form_section_validation.js with teh variables to use. |
|
6 | + * Important: in order for the JS to be loaded properly, you must construct a form section |
|
7 | + * before the hook wp_enqueue_scripts is called (so that the form section can enqueue its needed scripts). |
|
8 | + * However, you may output the form (usually by calling get_html_and_js) anywhere you like. |
|
9 | + */ |
|
10 | 10 | class EE_Form_Section_Proper extends EE_Form_Section_Validatable{ |
11 | 11 | |
12 | 12 | /** |
@@ -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,17 +184,17 @@ 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 | - $req_data = apply_filters( 'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', $req_data, $this, $validate ); |
|
189 | - if( $req_data === NULL){ |
|
187 | + public function receive_form_submission($req_data = NULL, $validate = TRUE) { |
|
188 | + $req_data = apply_filters('FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', $req_data, $this, $validate); |
|
189 | + if ($req_data === NULL) { |
|
190 | 190 | $req_data = $_REQUEST; |
191 | 191 | } |
192 | - $req_data = apply_filters( 'FHEE__EE_Form_Section_Proper__receive_form_submission__request_data', $req_data, $this ); |
|
192 | + $req_data = apply_filters('FHEE__EE_Form_Section_Proper__receive_form_submission__request_data', $req_data, $this); |
|
193 | 193 | $this->_normalize($req_data); |
194 | - if( $validate ){ |
|
194 | + if ($validate) { |
|
195 | 195 | $this->_validate(); |
196 | 196 | } |
197 | - do_action( 'AHEE__EE_Form_Section_Proper__receive_form_submission__end', $req_data, $this, $validate ); |
|
197 | + do_action('AHEE__EE_Form_Section_Proper__receive_form_submission__end', $req_data, $this, $validate); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | |
@@ -207,12 +207,12 @@ discard block |
||
207 | 207 | * the value being an array formatted in teh same way |
208 | 208 | * @param array $default_data |
209 | 209 | */ |
210 | - public function populate_defaults($default_data){ |
|
211 | - foreach($this->subsections() as $subsection_name => $subsection){ |
|
212 | - if(isset($default_data[$subsection_name])){ |
|
213 | - if($subsection instanceof EE_Form_Input_Base){ |
|
210 | + public function populate_defaults($default_data) { |
|
211 | + foreach ($this->subsections() as $subsection_name => $subsection) { |
|
212 | + if (isset($default_data[$subsection_name])) { |
|
213 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
214 | 214 | $subsection->set_default($default_data[$subsection_name]); |
215 | - }elseif($subsection instanceof EE_Form_Section_Proper){ |
|
215 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
216 | 216 | $subsection->populate_defaults($default_data[$subsection_name]); |
217 | 217 | } |
218 | 218 | } |
@@ -230,8 +230,8 @@ discard block |
||
230 | 230 | * (realizing that the subsections' html names might not be set yet, etc.) |
231 | 231 | * @return EE_Form_Section_Base |
232 | 232 | */ |
233 | - public function get_subsection($name, $require_construction_to_be_finalized = TRUE ){ |
|
234 | - if( $require_construction_to_be_finalized ){ |
|
233 | + public function get_subsection($name, $require_construction_to_be_finalized = TRUE) { |
|
234 | + if ($require_construction_to_be_finalized) { |
|
235 | 235 | $this->ensure_construct_finalized_called(); |
236 | 236 | } |
237 | 237 | return isset($this->_subsections[$name]) ? $this->_subsections[$name] : NULL; |
@@ -243,10 +243,10 @@ discard block |
||
243 | 243 | * Gets all the validatable subsections of this form section |
244 | 244 | * @return EE_Form_Section_Validatable[] |
245 | 245 | */ |
246 | - public function get_validatable_subsections(){ |
|
246 | + public function get_validatable_subsections() { |
|
247 | 247 | $validatable_subsections = array(); |
248 | - foreach($this->subsections() as $name=>$obj){ |
|
249 | - if($obj instanceof EE_Form_Section_Validatable){ |
|
248 | + foreach ($this->subsections() as $name=>$obj) { |
|
249 | + if ($obj instanceof EE_Form_Section_Validatable) { |
|
250 | 250 | $validatable_subsections[$name] = $obj; |
251 | 251 | } |
252 | 252 | } |
@@ -266,10 +266,10 @@ discard block |
||
266 | 266 | * @return EE_Form_Input_Base |
267 | 267 | * @throws EE_Error |
268 | 268 | */ |
269 | - public function get_input($name, $require_construction_to_be_finalized = TRUE ){ |
|
269 | + public function get_input($name, $require_construction_to_be_finalized = TRUE) { |
|
270 | 270 | $subsection = $this->get_subsection($name, $require_construction_to_be_finalized); |
271 | - if( ! $subsection instanceof EE_Form_Input_Base){ |
|
272 | - 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 | + if ( ! $subsection instanceof EE_Form_Input_Base) { |
|
272 | + 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'))); |
|
273 | 273 | } |
274 | 274 | return $subsection; |
275 | 275 | } |
@@ -287,10 +287,10 @@ discard block |
||
287 | 287 | * @return EE_Form_Section_Proper |
288 | 288 | * @throws EE_Error |
289 | 289 | */ |
290 | - public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE ){ |
|
291 | - $subsection = $this->get_subsection( $name, $require_construction_to_be_finalized ); |
|
292 | - if( ! $subsection instanceof EE_Form_Section_Proper){ |
|
293 | - throw new EE_Error(sprintf(__("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'),$name, get_class($this))); |
|
290 | + public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE) { |
|
291 | + $subsection = $this->get_subsection($name, $require_construction_to_be_finalized); |
|
292 | + if ( ! $subsection instanceof EE_Form_Section_Proper) { |
|
293 | + throw new EE_Error(sprintf(__("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'), $name, get_class($this))); |
|
294 | 294 | } |
295 | 295 | return $subsection; |
296 | 296 | } |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | * @param string $name |
304 | 304 | * @return mixed depending on the input's type and its normalization strategy |
305 | 305 | */ |
306 | - public function get_input_value($name){ |
|
306 | + public function get_input_value($name) { |
|
307 | 307 | $input = $this->get_input($name); |
308 | 308 | return $input->normalized_value(); |
309 | 309 | } |
@@ -316,16 +316,16 @@ discard block |
||
316 | 316 | * @return boolean |
317 | 317 | */ |
318 | 318 | public function is_valid() { |
319 | - if( ! $this->has_received_submission()){ |
|
319 | + if ( ! $this->has_received_submission()) { |
|
320 | 320 | throw new EE_Error(sprintf(__("You cannot check if a form is valid before receiving the form submission using receive_form_submission", "event_espresso"))); |
321 | 321 | } |
322 | - if( ! parent::is_valid()){ |
|
322 | + if ( ! parent::is_valid()) { |
|
323 | 323 | return false; |
324 | 324 | } |
325 | 325 | //ok so no errors general to this entire form section. so let's check the subsections |
326 | - foreach( $this->get_validatable_subsections() as $subsection ){ |
|
327 | - if( ! $subsection->is_valid() || $subsection->get_validation_error_string() != '' ){ |
|
328 | - $this->set_submission_error_message( $subsection->get_validation_error_string() ); |
|
326 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
327 | + if ( ! $subsection->is_valid() || $subsection->get_validation_error_string() != '') { |
|
328 | + $this->set_submission_error_message($subsection->get_validation_error_string()); |
|
329 | 329 | return false; |
330 | 330 | } |
331 | 331 | } |
@@ -338,11 +338,11 @@ discard block |
||
338 | 338 | * gets teh default name of this form section if none is specified |
339 | 339 | * @return string |
340 | 340 | */ |
341 | - protected function _set_default_name_if_empty(){ |
|
342 | - if( ! $this->_name ){ |
|
341 | + protected function _set_default_name_if_empty() { |
|
342 | + if ( ! $this->_name) { |
|
343 | 343 | $classname = get_class($this); |
344 | 344 | $default_name = str_replace("EE_", "", $classname); |
345 | - $this->_name = $default_name; |
|
345 | + $this->_name = $default_name; |
|
346 | 346 | } |
347 | 347 | } |
348 | 348 | |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | * Also returns the HTML for the form, except for the form opening and closing tags |
354 | 354 | * (as the form section doesn't know where you necessarily want to send the information to), and except for a submit button. |
355 | 355 | */ |
356 | - public function get_html_and_js(){ |
|
356 | + public function get_html_and_js() { |
|
357 | 357 | $this->enqueue_js(); |
358 | 358 | return $this->get_html(); |
359 | 359 | } |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | * returns HTML for displaying this form section. recursively calls display_section() on all subsections |
365 | 365 | * @return string |
366 | 366 | */ |
367 | - public function get_html(){ |
|
367 | + public function get_html() { |
|
368 | 368 | $this->ensure_construct_finalized_called(); |
369 | 369 | return $this->_layout_strategy->layout_form(); |
370 | 370 | } |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | * enqueues JS for the form |
376 | 376 | * @return string |
377 | 377 | */ |
378 | - public function enqueue_js(){ |
|
378 | + public function enqueue_js() { |
|
379 | 379 | $this->_enqueue_and_localize_form_js(); |
380 | 380 | } |
381 | 381 | |
@@ -391,11 +391,11 @@ discard block |
||
391 | 391 | * @param boolean $init_form_validation_automatically whether or not we want the form validation to be triggered automatically or not |
392 | 392 | * @return void |
393 | 393 | */ |
394 | - public static function wp_enqueue_scripts( $init_form_validation_automatically = false ){ |
|
395 | - add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
|
396 | - 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 | + public static function wp_enqueue_scripts($init_form_validation_automatically = false) { |
|
395 | + add_filter('FHEE_load_jquery_validate', '__return_true'); |
|
396 | + 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); |
|
397 | 397 | |
398 | - wp_localize_script( 'ee_form_section_validation', 'ee_form_section_validation_init', array( 'init' => $init_form_validation_automatically ) ); |
|
398 | + wp_localize_script('ee_form_section_validation', 'ee_form_section_validation_init', array('init' => $init_form_validation_automatically)); |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | |
@@ -405,14 +405,14 @@ discard block |
||
405 | 405 | * This needs to be called AFTER we've called $this->_enqueue_jquery_validate_script, |
406 | 406 | * but before the wordpress hook wp_loaded |
407 | 407 | */ |
408 | - public function _enqueue_and_localize_form_js(){ |
|
408 | + public function _enqueue_and_localize_form_js() { |
|
409 | 409 | $this->ensure_construct_finalized_called(); |
410 | 410 | //actually, we don't want to localize just yet. There may be other forms on the page. |
411 | 411 | //so we need to add our form section data to a static variable accessible by all form sections |
412 | 412 | //and localize it just before the footer |
413 | 413 | $this->localize_validation_rules(); |
414 | - add_action( 'wp_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ), 2 ); |
|
415 | - add_action( 'admin_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ) ); |
|
414 | + add_action('wp_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'), 2); |
|
415 | + add_action('admin_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms')); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | |
@@ -422,11 +422,11 @@ discard block |
||
422 | 422 | * @param bool $return_for_subsection |
423 | 423 | * @return void |
424 | 424 | */ |
425 | - public function localize_validation_rules( $return_for_subsection = FALSE ){ |
|
425 | + public function localize_validation_rules($return_for_subsection = FALSE) { |
|
426 | 426 | // 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 |
427 | - if ( ! $this->parent_section() || $return_for_subsection ) { |
|
428 | - EE_Form_Section_Proper::$_js_localization['form_data'][ $this->html_id() ] = array( |
|
429 | - 'form_section_id'=> $this->html_id( TRUE ), |
|
427 | + if ( ! $this->parent_section() || $return_for_subsection) { |
|
428 | + EE_Form_Section_Proper::$_js_localization['form_data'][$this->html_id()] = array( |
|
429 | + 'form_section_id'=> $this->html_id(TRUE), |
|
430 | 430 | 'validation_rules'=> $this->get_jquery_validation_rules(), |
431 | 431 | 'errors'=> $this->subsection_validation_errors_by_html_name() |
432 | 432 | ); |
@@ -441,12 +441,12 @@ discard block |
||
441 | 441 | * Keys are their form names, and values are the inputs themselves |
442 | 442 | * @return EE_Form_Input_Base |
443 | 443 | */ |
444 | - public function inputs_in_subsections(){ |
|
444 | + public function inputs_in_subsections() { |
|
445 | 445 | $inputs = array(); |
446 | - foreach($this->subsections() as $subsection){ |
|
447 | - if( $subsection instanceof EE_Form_Input_Base ){ |
|
448 | - $inputs[ $subsection->html_name() ] = $subsection; |
|
449 | - }elseif($subsection instanceof EE_Form_Section_Proper ){ |
|
446 | + foreach ($this->subsections() as $subsection) { |
|
447 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
448 | + $inputs[$subsection->html_name()] = $subsection; |
|
449 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
450 | 450 | $inputs += $subsection->inputs_in_subsections(); |
451 | 451 | } |
452 | 452 | } |
@@ -459,12 +459,12 @@ discard block |
||
459 | 459 | * and values are a string of all their validation errors |
460 | 460 | * @return string[] |
461 | 461 | */ |
462 | - public function subsection_validation_errors_by_html_name(){ |
|
462 | + public function subsection_validation_errors_by_html_name() { |
|
463 | 463 | $inputs = $this->inputs(); |
464 | 464 | $errors = array(); |
465 | - foreach( $inputs as $form_input ){ |
|
466 | - if ( $form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors() ){ |
|
467 | - $errors[ $form_input->html_name() ] = $form_input->get_validation_error_string(); |
|
465 | + foreach ($inputs as $form_input) { |
|
466 | + if ($form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors()) { |
|
467 | + $errors[$form_input->html_name()] = $form_input->get_validation_error_string(); |
|
468 | 468 | } |
469 | 469 | } |
470 | 470 | return $errors; |
@@ -476,12 +476,12 @@ discard block |
||
476 | 476 | * passes all the form data required by the JS to the JS, and enqueues the few required JS files. |
477 | 477 | * Should be setup by each form during the _enqueues_and_localize_form_js |
478 | 478 | */ |
479 | - public static function localize_script_for_all_forms(){ |
|
479 | + public static function localize_script_for_all_forms() { |
|
480 | 480 | //allow inputs and stuff to hook in their JS and stuff here |
481 | 481 | do_action('AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin'); |
482 | 482 | EE_Form_Section_Proper::$_js_localization['localized_error_messages'] = EE_Form_Section_Proper::_get_localized_error_messages(); |
483 | - wp_enqueue_script( 'ee_form_section_validation' ); |
|
484 | - wp_localize_script( 'ee_form_section_validation', 'ee_form_section_vars', EE_Form_Section_Proper::$_js_localization ); |
|
483 | + wp_enqueue_script('ee_form_section_validation'); |
|
484 | + wp_localize_script('ee_form_section_validation', 'ee_form_section_vars', EE_Form_Section_Proper::$_js_localization); |
|
485 | 485 | } |
486 | 486 | |
487 | 487 | |
@@ -489,8 +489,8 @@ discard block |
||
489 | 489 | /** |
490 | 490 | * ensure_scripts_localized |
491 | 491 | */ |
492 | - public function ensure_scripts_localized(){ |
|
493 | - if ( ! EE_Form_Section_Proper::$_scripts_localized ) { |
|
492 | + public function ensure_scripts_localized() { |
|
493 | + if ( ! EE_Form_Section_Proper::$_scripts_localized) { |
|
494 | 494 | $this->_enqueue_and_localize_form_js(); |
495 | 495 | } |
496 | 496 | } |
@@ -502,10 +502,10 @@ discard block |
||
502 | 502 | * is that the key here should be the same as the custom validation rule put in the JS file |
503 | 503 | * @return array keys are custom validation rules, and values are internationalized strings |
504 | 504 | */ |
505 | - private static function _get_localized_error_messages(){ |
|
505 | + private static function _get_localized_error_messages() { |
|
506 | 506 | return array( |
507 | 507 | 'validUrl'=> __("This is not a valid absolute URL. Eg, http://domain.com/monkey.jpg", "event_espresso"), |
508 | - 'regex' => __( 'Please check your input', 'event_espresso' ), |
|
508 | + 'regex' => __('Please check your input', 'event_espresso'), |
|
509 | 509 | ); |
510 | 510 | } |
511 | 511 | |
@@ -533,10 +533,10 @@ discard block |
||
533 | 533 | * Gets the JS to put inside the jquery validation rules for subsection of this form section. See parent function for more... |
534 | 534 | * @return array |
535 | 535 | */ |
536 | - function get_jquery_validation_rules(){ |
|
536 | + function get_jquery_validation_rules() { |
|
537 | 537 | $jquery_validation_rules = array(); |
538 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
539 | - $jquery_validation_rules = array_merge( $jquery_validation_rules, $subsection->get_jquery_validation_rules() ); |
|
538 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
539 | + $jquery_validation_rules = array_merge($jquery_validation_rules, $subsection->get_jquery_validation_rules()); |
|
540 | 540 | } |
541 | 541 | return $jquery_validation_rules; |
542 | 542 | } |
@@ -551,11 +551,11 @@ discard block |
||
551 | 551 | protected function _normalize($req_data) { |
552 | 552 | $this->_received_submission = TRUE; |
553 | 553 | $this->_validation_errors = array(); |
554 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
555 | - try{ |
|
554 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
555 | + try { |
|
556 | 556 | $subsection->_normalize($req_data); |
557 | - }catch( EE_Validation_Error $e ){ |
|
558 | - $subsection->add_validation_error( $e ); |
|
557 | + } catch (EE_Validation_Error $e) { |
|
558 | + $subsection->add_validation_error($e); |
|
559 | 559 | } |
560 | 560 | } |
561 | 561 | } |
@@ -569,9 +569,9 @@ discard block |
||
569 | 569 | * calling parent::_validate() first. |
570 | 570 | */ |
571 | 571 | protected function _validate() { |
572 | - foreach($this->get_validatable_subsections() as $subsection_name => $subsection){ |
|
573 | - if(method_exists($this,'_validate_'.$subsection_name)){ |
|
574 | - call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection)); |
|
572 | + foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) { |
|
573 | + if (method_exists($this, '_validate_'.$subsection_name)) { |
|
574 | + call_user_func_array(array($this, '_validate_'.$subsection_name), array($subsection)); |
|
575 | 575 | } |
576 | 576 | $subsection->_validate(); |
577 | 577 | } |
@@ -583,13 +583,13 @@ discard block |
||
583 | 583 | * Gets all the validated inputs for the form section |
584 | 584 | * @return array |
585 | 585 | */ |
586 | - public function valid_data(){ |
|
586 | + public function valid_data() { |
|
587 | 587 | $inputs = array(); |
588 | - foreach( $this->subsections() as $subsection_name =>$subsection ){ |
|
589 | - if ( $subsection instanceof EE_Form_Section_Proper ) { |
|
590 | - $inputs[ $subsection_name ] = $subsection->valid_data(); |
|
591 | - } else if ( $subsection instanceof EE_Form_Input_Base ){ |
|
592 | - $inputs[ $subsection_name ] = $subsection->normalized_value(); |
|
588 | + foreach ($this->subsections() as $subsection_name =>$subsection) { |
|
589 | + if ($subsection instanceof EE_Form_Section_Proper) { |
|
590 | + $inputs[$subsection_name] = $subsection->valid_data(); |
|
591 | + } else if ($subsection instanceof EE_Form_Input_Base) { |
|
592 | + $inputs[$subsection_name] = $subsection->normalized_value(); |
|
593 | 593 | } |
594 | 594 | } |
595 | 595 | return $inputs; |
@@ -601,11 +601,11 @@ discard block |
||
601 | 601 | * Gets all the inputs on this form section |
602 | 602 | * @return EE_Form_Input_Base[] |
603 | 603 | */ |
604 | - public function inputs(){ |
|
604 | + public function inputs() { |
|
605 | 605 | $inputs = array(); |
606 | - foreach( $this->subsections() as $subsection_name =>$subsection ){ |
|
607 | - if ( $subsection instanceof EE_Form_Input_Base ){ |
|
608 | - $inputs[ $subsection_name ] = $subsection; |
|
606 | + foreach ($this->subsections() as $subsection_name =>$subsection) { |
|
607 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
608 | + $inputs[$subsection_name] = $subsection; |
|
609 | 609 | } |
610 | 610 | } |
611 | 611 | return $inputs; |
@@ -617,10 +617,10 @@ discard block |
||
617 | 617 | * Gets all the subsections which are a proper form |
618 | 618 | * @return EE_Form_Section_Proper[] |
619 | 619 | */ |
620 | - public function subforms(){ |
|
620 | + public function subforms() { |
|
621 | 621 | $form_sections = array(); |
622 | - foreach($this->subsections() as $name=>$obj){ |
|
623 | - if($obj instanceof EE_Form_Section_Proper){ |
|
622 | + foreach ($this->subsections() as $name=>$obj) { |
|
623 | + if ($obj instanceof EE_Form_Section_Proper) { |
|
624 | 624 | $form_sections[$name] = $obj; |
625 | 625 | } |
626 | 626 | } |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | * if you only want form inputs or proper form sections. |
636 | 636 | * @return EE_Form_Section_Proper[] |
637 | 637 | */ |
638 | - public function subsections(){ |
|
638 | + public function subsections() { |
|
639 | 639 | $this->ensure_construct_finalized_called(); |
640 | 640 | return $this->_subsections; |
641 | 641 | } |
@@ -653,8 +653,8 @@ discard block |
||
653 | 653 | * it can be a multidimensional array where keys are always subsection names and values are either the |
654 | 654 | * input's normalized value, or an array like the top-level array |
655 | 655 | */ |
656 | - public function input_values( $include_subform_inputs = false, $flatten = false ){ |
|
657 | - return $this->_input_values( false, $include_subform_inputs, $flatten ); |
|
656 | + public function input_values($include_subform_inputs = false, $flatten = false) { |
|
657 | + return $this->_input_values(false, $include_subform_inputs, $flatten); |
|
658 | 658 | } |
659 | 659 | |
660 | 660 | /** |
@@ -670,8 +670,8 @@ discard block |
||
670 | 670 | * it can be a multidimensional array where keys are always subsection names and values are either the |
671 | 671 | * input's normalized value, or an array like the top-level array |
672 | 672 | */ |
673 | - public function input_pretty_values( $include_subform_inputs = false, $flatten = false ){ |
|
674 | - return $this->_input_values( true, $include_subform_inputs, $flatten ); |
|
673 | + public function input_pretty_values($include_subform_inputs = false, $flatten = false) { |
|
674 | + return $this->_input_values(true, $include_subform_inputs, $flatten); |
|
675 | 675 | } |
676 | 676 | |
677 | 677 | /** |
@@ -684,17 +684,17 @@ discard block |
||
684 | 684 | * it can be a multidimensional array where keys are always subsection names and values are either the |
685 | 685 | * input's normalized value, or an array like the top-level array |
686 | 686 | */ |
687 | - public function _input_values( $pretty = false, $include_subform_inputs = false, $flatten = false ) { |
|
687 | + public function _input_values($pretty = false, $include_subform_inputs = false, $flatten = false) { |
|
688 | 688 | $input_values = array(); |
689 | - foreach( $this->subsections() as $subsection_name => $subsection ) { |
|
690 | - if( $subsection instanceof EE_Form_Input_Base ) { |
|
691 | - $input_values[ $subsection_name ] = $pretty ? $subsection->pretty_value() : $subsection->normalized_value(); |
|
692 | - } else if( $subsection instanceof EE_Form_Section_Proper && $include_subform_inputs ) { |
|
693 | - $subform_input_values = $subsection->_input_values( $pretty, $include_subform_inputs, $flatten ); |
|
694 | - if( $flatten ) { |
|
695 | - $input_values = array_merge( $input_values, $subform_input_values ); |
|
689 | + foreach ($this->subsections() as $subsection_name => $subsection) { |
|
690 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
691 | + $input_values[$subsection_name] = $pretty ? $subsection->pretty_value() : $subsection->normalized_value(); |
|
692 | + } else if ($subsection instanceof EE_Form_Section_Proper && $include_subform_inputs) { |
|
693 | + $subform_input_values = $subsection->_input_values($pretty, $include_subform_inputs, $flatten); |
|
694 | + if ($flatten) { |
|
695 | + $input_values = array_merge($input_values, $subform_input_values); |
|
696 | 696 | } else { |
697 | - $input_values[ $subsection_name ] = $subform_input_values; |
|
697 | + $input_values[$subsection_name] = $subform_input_values; |
|
698 | 698 | } |
699 | 699 | } |
700 | 700 | } |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | * (ie, had receive_form_submission called on it yet) |
709 | 709 | * @return boolean |
710 | 710 | */ |
711 | - public function has_received_submission(){ |
|
711 | + public function has_received_submission() { |
|
712 | 712 | $this->ensure_construct_finalized_called(); |
713 | 713 | return $this->_received_submission; |
714 | 714 | } |
@@ -721,8 +721,8 @@ discard block |
||
721 | 721 | * @param array $inputs_to_exclude values are the input names |
722 | 722 | * @return void |
723 | 723 | */ |
724 | - public function exclude($inputs_to_exclude = array()){ |
|
725 | - foreach($inputs_to_exclude as $input_to_exclude_name){ |
|
724 | + public function exclude($inputs_to_exclude = array()) { |
|
725 | + foreach ($inputs_to_exclude as $input_to_exclude_name) { |
|
726 | 726 | unset($this->_subsections[$input_to_exclude_name]); |
727 | 727 | } |
728 | 728 | } |
@@ -732,8 +732,8 @@ discard block |
||
732 | 732 | /** |
733 | 733 | * @param array $inputs_to_hide |
734 | 734 | */ |
735 | - public function hide($inputs_to_hide= array()){ |
|
736 | - foreach($inputs_to_hide as $input_to_hide){ |
|
735 | + public function hide($inputs_to_hide = array()) { |
|
736 | + foreach ($inputs_to_hide as $input_to_hide) { |
|
737 | 737 | $input = $this->get_input($input_to_hide); |
738 | 738 | |
739 | 739 | $input->set_display_strategy(new EE_Hidden_Display_Strategy()); |
@@ -758,13 +758,13 @@ discard block |
||
758 | 758 | * or if $subsection_name_to_target is null, before or after entire subsections array |
759 | 759 | * @return void |
760 | 760 | */ |
761 | - public function add_subsections( $new_subsections, $subsection_name_to_target = NULL, $add_before = true ){ |
|
762 | - foreach($new_subsections as $subsection_name => $subsection){ |
|
763 | - if( ! $subsection instanceof EE_Form_Section_Base){ |
|
761 | + public function add_subsections($new_subsections, $subsection_name_to_target = NULL, $add_before = true) { |
|
762 | + foreach ($new_subsections as $subsection_name => $subsection) { |
|
763 | + if ( ! $subsection instanceof EE_Form_Section_Base) { |
|
764 | 764 | EE_Error::add_error( |
765 | 765 | sprintf( |
766 | 766 | __("Trying to add a %s as a subsection (it was named '%s') to the form section '%s'. It was removed.", "event_espresso"), |
767 | - get_class( $subsection ), |
|
767 | + get_class($subsection), |
|
768 | 768 | $subsection_name, |
769 | 769 | $this->name() |
770 | 770 | ) |
@@ -773,8 +773,8 @@ discard block |
||
773 | 773 | } |
774 | 774 | } |
775 | 775 | |
776 | - EE_Registry::instance()->load_helper( 'Array' ); |
|
777 | - $this->_subsections = EEH_Array::insert_into_array( $this->_subsections, $new_subsections, $subsection_name_to_target, $add_before ); |
|
776 | + EE_Registry::instance()->load_helper('Array'); |
|
777 | + $this->_subsections = EEH_Array::insert_into_array($this->_subsections, $new_subsections, $subsection_name_to_target, $add_before); |
|
778 | 778 | |
779 | 779 | /*$subsections_before = array(); |
780 | 780 | if( $subsection_name_to_target ){ |
@@ -805,8 +805,8 @@ discard block |
||
805 | 805 | $this->_subsections = $new_subsections; |
806 | 806 | } |
807 | 807 | }*/ |
808 | - if( $this->_construction_finalized ){ |
|
809 | - foreach($this->_subsections as $name => $subsection){ |
|
808 | + if ($this->_construction_finalized) { |
|
809 | + foreach ($this->_subsections as $name => $subsection) { |
|
810 | 810 | $subsection->_construct_finalize($this, $name); |
811 | 811 | } |
812 | 812 | } |
@@ -817,8 +817,8 @@ discard block |
||
817 | 817 | /** |
818 | 818 | * Just gets all validatable subsections to clean their sensitive data |
819 | 819 | */ |
820 | - public function clean_sensitive_data(){ |
|
821 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
820 | + public function clean_sensitive_data() { |
|
821 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
822 | 822 | $subsection->clean_sensitive_data(); |
823 | 823 | } |
824 | 824 | } |
@@ -828,8 +828,8 @@ discard block |
||
828 | 828 | /** |
829 | 829 | * @param string $form_submission_error_message |
830 | 830 | */ |
831 | - public function set_submission_error_message( $form_submission_error_message = '' ) { |
|
832 | - $this->_form_submission_error_message .= ! empty( $form_submission_error_message ) ? $form_submission_error_message : __( 'Form submission failed due to errors', 'event_espresso' ); |
|
831 | + public function set_submission_error_message($form_submission_error_message = '') { |
|
832 | + $this->_form_submission_error_message .= ! empty($form_submission_error_message) ? $form_submission_error_message : __('Form submission failed due to errors', 'event_espresso'); |
|
833 | 833 | } |
834 | 834 | |
835 | 835 | |
@@ -846,8 +846,8 @@ discard block |
||
846 | 846 | /** |
847 | 847 | * @param string $form_submission_success_message |
848 | 848 | */ |
849 | - public function set_submission_success_message( $form_submission_success_message ) { |
|
850 | - $this->_form_submission_success_message .= ! empty( $form_submission_success_message ) ? $form_submission_success_message : __( 'Form submitted successfully', 'event_espresso' ); |
|
849 | + public function set_submission_success_message($form_submission_success_message) { |
|
850 | + $this->_form_submission_success_message .= ! empty($form_submission_success_message) ? $form_submission_success_message : __('Form submitted successfully', 'event_espresso'); |
|
851 | 851 | } |
852 | 852 | |
853 | 853 | |
@@ -869,10 +869,10 @@ discard block |
||
869 | 869 | * EE_Form_Input_Base::_set_default_html_name_if_empty |
870 | 870 | * @return string |
871 | 871 | */ |
872 | - public function html_name_prefix(){ |
|
873 | - if( $this->parent_section() instanceof EE_Form_Section_Proper ){ |
|
874 | - return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']'; |
|
875 | - }else{ |
|
872 | + public function html_name_prefix() { |
|
873 | + if ($this->parent_section() instanceof EE_Form_Section_Proper) { |
|
874 | + return $this->parent_section()->html_name_prefix().'['.$this->name().']'; |
|
875 | + } else { |
|
876 | 876 | return $this->name(); |
877 | 877 | } |
878 | 878 | } |
@@ -883,7 +883,7 @@ discard block |
||
883 | 883 | * was set, which is probably nothing, or the classname) |
884 | 884 | * @return string |
885 | 885 | */ |
886 | - public function name(){ |
|
886 | + public function name() { |
|
887 | 887 | $this->ensure_construct_finalized_called(); |
888 | 888 | return parent::name(); |
889 | 889 | } |
@@ -892,7 +892,7 @@ discard block |
||
892 | 892 | * |
893 | 893 | * @return EE_Form_Section_Proper |
894 | 894 | */ |
895 | - public function parent_section(){ |
|
895 | + public function parent_section() { |
|
896 | 896 | $this->ensure_construct_finalized_called(); |
897 | 897 | return parent::parent_section(); |
898 | 898 | } |
@@ -901,9 +901,9 @@ discard block |
||
901 | 901 | * make sure construction finalized was called, otherwise children might not be ready |
902 | 902 | * @return void |
903 | 903 | */ |
904 | - public function ensure_construct_finalized_called(){ |
|
905 | - if( ! $this->_construction_finalized ){ |
|
906 | - $this->_construct_finalize($this->_parent_section, $this->_name ); |
|
904 | + public function ensure_construct_finalized_called() { |
|
905 | + if ( ! $this->_construction_finalized) { |
|
906 | + $this->_construct_finalize($this->_parent_section, $this->_name); |
|
907 | 907 | } |
908 | 908 | } |
909 | 909 | |
@@ -915,17 +915,17 @@ discard block |
||
915 | 915 | * @param array $req_data |
916 | 916 | * @return boolean |
917 | 917 | */ |
918 | - public function form_data_present_in( $req_data = NULL ) { |
|
919 | - if( $req_data === NULL){ |
|
918 | + public function form_data_present_in($req_data = NULL) { |
|
919 | + if ($req_data === NULL) { |
|
920 | 920 | $req_data = $_POST; |
921 | 921 | } |
922 | - foreach( $this->subsections() as $subsection ) { |
|
923 | - if($subsection instanceof EE_Form_Input_Base ) { |
|
924 | - if( $subsection->form_data_present_in( $req_data ) ) { |
|
922 | + foreach ($this->subsections() as $subsection) { |
|
923 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
924 | + if ($subsection->form_data_present_in($req_data)) { |
|
925 | 925 | return TRUE; |
926 | 926 | } |
927 | - }elseif( $subsection instanceof EE_Form_Section_Proper ) { |
|
928 | - if( $subsection->form_data_present_in( $req_data ) ) { |
|
927 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
928 | + if ($subsection->form_data_present_in($req_data)) { |
|
929 | 929 | return TRUE; |
930 | 930 | } |
931 | 931 | } |
@@ -942,14 +942,14 @@ discard block |
||
942 | 942 | */ |
943 | 943 | public function get_validation_errors_accumulated() { |
944 | 944 | $validation_errors = $this->get_validation_errors(); |
945 | - foreach($this->get_validatable_subsections() as $subsection ) { |
|
946 | - if( $subsection instanceof EE_Form_Section_Proper ) { |
|
945 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
946 | + if ($subsection instanceof EE_Form_Section_Proper) { |
|
947 | 947 | $validation_errors_on_this_subsection = $subsection->get_validation_errors_accumulated(); |
948 | 948 | } else { |
949 | - $validation_errors_on_this_subsection = $subsection->get_validation_errors(); |
|
949 | + $validation_errors_on_this_subsection = $subsection->get_validation_errors(); |
|
950 | 950 | } |
951 | - if( $validation_errors_on_this_subsection ){ |
|
952 | - $validation_errors = array_merge( $validation_errors, $validation_errors_on_this_subsection ); |
|
951 | + if ($validation_errors_on_this_subsection) { |
|
952 | + $validation_errors = array_merge($validation_errors, $validation_errors_on_this_subsection); |
|
953 | 953 | } |
954 | 954 | } |
955 | 955 | 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,13 +1,13 @@ |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | 2 | /** |
3 | - * EE_CCV_Input |
|
4 | - * Text-field, except should evaluate to a number, and should be completely emptied |
|
5 | - * when cleaning out sensitive data |
|
6 | - * |
|
7 | - * @package Event Espresso |
|
8 | - * @subpackage |
|
9 | - * @author Mike Nelson |
|
10 | - */ |
|
3 | + * EE_CCV_Input |
|
4 | + * Text-field, except should evaluate to a number, and should be completely emptied |
|
5 | + * when cleaning out sensitive data |
|
6 | + * |
|
7 | + * @package Event Espresso |
|
8 | + * @subpackage |
|
9 | + * @author Mike Nelson |
|
10 | + */ |
|
11 | 11 | class EE_CVV_Input extends EE_Text_Input{ |
12 | 12 | |
13 | 13 | /** |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @subpackage |
9 | 9 | * @author Mike Nelson |
10 | 10 | */ |
11 | -class EE_CVV_Input extends EE_Text_Input{ |
|
11 | +class EE_CVV_Input extends EE_Text_Input { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * @param array $input_settings { |
@@ -17,12 +17,12 @@ discard block |
||
17 | 17 | */ |
18 | 18 | public function __construct($input_settings = array()) { |
19 | 19 | $this->set_sensitive_data_removal_strategy(new EE_CCV_Sensitive_Data_Removal()); |
20 | - $this->_add_validation_strategy( new EE_Int_Validation_Strategy(isset( $input_settings[ 'validation_error_message' ] ) ? $input_settings[ 'validation_error_message' ] : NULL ) ); |
|
20 | + $this->_add_validation_strategy(new EE_Int_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : NULL)); |
|
21 | 21 | parent::__construct($input_settings); |
22 | - if( |
|
23 | - ! isset( $input_settings[ 'include_whats_this_link' ] ) || |
|
24 | - ( isset( $input_settings[ 'include_whats_this_link' ] ) && |
|
25 | - $input_settings[ 'include_whats_this_link' ] == true ) ) { |
|
22 | + if ( |
|
23 | + ! isset($input_settings['include_whats_this_link']) || |
|
24 | + (isset($input_settings['include_whats_this_link']) && |
|
25 | + $input_settings['include_whats_this_link'] == true) ) { |
|
26 | 26 | $this->_html_label_text = sprintf( |
27 | 27 | _x( |
28 | 28 | '%1$s %2$s(What\'s this?)%3$s', |