@@ -11,18 +11,18 @@ |
||
11 | 11 | */ |
12 | 12 | class EE_Credit_Card_Sensitive_Data_Removal extends EE_Sensitive_Data_Removal_Base |
13 | 13 | { |
14 | - public function remove_sensitive_data($normalized_value) |
|
15 | - { |
|
16 | - // Get the cc Length |
|
17 | - $cc_length = strlen($normalized_value); |
|
18 | - // Replace all characters of credit card except the last four and dashes |
|
19 | - for ($i=0; $i<$cc_length-4; $i++) { |
|
20 | - if ($normalized_value[ $i ] == '-') { |
|
21 | - continue; |
|
22 | - } |
|
23 | - $normalized_value[ $i ] = 'X'; |
|
24 | - } |
|
25 | - // Return the masked Credit Card # |
|
26 | - return $normalized_value; |
|
27 | - } |
|
14 | + public function remove_sensitive_data($normalized_value) |
|
15 | + { |
|
16 | + // Get the cc Length |
|
17 | + $cc_length = strlen($normalized_value); |
|
18 | + // Replace all characters of credit card except the last four and dashes |
|
19 | + for ($i=0; $i<$cc_length-4; $i++) { |
|
20 | + if ($normalized_value[ $i ] == '-') { |
|
21 | + continue; |
|
22 | + } |
|
23 | + $normalized_value[ $i ] = 'X'; |
|
24 | + } |
|
25 | + // Return the masked Credit Card # |
|
26 | + return $normalized_value; |
|
27 | + } |
|
28 | 28 | } |
@@ -16,11 +16,11 @@ |
||
16 | 16 | // Get the cc Length |
17 | 17 | $cc_length = strlen($normalized_value); |
18 | 18 | // Replace all characters of credit card except the last four and dashes |
19 | - for ($i=0; $i<$cc_length-4; $i++) { |
|
20 | - if ($normalized_value[ $i ] == '-') { |
|
19 | + for ($i = 0; $i < $cc_length - 4; $i++) { |
|
20 | + if ($normalized_value[$i] == '-') { |
|
21 | 21 | continue; |
22 | 22 | } |
23 | - $normalized_value[ $i ] = 'X'; |
|
23 | + $normalized_value[$i] = 'X'; |
|
24 | 24 | } |
25 | 25 | // Return the masked Credit Card # |
26 | 26 | return $normalized_value; |
@@ -11,16 +11,16 @@ |
||
11 | 11 | */ |
12 | 12 | abstract class EE_Sensitive_Data_Removal_Base extends EE_Form_Input_Strategy_Base |
13 | 13 | { |
14 | - /** |
|
15 | - * Removes all the sensitive data from this normalized value. |
|
16 | - * For example, should could 'mask' a credit card from |
|
17 | - * '1234 1234 1234 1234' TO '**** **** **** 1234'. |
|
18 | - * Or turn a ccv number from |
|
19 | - * '123' to '***', |
|
20 | - * or turn a password from |
|
21 | - * 'CantHac7Th15' to '*************', |
|
22 | - * or just leave htevalue as-is |
|
23 | - * @return mixed |
|
24 | - */ |
|
25 | - abstract public function remove_sensitive_data($normalized_value); |
|
14 | + /** |
|
15 | + * Removes all the sensitive data from this normalized value. |
|
16 | + * For example, should could 'mask' a credit card from |
|
17 | + * '1234 1234 1234 1234' TO '**** **** **** 1234'. |
|
18 | + * Or turn a ccv number from |
|
19 | + * '123' to '***', |
|
20 | + * or turn a password from |
|
21 | + * 'CantHac7Th15' to '*************', |
|
22 | + * or just leave htevalue as-is |
|
23 | + * @return mixed |
|
24 | + */ |
|
25 | + abstract public function remove_sensitive_data($normalized_value); |
|
26 | 26 | } |
@@ -11,23 +11,23 @@ |
||
11 | 11 | */ |
12 | 12 | class EE_All_Sensitive_Data_Removal extends EE_Sensitive_Data_Removal_Base |
13 | 13 | { |
14 | - public function remove_sensitive_data($normalized_value) |
|
15 | - { |
|
16 | - switch (gettype($normalized_value)) { |
|
17 | - case "boolean": |
|
18 | - return false; |
|
19 | - case "integer": |
|
20 | - case "double": |
|
21 | - return 0; |
|
22 | - case "string": |
|
23 | - return ''; |
|
24 | - case "array": |
|
25 | - return array(); |
|
26 | - case "object": |
|
27 | - case "resource": |
|
28 | - case "NULL": |
|
29 | - default: |
|
30 | - return null; |
|
31 | - } |
|
32 | - } |
|
14 | + public function remove_sensitive_data($normalized_value) |
|
15 | + { |
|
16 | + switch (gettype($normalized_value)) { |
|
17 | + case "boolean": |
|
18 | + return false; |
|
19 | + case "integer": |
|
20 | + case "double": |
|
21 | + return 0; |
|
22 | + case "string": |
|
23 | + return ''; |
|
24 | + case "array": |
|
25 | + return array(); |
|
26 | + case "object": |
|
27 | + case "resource": |
|
28 | + case "NULL": |
|
29 | + default: |
|
30 | + return null; |
|
31 | + } |
|
32 | + } |
|
33 | 33 | } |
@@ -11,18 +11,18 @@ |
||
11 | 11 | */ |
12 | 12 | class EE_CCV_Sensitive_Data_Removal extends EE_Sensitive_Data_Removal_Base |
13 | 13 | { |
14 | - public function remove_sensitive_data($normalized_value) |
|
15 | - { |
|
16 | - // Get the ccv Length |
|
17 | - $ccv_lenght = strlen($normalized_value); |
|
18 | - // Replace all characters of credit card except the last four and dashes |
|
19 | - for ($i=0; $i<$ccv_lenght; $i++) { |
|
20 | - if ($normalized_value[ $i ] == '-') { |
|
21 | - continue; |
|
22 | - } |
|
23 | - $normalized_value[ $i ] = 'X'; |
|
24 | - } |
|
25 | - // Return the masked Credit Card # |
|
26 | - return $normalized_value; |
|
27 | - } |
|
14 | + public function remove_sensitive_data($normalized_value) |
|
15 | + { |
|
16 | + // Get the ccv Length |
|
17 | + $ccv_lenght = strlen($normalized_value); |
|
18 | + // Replace all characters of credit card except the last four and dashes |
|
19 | + for ($i=0; $i<$ccv_lenght; $i++) { |
|
20 | + if ($normalized_value[ $i ] == '-') { |
|
21 | + continue; |
|
22 | + } |
|
23 | + $normalized_value[ $i ] = 'X'; |
|
24 | + } |
|
25 | + // Return the masked Credit Card # |
|
26 | + return $normalized_value; |
|
27 | + } |
|
28 | 28 | } |
@@ -16,11 +16,11 @@ |
||
16 | 16 | // Get the ccv Length |
17 | 17 | $ccv_lenght = strlen($normalized_value); |
18 | 18 | // Replace all characters of credit card except the last four and dashes |
19 | - for ($i=0; $i<$ccv_lenght; $i++) { |
|
20 | - if ($normalized_value[ $i ] == '-') { |
|
19 | + for ($i = 0; $i < $ccv_lenght; $i++) { |
|
20 | + if ($normalized_value[$i] == '-') { |
|
21 | 21 | continue; |
22 | 22 | } |
23 | - $normalized_value[ $i ] = 'X'; |
|
23 | + $normalized_value[$i] = 'X'; |
|
24 | 24 | } |
25 | 25 | // Return the masked Credit Card # |
26 | 26 | return $normalized_value; |
@@ -11,8 +11,8 @@ |
||
11 | 11 | */ |
12 | 12 | class EE_No_Sensitive_Data_Removal extends EE_Sensitive_Data_Removal_Base |
13 | 13 | { |
14 | - public function remove_sensitive_data($normalized_value) |
|
15 | - { |
|
16 | - return $normalized_value; |
|
17 | - } |
|
14 | + public function remove_sensitive_data($normalized_value) |
|
15 | + { |
|
16 | + return $normalized_value; |
|
17 | + } |
|
18 | 18 | } |
@@ -15,486 +15,486 @@ |
||
15 | 15 | abstract class EE_Form_Section_Base |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * the URL the form is submitted to |
|
20 | - * |
|
21 | - * @var string |
|
22 | - */ |
|
23 | - protected $_action; |
|
24 | - |
|
25 | - /** |
|
26 | - * POST (default) or GET |
|
27 | - * |
|
28 | - * @var string |
|
29 | - */ |
|
30 | - protected $_method; |
|
31 | - |
|
32 | - /** |
|
33 | - * html_id and html_name are derived from this by default |
|
34 | - * |
|
35 | - * @var string |
|
36 | - */ |
|
37 | - protected $_name; |
|
38 | - |
|
39 | - /** |
|
40 | - * $_html_id |
|
41 | - * @var string |
|
42 | - */ |
|
43 | - protected $_html_id; |
|
44 | - |
|
45 | - /** |
|
46 | - * $_html_class |
|
47 | - * @var string |
|
48 | - */ |
|
49 | - protected $_html_class; |
|
50 | - |
|
51 | - /** |
|
52 | - * $_html_style |
|
53 | - * @var string |
|
54 | - */ |
|
55 | - protected $_html_style; |
|
56 | - |
|
57 | - /** |
|
58 | - * $_other_html_attributes |
|
59 | - * @var string |
|
60 | - */ |
|
61 | - protected $_other_html_attributes; |
|
62 | - |
|
63 | - /** |
|
64 | - * The form section of which this form section is a part |
|
65 | - * |
|
66 | - * @var EE_Form_Section_Proper |
|
67 | - */ |
|
68 | - protected $_parent_section; |
|
69 | - |
|
70 | - /** |
|
71 | - * flag indicating that _construct_finalize has been called. |
|
72 | - * If it has not been called and we try to use functions which require it, we call it |
|
73 | - * with no parameters. But normally, _construct_finalize should be called by the instantiating class |
|
74 | - * |
|
75 | - * @var boolean |
|
76 | - */ |
|
77 | - protected $_construction_finalized; |
|
78 | - |
|
79 | - /** |
|
80 | - * Strategy for parsing the form HTML upon display |
|
81 | - * |
|
82 | - * @var FormHtmlFilter |
|
83 | - */ |
|
84 | - protected $_form_html_filter; |
|
85 | - |
|
86 | - |
|
87 | - /** |
|
88 | - * @param array $options_array { |
|
89 | - * @type $name string the name for this form section, if you want to explicitly define it |
|
90 | - * } |
|
91 | - * @throws InvalidDataTypeException |
|
92 | - */ |
|
93 | - public function __construct($options_array = array()) |
|
94 | - { |
|
95 | - // used by display strategies |
|
96 | - // assign incoming values to properties |
|
97 | - foreach ($options_array as $key => $value) { |
|
98 | - $key = '_' . $key; |
|
99 | - if (property_exists($this, $key) && empty($this->{$key})) { |
|
100 | - $this->{$key} = $value; |
|
101 | - if ($key === '_subsections' && ! is_array($value)) { |
|
102 | - throw new InvalidDataTypeException($key, $value, 'array'); |
|
103 | - } |
|
104 | - } |
|
105 | - } |
|
106 | - // set parser which allows the form section's rendered HTML to be filtered |
|
107 | - if (isset($options_array['form_html_filter']) && $options_array['form_html_filter'] instanceof FormHtmlFilter) { |
|
108 | - $this->_form_html_filter = $options_array['form_html_filter']; |
|
109 | - } |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * @param $parent_form_section |
|
116 | - * @param $name |
|
117 | - * @throws \EE_Error |
|
118 | - */ |
|
119 | - protected function _construct_finalize($parent_form_section, $name) |
|
120 | - { |
|
121 | - $this->_construction_finalized = true; |
|
122 | - $this->_parent_section = $parent_form_section; |
|
123 | - if ($name !== null) { |
|
124 | - $this->_name = $name; |
|
125 | - } |
|
126 | - } |
|
127 | - |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * make sure construction finalized was called, otherwise children might not be ready |
|
132 | - * |
|
133 | - * @return void |
|
134 | - * @throws \EE_Error |
|
135 | - */ |
|
136 | - public function ensure_construct_finalized_called() |
|
137 | - { |
|
138 | - if (! $this->_construction_finalized) { |
|
139 | - $this->_construct_finalize($this->_parent_section, $this->_name); |
|
140 | - } |
|
141 | - } |
|
142 | - |
|
143 | - |
|
144 | - |
|
145 | - /** |
|
146 | - * @return string |
|
147 | - */ |
|
148 | - public function action() |
|
149 | - { |
|
150 | - return $this->_action; |
|
151 | - } |
|
152 | - |
|
153 | - |
|
154 | - |
|
155 | - /** |
|
156 | - * @param string $action |
|
157 | - */ |
|
158 | - public function set_action($action) |
|
159 | - { |
|
160 | - $this->_action = $action; |
|
161 | - } |
|
162 | - |
|
163 | - |
|
164 | - |
|
165 | - /** |
|
166 | - * @return string |
|
167 | - */ |
|
168 | - public function method() |
|
169 | - { |
|
170 | - return ! empty($this->_method) ? $this->_method : 'POST'; |
|
171 | - } |
|
172 | - |
|
173 | - |
|
174 | - |
|
175 | - /** |
|
176 | - * @param string $method |
|
177 | - */ |
|
178 | - public function set_method($method) |
|
179 | - { |
|
180 | - switch ($method) { |
|
181 | - case 'get': |
|
182 | - case 'GET': |
|
183 | - $this->_method = 'GET'; |
|
184 | - break; |
|
185 | - default: |
|
186 | - $this->_method = 'POST'; |
|
187 | - } |
|
188 | - } |
|
189 | - |
|
190 | - |
|
191 | - |
|
192 | - /** |
|
193 | - * Sets the html_id to its default value, if none was specified in the constructor. |
|
194 | - * Calculation involves using the name and the parent's html id |
|
195 | - * return void |
|
196 | - * |
|
197 | - * @throws \EE_Error |
|
198 | - */ |
|
199 | - protected function _set_default_html_id_if_empty() |
|
200 | - { |
|
201 | - if (! $this->_html_id) { |
|
202 | - if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
|
203 | - $this->_html_id = $this->_parent_section->html_id() |
|
204 | - . '-' |
|
205 | - . $this->_prep_name_for_html_id($this->name()); |
|
206 | - } else { |
|
207 | - $this->_html_id = $this->_prep_name_for_html_id($this->name()); |
|
208 | - } |
|
209 | - } |
|
210 | - } |
|
211 | - |
|
212 | - |
|
213 | - |
|
214 | - /** |
|
215 | - * _prep_name_for_html_id |
|
216 | - * |
|
217 | - * @param $name |
|
218 | - * @return string |
|
219 | - */ |
|
220 | - private function _prep_name_for_html_id($name) |
|
221 | - { |
|
222 | - return sanitize_key(str_replace(array(' ', ' ', '_'), '-', $name)); |
|
223 | - } |
|
18 | + /** |
|
19 | + * the URL the form is submitted to |
|
20 | + * |
|
21 | + * @var string |
|
22 | + */ |
|
23 | + protected $_action; |
|
24 | + |
|
25 | + /** |
|
26 | + * POST (default) or GET |
|
27 | + * |
|
28 | + * @var string |
|
29 | + */ |
|
30 | + protected $_method; |
|
31 | + |
|
32 | + /** |
|
33 | + * html_id and html_name are derived from this by default |
|
34 | + * |
|
35 | + * @var string |
|
36 | + */ |
|
37 | + protected $_name; |
|
38 | + |
|
39 | + /** |
|
40 | + * $_html_id |
|
41 | + * @var string |
|
42 | + */ |
|
43 | + protected $_html_id; |
|
44 | + |
|
45 | + /** |
|
46 | + * $_html_class |
|
47 | + * @var string |
|
48 | + */ |
|
49 | + protected $_html_class; |
|
50 | + |
|
51 | + /** |
|
52 | + * $_html_style |
|
53 | + * @var string |
|
54 | + */ |
|
55 | + protected $_html_style; |
|
56 | + |
|
57 | + /** |
|
58 | + * $_other_html_attributes |
|
59 | + * @var string |
|
60 | + */ |
|
61 | + protected $_other_html_attributes; |
|
62 | + |
|
63 | + /** |
|
64 | + * The form section of which this form section is a part |
|
65 | + * |
|
66 | + * @var EE_Form_Section_Proper |
|
67 | + */ |
|
68 | + protected $_parent_section; |
|
69 | + |
|
70 | + /** |
|
71 | + * flag indicating that _construct_finalize has been called. |
|
72 | + * If it has not been called and we try to use functions which require it, we call it |
|
73 | + * with no parameters. But normally, _construct_finalize should be called by the instantiating class |
|
74 | + * |
|
75 | + * @var boolean |
|
76 | + */ |
|
77 | + protected $_construction_finalized; |
|
78 | + |
|
79 | + /** |
|
80 | + * Strategy for parsing the form HTML upon display |
|
81 | + * |
|
82 | + * @var FormHtmlFilter |
|
83 | + */ |
|
84 | + protected $_form_html_filter; |
|
85 | + |
|
86 | + |
|
87 | + /** |
|
88 | + * @param array $options_array { |
|
89 | + * @type $name string the name for this form section, if you want to explicitly define it |
|
90 | + * } |
|
91 | + * @throws InvalidDataTypeException |
|
92 | + */ |
|
93 | + public function __construct($options_array = array()) |
|
94 | + { |
|
95 | + // used by display strategies |
|
96 | + // assign incoming values to properties |
|
97 | + foreach ($options_array as $key => $value) { |
|
98 | + $key = '_' . $key; |
|
99 | + if (property_exists($this, $key) && empty($this->{$key})) { |
|
100 | + $this->{$key} = $value; |
|
101 | + if ($key === '_subsections' && ! is_array($value)) { |
|
102 | + throw new InvalidDataTypeException($key, $value, 'array'); |
|
103 | + } |
|
104 | + } |
|
105 | + } |
|
106 | + // set parser which allows the form section's rendered HTML to be filtered |
|
107 | + if (isset($options_array['form_html_filter']) && $options_array['form_html_filter'] instanceof FormHtmlFilter) { |
|
108 | + $this->_form_html_filter = $options_array['form_html_filter']; |
|
109 | + } |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * @param $parent_form_section |
|
116 | + * @param $name |
|
117 | + * @throws \EE_Error |
|
118 | + */ |
|
119 | + protected function _construct_finalize($parent_form_section, $name) |
|
120 | + { |
|
121 | + $this->_construction_finalized = true; |
|
122 | + $this->_parent_section = $parent_form_section; |
|
123 | + if ($name !== null) { |
|
124 | + $this->_name = $name; |
|
125 | + } |
|
126 | + } |
|
127 | + |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * make sure construction finalized was called, otherwise children might not be ready |
|
132 | + * |
|
133 | + * @return void |
|
134 | + * @throws \EE_Error |
|
135 | + */ |
|
136 | + public function ensure_construct_finalized_called() |
|
137 | + { |
|
138 | + if (! $this->_construction_finalized) { |
|
139 | + $this->_construct_finalize($this->_parent_section, $this->_name); |
|
140 | + } |
|
141 | + } |
|
142 | + |
|
143 | + |
|
144 | + |
|
145 | + /** |
|
146 | + * @return string |
|
147 | + */ |
|
148 | + public function action() |
|
149 | + { |
|
150 | + return $this->_action; |
|
151 | + } |
|
152 | + |
|
153 | + |
|
154 | + |
|
155 | + /** |
|
156 | + * @param string $action |
|
157 | + */ |
|
158 | + public function set_action($action) |
|
159 | + { |
|
160 | + $this->_action = $action; |
|
161 | + } |
|
162 | + |
|
163 | + |
|
164 | + |
|
165 | + /** |
|
166 | + * @return string |
|
167 | + */ |
|
168 | + public function method() |
|
169 | + { |
|
170 | + return ! empty($this->_method) ? $this->_method : 'POST'; |
|
171 | + } |
|
172 | + |
|
173 | + |
|
174 | + |
|
175 | + /** |
|
176 | + * @param string $method |
|
177 | + */ |
|
178 | + public function set_method($method) |
|
179 | + { |
|
180 | + switch ($method) { |
|
181 | + case 'get': |
|
182 | + case 'GET': |
|
183 | + $this->_method = 'GET'; |
|
184 | + break; |
|
185 | + default: |
|
186 | + $this->_method = 'POST'; |
|
187 | + } |
|
188 | + } |
|
189 | + |
|
190 | + |
|
191 | + |
|
192 | + /** |
|
193 | + * Sets the html_id to its default value, if none was specified in the constructor. |
|
194 | + * Calculation involves using the name and the parent's html id |
|
195 | + * return void |
|
196 | + * |
|
197 | + * @throws \EE_Error |
|
198 | + */ |
|
199 | + protected function _set_default_html_id_if_empty() |
|
200 | + { |
|
201 | + if (! $this->_html_id) { |
|
202 | + if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
|
203 | + $this->_html_id = $this->_parent_section->html_id() |
|
204 | + . '-' |
|
205 | + . $this->_prep_name_for_html_id($this->name()); |
|
206 | + } else { |
|
207 | + $this->_html_id = $this->_prep_name_for_html_id($this->name()); |
|
208 | + } |
|
209 | + } |
|
210 | + } |
|
211 | + |
|
212 | + |
|
213 | + |
|
214 | + /** |
|
215 | + * _prep_name_for_html_id |
|
216 | + * |
|
217 | + * @param $name |
|
218 | + * @return string |
|
219 | + */ |
|
220 | + private function _prep_name_for_html_id($name) |
|
221 | + { |
|
222 | + return sanitize_key(str_replace(array(' ', ' ', '_'), '-', $name)); |
|
223 | + } |
|
224 | 224 | |
225 | 225 | |
226 | 226 | |
227 | - /** |
|
228 | - * Returns the HTML, JS, and CSS necessary to display this form section on a page. |
|
229 | - * Note however, it's recommended that you instead call enqueue_js on the "wp_enqueue_scripts" action, |
|
230 | - * and call get_html when you want to output the html. Calling get_html_and_js after |
|
231 | - * "wp_enqueue_scripts" has already fired seems to work for now, but is contrary |
|
232 | - * to the instructions on https://developer.wordpress.org/reference/functions/wp_enqueue_script/ |
|
233 | - * and so might stop working anytime. |
|
234 | - * |
|
235 | - * @return string |
|
236 | - */ |
|
237 | - public function get_html_and_js() |
|
238 | - { |
|
239 | - return $this->get_html(); |
|
240 | - } |
|
227 | + /** |
|
228 | + * Returns the HTML, JS, and CSS necessary to display this form section on a page. |
|
229 | + * Note however, it's recommended that you instead call enqueue_js on the "wp_enqueue_scripts" action, |
|
230 | + * and call get_html when you want to output the html. Calling get_html_and_js after |
|
231 | + * "wp_enqueue_scripts" has already fired seems to work for now, but is contrary |
|
232 | + * to the instructions on https://developer.wordpress.org/reference/functions/wp_enqueue_script/ |
|
233 | + * and so might stop working anytime. |
|
234 | + * |
|
235 | + * @return string |
|
236 | + */ |
|
237 | + public function get_html_and_js() |
|
238 | + { |
|
239 | + return $this->get_html(); |
|
240 | + } |
|
241 | 241 | |
242 | 242 | |
243 | - |
|
244 | - /** |
|
245 | - * Gets the HTML for displaying this form section |
|
246 | - * |
|
247 | - * @return string |
|
248 | - */ |
|
249 | - abstract public function get_html(); |
|
250 | - |
|
251 | - |
|
252 | - /** |
|
253 | - * @param bool $add_pound_sign |
|
254 | - * @return string |
|
255 | - * @throws EE_Error |
|
256 | - */ |
|
257 | - public function html_id($add_pound_sign = false) |
|
258 | - { |
|
259 | - $this->_set_default_html_id_if_empty(); |
|
260 | - return $add_pound_sign ? '#' . $this->_html_id : $this->_html_id; |
|
261 | - } |
|
262 | - |
|
263 | - |
|
264 | - |
|
265 | - /** |
|
266 | - * @return string |
|
267 | - */ |
|
268 | - public function html_class() |
|
269 | - { |
|
270 | - return $this->_html_class; |
|
271 | - } |
|
272 | - |
|
273 | - |
|
274 | - |
|
275 | - /** |
|
276 | - * @return string |
|
277 | - */ |
|
278 | - public function html_style() |
|
279 | - { |
|
280 | - return $this->_html_style; |
|
281 | - } |
|
282 | - |
|
283 | - |
|
284 | - |
|
285 | - /** |
|
286 | - * @param mixed $html_class |
|
287 | - */ |
|
288 | - public function set_html_class($html_class) |
|
289 | - { |
|
290 | - $this->_html_class = $html_class; |
|
291 | - } |
|
292 | - |
|
293 | - |
|
294 | - |
|
295 | - /** |
|
296 | - * @param mixed $html_id |
|
297 | - */ |
|
298 | - public function set_html_id($html_id) |
|
299 | - { |
|
300 | - $this->_html_id = $html_id; |
|
301 | - } |
|
302 | - |
|
303 | - |
|
304 | - |
|
305 | - /** |
|
306 | - * @param mixed $html_style |
|
307 | - */ |
|
308 | - public function set_html_style($html_style) |
|
309 | - { |
|
310 | - $this->_html_style = $html_style; |
|
311 | - } |
|
312 | - |
|
313 | - |
|
314 | - |
|
315 | - /** |
|
316 | - * @param string $other_html_attributes |
|
317 | - */ |
|
318 | - public function set_other_html_attributes($other_html_attributes) |
|
319 | - { |
|
320 | - $this->_other_html_attributes = $other_html_attributes; |
|
321 | - } |
|
322 | - |
|
323 | - |
|
324 | - |
|
325 | - /** |
|
326 | - * @return string |
|
327 | - */ |
|
328 | - public function other_html_attributes() |
|
329 | - { |
|
330 | - return $this->_other_html_attributes; |
|
331 | - } |
|
332 | - |
|
333 | - |
|
334 | - |
|
335 | - /** |
|
336 | - * Gets the name of the form section. This is not the same as the HTML name. |
|
337 | - * |
|
338 | - * @throws EE_Error |
|
339 | - * @return string |
|
340 | - */ |
|
341 | - public function name() |
|
342 | - { |
|
343 | - if (! $this->_construction_finalized) { |
|
344 | - throw new EE_Error(sprintf(__( |
|
345 | - 'You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'', |
|
346 | - 'event_espresso' |
|
347 | - ), get_class($this))); |
|
348 | - } |
|
349 | - return $this->_name; |
|
350 | - } |
|
351 | - |
|
352 | - |
|
353 | - |
|
354 | - /** |
|
355 | - * Gets the parent section |
|
356 | - * |
|
357 | - * @return EE_Form_Section_Proper |
|
358 | - */ |
|
359 | - public function parent_section() |
|
360 | - { |
|
361 | - return $this->_parent_section; |
|
362 | - } |
|
363 | - |
|
364 | - |
|
365 | - /** |
|
366 | - * returns HTML for generating the opening form HTML tag (<form>) |
|
367 | - * |
|
368 | - * @param string $action the URL the form is submitted to |
|
369 | - * @param string $method POST (default) or GET |
|
370 | - * @param string $other_attributes anything else added to the form open tag, MUST BE VALID HTML |
|
371 | - * @return string |
|
372 | - * @throws EE_Error |
|
373 | - */ |
|
374 | - public function form_open($action = '', $method = '', $other_attributes = '') |
|
375 | - { |
|
376 | - if (! empty($action)) { |
|
377 | - $this->set_action($action); |
|
378 | - } |
|
379 | - if (! empty($method)) { |
|
380 | - $this->set_method($method); |
|
381 | - } |
|
382 | - $html = EEH_HTML::nl(1, 'form') . '<form'; |
|
383 | - $html .= $this->html_id() !== '' ? ' id="' . $this->get_html_id_for_form($this->html_id()) . '"' : ''; |
|
384 | - $html .= ' action="' . $this->action() . '"'; |
|
385 | - $html .= ' method="' . $this->method() . '"'; |
|
386 | - $html .= ' name="' . $this->name() . '"'; |
|
387 | - $html .= $other_attributes . '>'; |
|
388 | - return $html; |
|
389 | - } |
|
390 | - |
|
391 | - |
|
392 | - |
|
393 | - /** |
|
394 | - * ensures that html id for form either ends in "-form" or "-frm" |
|
395 | - * so that id doesn't conflict/collide with other elements |
|
396 | - * |
|
397 | - * @param string $html_id |
|
398 | - * @return string |
|
399 | - */ |
|
400 | - protected function get_html_id_for_form($html_id) |
|
401 | - { |
|
402 | - $strlen = strlen($html_id); |
|
403 | - $html_id = strpos($html_id, '-form') === $strlen-5 || strpos($html_id, '-frm') === $strlen - 4 |
|
404 | - ? $html_id |
|
405 | - : $html_id . '-frm'; |
|
406 | - return $html_id; |
|
407 | - } |
|
408 | - |
|
409 | - |
|
410 | - /** |
|
411 | - * returns HTML for generating the closing form HTML tag (</form>) |
|
412 | - * |
|
413 | - * @return string |
|
414 | - * @throws EE_Error |
|
415 | - */ |
|
416 | - public function form_close() |
|
417 | - { |
|
418 | - return EEH_HTML::nl(-1, 'form') |
|
419 | - . '</form>' |
|
420 | - . EEH_HTML::nl() |
|
421 | - . '<!-- end of ee-' |
|
422 | - . $this->html_id() |
|
423 | - . '-form -->' |
|
424 | - . EEH_HTML::nl(); |
|
425 | - } |
|
426 | - |
|
427 | - |
|
428 | - |
|
429 | - /** |
|
430 | - * enqueues JS (and CSS) for the form (ie immediately call wp_enqueue_script and |
|
431 | - * wp_enqueue_style; the scripts could have optionally been registered earlier) |
|
432 | - * Default does nothing, but child classes can override |
|
433 | - * |
|
434 | - * @return void |
|
435 | - */ |
|
436 | - public function enqueue_js() |
|
437 | - { |
|
438 | - // defaults to enqueue NO js or css |
|
439 | - } |
|
440 | - |
|
441 | - |
|
442 | - |
|
443 | - /** |
|
444 | - * Adds any extra data needed by js. Eventually we'll call wp_localize_script |
|
445 | - * with it, and it will be on each form section's 'other_data' property. |
|
446 | - * By default nothing is added, but child classes can extend this method to add something. |
|
447 | - * Eg, if you have an input that will cause a modal dialog to appear, |
|
448 | - * here you could add an entry like 'modal_dialog_inputs' to this array |
|
449 | - * to map between the input's html ID and the modal dialogue's ID, so that |
|
450 | - * your JS code will know where to find the modal dialog when the input is pressed. |
|
451 | - * Eg $form_other_js_data['modal_dialog_inputs']['some-input-id']='modal-dialog-id'; |
|
452 | - * |
|
453 | - * @param array $form_other_js_data |
|
454 | - * @return array |
|
455 | - */ |
|
456 | - public function get_other_js_data($form_other_js_data = array()) |
|
457 | - { |
|
458 | - return $form_other_js_data; |
|
459 | - } |
|
460 | - |
|
461 | - |
|
462 | - |
|
463 | - /** |
|
464 | - * This isn't just the name of an input, it's a path pointing to an input. The |
|
465 | - * path is similar to a folder path: slash (/) means to descend into a subsection, |
|
466 | - * dot-dot-slash (../) means to ascend into the parent section. |
|
467 | - * After a series of slashes and dot-dot-slashes, there should be the name of an input, |
|
468 | - * which will be returned. |
|
469 | - * Eg, if you want the related input to be conditional on a sibling input name 'foobar' |
|
470 | - * just use 'foobar'. If you want it to be conditional on an aunt/uncle input name |
|
471 | - * 'baz', use '../baz'. If you want it to be conditional on a cousin input, |
|
472 | - * the child of 'baz_section' named 'baz_child', use '../baz_section/baz_child'. |
|
473 | - * Etc |
|
474 | - * |
|
475 | - * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false |
|
476 | - * @return EE_Form_Section_Base |
|
477 | - */ |
|
478 | - public function find_section_from_path($form_section_path) |
|
479 | - { |
|
480 | - if (strpos($form_section_path, '/') === 0) { |
|
481 | - $form_section_path = substr($form_section_path, strlen('/')); |
|
482 | - } |
|
483 | - if (empty($form_section_path)) { |
|
484 | - return $this; |
|
485 | - } |
|
486 | - if (strpos($form_section_path, '../') === 0) { |
|
487 | - $parent = $this->parent_section(); |
|
488 | - $form_section_path = substr($form_section_path, strlen('../')); |
|
489 | - if ($parent instanceof EE_Form_Section_Base) { |
|
490 | - return $parent->find_section_from_path($form_section_path); |
|
491 | - } |
|
492 | - if (empty($form_section_path)) { |
|
493 | - return $this; |
|
494 | - } |
|
495 | - } |
|
496 | - // couldn't find it using simple parent following |
|
497 | - return null; |
|
498 | - } |
|
243 | + |
|
244 | + /** |
|
245 | + * Gets the HTML for displaying this form section |
|
246 | + * |
|
247 | + * @return string |
|
248 | + */ |
|
249 | + abstract public function get_html(); |
|
250 | + |
|
251 | + |
|
252 | + /** |
|
253 | + * @param bool $add_pound_sign |
|
254 | + * @return string |
|
255 | + * @throws EE_Error |
|
256 | + */ |
|
257 | + public function html_id($add_pound_sign = false) |
|
258 | + { |
|
259 | + $this->_set_default_html_id_if_empty(); |
|
260 | + return $add_pound_sign ? '#' . $this->_html_id : $this->_html_id; |
|
261 | + } |
|
262 | + |
|
263 | + |
|
264 | + |
|
265 | + /** |
|
266 | + * @return string |
|
267 | + */ |
|
268 | + public function html_class() |
|
269 | + { |
|
270 | + return $this->_html_class; |
|
271 | + } |
|
272 | + |
|
273 | + |
|
274 | + |
|
275 | + /** |
|
276 | + * @return string |
|
277 | + */ |
|
278 | + public function html_style() |
|
279 | + { |
|
280 | + return $this->_html_style; |
|
281 | + } |
|
282 | + |
|
283 | + |
|
284 | + |
|
285 | + /** |
|
286 | + * @param mixed $html_class |
|
287 | + */ |
|
288 | + public function set_html_class($html_class) |
|
289 | + { |
|
290 | + $this->_html_class = $html_class; |
|
291 | + } |
|
292 | + |
|
293 | + |
|
294 | + |
|
295 | + /** |
|
296 | + * @param mixed $html_id |
|
297 | + */ |
|
298 | + public function set_html_id($html_id) |
|
299 | + { |
|
300 | + $this->_html_id = $html_id; |
|
301 | + } |
|
302 | + |
|
303 | + |
|
304 | + |
|
305 | + /** |
|
306 | + * @param mixed $html_style |
|
307 | + */ |
|
308 | + public function set_html_style($html_style) |
|
309 | + { |
|
310 | + $this->_html_style = $html_style; |
|
311 | + } |
|
312 | + |
|
313 | + |
|
314 | + |
|
315 | + /** |
|
316 | + * @param string $other_html_attributes |
|
317 | + */ |
|
318 | + public function set_other_html_attributes($other_html_attributes) |
|
319 | + { |
|
320 | + $this->_other_html_attributes = $other_html_attributes; |
|
321 | + } |
|
322 | + |
|
323 | + |
|
324 | + |
|
325 | + /** |
|
326 | + * @return string |
|
327 | + */ |
|
328 | + public function other_html_attributes() |
|
329 | + { |
|
330 | + return $this->_other_html_attributes; |
|
331 | + } |
|
332 | + |
|
333 | + |
|
334 | + |
|
335 | + /** |
|
336 | + * Gets the name of the form section. This is not the same as the HTML name. |
|
337 | + * |
|
338 | + * @throws EE_Error |
|
339 | + * @return string |
|
340 | + */ |
|
341 | + public function name() |
|
342 | + { |
|
343 | + if (! $this->_construction_finalized) { |
|
344 | + throw new EE_Error(sprintf(__( |
|
345 | + 'You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'', |
|
346 | + 'event_espresso' |
|
347 | + ), get_class($this))); |
|
348 | + } |
|
349 | + return $this->_name; |
|
350 | + } |
|
351 | + |
|
352 | + |
|
353 | + |
|
354 | + /** |
|
355 | + * Gets the parent section |
|
356 | + * |
|
357 | + * @return EE_Form_Section_Proper |
|
358 | + */ |
|
359 | + public function parent_section() |
|
360 | + { |
|
361 | + return $this->_parent_section; |
|
362 | + } |
|
363 | + |
|
364 | + |
|
365 | + /** |
|
366 | + * returns HTML for generating the opening form HTML tag (<form>) |
|
367 | + * |
|
368 | + * @param string $action the URL the form is submitted to |
|
369 | + * @param string $method POST (default) or GET |
|
370 | + * @param string $other_attributes anything else added to the form open tag, MUST BE VALID HTML |
|
371 | + * @return string |
|
372 | + * @throws EE_Error |
|
373 | + */ |
|
374 | + public function form_open($action = '', $method = '', $other_attributes = '') |
|
375 | + { |
|
376 | + if (! empty($action)) { |
|
377 | + $this->set_action($action); |
|
378 | + } |
|
379 | + if (! empty($method)) { |
|
380 | + $this->set_method($method); |
|
381 | + } |
|
382 | + $html = EEH_HTML::nl(1, 'form') . '<form'; |
|
383 | + $html .= $this->html_id() !== '' ? ' id="' . $this->get_html_id_for_form($this->html_id()) . '"' : ''; |
|
384 | + $html .= ' action="' . $this->action() . '"'; |
|
385 | + $html .= ' method="' . $this->method() . '"'; |
|
386 | + $html .= ' name="' . $this->name() . '"'; |
|
387 | + $html .= $other_attributes . '>'; |
|
388 | + return $html; |
|
389 | + } |
|
390 | + |
|
391 | + |
|
392 | + |
|
393 | + /** |
|
394 | + * ensures that html id for form either ends in "-form" or "-frm" |
|
395 | + * so that id doesn't conflict/collide with other elements |
|
396 | + * |
|
397 | + * @param string $html_id |
|
398 | + * @return string |
|
399 | + */ |
|
400 | + protected function get_html_id_for_form($html_id) |
|
401 | + { |
|
402 | + $strlen = strlen($html_id); |
|
403 | + $html_id = strpos($html_id, '-form') === $strlen-5 || strpos($html_id, '-frm') === $strlen - 4 |
|
404 | + ? $html_id |
|
405 | + : $html_id . '-frm'; |
|
406 | + return $html_id; |
|
407 | + } |
|
408 | + |
|
409 | + |
|
410 | + /** |
|
411 | + * returns HTML for generating the closing form HTML tag (</form>) |
|
412 | + * |
|
413 | + * @return string |
|
414 | + * @throws EE_Error |
|
415 | + */ |
|
416 | + public function form_close() |
|
417 | + { |
|
418 | + return EEH_HTML::nl(-1, 'form') |
|
419 | + . '</form>' |
|
420 | + . EEH_HTML::nl() |
|
421 | + . '<!-- end of ee-' |
|
422 | + . $this->html_id() |
|
423 | + . '-form -->' |
|
424 | + . EEH_HTML::nl(); |
|
425 | + } |
|
426 | + |
|
427 | + |
|
428 | + |
|
429 | + /** |
|
430 | + * enqueues JS (and CSS) for the form (ie immediately call wp_enqueue_script and |
|
431 | + * wp_enqueue_style; the scripts could have optionally been registered earlier) |
|
432 | + * Default does nothing, but child classes can override |
|
433 | + * |
|
434 | + * @return void |
|
435 | + */ |
|
436 | + public function enqueue_js() |
|
437 | + { |
|
438 | + // defaults to enqueue NO js or css |
|
439 | + } |
|
440 | + |
|
441 | + |
|
442 | + |
|
443 | + /** |
|
444 | + * Adds any extra data needed by js. Eventually we'll call wp_localize_script |
|
445 | + * with it, and it will be on each form section's 'other_data' property. |
|
446 | + * By default nothing is added, but child classes can extend this method to add something. |
|
447 | + * Eg, if you have an input that will cause a modal dialog to appear, |
|
448 | + * here you could add an entry like 'modal_dialog_inputs' to this array |
|
449 | + * to map between the input's html ID and the modal dialogue's ID, so that |
|
450 | + * your JS code will know where to find the modal dialog when the input is pressed. |
|
451 | + * Eg $form_other_js_data['modal_dialog_inputs']['some-input-id']='modal-dialog-id'; |
|
452 | + * |
|
453 | + * @param array $form_other_js_data |
|
454 | + * @return array |
|
455 | + */ |
|
456 | + public function get_other_js_data($form_other_js_data = array()) |
|
457 | + { |
|
458 | + return $form_other_js_data; |
|
459 | + } |
|
460 | + |
|
461 | + |
|
462 | + |
|
463 | + /** |
|
464 | + * This isn't just the name of an input, it's a path pointing to an input. The |
|
465 | + * path is similar to a folder path: slash (/) means to descend into a subsection, |
|
466 | + * dot-dot-slash (../) means to ascend into the parent section. |
|
467 | + * After a series of slashes and dot-dot-slashes, there should be the name of an input, |
|
468 | + * which will be returned. |
|
469 | + * Eg, if you want the related input to be conditional on a sibling input name 'foobar' |
|
470 | + * just use 'foobar'. If you want it to be conditional on an aunt/uncle input name |
|
471 | + * 'baz', use '../baz'. If you want it to be conditional on a cousin input, |
|
472 | + * the child of 'baz_section' named 'baz_child', use '../baz_section/baz_child'. |
|
473 | + * Etc |
|
474 | + * |
|
475 | + * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false |
|
476 | + * @return EE_Form_Section_Base |
|
477 | + */ |
|
478 | + public function find_section_from_path($form_section_path) |
|
479 | + { |
|
480 | + if (strpos($form_section_path, '/') === 0) { |
|
481 | + $form_section_path = substr($form_section_path, strlen('/')); |
|
482 | + } |
|
483 | + if (empty($form_section_path)) { |
|
484 | + return $this; |
|
485 | + } |
|
486 | + if (strpos($form_section_path, '../') === 0) { |
|
487 | + $parent = $this->parent_section(); |
|
488 | + $form_section_path = substr($form_section_path, strlen('../')); |
|
489 | + if ($parent instanceof EE_Form_Section_Base) { |
|
490 | + return $parent->find_section_from_path($form_section_path); |
|
491 | + } |
|
492 | + if (empty($form_section_path)) { |
|
493 | + return $this; |
|
494 | + } |
|
495 | + } |
|
496 | + // couldn't find it using simple parent following |
|
497 | + return null; |
|
498 | + } |
|
499 | 499 | } |
500 | 500 | // End of file EE_Form_Section_Base.form.php |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | // used by display strategies |
96 | 96 | // assign incoming values to properties |
97 | 97 | foreach ($options_array as $key => $value) { |
98 | - $key = '_' . $key; |
|
98 | + $key = '_'.$key; |
|
99 | 99 | if (property_exists($this, $key) && empty($this->{$key})) { |
100 | 100 | $this->{$key} = $value; |
101 | 101 | if ($key === '_subsections' && ! is_array($value)) { |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function ensure_construct_finalized_called() |
137 | 137 | { |
138 | - if (! $this->_construction_finalized) { |
|
138 | + if ( ! $this->_construction_finalized) { |
|
139 | 139 | $this->_construct_finalize($this->_parent_section, $this->_name); |
140 | 140 | } |
141 | 141 | } |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | */ |
199 | 199 | protected function _set_default_html_id_if_empty() |
200 | 200 | { |
201 | - if (! $this->_html_id) { |
|
201 | + if ( ! $this->_html_id) { |
|
202 | 202 | if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
203 | 203 | $this->_html_id = $this->_parent_section->html_id() |
204 | 204 | . '-' |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | public function html_id($add_pound_sign = false) |
258 | 258 | { |
259 | 259 | $this->_set_default_html_id_if_empty(); |
260 | - return $add_pound_sign ? '#' . $this->_html_id : $this->_html_id; |
|
260 | + return $add_pound_sign ? '#'.$this->_html_id : $this->_html_id; |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | */ |
341 | 341 | public function name() |
342 | 342 | { |
343 | - if (! $this->_construction_finalized) { |
|
343 | + if ( ! $this->_construction_finalized) { |
|
344 | 344 | throw new EE_Error(sprintf(__( |
345 | 345 | 'You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'', |
346 | 346 | 'event_espresso' |
@@ -373,18 +373,18 @@ discard block |
||
373 | 373 | */ |
374 | 374 | public function form_open($action = '', $method = '', $other_attributes = '') |
375 | 375 | { |
376 | - if (! empty($action)) { |
|
376 | + if ( ! empty($action)) { |
|
377 | 377 | $this->set_action($action); |
378 | 378 | } |
379 | - if (! empty($method)) { |
|
379 | + if ( ! empty($method)) { |
|
380 | 380 | $this->set_method($method); |
381 | 381 | } |
382 | - $html = EEH_HTML::nl(1, 'form') . '<form'; |
|
383 | - $html .= $this->html_id() !== '' ? ' id="' . $this->get_html_id_for_form($this->html_id()) . '"' : ''; |
|
384 | - $html .= ' action="' . $this->action() . '"'; |
|
385 | - $html .= ' method="' . $this->method() . '"'; |
|
386 | - $html .= ' name="' . $this->name() . '"'; |
|
387 | - $html .= $other_attributes . '>'; |
|
382 | + $html = EEH_HTML::nl(1, 'form').'<form'; |
|
383 | + $html .= $this->html_id() !== '' ? ' id="'.$this->get_html_id_for_form($this->html_id()).'"' : ''; |
|
384 | + $html .= ' action="'.$this->action().'"'; |
|
385 | + $html .= ' method="'.$this->method().'"'; |
|
386 | + $html .= ' name="'.$this->name().'"'; |
|
387 | + $html .= $other_attributes.'>'; |
|
388 | 388 | return $html; |
389 | 389 | } |
390 | 390 | |
@@ -400,9 +400,9 @@ discard block |
||
400 | 400 | protected function get_html_id_for_form($html_id) |
401 | 401 | { |
402 | 402 | $strlen = strlen($html_id); |
403 | - $html_id = strpos($html_id, '-form') === $strlen-5 || strpos($html_id, '-frm') === $strlen - 4 |
|
403 | + $html_id = strpos($html_id, '-form') === $strlen - 5 || strpos($html_id, '-frm') === $strlen - 4 |
|
404 | 404 | ? $html_id |
405 | - : $html_id . '-frm'; |
|
405 | + : $html_id.'-frm'; |
|
406 | 406 | return $html_id; |
407 | 407 | } |
408 | 408 |
@@ -14,30 +14,30 @@ |
||
14 | 14 | class EE_Form_Section_HTML extends EE_Form_Section_Base |
15 | 15 | { |
16 | 16 | |
17 | - protected $_html = ''; |
|
17 | + protected $_html = ''; |
|
18 | 18 | |
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * @param string $html |
|
23 | - * @param array $options_array |
|
24 | - */ |
|
25 | - public function __construct($html = '', $options_array = array()) |
|
26 | - { |
|
27 | - $this->_html = $html; |
|
28 | - parent::__construct($options_array); |
|
29 | - } |
|
21 | + /** |
|
22 | + * @param string $html |
|
23 | + * @param array $options_array |
|
24 | + */ |
|
25 | + public function __construct($html = '', $options_array = array()) |
|
26 | + { |
|
27 | + $this->_html = $html; |
|
28 | + parent::__construct($options_array); |
|
29 | + } |
|
30 | 30 | |
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * Returns the HTML |
|
35 | - * @return string |
|
36 | - */ |
|
37 | - public function get_html() |
|
38 | - { |
|
39 | - return $this->_html; |
|
40 | - } |
|
33 | + /** |
|
34 | + * Returns the HTML |
|
35 | + * @return string |
|
36 | + */ |
|
37 | + public function get_html() |
|
38 | + { |
|
39 | + return $this->_html; |
|
40 | + } |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | // End of file EE_Form_Section_HTML.form.php |
@@ -11,11 +11,11 @@ |
||
11 | 11 | */ |
12 | 12 | class EE_Form_Section_HTML_From_Template extends EE_Form_Section_HTML |
13 | 13 | { |
14 | - public function __construct($template_file, $args = array(), $options_array = array()) |
|
15 | - { |
|
16 | - $html = EEH_Template::locate_template($template_file, $args); |
|
14 | + public function __construct($template_file, $args = array(), $options_array = array()) |
|
15 | + { |
|
16 | + $html = EEH_Template::locate_template($template_file, $args); |
|
17 | 17 | |
18 | 18 | // echo " filepath:$template_file html $html"; |
19 | - parent::__construct($html, $options_array); |
|
20 | - } |
|
19 | + parent::__construct($html, $options_array); |
|
20 | + } |
|
21 | 21 | } |
@@ -21,150 +21,150 @@ |
||
21 | 21 | abstract class EE_Form_Section_Validatable extends EE_Form_Section_Base |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * Array of validation errors in this section. Does not contain validation errors in subsections, however. |
|
26 | - * Those are stored individually on each subsection. |
|
27 | - * |
|
28 | - * @var EE_Validation_Error[] |
|
29 | - */ |
|
30 | - protected $_validation_errors = array(); |
|
31 | - |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * Errors on this form section. Note: EE_Form_Section_Proper |
|
36 | - * has another function for getting all errors in this form section and subsections |
|
37 | - * called get_validation_errors_accumulated |
|
38 | - * |
|
39 | - * @return EE_Validation_Error[] |
|
40 | - */ |
|
41 | - public function get_validation_errors() |
|
42 | - { |
|
43 | - return $this->_validation_errors; |
|
44 | - } |
|
45 | - |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * returns a comma-separated list of all the validation errors in it. |
|
50 | - * If we want this to be customizable, we may decide to create a strategy for displaying it |
|
51 | - * |
|
52 | - * @return string |
|
53 | - */ |
|
54 | - public function get_validation_error_string() |
|
55 | - { |
|
56 | - $validation_error_messages = array(); |
|
57 | - if ($this->get_validation_errors()) { |
|
58 | - foreach ($this->get_validation_errors() as $validation_error) { |
|
59 | - if ($validation_error instanceof EE_Validation_Error) { |
|
60 | - $validation_error_messages[] = $validation_error->getMessage(); |
|
61 | - } |
|
62 | - } |
|
63 | - } |
|
64 | - return implode(", ", $validation_error_messages); |
|
65 | - } |
|
66 | - |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * Performs validation on this form section (and subsections). Should be called after _normalize() |
|
71 | - * |
|
72 | - * @return boolean of whether or not the form section is valid |
|
73 | - */ |
|
74 | - abstract protected function _validate(); |
|
75 | - |
|
76 | - |
|
77 | - |
|
78 | - /** |
|
79 | - * Checks if this field has any validation errors |
|
80 | - * |
|
81 | - * @return boolean |
|
82 | - */ |
|
83 | - public function is_valid() |
|
84 | - { |
|
85 | - if (count($this->_validation_errors)) { |
|
86 | - return false; |
|
87 | - } else { |
|
88 | - return true; |
|
89 | - } |
|
90 | - } |
|
91 | - |
|
92 | - |
|
93 | - |
|
94 | - /** |
|
95 | - * Sanitizes input for this form section |
|
96 | - * |
|
97 | - * @param array $req_data is the full request data like $_POST |
|
98 | - * @return boolean of whether a normalization error occurred |
|
99 | - */ |
|
100 | - abstract protected function _normalize($req_data); |
|
101 | - |
|
102 | - |
|
103 | - |
|
104 | - /** |
|
105 | - * Creates a validation error from the arguments provided, and adds it to the form section's list. |
|
106 | - * If such an EE_Validation_Error object is passed in as the first arg, simply sets this as its form section, and |
|
107 | - * adds it to the list of validation errors of errors |
|
108 | - * |
|
109 | - * @param mixed $message_or_object internationalized string describing the validation error; or it could be a |
|
110 | - * proper EE_Validation_Error object |
|
111 | - * @param string $error_code a short key which can be used to uniquely identify the error |
|
112 | - * @param Exception $previous_exception if there was an exception that caused the error, that exception |
|
113 | - * @return void |
|
114 | - */ |
|
115 | - public function add_validation_error($message_or_object, $error_code = null, $previous_exception = null) |
|
116 | - { |
|
117 | - if ($message_or_object instanceof EE_Validation_Error) { |
|
118 | - $validation_error = $message_or_object; |
|
119 | - $validation_error->set_form_section($this); |
|
120 | - } else { |
|
121 | - $validation_error = new EE_Validation_Error($message_or_object, $error_code, $this, $previous_exception); |
|
122 | - } |
|
123 | - $this->_validation_errors[] = $validation_error; |
|
124 | - } |
|
125 | - |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * When generating the JS for the jquery validation rules like<br> |
|
130 | - * <code>$( "#myform" ).validate({ |
|
131 | - * rules: { |
|
132 | - * password: "required", |
|
133 | - * password_again: { |
|
134 | - * equalTo: "#password" |
|
135 | - * } |
|
136 | - * } |
|
137 | - * });</code> |
|
138 | - * gets the sections like |
|
139 | - * <br><code>password: "required", |
|
140 | - * password_again: { |
|
141 | - * equalTo: "#password" |
|
142 | - * }</code> |
|
143 | - * except we leave it as a PHP object, and leave wp_localize_script to |
|
144 | - * turn it into a JSON object which can be used by the js |
|
145 | - * |
|
146 | - * @return array |
|
147 | - */ |
|
148 | - abstract public function get_jquery_validation_rules(); |
|
149 | - |
|
150 | - |
|
151 | - |
|
152 | - /** |
|
153 | - * Checks if this form section's data is present in the req data specified |
|
154 | - * |
|
155 | - * @param array $req_data usually $_POST, if null that's what's used |
|
156 | - * @return boolean |
|
157 | - */ |
|
158 | - abstract public function form_data_present_in($req_data = null); |
|
159 | - |
|
160 | - |
|
161 | - |
|
162 | - /** |
|
163 | - * Removes teh sensitive data from this form section (usually done after |
|
164 | - * utilizing the data business function, but before saving it somewhere. Eg, |
|
165 | - * may remove a password from the form after verifying it was correct) |
|
166 | - * |
|
167 | - * @return void |
|
168 | - */ |
|
169 | - abstract public function clean_sensitive_data(); |
|
24 | + /** |
|
25 | + * Array of validation errors in this section. Does not contain validation errors in subsections, however. |
|
26 | + * Those are stored individually on each subsection. |
|
27 | + * |
|
28 | + * @var EE_Validation_Error[] |
|
29 | + */ |
|
30 | + protected $_validation_errors = array(); |
|
31 | + |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * Errors on this form section. Note: EE_Form_Section_Proper |
|
36 | + * has another function for getting all errors in this form section and subsections |
|
37 | + * called get_validation_errors_accumulated |
|
38 | + * |
|
39 | + * @return EE_Validation_Error[] |
|
40 | + */ |
|
41 | + public function get_validation_errors() |
|
42 | + { |
|
43 | + return $this->_validation_errors; |
|
44 | + } |
|
45 | + |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * returns a comma-separated list of all the validation errors in it. |
|
50 | + * If we want this to be customizable, we may decide to create a strategy for displaying it |
|
51 | + * |
|
52 | + * @return string |
|
53 | + */ |
|
54 | + public function get_validation_error_string() |
|
55 | + { |
|
56 | + $validation_error_messages = array(); |
|
57 | + if ($this->get_validation_errors()) { |
|
58 | + foreach ($this->get_validation_errors() as $validation_error) { |
|
59 | + if ($validation_error instanceof EE_Validation_Error) { |
|
60 | + $validation_error_messages[] = $validation_error->getMessage(); |
|
61 | + } |
|
62 | + } |
|
63 | + } |
|
64 | + return implode(", ", $validation_error_messages); |
|
65 | + } |
|
66 | + |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * Performs validation on this form section (and subsections). Should be called after _normalize() |
|
71 | + * |
|
72 | + * @return boolean of whether or not the form section is valid |
|
73 | + */ |
|
74 | + abstract protected function _validate(); |
|
75 | + |
|
76 | + |
|
77 | + |
|
78 | + /** |
|
79 | + * Checks if this field has any validation errors |
|
80 | + * |
|
81 | + * @return boolean |
|
82 | + */ |
|
83 | + public function is_valid() |
|
84 | + { |
|
85 | + if (count($this->_validation_errors)) { |
|
86 | + return false; |
|
87 | + } else { |
|
88 | + return true; |
|
89 | + } |
|
90 | + } |
|
91 | + |
|
92 | + |
|
93 | + |
|
94 | + /** |
|
95 | + * Sanitizes input for this form section |
|
96 | + * |
|
97 | + * @param array $req_data is the full request data like $_POST |
|
98 | + * @return boolean of whether a normalization error occurred |
|
99 | + */ |
|
100 | + abstract protected function _normalize($req_data); |
|
101 | + |
|
102 | + |
|
103 | + |
|
104 | + /** |
|
105 | + * Creates a validation error from the arguments provided, and adds it to the form section's list. |
|
106 | + * If such an EE_Validation_Error object is passed in as the first arg, simply sets this as its form section, and |
|
107 | + * adds it to the list of validation errors of errors |
|
108 | + * |
|
109 | + * @param mixed $message_or_object internationalized string describing the validation error; or it could be a |
|
110 | + * proper EE_Validation_Error object |
|
111 | + * @param string $error_code a short key which can be used to uniquely identify the error |
|
112 | + * @param Exception $previous_exception if there was an exception that caused the error, that exception |
|
113 | + * @return void |
|
114 | + */ |
|
115 | + public function add_validation_error($message_or_object, $error_code = null, $previous_exception = null) |
|
116 | + { |
|
117 | + if ($message_or_object instanceof EE_Validation_Error) { |
|
118 | + $validation_error = $message_or_object; |
|
119 | + $validation_error->set_form_section($this); |
|
120 | + } else { |
|
121 | + $validation_error = new EE_Validation_Error($message_or_object, $error_code, $this, $previous_exception); |
|
122 | + } |
|
123 | + $this->_validation_errors[] = $validation_error; |
|
124 | + } |
|
125 | + |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * When generating the JS for the jquery validation rules like<br> |
|
130 | + * <code>$( "#myform" ).validate({ |
|
131 | + * rules: { |
|
132 | + * password: "required", |
|
133 | + * password_again: { |
|
134 | + * equalTo: "#password" |
|
135 | + * } |
|
136 | + * } |
|
137 | + * });</code> |
|
138 | + * gets the sections like |
|
139 | + * <br><code>password: "required", |
|
140 | + * password_again: { |
|
141 | + * equalTo: "#password" |
|
142 | + * }</code> |
|
143 | + * except we leave it as a PHP object, and leave wp_localize_script to |
|
144 | + * turn it into a JSON object which can be used by the js |
|
145 | + * |
|
146 | + * @return array |
|
147 | + */ |
|
148 | + abstract public function get_jquery_validation_rules(); |
|
149 | + |
|
150 | + |
|
151 | + |
|
152 | + /** |
|
153 | + * Checks if this form section's data is present in the req data specified |
|
154 | + * |
|
155 | + * @param array $req_data usually $_POST, if null that's what's used |
|
156 | + * @return boolean |
|
157 | + */ |
|
158 | + abstract public function form_data_present_in($req_data = null); |
|
159 | + |
|
160 | + |
|
161 | + |
|
162 | + /** |
|
163 | + * Removes teh sensitive data from this form section (usually done after |
|
164 | + * utilizing the data business function, but before saving it somewhere. Eg, |
|
165 | + * may remove a password from the form after verifying it was correct) |
|
166 | + * |
|
167 | + * @return void |
|
168 | + */ |
|
169 | + abstract public function clean_sensitive_data(); |
|
170 | 170 | } |