@@ -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 | /** |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @return bool | int |
31 | 31 | * @throws \EE_Error |
32 | 32 | */ |
33 | - public function persist( $persistence_callback = '', $persistence_arguments = array() ); |
|
33 | + public function persist($persistence_callback = '', $persistence_arguments = array()); |
|
34 | 34 | |
35 | 35 | |
36 | 36 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @param string $persistence_callback name of method found on object that can be used for persisting it |
44 | 44 | * @return bool | int |
45 | 45 | */ |
46 | - public function persist_all( $persistence_callback = '' ); |
|
46 | + public function persist_all($persistence_callback = ''); |
|
47 | 47 | |
48 | 48 | } |
49 | 49 | // End of file EEI_Repository.interface.php |
@@ -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 | * Class EEI_Line_Item |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @param mixed $field_value |
19 | 19 | * @param bool $use_default |
20 | 20 | */ |
21 | - public function set( $field_name, $field_value, $use_default = false ); |
|
21 | + public function set($field_name, $field_value, $use_default = false); |
|
22 | 22 | |
23 | 23 | |
24 | 24 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * Sets quantity |
57 | 57 | * @param int $quantity |
58 | 58 | */ |
59 | - function set_quantity( $quantity ); |
|
59 | + function set_quantity($quantity); |
|
60 | 60 | |
61 | 61 | |
62 | 62 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @param int $txn_id if none is provided, assumes $this->TXN_ID() |
116 | 116 | * @return int count of items saved |
117 | 117 | */ |
118 | - function save_this_and_descendants_to_txn( $txn_id = null ); |
|
118 | + function save_this_and_descendants_to_txn($txn_id = null); |
|
119 | 119 | |
120 | 120 | |
121 | 121 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @param bool $set_order |
143 | 143 | * @return bool true for success, false for fail |
144 | 144 | */ |
145 | - function add_child_line_item( EEI_Line_Item $line_item, $set_order = true ); |
|
145 | + function add_child_line_item(EEI_Line_Item $line_item, $set_order = true); |
|
146 | 146 | |
147 | 147 | |
148 | 148 | |
@@ -197,14 +197,14 @@ discard block |
||
197 | 197 | * @param float $total |
198 | 198 | * @return boolean |
199 | 199 | */ |
200 | - function set_total( $total ); |
|
200 | + function set_total($total); |
|
201 | 201 | |
202 | 202 | /** |
203 | 203 | * Sets unit_price |
204 | 204 | * @param float $unit_price |
205 | 205 | * @return boolean |
206 | 206 | */ |
207 | - function set_unit_price( $unit_price ); |
|
207 | + function set_unit_price($unit_price); |
|
208 | 208 | |
209 | 209 | /** |
210 | 210 | * If this line item has been saved to the DB, deletes its child with LIN_code == $code. If this line |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * @param bool $stop_search_once_found |
216 | 216 | * @return int count of items deleted (or simply removed from the line item's cache, if not has not been saved to the DB yet) |
217 | 217 | */ |
218 | - function delete_child_line_item( $code, $stop_search_once_found = true ); |
|
218 | + function delete_child_line_item($code, $stop_search_once_found = true); |
|
219 | 219 | |
220 | 220 | /** |
221 | 221 | * Forgets the cached model of the given relation Name. So the next time we request it, |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | * @param boolean $allow_persist |
239 | 239 | * @return boolean |
240 | 240 | */ |
241 | - function set_allow_persist( $allow_persist ); |
|
241 | + function set_allow_persist($allow_persist); |
|
242 | 242 | |
243 | 243 | |
244 | 244 | } |
@@ -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 | * |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | if(isset($default_data[$subsection_name])){ |
210 | 210 | if($subsection instanceof EE_Form_Input_Base){ |
211 | 211 | $subsection->set_default($default_data[$subsection_name]); |
212 | - }elseif($subsection instanceof EE_Form_Section_Proper){ |
|
212 | + } elseif($subsection instanceof EE_Form_Section_Proper){ |
|
213 | 213 | $subsection->populate_defaults($default_data[$subsection_name]); |
214 | 214 | } |
215 | 215 | } |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | foreach($this->subsections() as $subsection){ |
441 | 441 | if( $subsection instanceof EE_Form_Input_Base ){ |
442 | 442 | $inputs[ $subsection->html_name() ] = $subsection; |
443 | - }elseif($subsection instanceof EE_Form_Section_Proper ){ |
|
443 | + } elseif($subsection instanceof EE_Form_Section_Proper ){ |
|
444 | 444 | $inputs += $subsection->inputs_in_subsections(); |
445 | 445 | } |
446 | 446 | } |
@@ -548,7 +548,7 @@ discard block |
||
548 | 548 | foreach($this->get_validatable_subsections() as $subsection){ |
549 | 549 | try{ |
550 | 550 | $subsection->_normalize($req_data); |
551 | - }catch( EE_Validation_Error $e ){ |
|
551 | + } catch( EE_Validation_Error $e ){ |
|
552 | 552 | $subsection->add_validation_error( $e ); |
553 | 553 | } |
554 | 554 | } |
@@ -866,7 +866,7 @@ discard block |
||
866 | 866 | public function html_name_prefix(){ |
867 | 867 | if( $this->parent_section() instanceof EE_Form_Section_Proper ){ |
868 | 868 | return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']'; |
869 | - }else{ |
|
869 | + } else{ |
|
870 | 870 | return $this->name(); |
871 | 871 | } |
872 | 872 | } |
@@ -918,7 +918,7 @@ discard block |
||
918 | 918 | if( $subsection->form_data_present_in( $req_data ) ) { |
919 | 919 | return TRUE; |
920 | 920 | } |
921 | - }elseif( $subsection instanceof EE_Form_Section_Proper ) { |
|
921 | + } elseif( $subsection instanceof EE_Form_Section_Proper ) { |
|
922 | 922 | if( $subsection->form_data_present_in( $req_data ) ) { |
923 | 923 | return TRUE; |
924 | 924 | } |
@@ -225,7 +225,7 @@ |
||
225 | 225 | * leave this as TRUE so that the inputs will be properly configured. However, |
226 | 226 | * some client code may be ok with construction finalize being called later |
227 | 227 | * (realizing that the subsections' html names might not be set yet, etc.) |
228 | - * @return EE_Form_Section_Base |
|
228 | + * @return EE_Form_Section_Validatable|null |
|
229 | 229 | */ |
230 | 230 | public function get_subsection($name, $require_construction_to_be_finalized = TRUE ){ |
231 | 231 | if( $require_construction_to_be_finalized ){ |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * before the hook wp_enqueue_scripts is called (so that the form section can enqueue its needed scripts). |
8 | 8 | * However, you may output the form (usually by calling get_html_and_js) anywhere you like. |
9 | 9 | */ |
10 | -class EE_Form_Section_Proper extends EE_Form_Section_Validatable{ |
|
10 | +class EE_Form_Section_Proper extends EE_Form_Section_Validatable { |
|
11 | 11 | |
12 | 12 | /** |
13 | 13 | * Subsections |
@@ -68,40 +68,40 @@ discard block |
||
68 | 68 | * } @see EE_Form_Section_Validatable::__construct() |
69 | 69 | * |
70 | 70 | */ |
71 | - public function __construct( $options_array = array() ){ |
|
72 | - $options_array = apply_filters( 'FHEE__EE_Form_Section_Proper___construct__options_array', $options_array, $this ); |
|
71 | + public function __construct($options_array = array()) { |
|
72 | + $options_array = apply_filters('FHEE__EE_Form_Section_Proper___construct__options_array', $options_array, $this); |
|
73 | 73 | //call parent first, as it may be setting the name |
74 | 74 | parent::__construct($options_array); |
75 | 75 | //if they've included subsections in the constructor, add them now |
76 | - if( isset( $options_array['include'] )){ |
|
76 | + if (isset($options_array['include'])) { |
|
77 | 77 | //we are going to make sure we ONLY have those subsections to include |
78 | 78 | //AND we are going to make sure they're in that specified order |
79 | 79 | $reordered_subsections = array(); |
80 | - foreach($options_array['include'] as $input_name){ |
|
81 | - if(isset($this->_subsections[$input_name])){ |
|
80 | + foreach ($options_array['include'] as $input_name) { |
|
81 | + if (isset($this->_subsections[$input_name])) { |
|
82 | 82 | $reordered_subsections[$input_name] = $this->_subsections[$input_name]; |
83 | 83 | } |
84 | 84 | } |
85 | 85 | $this->_subsections = $reordered_subsections; |
86 | 86 | } |
87 | - if(isset($options_array['exclude'])){ |
|
87 | + if (isset($options_array['exclude'])) { |
|
88 | 88 | $exclude = $options_array['exclude']; |
89 | 89 | $this->_subsections = array_diff_key($this->_subsections, array_flip($exclude)); |
90 | 90 | } |
91 | - if(isset($options_array['layout_strategy'])){ |
|
91 | + if (isset($options_array['layout_strategy'])) { |
|
92 | 92 | $this->_layout_strategy = $options_array['layout_strategy']; |
93 | 93 | } |
94 | - if( ! $this->_layout_strategy){ |
|
94 | + if ( ! $this->_layout_strategy) { |
|
95 | 95 | $this->_layout_strategy = new EE_Two_Column_Layout(); |
96 | 96 | } |
97 | 97 | $this->_layout_strategy->_construct_finalize($this); |
98 | 98 | |
99 | - add_action( 'wp_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' )); |
|
100 | - add_action( 'admin_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' )); |
|
101 | - add_action( 'wp_footer', array( $this, 'ensure_scripts_localized' ), 1 ); |
|
99 | + add_action('wp_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts')); |
|
100 | + add_action('admin_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts')); |
|
101 | + add_action('wp_footer', array($this, 'ensure_scripts_localized'), 1); |
|
102 | 102 | |
103 | - if( isset( $options_array[ 'name' ] ) ) { |
|
104 | - $this->_construct_finalize( null, $options_array[ 'name' ] ); |
|
103 | + if (isset($options_array['name'])) { |
|
104 | + $this->_construct_finalize(null, $options_array['name']); |
|
105 | 105 | } |
106 | 106 | } |
107 | 107 | |
@@ -114,25 +114,25 @@ discard block |
||
114 | 114 | * @param string $name |
115 | 115 | * @throws \EE_Error |
116 | 116 | */ |
117 | - public function _construct_finalize( $parent_form_section, $name ) { |
|
117 | + public function _construct_finalize($parent_form_section, $name) { |
|
118 | 118 | parent::_construct_finalize($parent_form_section, $name); |
119 | 119 | $this->_set_default_name_if_empty(); |
120 | 120 | $this->_set_default_html_id_if_empty(); |
121 | - foreach( $this->_subsections as $subsection_name => $subsection ){ |
|
122 | - if ( $subsection instanceof EE_Form_Section_Base ) { |
|
123 | - $subsection->_construct_finalize( $this, $subsection_name ); |
|
121 | + foreach ($this->_subsections as $subsection_name => $subsection) { |
|
122 | + if ($subsection instanceof EE_Form_Section_Base) { |
|
123 | + $subsection->_construct_finalize($this, $subsection_name); |
|
124 | 124 | } else { |
125 | 125 | throw new EE_Error( |
126 | 126 | sprintf( |
127 | - __( 'Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso' ), |
|
127 | + __('Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso'), |
|
128 | 128 | $subsection_name, |
129 | 129 | get_class($this), |
130 | - $subsection ? get_class($subsection) : __( 'NULL', 'event_espresso' ) |
|
130 | + $subsection ? get_class($subsection) : __('NULL', 'event_espresso') |
|
131 | 131 | ) |
132 | 132 | ); |
133 | 133 | } |
134 | 134 | } |
135 | - do_action( 'AHEE__EE_Form_Section_Proper___construct_finalize__end', $this, $parent_form_section, $name ); |
|
135 | + do_action('AHEE__EE_Form_Section_Proper___construct_finalize__end', $this, $parent_form_section, $name); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * Gets the layout strategy for this form section |
142 | 142 | * @return EE_Form_Section_Layout_Base |
143 | 143 | */ |
144 | - public function get_layout_strategy(){ |
|
144 | + public function get_layout_strategy() { |
|
145 | 145 | return $this->_layout_strategy; |
146 | 146 | } |
147 | 147 | |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @param EE_Form_Input_Base $input |
154 | 154 | * @return string |
155 | 155 | */ |
156 | - public function get_html_for_input($input){ |
|
156 | + public function get_html_for_input($input) { |
|
157 | 157 | return $this->_layout_strategy->layout_input($input); |
158 | 158 | } |
159 | 159 | |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * @param null $form_data |
167 | 167 | * @return boolean |
168 | 168 | */ |
169 | - public function was_submitted($form_data = NULL){ |
|
169 | + public function was_submitted($form_data = NULL) { |
|
170 | 170 | return $this->form_data_present_in($form_data); |
171 | 171 | } |
172 | 172 | |
@@ -191,17 +191,17 @@ discard block |
||
191 | 191 | * (eg you validated the data then stored it in the DB) you may want to skip this step. |
192 | 192 | * @return void |
193 | 193 | */ |
194 | - public function receive_form_submission($req_data = NULL, $validate = TRUE){ |
|
195 | - $req_data = apply_filters( 'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', $req_data, $this, $validate ); |
|
196 | - if( $req_data === NULL){ |
|
197 | - $req_data = array_merge( $_GET, $_POST ); |
|
194 | + public function receive_form_submission($req_data = NULL, $validate = TRUE) { |
|
195 | + $req_data = apply_filters('FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', $req_data, $this, $validate); |
|
196 | + if ($req_data === NULL) { |
|
197 | + $req_data = array_merge($_GET, $_POST); |
|
198 | 198 | } |
199 | - $req_data = apply_filters( 'FHEE__EE_Form_Section_Proper__receive_form_submission__request_data', $req_data, $this ); |
|
199 | + $req_data = apply_filters('FHEE__EE_Form_Section_Proper__receive_form_submission__request_data', $req_data, $this); |
|
200 | 200 | $this->_normalize($req_data); |
201 | - if( $validate ){ |
|
201 | + if ($validate) { |
|
202 | 202 | $this->_validate(); |
203 | 203 | } |
204 | - do_action( 'AHEE__EE_Form_Section_Proper__receive_form_submission__end', $req_data, $this, $validate ); |
|
204 | + do_action('AHEE__EE_Form_Section_Proper__receive_form_submission__end', $req_data, $this, $validate); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | |
@@ -214,12 +214,12 @@ discard block |
||
214 | 214 | * the value being an array formatted in teh same way |
215 | 215 | * @param array $default_data |
216 | 216 | */ |
217 | - public function populate_defaults($default_data){ |
|
218 | - foreach($this->subsections() as $subsection_name => $subsection){ |
|
219 | - if(isset($default_data[$subsection_name])){ |
|
220 | - if($subsection instanceof EE_Form_Input_Base){ |
|
217 | + public function populate_defaults($default_data) { |
|
218 | + foreach ($this->subsections() as $subsection_name => $subsection) { |
|
219 | + if (isset($default_data[$subsection_name])) { |
|
220 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
221 | 221 | $subsection->set_default($default_data[$subsection_name]); |
222 | - }elseif($subsection instanceof EE_Form_Section_Proper){ |
|
222 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
223 | 223 | $subsection->populate_defaults($default_data[$subsection_name]); |
224 | 224 | } |
225 | 225 | } |
@@ -237,8 +237,8 @@ discard block |
||
237 | 237 | * (realizing that the subsections' html names might not be set yet, etc.) |
238 | 238 | * @return EE_Form_Section_Base |
239 | 239 | */ |
240 | - public function get_subsection($name, $require_construction_to_be_finalized = TRUE ){ |
|
241 | - if( $require_construction_to_be_finalized ){ |
|
240 | + public function get_subsection($name, $require_construction_to_be_finalized = TRUE) { |
|
241 | + if ($require_construction_to_be_finalized) { |
|
242 | 242 | $this->ensure_construct_finalized_called(); |
243 | 243 | } |
244 | 244 | return isset($this->_subsections[$name]) ? $this->_subsections[$name] : NULL; |
@@ -250,10 +250,10 @@ discard block |
||
250 | 250 | * Gets all the validatable subsections of this form section |
251 | 251 | * @return EE_Form_Section_Validatable[] |
252 | 252 | */ |
253 | - public function get_validatable_subsections(){ |
|
253 | + public function get_validatable_subsections() { |
|
254 | 254 | $validatable_subsections = array(); |
255 | - foreach($this->subsections() as $name=>$obj){ |
|
256 | - if($obj instanceof EE_Form_Section_Validatable){ |
|
255 | + foreach ($this->subsections() as $name=>$obj) { |
|
256 | + if ($obj instanceof EE_Form_Section_Validatable) { |
|
257 | 257 | $validatable_subsections[$name] = $obj; |
258 | 258 | } |
259 | 259 | } |
@@ -273,10 +273,10 @@ discard block |
||
273 | 273 | * @return EE_Form_Input_Base |
274 | 274 | * @throws EE_Error |
275 | 275 | */ |
276 | - public function get_input($name, $require_construction_to_be_finalized = TRUE ){ |
|
276 | + public function get_input($name, $require_construction_to_be_finalized = TRUE) { |
|
277 | 277 | $subsection = $this->get_subsection($name, $require_construction_to_be_finalized); |
278 | - if( ! $subsection instanceof EE_Form_Input_Base){ |
|
279 | - 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'))); |
|
278 | + if ( ! $subsection instanceof EE_Form_Input_Base) { |
|
279 | + 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'))); |
|
280 | 280 | } |
281 | 281 | return $subsection; |
282 | 282 | } |
@@ -294,10 +294,10 @@ discard block |
||
294 | 294 | * @return EE_Form_Section_Proper |
295 | 295 | * @throws EE_Error |
296 | 296 | */ |
297 | - public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE ){ |
|
298 | - $subsection = $this->get_subsection( $name, $require_construction_to_be_finalized ); |
|
299 | - if( ! $subsection instanceof EE_Form_Section_Proper){ |
|
300 | - throw new EE_Error(sprintf(__("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'),$name, get_class($this))); |
|
297 | + public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE) { |
|
298 | + $subsection = $this->get_subsection($name, $require_construction_to_be_finalized); |
|
299 | + if ( ! $subsection instanceof EE_Form_Section_Proper) { |
|
300 | + throw new EE_Error(sprintf(__("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'), $name, get_class($this))); |
|
301 | 301 | } |
302 | 302 | return $subsection; |
303 | 303 | } |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | * @param string $name |
311 | 311 | * @return mixed depending on the input's type and its normalization strategy |
312 | 312 | */ |
313 | - public function get_input_value($name){ |
|
313 | + public function get_input_value($name) { |
|
314 | 314 | $input = $this->get_input($name); |
315 | 315 | return $input->normalized_value(); |
316 | 316 | } |
@@ -323,16 +323,16 @@ discard block |
||
323 | 323 | * @return boolean |
324 | 324 | */ |
325 | 325 | public function is_valid() { |
326 | - if( ! $this->has_received_submission()){ |
|
326 | + if ( ! $this->has_received_submission()) { |
|
327 | 327 | throw new EE_Error(sprintf(__("You cannot check if a form is valid before receiving the form submission using receive_form_submission", "event_espresso"))); |
328 | 328 | } |
329 | - if( ! parent::is_valid()){ |
|
329 | + if ( ! parent::is_valid()) { |
|
330 | 330 | return false; |
331 | 331 | } |
332 | 332 | //ok so no errors general to this entire form section. so let's check the subsections |
333 | - foreach( $this->get_validatable_subsections() as $subsection ){ |
|
334 | - if( ! $subsection->is_valid() || $subsection->get_validation_error_string() != '' ){ |
|
335 | - $this->set_submission_error_message( $subsection->get_validation_error_string() ); |
|
333 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
334 | + if ( ! $subsection->is_valid() || $subsection->get_validation_error_string() != '') { |
|
335 | + $this->set_submission_error_message($subsection->get_validation_error_string()); |
|
336 | 336 | return false; |
337 | 337 | } |
338 | 338 | } |
@@ -345,11 +345,11 @@ discard block |
||
345 | 345 | * gets teh default name of this form section if none is specified |
346 | 346 | * @return string |
347 | 347 | */ |
348 | - protected function _set_default_name_if_empty(){ |
|
349 | - if( ! $this->_name ){ |
|
348 | + protected function _set_default_name_if_empty() { |
|
349 | + if ( ! $this->_name) { |
|
350 | 350 | $classname = get_class($this); |
351 | 351 | $default_name = str_replace("EE_", "", $classname); |
352 | - $this->_name = $default_name; |
|
352 | + $this->_name = $default_name; |
|
353 | 353 | } |
354 | 354 | } |
355 | 355 | |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | * Also returns the HTML for the form, except for the form opening and closing tags |
361 | 361 | * (as the form section doesn't know where you necessarily want to send the information to), and except for a submit button. |
362 | 362 | */ |
363 | - public function get_html_and_js(){ |
|
363 | + public function get_html_and_js() { |
|
364 | 364 | $this->enqueue_js(); |
365 | 365 | return $this->get_html(); |
366 | 366 | } |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | * returns HTML for displaying this form section. recursively calls display_section() on all subsections |
372 | 372 | * @return string |
373 | 373 | */ |
374 | - public function get_html(){ |
|
374 | + public function get_html() { |
|
375 | 375 | $this->ensure_construct_finalized_called(); |
376 | 376 | return $this->_layout_strategy->layout_form(); |
377 | 377 | } |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | * enqueues JS for the form |
383 | 383 | * @return string |
384 | 384 | */ |
385 | - public function enqueue_js(){ |
|
385 | + public function enqueue_js() { |
|
386 | 386 | $this->_enqueue_and_localize_form_js(); |
387 | 387 | } |
388 | 388 | |
@@ -398,10 +398,10 @@ discard block |
||
398 | 398 | * @param boolean $init_form_validation_automatically whether or not we want the form validation to be triggered automatically or not |
399 | 399 | * @return void |
400 | 400 | */ |
401 | - public static function wp_enqueue_scripts( $init_form_validation_automatically = false ){ |
|
402 | - add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
|
403 | - wp_register_script( 'ee_form_section_validation', EE_GLOBAL_ASSETS_URL . 'scripts' . DS . 'form_section_validation.js', array( 'jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods' ), EVENT_ESPRESSO_VERSION, TRUE ); |
|
404 | - wp_localize_script( 'ee_form_section_validation', 'ee_form_section_validation_init', array( 'init' => $init_form_validation_automatically ) ); |
|
401 | + public static function wp_enqueue_scripts($init_form_validation_automatically = false) { |
|
402 | + add_filter('FHEE_load_jquery_validate', '__return_true'); |
|
403 | + wp_register_script('ee_form_section_validation', EE_GLOBAL_ASSETS_URL.'scripts'.DS.'form_section_validation.js', array('jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods'), EVENT_ESPRESSO_VERSION, TRUE); |
|
404 | + wp_localize_script('ee_form_section_validation', 'ee_form_section_validation_init', array('init' => $init_form_validation_automatically)); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | |
@@ -411,14 +411,14 @@ discard block |
||
411 | 411 | * This needs to be called AFTER we've called $this->_enqueue_jquery_validate_script, |
412 | 412 | * but before the wordpress hook wp_loaded |
413 | 413 | */ |
414 | - public function _enqueue_and_localize_form_js(){ |
|
414 | + public function _enqueue_and_localize_form_js() { |
|
415 | 415 | $this->ensure_construct_finalized_called(); |
416 | 416 | //actually, we don't want to localize just yet. There may be other forms on the page. |
417 | 417 | //so we need to add our form section data to a static variable accessible by all form sections |
418 | 418 | //and localize it just before the footer |
419 | 419 | $this->localize_validation_rules(); |
420 | - add_action( 'wp_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ), 2 ); |
|
421 | - add_action( 'admin_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ) ); |
|
420 | + add_action('wp_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'), 2); |
|
421 | + add_action('admin_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms')); |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | |
@@ -428,11 +428,11 @@ discard block |
||
428 | 428 | * @param bool $return_for_subsection |
429 | 429 | * @return void |
430 | 430 | */ |
431 | - public function localize_validation_rules( $return_for_subsection = FALSE ){ |
|
431 | + public function localize_validation_rules($return_for_subsection = FALSE) { |
|
432 | 432 | // 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 |
433 | - if ( ! $this->parent_section() || $return_for_subsection ) { |
|
434 | - EE_Form_Section_Proper::$_js_localization['form_data'][ $this->html_id() ] = array( |
|
435 | - 'form_section_id'=> $this->html_id( TRUE ), |
|
433 | + if ( ! $this->parent_section() || $return_for_subsection) { |
|
434 | + EE_Form_Section_Proper::$_js_localization['form_data'][$this->html_id()] = array( |
|
435 | + 'form_section_id'=> $this->html_id(TRUE), |
|
436 | 436 | 'validation_rules'=> $this->get_jquery_validation_rules(), |
437 | 437 | 'other_data' => $this->get_other_js_data(), |
438 | 438 | 'errors'=> $this->subsection_validation_errors_by_html_name() |
@@ -448,9 +448,9 @@ discard block |
||
448 | 448 | * @param array $form_other_js_data |
449 | 449 | * @return array |
450 | 450 | */ |
451 | - public function get_other_js_data( $form_other_js_data = array() ) { |
|
452 | - foreach( $this->subsections() as $subsection ) { |
|
453 | - $form_other_js_data = $subsection->get_other_js_data( $form_other_js_data ); |
|
451 | + public function get_other_js_data($form_other_js_data = array()) { |
|
452 | + foreach ($this->subsections() as $subsection) { |
|
453 | + $form_other_js_data = $subsection->get_other_js_data($form_other_js_data); |
|
454 | 454 | } |
455 | 455 | return $form_other_js_data; |
456 | 456 | } |
@@ -461,12 +461,12 @@ discard block |
||
461 | 461 | * Keys are their form names, and values are the inputs themselves |
462 | 462 | * @return EE_Form_Input_Base |
463 | 463 | */ |
464 | - public function inputs_in_subsections(){ |
|
464 | + public function inputs_in_subsections() { |
|
465 | 465 | $inputs = array(); |
466 | - foreach($this->subsections() as $subsection){ |
|
467 | - if( $subsection instanceof EE_Form_Input_Base ){ |
|
468 | - $inputs[ $subsection->html_name() ] = $subsection; |
|
469 | - }elseif($subsection instanceof EE_Form_Section_Proper ){ |
|
466 | + foreach ($this->subsections() as $subsection) { |
|
467 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
468 | + $inputs[$subsection->html_name()] = $subsection; |
|
469 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
470 | 470 | $inputs += $subsection->inputs_in_subsections(); |
471 | 471 | } |
472 | 472 | } |
@@ -479,12 +479,12 @@ discard block |
||
479 | 479 | * and values are a string of all their validation errors |
480 | 480 | * @return string[] |
481 | 481 | */ |
482 | - public function subsection_validation_errors_by_html_name(){ |
|
482 | + public function subsection_validation_errors_by_html_name() { |
|
483 | 483 | $inputs = $this->inputs(); |
484 | 484 | $errors = array(); |
485 | - foreach( $inputs as $form_input ){ |
|
486 | - if ( $form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors() ){ |
|
487 | - $errors[ $form_input->html_name() ] = $form_input->get_validation_error_string(); |
|
485 | + foreach ($inputs as $form_input) { |
|
486 | + if ($form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors()) { |
|
487 | + $errors[$form_input->html_name()] = $form_input->get_validation_error_string(); |
|
488 | 488 | } |
489 | 489 | } |
490 | 490 | return $errors; |
@@ -496,16 +496,16 @@ discard block |
||
496 | 496 | * passes all the form data required by the JS to the JS, and enqueues the few required JS files. |
497 | 497 | * Should be setup by each form during the _enqueues_and_localize_form_js |
498 | 498 | */ |
499 | - public static function localize_script_for_all_forms(){ |
|
499 | + public static function localize_script_for_all_forms() { |
|
500 | 500 | //allow inputs and stuff to hook in their JS and stuff here |
501 | 501 | do_action('AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin'); |
502 | 502 | EE_Form_Section_Proper::$_js_localization['localized_error_messages'] = EE_Form_Section_Proper::_get_localized_error_messages(); |
503 | - $email_validation_level = isset( EE_Registry::instance()->CFG->registration->email_validation_level ) |
|
503 | + $email_validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level) |
|
504 | 504 | ? EE_Registry::instance()->CFG->registration->email_validation_level |
505 | 505 | : 'wp_default'; |
506 | 506 | EE_Form_Section_Proper::$_js_localization['email_validation_level'] = $email_validation_level; |
507 | - wp_enqueue_script( 'ee_form_section_validation' ); |
|
508 | - wp_localize_script( 'ee_form_section_validation', 'ee_form_section_vars', EE_Form_Section_Proper::$_js_localization ); |
|
507 | + wp_enqueue_script('ee_form_section_validation'); |
|
508 | + wp_localize_script('ee_form_section_validation', 'ee_form_section_vars', EE_Form_Section_Proper::$_js_localization); |
|
509 | 509 | } |
510 | 510 | |
511 | 511 | |
@@ -513,8 +513,8 @@ discard block |
||
513 | 513 | /** |
514 | 514 | * ensure_scripts_localized |
515 | 515 | */ |
516 | - public function ensure_scripts_localized(){ |
|
517 | - if ( ! EE_Form_Section_Proper::$_scripts_localized ) { |
|
516 | + public function ensure_scripts_localized() { |
|
517 | + if ( ! EE_Form_Section_Proper::$_scripts_localized) { |
|
518 | 518 | $this->_enqueue_and_localize_form_js(); |
519 | 519 | } |
520 | 520 | } |
@@ -526,10 +526,10 @@ discard block |
||
526 | 526 | * is that the key here should be the same as the custom validation rule put in the JS file |
527 | 527 | * @return array keys are custom validation rules, and values are internationalized strings |
528 | 528 | */ |
529 | - private static function _get_localized_error_messages(){ |
|
529 | + private static function _get_localized_error_messages() { |
|
530 | 530 | return array( |
531 | 531 | 'validUrl'=> __("This is not a valid absolute URL. Eg, http://domain.com/monkey.jpg", "event_espresso"), |
532 | - 'regex' => __( 'Please check your input', 'event_espresso' ), |
|
532 | + 'regex' => __('Please check your input', 'event_espresso'), |
|
533 | 533 | ); |
534 | 534 | } |
535 | 535 | |
@@ -557,10 +557,10 @@ discard block |
||
557 | 557 | * Gets the JS to put inside the jquery validation rules for subsection of this form section. See parent function for more... |
558 | 558 | * @return array |
559 | 559 | */ |
560 | - public function get_jquery_validation_rules(){ |
|
560 | + public function get_jquery_validation_rules() { |
|
561 | 561 | $jquery_validation_rules = array(); |
562 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
563 | - $jquery_validation_rules = array_merge( $jquery_validation_rules, $subsection->get_jquery_validation_rules() ); |
|
562 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
563 | + $jquery_validation_rules = array_merge($jquery_validation_rules, $subsection->get_jquery_validation_rules()); |
|
564 | 564 | } |
565 | 565 | return $jquery_validation_rules; |
566 | 566 | } |
@@ -575,11 +575,11 @@ discard block |
||
575 | 575 | protected function _normalize($req_data) { |
576 | 576 | $this->_received_submission = TRUE; |
577 | 577 | $this->_validation_errors = array(); |
578 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
579 | - try{ |
|
578 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
579 | + try { |
|
580 | 580 | $subsection->_normalize($req_data); |
581 | - }catch( EE_Validation_Error $e ){ |
|
582 | - $subsection->add_validation_error( $e ); |
|
581 | + } catch (EE_Validation_Error $e) { |
|
582 | + $subsection->add_validation_error($e); |
|
583 | 583 | } |
584 | 584 | } |
585 | 585 | } |
@@ -593,9 +593,9 @@ discard block |
||
593 | 593 | * calling parent::_validate() first. |
594 | 594 | */ |
595 | 595 | protected function _validate() { |
596 | - foreach($this->get_validatable_subsections() as $subsection_name => $subsection){ |
|
597 | - if(method_exists($this,'_validate_'.$subsection_name)){ |
|
598 | - call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection)); |
|
596 | + foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) { |
|
597 | + if (method_exists($this, '_validate_'.$subsection_name)) { |
|
598 | + call_user_func_array(array($this, '_validate_'.$subsection_name), array($subsection)); |
|
599 | 599 | } |
600 | 600 | $subsection->_validate(); |
601 | 601 | } |
@@ -607,13 +607,13 @@ discard block |
||
607 | 607 | * Gets all the validated inputs for the form section |
608 | 608 | * @return array |
609 | 609 | */ |
610 | - public function valid_data(){ |
|
610 | + public function valid_data() { |
|
611 | 611 | $inputs = array(); |
612 | - foreach( $this->subsections() as $subsection_name =>$subsection ){ |
|
613 | - if ( $subsection instanceof EE_Form_Section_Proper ) { |
|
614 | - $inputs[ $subsection_name ] = $subsection->valid_data(); |
|
615 | - } else if ( $subsection instanceof EE_Form_Input_Base ){ |
|
616 | - $inputs[ $subsection_name ] = $subsection->normalized_value(); |
|
612 | + foreach ($this->subsections() as $subsection_name =>$subsection) { |
|
613 | + if ($subsection instanceof EE_Form_Section_Proper) { |
|
614 | + $inputs[$subsection_name] = $subsection->valid_data(); |
|
615 | + } else if ($subsection instanceof EE_Form_Input_Base) { |
|
616 | + $inputs[$subsection_name] = $subsection->normalized_value(); |
|
617 | 617 | } |
618 | 618 | } |
619 | 619 | return $inputs; |
@@ -625,11 +625,11 @@ discard block |
||
625 | 625 | * Gets all the inputs on this form section |
626 | 626 | * @return EE_Form_Input_Base[] |
627 | 627 | */ |
628 | - public function inputs(){ |
|
628 | + public function inputs() { |
|
629 | 629 | $inputs = array(); |
630 | - foreach( $this->subsections() as $subsection_name =>$subsection ){ |
|
631 | - if ( $subsection instanceof EE_Form_Input_Base ){ |
|
632 | - $inputs[ $subsection_name ] = $subsection; |
|
630 | + foreach ($this->subsections() as $subsection_name =>$subsection) { |
|
631 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
632 | + $inputs[$subsection_name] = $subsection; |
|
633 | 633 | } |
634 | 634 | } |
635 | 635 | return $inputs; |
@@ -641,10 +641,10 @@ discard block |
||
641 | 641 | * Gets all the subsections which are a proper form |
642 | 642 | * @return EE_Form_Section_Proper[] |
643 | 643 | */ |
644 | - public function subforms(){ |
|
644 | + public function subforms() { |
|
645 | 645 | $form_sections = array(); |
646 | - foreach($this->subsections() as $name=>$obj){ |
|
647 | - if($obj instanceof EE_Form_Section_Proper){ |
|
646 | + foreach ($this->subsections() as $name=>$obj) { |
|
647 | + if ($obj instanceof EE_Form_Section_Proper) { |
|
648 | 648 | $form_sections[$name] = $obj; |
649 | 649 | } |
650 | 650 | } |
@@ -659,7 +659,7 @@ discard block |
||
659 | 659 | * if you only want form inputs or proper form sections. |
660 | 660 | * @return EE_Form_Section_Proper[] |
661 | 661 | */ |
662 | - public function subsections(){ |
|
662 | + public function subsections() { |
|
663 | 663 | $this->ensure_construct_finalized_called(); |
664 | 664 | return $this->_subsections; |
665 | 665 | } |
@@ -677,8 +677,8 @@ discard block |
||
677 | 677 | * it can be a multidimensional array where keys are always subsection names and values are either the |
678 | 678 | * input's normalized value, or an array like the top-level array |
679 | 679 | */ |
680 | - public function input_values( $include_subform_inputs = false, $flatten = false ){ |
|
681 | - return $this->_input_values( false, $include_subform_inputs, $flatten ); |
|
680 | + public function input_values($include_subform_inputs = false, $flatten = false) { |
|
681 | + return $this->_input_values(false, $include_subform_inputs, $flatten); |
|
682 | 682 | } |
683 | 683 | |
684 | 684 | /** |
@@ -694,8 +694,8 @@ discard block |
||
694 | 694 | * it can be a multidimensional array where keys are always subsection names and values are either the |
695 | 695 | * input's normalized value, or an array like the top-level array |
696 | 696 | */ |
697 | - public function input_pretty_values( $include_subform_inputs = false, $flatten = false ){ |
|
698 | - return $this->_input_values( true, $include_subform_inputs, $flatten ); |
|
697 | + public function input_pretty_values($include_subform_inputs = false, $flatten = false) { |
|
698 | + return $this->_input_values(true, $include_subform_inputs, $flatten); |
|
699 | 699 | } |
700 | 700 | |
701 | 701 | /** |
@@ -708,17 +708,17 @@ discard block |
||
708 | 708 | * it can be a multidimensional array where keys are always subsection names and values are either the |
709 | 709 | * input's normalized value, or an array like the top-level array |
710 | 710 | */ |
711 | - public function _input_values( $pretty = false, $include_subform_inputs = false, $flatten = false ) { |
|
711 | + public function _input_values($pretty = false, $include_subform_inputs = false, $flatten = false) { |
|
712 | 712 | $input_values = array(); |
713 | - foreach( $this->subsections() as $subsection_name => $subsection ) { |
|
714 | - if( $subsection instanceof EE_Form_Input_Base ) { |
|
715 | - $input_values[ $subsection_name ] = $pretty ? $subsection->pretty_value() : $subsection->normalized_value(); |
|
716 | - } else if( $subsection instanceof EE_Form_Section_Proper && $include_subform_inputs ) { |
|
717 | - $subform_input_values = $subsection->_input_values( $pretty, $include_subform_inputs, $flatten ); |
|
718 | - if( $flatten ) { |
|
719 | - $input_values = array_merge( $input_values, $subform_input_values ); |
|
713 | + foreach ($this->subsections() as $subsection_name => $subsection) { |
|
714 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
715 | + $input_values[$subsection_name] = $pretty ? $subsection->pretty_value() : $subsection->normalized_value(); |
|
716 | + } else if ($subsection instanceof EE_Form_Section_Proper && $include_subform_inputs) { |
|
717 | + $subform_input_values = $subsection->_input_values($pretty, $include_subform_inputs, $flatten); |
|
718 | + if ($flatten) { |
|
719 | + $input_values = array_merge($input_values, $subform_input_values); |
|
720 | 720 | } else { |
721 | - $input_values[ $subsection_name ] = $subform_input_values; |
|
721 | + $input_values[$subsection_name] = $subform_input_values; |
|
722 | 722 | } |
723 | 723 | } |
724 | 724 | } |
@@ -732,7 +732,7 @@ discard block |
||
732 | 732 | * (ie, had receive_form_submission called on it yet) |
733 | 733 | * @return boolean |
734 | 734 | */ |
735 | - public function has_received_submission(){ |
|
735 | + public function has_received_submission() { |
|
736 | 736 | $this->ensure_construct_finalized_called(); |
737 | 737 | return $this->_received_submission; |
738 | 738 | } |
@@ -745,8 +745,8 @@ discard block |
||
745 | 745 | * @param array $inputs_to_exclude values are the input names |
746 | 746 | * @return void |
747 | 747 | */ |
748 | - public function exclude($inputs_to_exclude = array()){ |
|
749 | - foreach($inputs_to_exclude as $input_to_exclude_name){ |
|
748 | + public function exclude($inputs_to_exclude = array()) { |
|
749 | + foreach ($inputs_to_exclude as $input_to_exclude_name) { |
|
750 | 750 | unset($this->_subsections[$input_to_exclude_name]); |
751 | 751 | } |
752 | 752 | } |
@@ -756,8 +756,8 @@ discard block |
||
756 | 756 | /** |
757 | 757 | * @param array $inputs_to_hide |
758 | 758 | */ |
759 | - public function hide($inputs_to_hide= array()){ |
|
760 | - foreach($inputs_to_hide as $input_to_hide){ |
|
759 | + public function hide($inputs_to_hide = array()) { |
|
760 | + foreach ($inputs_to_hide as $input_to_hide) { |
|
761 | 761 | $input = $this->get_input($input_to_hide); |
762 | 762 | |
763 | 763 | $input->set_display_strategy(new EE_Hidden_Display_Strategy()); |
@@ -782,13 +782,13 @@ discard block |
||
782 | 782 | * or if $subsection_name_to_target is null, before or after entire subsections array |
783 | 783 | * @return void |
784 | 784 | */ |
785 | - public function add_subsections( $new_subsections, $subsection_name_to_target = NULL, $add_before = true ){ |
|
786 | - foreach($new_subsections as $subsection_name => $subsection){ |
|
787 | - if( ! $subsection instanceof EE_Form_Section_Base){ |
|
785 | + public function add_subsections($new_subsections, $subsection_name_to_target = NULL, $add_before = true) { |
|
786 | + foreach ($new_subsections as $subsection_name => $subsection) { |
|
787 | + if ( ! $subsection instanceof EE_Form_Section_Base) { |
|
788 | 788 | EE_Error::add_error( |
789 | 789 | sprintf( |
790 | 790 | __("Trying to add a %s as a subsection (it was named '%s') to the form section '%s'. It was removed.", "event_espresso"), |
791 | - get_class( $subsection ), |
|
791 | + get_class($subsection), |
|
792 | 792 | $subsection_name, |
793 | 793 | $this->name() |
794 | 794 | ) |
@@ -797,7 +797,7 @@ discard block |
||
797 | 797 | } |
798 | 798 | } |
799 | 799 | |
800 | - $this->_subsections = EEH_Array::insert_into_array( $this->_subsections, $new_subsections, $subsection_name_to_target, $add_before ); |
|
800 | + $this->_subsections = EEH_Array::insert_into_array($this->_subsections, $new_subsections, $subsection_name_to_target, $add_before); |
|
801 | 801 | |
802 | 802 | /*$subsections_before = array(); |
803 | 803 | if( $subsection_name_to_target ){ |
@@ -828,8 +828,8 @@ discard block |
||
828 | 828 | $this->_subsections = $new_subsections; |
829 | 829 | } |
830 | 830 | }*/ |
831 | - if( $this->_construction_finalized ){ |
|
832 | - foreach($this->_subsections as $name => $subsection){ |
|
831 | + if ($this->_construction_finalized) { |
|
832 | + foreach ($this->_subsections as $name => $subsection) { |
|
833 | 833 | $subsection->_construct_finalize($this, $name); |
834 | 834 | } |
835 | 835 | } |
@@ -840,8 +840,8 @@ discard block |
||
840 | 840 | /** |
841 | 841 | * Just gets all validatable subsections to clean their sensitive data |
842 | 842 | */ |
843 | - public function clean_sensitive_data(){ |
|
844 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
843 | + public function clean_sensitive_data() { |
|
844 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
845 | 845 | $subsection->clean_sensitive_data(); |
846 | 846 | } |
847 | 847 | } |
@@ -851,8 +851,8 @@ discard block |
||
851 | 851 | /** |
852 | 852 | * @param string $form_submission_error_message |
853 | 853 | */ |
854 | - public function set_submission_error_message( $form_submission_error_message = '' ) { |
|
855 | - $this->_form_submission_error_message .= ! empty( $form_submission_error_message ) ? $form_submission_error_message : __( 'Form submission failed due to errors', 'event_espresso' ); |
|
854 | + public function set_submission_error_message($form_submission_error_message = '') { |
|
855 | + $this->_form_submission_error_message .= ! empty($form_submission_error_message) ? $form_submission_error_message : __('Form submission failed due to errors', 'event_espresso'); |
|
856 | 856 | } |
857 | 857 | |
858 | 858 | |
@@ -869,8 +869,8 @@ discard block |
||
869 | 869 | /** |
870 | 870 | * @param string $form_submission_success_message |
871 | 871 | */ |
872 | - public function set_submission_success_message( $form_submission_success_message ) { |
|
873 | - $this->_form_submission_success_message .= ! empty( $form_submission_success_message ) ? $form_submission_success_message : __( 'Form submitted successfully', 'event_espresso' ); |
|
872 | + public function set_submission_success_message($form_submission_success_message) { |
|
873 | + $this->_form_submission_success_message .= ! empty($form_submission_success_message) ? $form_submission_success_message : __('Form submitted successfully', 'event_espresso'); |
|
874 | 874 | } |
875 | 875 | |
876 | 876 | |
@@ -892,10 +892,10 @@ discard block |
||
892 | 892 | * EE_Form_Input_Base::_set_default_html_name_if_empty |
893 | 893 | * @return string |
894 | 894 | */ |
895 | - public function html_name_prefix(){ |
|
896 | - if( $this->parent_section() instanceof EE_Form_Section_Proper ){ |
|
897 | - return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']'; |
|
898 | - }else{ |
|
895 | + public function html_name_prefix() { |
|
896 | + if ($this->parent_section() instanceof EE_Form_Section_Proper) { |
|
897 | + return $this->parent_section()->html_name_prefix().'['.$this->name().']'; |
|
898 | + } else { |
|
899 | 899 | return $this->name(); |
900 | 900 | } |
901 | 901 | } |
@@ -906,7 +906,7 @@ discard block |
||
906 | 906 | * was set, which is probably nothing, or the classname) |
907 | 907 | * @return string |
908 | 908 | */ |
909 | - public function name(){ |
|
909 | + public function name() { |
|
910 | 910 | $this->ensure_construct_finalized_called(); |
911 | 911 | return parent::name(); |
912 | 912 | } |
@@ -915,7 +915,7 @@ discard block |
||
915 | 915 | * |
916 | 916 | * @return EE_Form_Section_Proper |
917 | 917 | */ |
918 | - public function parent_section(){ |
|
918 | + public function parent_section() { |
|
919 | 919 | $this->ensure_construct_finalized_called(); |
920 | 920 | return parent::parent_section(); |
921 | 921 | } |
@@ -924,9 +924,9 @@ discard block |
||
924 | 924 | * make sure construction finalized was called, otherwise children might not be ready |
925 | 925 | * @return void |
926 | 926 | */ |
927 | - public function ensure_construct_finalized_called(){ |
|
928 | - if( ! $this->_construction_finalized ){ |
|
929 | - $this->_construct_finalize($this->_parent_section, $this->_name ); |
|
927 | + public function ensure_construct_finalized_called() { |
|
928 | + if ( ! $this->_construction_finalized) { |
|
929 | + $this->_construct_finalize($this->_parent_section, $this->_name); |
|
930 | 930 | } |
931 | 931 | } |
932 | 932 | |
@@ -938,17 +938,17 @@ discard block |
||
938 | 938 | * @param array $req_data |
939 | 939 | * @return boolean |
940 | 940 | */ |
941 | - public function form_data_present_in( $req_data = NULL ) { |
|
942 | - if( $req_data === NULL){ |
|
941 | + public function form_data_present_in($req_data = NULL) { |
|
942 | + if ($req_data === NULL) { |
|
943 | 943 | $req_data = $_POST; |
944 | 944 | } |
945 | - foreach( $this->subsections() as $subsection ) { |
|
946 | - if($subsection instanceof EE_Form_Input_Base ) { |
|
947 | - if( $subsection->form_data_present_in( $req_data ) ) { |
|
945 | + foreach ($this->subsections() as $subsection) { |
|
946 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
947 | + if ($subsection->form_data_present_in($req_data)) { |
|
948 | 948 | return TRUE; |
949 | 949 | } |
950 | - }elseif( $subsection instanceof EE_Form_Section_Proper ) { |
|
951 | - if( $subsection->form_data_present_in( $req_data ) ) { |
|
950 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
951 | + if ($subsection->form_data_present_in($req_data)) { |
|
952 | 952 | return TRUE; |
953 | 953 | } |
954 | 954 | } |
@@ -965,14 +965,14 @@ discard block |
||
965 | 965 | */ |
966 | 966 | public function get_validation_errors_accumulated() { |
967 | 967 | $validation_errors = $this->get_validation_errors(); |
968 | - foreach($this->get_validatable_subsections() as $subsection ) { |
|
969 | - if( $subsection instanceof EE_Form_Section_Proper ) { |
|
968 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
969 | + if ($subsection instanceof EE_Form_Section_Proper) { |
|
970 | 970 | $validation_errors_on_this_subsection = $subsection->get_validation_errors_accumulated(); |
971 | 971 | } else { |
972 | - $validation_errors_on_this_subsection = $subsection->get_validation_errors(); |
|
972 | + $validation_errors_on_this_subsection = $subsection->get_validation_errors(); |
|
973 | 973 | } |
974 | - if( $validation_errors_on_this_subsection ){ |
|
975 | - $validation_errors = array_merge( $validation_errors, $validation_errors_on_this_subsection ); |
|
974 | + if ($validation_errors_on_this_subsection) { |
|
975 | + $validation_errors = array_merge($validation_errors, $validation_errors_on_this_subsection); |
|
976 | 976 | } |
977 | 977 | } |
978 | 978 | return $validation_errors; |
@@ -994,24 +994,24 @@ discard block |
||
994 | 994 | * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false |
995 | 995 | * @return EE_Form_Section_Base |
996 | 996 | */ |
997 | - public function find_section_from_path( $form_section_path ) { |
|
997 | + public function find_section_from_path($form_section_path) { |
|
998 | 998 | //check if we can find the input from purely going straight up the tree |
999 | - $input = parent::find_section_from_path( $form_section_path ); |
|
1000 | - if( $input instanceof EE_Form_Section_Base ) { |
|
999 | + $input = parent::find_section_from_path($form_section_path); |
|
1000 | + if ($input instanceof EE_Form_Section_Base) { |
|
1001 | 1001 | return $input; |
1002 | 1002 | } |
1003 | 1003 | |
1004 | - $next_slash_pos = strpos( $form_section_path, '/' ); |
|
1005 | - if( $next_slash_pos !== false ) { |
|
1006 | - $child_section_name = substr( $form_section_path, 0, $next_slash_pos ); |
|
1007 | - $subpath = substr( $form_section_path, $next_slash_pos + 1 ); |
|
1004 | + $next_slash_pos = strpos($form_section_path, '/'); |
|
1005 | + if ($next_slash_pos !== false) { |
|
1006 | + $child_section_name = substr($form_section_path, 0, $next_slash_pos); |
|
1007 | + $subpath = substr($form_section_path, $next_slash_pos + 1); |
|
1008 | 1008 | } else { |
1009 | 1009 | $child_section_name = $form_section_path; |
1010 | 1010 | $subpath = ''; |
1011 | 1011 | } |
1012 | - $child_section = $this->get_subsection( $child_section_name ); |
|
1013 | - if ( $child_section instanceof EE_Form_Section_Base ) { |
|
1014 | - return $child_section->find_section_from_path( $subpath ); |
|
1012 | + $child_section = $this->get_subsection($child_section_name); |
|
1013 | + if ($child_section instanceof EE_Form_Section_Base) { |
|
1014 | + return $child_section->find_section_from_path($subpath); |
|
1015 | 1015 | } else { |
1016 | 1016 | return null; |
1017 | 1017 | } |
@@ -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 |