@@ -13,58 +13,58 @@ |
||
13 | 13 | */ |
14 | 14 | class EE_Many_Valued_Validation_Strategy extends EE_Validation_Strategy_Base |
15 | 15 | { |
16 | - protected $_individual_item_validation_strategies = array(); |
|
17 | - /** |
|
18 | - * |
|
19 | - * @param EE_Validation_Strategy_Base[] $individual_item_validation_strategies (or a single EE_Validation_Strategy_Base) |
|
20 | - */ |
|
21 | - public function __construct($individual_item_validation_strategies) |
|
22 | - { |
|
23 | - if (! is_array($individual_item_validation_strategies)) { |
|
24 | - $individual_item_validation_strategies = array($individual_item_validation_strategies); |
|
25 | - } |
|
26 | - $this->_individual_item_validation_strategies = $individual_item_validation_strategies; |
|
27 | - parent::__construct(); |
|
28 | - } |
|
16 | + protected $_individual_item_validation_strategies = array(); |
|
17 | + /** |
|
18 | + * |
|
19 | + * @param EE_Validation_Strategy_Base[] $individual_item_validation_strategies (or a single EE_Validation_Strategy_Base) |
|
20 | + */ |
|
21 | + public function __construct($individual_item_validation_strategies) |
|
22 | + { |
|
23 | + if (! is_array($individual_item_validation_strategies)) { |
|
24 | + $individual_item_validation_strategies = array($individual_item_validation_strategies); |
|
25 | + } |
|
26 | + $this->_individual_item_validation_strategies = $individual_item_validation_strategies; |
|
27 | + parent::__construct(); |
|
28 | + } |
|
29 | 29 | |
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * Applies all teh individual item validation strategies on each item in the array |
|
34 | - * @param array $normalized_value |
|
35 | - * @return boolean |
|
36 | - */ |
|
37 | - public function validate($normalized_value) |
|
38 | - { |
|
39 | - if (is_array($normalized_value)) { |
|
40 | - $items_to_validate = $normalized_value; |
|
41 | - } else { |
|
42 | - $items_to_validate = array($normalized_value); |
|
43 | - } |
|
44 | - foreach ($items_to_validate as $individual_item) { |
|
45 | - foreach ($this->_individual_item_validation_strategies as $validation_strategy) { |
|
46 | - if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
47 | - $validation_strategy->validate($individual_item); |
|
48 | - } |
|
49 | - } |
|
50 | - } |
|
51 | - return true; |
|
52 | - } |
|
32 | + /** |
|
33 | + * Applies all teh individual item validation strategies on each item in the array |
|
34 | + * @param array $normalized_value |
|
35 | + * @return boolean |
|
36 | + */ |
|
37 | + public function validate($normalized_value) |
|
38 | + { |
|
39 | + if (is_array($normalized_value)) { |
|
40 | + $items_to_validate = $normalized_value; |
|
41 | + } else { |
|
42 | + $items_to_validate = array($normalized_value); |
|
43 | + } |
|
44 | + foreach ($items_to_validate as $individual_item) { |
|
45 | + foreach ($this->_individual_item_validation_strategies as $validation_strategy) { |
|
46 | + if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
47 | + $validation_strategy->validate($individual_item); |
|
48 | + } |
|
49 | + } |
|
50 | + } |
|
51 | + return true; |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | 55 | |
56 | - /** |
|
57 | - * Extends parent's _construct_finalize so we ALSO set the input |
|
58 | - * on each sub-validation-strategy |
|
59 | - * @param \EE_Form_Input_Base $form_input |
|
60 | - */ |
|
61 | - public function _construct_finalize(\EE_Form_Input_Base $form_input) |
|
62 | - { |
|
63 | - parent::_construct_finalize($form_input); |
|
64 | - foreach ($this->_individual_item_validation_strategies as $item_validation_strategy) { |
|
65 | - if ($item_validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
66 | - $item_validation_strategy->_construct_finalize($form_input); |
|
67 | - } |
|
68 | - } |
|
69 | - } |
|
56 | + /** |
|
57 | + * Extends parent's _construct_finalize so we ALSO set the input |
|
58 | + * on each sub-validation-strategy |
|
59 | + * @param \EE_Form_Input_Base $form_input |
|
60 | + */ |
|
61 | + public function _construct_finalize(\EE_Form_Input_Base $form_input) |
|
62 | + { |
|
63 | + parent::_construct_finalize($form_input); |
|
64 | + foreach ($this->_individual_item_validation_strategies as $item_validation_strategy) { |
|
65 | + if ($item_validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
66 | + $item_validation_strategy->_construct_finalize($form_input); |
|
67 | + } |
|
68 | + } |
|
69 | + } |
|
70 | 70 | } |
@@ -20,7 +20,7 @@ |
||
20 | 20 | */ |
21 | 21 | public function __construct($individual_item_validation_strategies) |
22 | 22 | { |
23 | - if (! is_array($individual_item_validation_strategies)) { |
|
23 | + if ( ! is_array($individual_item_validation_strategies)) { |
|
24 | 24 | $individual_item_validation_strategies = array($individual_item_validation_strategies); |
25 | 25 | } |
26 | 26 | $this->_individual_item_validation_strategies = $individual_item_validation_strategies; |
@@ -11,51 +11,51 @@ |
||
11 | 11 | class EE_Enum_Validation_Strategy extends EE_Validation_Strategy_Base |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * Check that the value is in the allowed list |
|
16 | - * @param $normalized_value |
|
17 | - * @throws EE_Error |
|
18 | - * @throws EE_Validation_Error |
|
19 | - * @return boolean |
|
20 | - */ |
|
21 | - public function validate($normalized_value) |
|
22 | - { |
|
23 | - parent::validate($normalized_value); |
|
24 | - if (! $this->_input instanceof EE_Form_Input_With_Options_Base) { |
|
25 | - throw new EE_Error(sprintf(__("Cannot use Enum Validation Strategy with an input that doesn't have options", "event_espresso"))); |
|
26 | - } |
|
27 | - $enum_options = $this->_input->flat_options(); |
|
28 | - if ($normalized_value === true) { |
|
29 | - $normalized_value = 1; |
|
30 | - } elseif ($normalized_value === false) { |
|
31 | - $normalized_value = 0; |
|
32 | - } |
|
33 | - if ($normalized_value !== null && ! array_key_exists($normalized_value, $enum_options)) { |
|
34 | - throw new EE_Validation_Error( |
|
35 | - $this->get_validation_error_message(), |
|
36 | - 'invalid_enum_value' |
|
37 | - ); |
|
38 | - } else { |
|
39 | - return true; |
|
40 | - } |
|
41 | - } |
|
14 | + /** |
|
15 | + * Check that the value is in the allowed list |
|
16 | + * @param $normalized_value |
|
17 | + * @throws EE_Error |
|
18 | + * @throws EE_Validation_Error |
|
19 | + * @return boolean |
|
20 | + */ |
|
21 | + public function validate($normalized_value) |
|
22 | + { |
|
23 | + parent::validate($normalized_value); |
|
24 | + if (! $this->_input instanceof EE_Form_Input_With_Options_Base) { |
|
25 | + throw new EE_Error(sprintf(__("Cannot use Enum Validation Strategy with an input that doesn't have options", "event_espresso"))); |
|
26 | + } |
|
27 | + $enum_options = $this->_input->flat_options(); |
|
28 | + if ($normalized_value === true) { |
|
29 | + $normalized_value = 1; |
|
30 | + } elseif ($normalized_value === false) { |
|
31 | + $normalized_value = 0; |
|
32 | + } |
|
33 | + if ($normalized_value !== null && ! array_key_exists($normalized_value, $enum_options)) { |
|
34 | + throw new EE_Validation_Error( |
|
35 | + $this->get_validation_error_message(), |
|
36 | + 'invalid_enum_value' |
|
37 | + ); |
|
38 | + } else { |
|
39 | + return true; |
|
40 | + } |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * If we are using the default validation error message, make it dynamic based |
|
45 | - * on the allowed options. |
|
46 | - * @return string |
|
47 | - */ |
|
48 | - public function get_validation_error_message() |
|
49 | - { |
|
50 | - $parent_validation_error_message = parent::get_validation_error_message(); |
|
51 | - if (! $parent_validation_error_message) { |
|
52 | - $enum_options = $this->_input instanceof EE_Form_Input_With_Options_Base ? $this->_input->flat_options() : ''; |
|
53 | - return sprintf( |
|
54 | - __("This is not allowed option. Allowed options are %s.", "event_espresso"), |
|
55 | - implode(', ', $enum_options) |
|
56 | - ); |
|
57 | - } else { |
|
58 | - return $parent_validation_error_message; |
|
59 | - } |
|
60 | - } |
|
43 | + /** |
|
44 | + * If we are using the default validation error message, make it dynamic based |
|
45 | + * on the allowed options. |
|
46 | + * @return string |
|
47 | + */ |
|
48 | + public function get_validation_error_message() |
|
49 | + { |
|
50 | + $parent_validation_error_message = parent::get_validation_error_message(); |
|
51 | + if (! $parent_validation_error_message) { |
|
52 | + $enum_options = $this->_input instanceof EE_Form_Input_With_Options_Base ? $this->_input->flat_options() : ''; |
|
53 | + return sprintf( |
|
54 | + __("This is not allowed option. Allowed options are %s.", "event_espresso"), |
|
55 | + implode(', ', $enum_options) |
|
56 | + ); |
|
57 | + } else { |
|
58 | + return $parent_validation_error_message; |
|
59 | + } |
|
60 | + } |
|
61 | 61 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | public function validate($normalized_value) |
22 | 22 | { |
23 | 23 | parent::validate($normalized_value); |
24 | - if (! $this->_input instanceof EE_Form_Input_With_Options_Base) { |
|
24 | + if ( ! $this->_input instanceof EE_Form_Input_With_Options_Base) { |
|
25 | 25 | throw new EE_Error(sprintf(__("Cannot use Enum Validation Strategy with an input that doesn't have options", "event_espresso"))); |
26 | 26 | } |
27 | 27 | $enum_options = $this->_input->flat_options(); |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | public function get_validation_error_message() |
49 | 49 | { |
50 | 50 | $parent_validation_error_message = parent::get_validation_error_message(); |
51 | - if (! $parent_validation_error_message) { |
|
51 | + if ( ! $parent_validation_error_message) { |
|
52 | 52 | $enum_options = $this->_input instanceof EE_Form_Input_With_Options_Base ? $this->_input->flat_options() : ''; |
53 | 53 | return sprintf( |
54 | 54 | __("This is not allowed option. Allowed options are %s.", "event_espresso"), |
@@ -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,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 | } |
@@ -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 | } |
@@ -14,74 +14,74 @@ |
||
14 | 14 | class EE_Billing_Info_Form extends EE_Form_Section_Proper |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * The payment method this billing form is for |
|
19 | - * @var EE_Payment_Method |
|
20 | - */ |
|
21 | - protected $_pm_instance; |
|
22 | - |
|
23 | - |
|
24 | - |
|
25 | - /** |
|
26 | - * |
|
27 | - * @param EE_Payment_Method $payment_method |
|
28 | - * @param array $options_array @see EE_Form_Section_Proper::__construct() |
|
29 | - */ |
|
30 | - public function __construct(EE_Payment_Method $payment_method, $options_array = array()) |
|
31 | - { |
|
32 | - $this->_pm_instance = $payment_method; |
|
33 | - $this->_layout_strategy = new EE_Div_Per_Section_Layout(); |
|
34 | - parent::__construct($options_array); |
|
35 | - } |
|
36 | - |
|
37 | - |
|
38 | - |
|
39 | - /** |
|
40 | - * Sets the payment method for this billing form |
|
41 | - * @param EE_Payment_Method $payment_method |
|
42 | - * @return void |
|
43 | - */ |
|
44 | - public function set_payment_method(EE_Payment_Method $payment_method) |
|
45 | - { |
|
46 | - $this->_pm_instance = $payment_method; |
|
47 | - } |
|
48 | - |
|
49 | - |
|
50 | - |
|
51 | - /** |
|
52 | - * Returns the instance of the payment method this billing form is for |
|
53 | - * @return EE_Payment_Method |
|
54 | - */ |
|
55 | - public function payment_method() |
|
56 | - { |
|
57 | - return $this->_pm_instance; |
|
58 | - } |
|
59 | - |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * payment_fields_autofilled_notice_html |
|
64 | - * @return string |
|
65 | - */ |
|
66 | - public function payment_fields_autofilled_notice_html() |
|
67 | - { |
|
68 | - return new EE_Form_Section_HTML( |
|
69 | - EEH_HTML::p( |
|
70 | - apply_filters('FHEE__EE_Billing_Info_Form__payment_fields_autofilled_notice_html_text', __('Payment fields have been autofilled because you are in debug mode', 'event_espresso')), |
|
71 | - '', |
|
72 | - 'important-notice' |
|
73 | - ) |
|
74 | - ); |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - |
|
79 | - /** |
|
80 | - * @return string |
|
81 | - */ |
|
82 | - public function html_class() |
|
83 | - { |
|
84 | - return ! empty($this->_html_class) ? $this->_html_class . ' ee-billing-form' : 'ee-billing-form'; |
|
85 | - } |
|
17 | + /** |
|
18 | + * The payment method this billing form is for |
|
19 | + * @var EE_Payment_Method |
|
20 | + */ |
|
21 | + protected $_pm_instance; |
|
22 | + |
|
23 | + |
|
24 | + |
|
25 | + /** |
|
26 | + * |
|
27 | + * @param EE_Payment_Method $payment_method |
|
28 | + * @param array $options_array @see EE_Form_Section_Proper::__construct() |
|
29 | + */ |
|
30 | + public function __construct(EE_Payment_Method $payment_method, $options_array = array()) |
|
31 | + { |
|
32 | + $this->_pm_instance = $payment_method; |
|
33 | + $this->_layout_strategy = new EE_Div_Per_Section_Layout(); |
|
34 | + parent::__construct($options_array); |
|
35 | + } |
|
36 | + |
|
37 | + |
|
38 | + |
|
39 | + /** |
|
40 | + * Sets the payment method for this billing form |
|
41 | + * @param EE_Payment_Method $payment_method |
|
42 | + * @return void |
|
43 | + */ |
|
44 | + public function set_payment_method(EE_Payment_Method $payment_method) |
|
45 | + { |
|
46 | + $this->_pm_instance = $payment_method; |
|
47 | + } |
|
48 | + |
|
49 | + |
|
50 | + |
|
51 | + /** |
|
52 | + * Returns the instance of the payment method this billing form is for |
|
53 | + * @return EE_Payment_Method |
|
54 | + */ |
|
55 | + public function payment_method() |
|
56 | + { |
|
57 | + return $this->_pm_instance; |
|
58 | + } |
|
59 | + |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * payment_fields_autofilled_notice_html |
|
64 | + * @return string |
|
65 | + */ |
|
66 | + public function payment_fields_autofilled_notice_html() |
|
67 | + { |
|
68 | + return new EE_Form_Section_HTML( |
|
69 | + EEH_HTML::p( |
|
70 | + apply_filters('FHEE__EE_Billing_Info_Form__payment_fields_autofilled_notice_html_text', __('Payment fields have been autofilled because you are in debug mode', 'event_espresso')), |
|
71 | + '', |
|
72 | + 'important-notice' |
|
73 | + ) |
|
74 | + ); |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + |
|
79 | + /** |
|
80 | + * @return string |
|
81 | + */ |
|
82 | + public function html_class() |
|
83 | + { |
|
84 | + return ! empty($this->_html_class) ? $this->_html_class . ' ee-billing-form' : 'ee-billing-form'; |
|
85 | + } |
|
86 | 86 | } |
87 | 87 | // End of file EE_Billing_Info_Form.form.php |
@@ -81,7 +81,7 @@ |
||
81 | 81 | */ |
82 | 82 | public function html_class() |
83 | 83 | { |
84 | - return ! empty($this->_html_class) ? $this->_html_class . ' ee-billing-form' : 'ee-billing-form'; |
|
84 | + return ! empty($this->_html_class) ? $this->_html_class.' ee-billing-form' : 'ee-billing-form'; |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | // End of file EE_Billing_Info_Form.form.php |