@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @since 4.3.0 |
8 | 8 | */ |
9 | 9 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
10 | - exit('No direct script access allowed'); |
|
10 | + exit('No direct script access allowed'); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
@@ -22,461 +22,461 @@ discard block |
||
22 | 22 | { |
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * Holds values for registered message types |
|
27 | - * |
|
28 | - * @var array |
|
29 | - */ |
|
30 | - protected static $_ee_message_type_registry = array(); |
|
25 | + /** |
|
26 | + * Holds values for registered message types |
|
27 | + * |
|
28 | + * @var array |
|
29 | + */ |
|
30 | + protected static $_ee_message_type_registry = array(); |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * Method for registering new message types in the EE_messages system. |
|
35 | - * Note: All message types must have the following files in order to work: |
|
36 | - * Template files for default templates getting setup. |
|
37 | - * See /core/libraries/messages/defaults/default/ for examples |
|
38 | - * (note that template files match a specific naming schema). |
|
39 | - * These templates will need to be registered with the default template pack. |
|
40 | - * - EE_Messages_Validator extended class(es). See /core/libraries/messages/validators/email/ |
|
41 | - * for examples. Note for any new message types, there will need to be a validator for each |
|
42 | - * messenger combo this message type can activate with. |
|
43 | - * - And of course the main EE_{Message_Type_Name}_message_type class that defines the new |
|
44 | - * message type and its properties. |
|
45 | - * |
|
46 | - * @since 4.3.0 |
|
47 | - * @param string $mt_name Whatever is defined for the $name property of |
|
48 | - * the message type you are registering (eg. |
|
49 | - * declined_registration). Required. |
|
50 | - * @param array $setup_args An array of arguments provided for registering the message type. |
|
51 | - * @see inline docs in the register method for what can be passed in as arguments. |
|
52 | - * @throws \EE_Error |
|
53 | - * } |
|
54 | - */ |
|
55 | - public static function register($mt_name = null, $setup_args = array()) |
|
56 | - { |
|
57 | - //required fields MUST be present, so let's make sure they are. |
|
58 | - if ( |
|
59 | - ! isset($mt_name) |
|
60 | - || ! is_array($setup_args) |
|
61 | - || empty($setup_args['mtfilename']) || empty($setup_args['autoloadpaths']) |
|
62 | - ) { |
|
63 | - throw new EE_Error( |
|
64 | - __('In order to register a message type with EE_Register_Message_Type::register, you must include a unique name for the message type, plus an array containing the following keys: "mtfilename", "autoloadpaths"', |
|
65 | - 'event_espresso') |
|
66 | - ); |
|
67 | - } |
|
33 | + /** |
|
34 | + * Method for registering new message types in the EE_messages system. |
|
35 | + * Note: All message types must have the following files in order to work: |
|
36 | + * Template files for default templates getting setup. |
|
37 | + * See /core/libraries/messages/defaults/default/ for examples |
|
38 | + * (note that template files match a specific naming schema). |
|
39 | + * These templates will need to be registered with the default template pack. |
|
40 | + * - EE_Messages_Validator extended class(es). See /core/libraries/messages/validators/email/ |
|
41 | + * for examples. Note for any new message types, there will need to be a validator for each |
|
42 | + * messenger combo this message type can activate with. |
|
43 | + * - And of course the main EE_{Message_Type_Name}_message_type class that defines the new |
|
44 | + * message type and its properties. |
|
45 | + * |
|
46 | + * @since 4.3.0 |
|
47 | + * @param string $mt_name Whatever is defined for the $name property of |
|
48 | + * the message type you are registering (eg. |
|
49 | + * declined_registration). Required. |
|
50 | + * @param array $setup_args An array of arguments provided for registering the message type. |
|
51 | + * @see inline docs in the register method for what can be passed in as arguments. |
|
52 | + * @throws \EE_Error |
|
53 | + * } |
|
54 | + */ |
|
55 | + public static function register($mt_name = null, $setup_args = array()) |
|
56 | + { |
|
57 | + //required fields MUST be present, so let's make sure they are. |
|
58 | + if ( |
|
59 | + ! isset($mt_name) |
|
60 | + || ! is_array($setup_args) |
|
61 | + || empty($setup_args['mtfilename']) || empty($setup_args['autoloadpaths']) |
|
62 | + ) { |
|
63 | + throw new EE_Error( |
|
64 | + __('In order to register a message type with EE_Register_Message_Type::register, you must include a unique name for the message type, plus an array containing the following keys: "mtfilename", "autoloadpaths"', |
|
65 | + 'event_espresso') |
|
66 | + ); |
|
67 | + } |
|
68 | 68 | |
69 | - //make sure we don't register twice |
|
70 | - if (isset(self::$_ee_message_type_registry[$mt_name])) { |
|
71 | - return; |
|
72 | - } |
|
69 | + //make sure we don't register twice |
|
70 | + if (isset(self::$_ee_message_type_registry[$mt_name])) { |
|
71 | + return; |
|
72 | + } |
|
73 | 73 | |
74 | - //make sure this was called in the right place! |
|
75 | - if ( |
|
76 | - ! did_action('EE_Brewing_Regular___messages_caf') |
|
77 | - || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations') |
|
78 | - ) { |
|
79 | - EE_Error::doing_it_wrong( |
|
80 | - __METHOD__, |
|
81 | - sprintf( |
|
82 | - __('A message type named "%s" has been attempted to be registered with the EE Messages System. It may or may not work because it should be only called on the "EE_Brewing_Regular___messages_caf" hook.', |
|
83 | - 'event_espresso'), |
|
84 | - $mt_name |
|
85 | - ), |
|
86 | - '4.3.0' |
|
87 | - ); |
|
88 | - } |
|
89 | - //setup $__ee_message_type_registry array from incoming values. |
|
90 | - self::$_ee_message_type_registry[$mt_name] = array( |
|
91 | - /** |
|
92 | - * The file name for the message type being registered. |
|
93 | - * Required. |
|
94 | - * @type string |
|
95 | - */ |
|
96 | - 'mtfilename' => (string)$setup_args['mtfilename'], |
|
97 | - /** |
|
98 | - * Autoload paths for classes used by the message type. |
|
99 | - * Required. |
|
100 | - * @type array |
|
101 | - */ |
|
102 | - 'autoloadpaths' => (array)$setup_args['autoloadpaths'], |
|
103 | - /** |
|
104 | - * Messengers that the message type should be able to activate with. |
|
105 | - * Use messenger slugs. |
|
106 | - * @type array |
|
107 | - */ |
|
108 | - 'messengers_to_activate_with' => ! empty($setup_args['messengers_to_activate_with']) |
|
109 | - ? (array)$setup_args['messengers_to_activate_with'] |
|
110 | - : array(), |
|
111 | - /** |
|
112 | - * Messengers that the message type should validate with. |
|
113 | - * Use messenger slugs. |
|
114 | - * @type array |
|
115 | - */ |
|
116 | - 'messengers_to_validate_with' => ! empty($setup_args['messengers_to_validate_with']) |
|
117 | - ? (array)$setup_args['messengers_to_validate_with'] |
|
118 | - : array(), |
|
119 | - /** |
|
120 | - * Whether to force activate this message type the first time it is registered. |
|
121 | - * @type bool False means its not activated by default and left up to the end user to activate. |
|
122 | - */ |
|
123 | - 'force_activation' => ! empty($setup_args['force_activation']) |
|
124 | - ? (bool)$setup_args['force_activation'] |
|
125 | - : false, |
|
126 | - /** |
|
127 | - * What messengers this message type supports the default template pack for. |
|
128 | - * Note: If you do not set this (or any of the following template pack/variation related arguments) to true, |
|
129 | - * then it is expected that the message type being registered is doing its own custom default template |
|
130 | - * pack/variation registration. |
|
131 | - * |
|
132 | - * If this is set and has values, then it is expected that the following arguments are also set in the incoming options |
|
133 | - * $setup_arguments array as well: |
|
134 | - * - 'base_path_for_default_templates' |
|
135 | - * |
|
136 | - * @type array Expect an array of messengers this supports default template packs for. |
|
137 | - */ |
|
138 | - 'messengers_supporting_default_template_pack_with' => isset($setup_args['messengers_supporting_default_template_pack_with']) |
|
139 | - ? (array)$setup_args['messengers_supporting_default_template_pack_with'] |
|
140 | - : array(), |
|
141 | - /** |
|
142 | - * The base path where the default templates for this message type can be found. |
|
143 | - * @type string |
|
144 | - */ |
|
145 | - 'base_path_for_default_templates' => isset($setup_args['base_path_for_default_templates']) |
|
146 | - ? $setup_args['base_path_for_default_templates'] |
|
147 | - : '', |
|
148 | - /** |
|
149 | - * The base path where the default variations for this message type can be found. |
|
150 | - * @type string |
|
151 | - */ |
|
152 | - 'base_path_for_default_variation' => isset($setup_args['base_path_for_default_variation']) |
|
153 | - ? $setup_args['base_path_for_default_variation'] |
|
154 | - : '', |
|
155 | - /** |
|
156 | - * The base url for the default variations for this message type. |
|
157 | - * @type string |
|
158 | - */ |
|
159 | - 'base_url_for_default_variation' => isset($setup_args['base_url_for_default_variation']) |
|
160 | - ? $setup_args['base_url_for_default_variation'] |
|
161 | - : '' |
|
162 | - ); |
|
163 | - //add filters but only if they haven't already been set (these filters only need to be registered ONCE because |
|
164 | - //the callback handles all registered message types. |
|
165 | - if ( false === has_filter( |
|
166 | - 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', |
|
167 | - array('EE_Register_Message_Type', 'register_msgs_autoload_paths') |
|
168 | - )) { |
|
169 | - add_filter( |
|
170 | - 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', |
|
171 | - array('EE_Register_Message_Type', 'register_msgs_autoload_paths'), |
|
172 | - 10 |
|
173 | - ); |
|
174 | - add_filter( |
|
175 | - 'FHEE__EE_messages__get_installed__messagetype_files', |
|
176 | - array('EE_Register_Message_Type', 'register_messagetype_files'), |
|
177 | - 10, |
|
178 | - 1 |
|
179 | - ); |
|
180 | - add_filter( |
|
181 | - 'FHEE__EE_messenger__get_default_message_types__default_types', |
|
182 | - array('EE_Register_Message_Type', 'register_messengers_to_activate_mt_with'), |
|
183 | - 10, |
|
184 | - 2 |
|
185 | - ); |
|
186 | - add_filter( |
|
187 | - 'FHEE__EE_messenger__get_valid_message_types__valid_types', |
|
188 | - array('EE_Register_Message_Type', 'register_messengers_to_validate_mt_with'), |
|
189 | - 10, |
|
190 | - 2 |
|
191 | - ); |
|
192 | - //actions |
|
193 | - add_action( |
|
194 | - 'AHEE__EE_Addon__initialize_default_data__begin', |
|
195 | - array('EE_Register_Message_Type', 'set_defaults') |
|
196 | - ); |
|
74 | + //make sure this was called in the right place! |
|
75 | + if ( |
|
76 | + ! did_action('EE_Brewing_Regular___messages_caf') |
|
77 | + || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations') |
|
78 | + ) { |
|
79 | + EE_Error::doing_it_wrong( |
|
80 | + __METHOD__, |
|
81 | + sprintf( |
|
82 | + __('A message type named "%s" has been attempted to be registered with the EE Messages System. It may or may not work because it should be only called on the "EE_Brewing_Regular___messages_caf" hook.', |
|
83 | + 'event_espresso'), |
|
84 | + $mt_name |
|
85 | + ), |
|
86 | + '4.3.0' |
|
87 | + ); |
|
88 | + } |
|
89 | + //setup $__ee_message_type_registry array from incoming values. |
|
90 | + self::$_ee_message_type_registry[$mt_name] = array( |
|
91 | + /** |
|
92 | + * The file name for the message type being registered. |
|
93 | + * Required. |
|
94 | + * @type string |
|
95 | + */ |
|
96 | + 'mtfilename' => (string)$setup_args['mtfilename'], |
|
97 | + /** |
|
98 | + * Autoload paths for classes used by the message type. |
|
99 | + * Required. |
|
100 | + * @type array |
|
101 | + */ |
|
102 | + 'autoloadpaths' => (array)$setup_args['autoloadpaths'], |
|
103 | + /** |
|
104 | + * Messengers that the message type should be able to activate with. |
|
105 | + * Use messenger slugs. |
|
106 | + * @type array |
|
107 | + */ |
|
108 | + 'messengers_to_activate_with' => ! empty($setup_args['messengers_to_activate_with']) |
|
109 | + ? (array)$setup_args['messengers_to_activate_with'] |
|
110 | + : array(), |
|
111 | + /** |
|
112 | + * Messengers that the message type should validate with. |
|
113 | + * Use messenger slugs. |
|
114 | + * @type array |
|
115 | + */ |
|
116 | + 'messengers_to_validate_with' => ! empty($setup_args['messengers_to_validate_with']) |
|
117 | + ? (array)$setup_args['messengers_to_validate_with'] |
|
118 | + : array(), |
|
119 | + /** |
|
120 | + * Whether to force activate this message type the first time it is registered. |
|
121 | + * @type bool False means its not activated by default and left up to the end user to activate. |
|
122 | + */ |
|
123 | + 'force_activation' => ! empty($setup_args['force_activation']) |
|
124 | + ? (bool)$setup_args['force_activation'] |
|
125 | + : false, |
|
126 | + /** |
|
127 | + * What messengers this message type supports the default template pack for. |
|
128 | + * Note: If you do not set this (or any of the following template pack/variation related arguments) to true, |
|
129 | + * then it is expected that the message type being registered is doing its own custom default template |
|
130 | + * pack/variation registration. |
|
131 | + * |
|
132 | + * If this is set and has values, then it is expected that the following arguments are also set in the incoming options |
|
133 | + * $setup_arguments array as well: |
|
134 | + * - 'base_path_for_default_templates' |
|
135 | + * |
|
136 | + * @type array Expect an array of messengers this supports default template packs for. |
|
137 | + */ |
|
138 | + 'messengers_supporting_default_template_pack_with' => isset($setup_args['messengers_supporting_default_template_pack_with']) |
|
139 | + ? (array)$setup_args['messengers_supporting_default_template_pack_with'] |
|
140 | + : array(), |
|
141 | + /** |
|
142 | + * The base path where the default templates for this message type can be found. |
|
143 | + * @type string |
|
144 | + */ |
|
145 | + 'base_path_for_default_templates' => isset($setup_args['base_path_for_default_templates']) |
|
146 | + ? $setup_args['base_path_for_default_templates'] |
|
147 | + : '', |
|
148 | + /** |
|
149 | + * The base path where the default variations for this message type can be found. |
|
150 | + * @type string |
|
151 | + */ |
|
152 | + 'base_path_for_default_variation' => isset($setup_args['base_path_for_default_variation']) |
|
153 | + ? $setup_args['base_path_for_default_variation'] |
|
154 | + : '', |
|
155 | + /** |
|
156 | + * The base url for the default variations for this message type. |
|
157 | + * @type string |
|
158 | + */ |
|
159 | + 'base_url_for_default_variation' => isset($setup_args['base_url_for_default_variation']) |
|
160 | + ? $setup_args['base_url_for_default_variation'] |
|
161 | + : '' |
|
162 | + ); |
|
163 | + //add filters but only if they haven't already been set (these filters only need to be registered ONCE because |
|
164 | + //the callback handles all registered message types. |
|
165 | + if ( false === has_filter( |
|
166 | + 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', |
|
167 | + array('EE_Register_Message_Type', 'register_msgs_autoload_paths') |
|
168 | + )) { |
|
169 | + add_filter( |
|
170 | + 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', |
|
171 | + array('EE_Register_Message_Type', 'register_msgs_autoload_paths'), |
|
172 | + 10 |
|
173 | + ); |
|
174 | + add_filter( |
|
175 | + 'FHEE__EE_messages__get_installed__messagetype_files', |
|
176 | + array('EE_Register_Message_Type', 'register_messagetype_files'), |
|
177 | + 10, |
|
178 | + 1 |
|
179 | + ); |
|
180 | + add_filter( |
|
181 | + 'FHEE__EE_messenger__get_default_message_types__default_types', |
|
182 | + array('EE_Register_Message_Type', 'register_messengers_to_activate_mt_with'), |
|
183 | + 10, |
|
184 | + 2 |
|
185 | + ); |
|
186 | + add_filter( |
|
187 | + 'FHEE__EE_messenger__get_valid_message_types__valid_types', |
|
188 | + array('EE_Register_Message_Type', 'register_messengers_to_validate_mt_with'), |
|
189 | + 10, |
|
190 | + 2 |
|
191 | + ); |
|
192 | + //actions |
|
193 | + add_action( |
|
194 | + 'AHEE__EE_Addon__initialize_default_data__begin', |
|
195 | + array('EE_Register_Message_Type', 'set_defaults') |
|
196 | + ); |
|
197 | 197 | |
198 | - //default template packs and variations related |
|
199 | - add_filter( |
|
200 | - 'FHEE__EE_Messages_Template_Pack_Default__get_supports', |
|
201 | - array('EE_Register_Message_Type', 'register_default_template_pack_supports') |
|
202 | - ); |
|
203 | - add_filter( |
|
204 | - 'FHEE__EE_Template_Pack___get_specific_template__filtered_base_path', |
|
205 | - array('EE_Register_Message_Type', 'register_base_template_path'), |
|
206 | - 10, |
|
207 | - 6 |
|
208 | - ); |
|
209 | - add_filter( |
|
210 | - 'FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url', |
|
211 | - array('EE_Register_Message_Type', 'register_variation_base_path_or_url'), |
|
212 | - 10, |
|
213 | - 8 |
|
214 | - ); |
|
215 | - add_filter( |
|
216 | - 'FHEE__EE_Messages_Template_Pack__get_variation__base_path', |
|
217 | - array('EE_Register_Message_Type', 'register_variation_base_path_or_url'), |
|
218 | - 10, |
|
219 | - 8 |
|
220 | - ); |
|
221 | - } |
|
222 | - } |
|
198 | + //default template packs and variations related |
|
199 | + add_filter( |
|
200 | + 'FHEE__EE_Messages_Template_Pack_Default__get_supports', |
|
201 | + array('EE_Register_Message_Type', 'register_default_template_pack_supports') |
|
202 | + ); |
|
203 | + add_filter( |
|
204 | + 'FHEE__EE_Template_Pack___get_specific_template__filtered_base_path', |
|
205 | + array('EE_Register_Message_Type', 'register_base_template_path'), |
|
206 | + 10, |
|
207 | + 6 |
|
208 | + ); |
|
209 | + add_filter( |
|
210 | + 'FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url', |
|
211 | + array('EE_Register_Message_Type', 'register_variation_base_path_or_url'), |
|
212 | + 10, |
|
213 | + 8 |
|
214 | + ); |
|
215 | + add_filter( |
|
216 | + 'FHEE__EE_Messages_Template_Pack__get_variation__base_path', |
|
217 | + array('EE_Register_Message_Type', 'register_variation_base_path_or_url'), |
|
218 | + 10, |
|
219 | + 8 |
|
220 | + ); |
|
221 | + } |
|
222 | + } |
|
223 | 223 | |
224 | 224 | |
225 | - /** |
|
226 | - * This just ensures that when an addon registers a message type that on initial activation/reactivation the |
|
227 | - * defaults the addon sets are taken care of. |
|
228 | - */ |
|
229 | - public static function set_defaults() |
|
230 | - { |
|
231 | - /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
232 | - $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
225 | + /** |
|
226 | + * This just ensures that when an addon registers a message type that on initial activation/reactivation the |
|
227 | + * defaults the addon sets are taken care of. |
|
228 | + */ |
|
229 | + public static function set_defaults() |
|
230 | + { |
|
231 | + /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
232 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
233 | 233 | |
234 | - //for any message types with force activation, let's ensure they are activated |
|
235 | - foreach (self::$_ee_message_type_registry as $message_type_name => $settings) { |
|
236 | - if ($settings['force_activation']) { |
|
237 | - foreach ($settings['messengers_to_activate_with'] as $messenger) { |
|
238 | - //DO not force activation if this message type has already been activated in the system |
|
239 | - if (! $message_resource_manager->has_message_type_been_activated_for_messenger($message_type_name, |
|
240 | - $messenger) |
|
241 | - ) { |
|
242 | - $message_resource_manager->ensure_message_type_is_active($message_type_name, $messenger); |
|
243 | - } |
|
244 | - } |
|
245 | - } |
|
246 | - } |
|
247 | - } |
|
234 | + //for any message types with force activation, let's ensure they are activated |
|
235 | + foreach (self::$_ee_message_type_registry as $message_type_name => $settings) { |
|
236 | + if ($settings['force_activation']) { |
|
237 | + foreach ($settings['messengers_to_activate_with'] as $messenger) { |
|
238 | + //DO not force activation if this message type has already been activated in the system |
|
239 | + if (! $message_resource_manager->has_message_type_been_activated_for_messenger($message_type_name, |
|
240 | + $messenger) |
|
241 | + ) { |
|
242 | + $message_resource_manager->ensure_message_type_is_active($message_type_name, $messenger); |
|
243 | + } |
|
244 | + } |
|
245 | + } |
|
246 | + } |
|
247 | + } |
|
248 | 248 | |
249 | 249 | |
250 | - /** |
|
251 | - * This deregisters a message type that was previously registered with a specific message_type_name. |
|
252 | - * |
|
253 | - * @since 4.3.0 |
|
254 | - * @param string $message_type_name the name for the message type that was previously registered |
|
255 | - * @return void |
|
256 | - */ |
|
257 | - public static function deregister($message_type_name = null) |
|
258 | - { |
|
259 | - if (! empty(self::$_ee_message_type_registry[$message_type_name])) { |
|
260 | - //let's make sure that we remove any place this message type was made active |
|
261 | - /** @var EE_Message_Resource_Manager $Message_Resource_Manager */ |
|
262 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
263 | - //ensures that if this message type is registered again that it retains its previous active state vs |
|
264 | - //remaining inactive. |
|
265 | - $Message_Resource_Manager->remove_message_type_has_been_activated_from_all_messengers( |
|
266 | - $message_type_name, |
|
267 | - true |
|
268 | - ); |
|
269 | - $Message_Resource_Manager->deactivate_message_type($message_type_name, false); |
|
270 | - unset(self::$_ee_message_type_registry[$message_type_name]); |
|
271 | - } |
|
272 | - } |
|
250 | + /** |
|
251 | + * This deregisters a message type that was previously registered with a specific message_type_name. |
|
252 | + * |
|
253 | + * @since 4.3.0 |
|
254 | + * @param string $message_type_name the name for the message type that was previously registered |
|
255 | + * @return void |
|
256 | + */ |
|
257 | + public static function deregister($message_type_name = null) |
|
258 | + { |
|
259 | + if (! empty(self::$_ee_message_type_registry[$message_type_name])) { |
|
260 | + //let's make sure that we remove any place this message type was made active |
|
261 | + /** @var EE_Message_Resource_Manager $Message_Resource_Manager */ |
|
262 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
263 | + //ensures that if this message type is registered again that it retains its previous active state vs |
|
264 | + //remaining inactive. |
|
265 | + $Message_Resource_Manager->remove_message_type_has_been_activated_from_all_messengers( |
|
266 | + $message_type_name, |
|
267 | + true |
|
268 | + ); |
|
269 | + $Message_Resource_Manager->deactivate_message_type($message_type_name, false); |
|
270 | + unset(self::$_ee_message_type_registry[$message_type_name]); |
|
271 | + } |
|
272 | + } |
|
273 | 273 | |
274 | 274 | |
275 | - /** |
|
276 | - * callback for FHEE__EE_messages__get_installed__messagetype_files filter. |
|
277 | - * |
|
278 | - * @since 4.3.0 |
|
279 | - * @param array $messagetype_files The current array of message type file names |
|
280 | - * @return array Array of message type file names |
|
281 | - */ |
|
282 | - public static function register_messagetype_files($messagetype_files) |
|
283 | - { |
|
284 | - if (empty(self::$_ee_message_type_registry)) { |
|
285 | - return $messagetype_files; |
|
286 | - } |
|
287 | - foreach (self::$_ee_message_type_registry as $mt_reg) { |
|
288 | - if (empty($mt_reg['mtfilename'])) { |
|
289 | - continue; |
|
290 | - } |
|
291 | - $messagetype_files[] = $mt_reg['mtfilename']; |
|
292 | - } |
|
293 | - return $messagetype_files; |
|
294 | - } |
|
275 | + /** |
|
276 | + * callback for FHEE__EE_messages__get_installed__messagetype_files filter. |
|
277 | + * |
|
278 | + * @since 4.3.0 |
|
279 | + * @param array $messagetype_files The current array of message type file names |
|
280 | + * @return array Array of message type file names |
|
281 | + */ |
|
282 | + public static function register_messagetype_files($messagetype_files) |
|
283 | + { |
|
284 | + if (empty(self::$_ee_message_type_registry)) { |
|
285 | + return $messagetype_files; |
|
286 | + } |
|
287 | + foreach (self::$_ee_message_type_registry as $mt_reg) { |
|
288 | + if (empty($mt_reg['mtfilename'])) { |
|
289 | + continue; |
|
290 | + } |
|
291 | + $messagetype_files[] = $mt_reg['mtfilename']; |
|
292 | + } |
|
293 | + return $messagetype_files; |
|
294 | + } |
|
295 | 295 | |
296 | 296 | |
297 | - /** |
|
298 | - * callback for FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter. |
|
299 | - * |
|
300 | - * @since 4.3.0 |
|
301 | - * @param array $paths array of paths to be checked by EE_messages autoloader. |
|
302 | - * @return array |
|
303 | - */ |
|
304 | - public static function register_msgs_autoload_paths($paths) |
|
305 | - { |
|
306 | - if (! empty(self::$_ee_message_type_registry)) { |
|
307 | - foreach (self::$_ee_message_type_registry as $mt_reg) { |
|
308 | - if (empty($mt_reg['autoloadpaths'])) { |
|
309 | - continue; |
|
310 | - } |
|
311 | - $paths = array_merge($paths, $mt_reg['autoloadpaths']); |
|
312 | - } |
|
313 | - } |
|
314 | - return $paths; |
|
315 | - } |
|
297 | + /** |
|
298 | + * callback for FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter. |
|
299 | + * |
|
300 | + * @since 4.3.0 |
|
301 | + * @param array $paths array of paths to be checked by EE_messages autoloader. |
|
302 | + * @return array |
|
303 | + */ |
|
304 | + public static function register_msgs_autoload_paths($paths) |
|
305 | + { |
|
306 | + if (! empty(self::$_ee_message_type_registry)) { |
|
307 | + foreach (self::$_ee_message_type_registry as $mt_reg) { |
|
308 | + if (empty($mt_reg['autoloadpaths'])) { |
|
309 | + continue; |
|
310 | + } |
|
311 | + $paths = array_merge($paths, $mt_reg['autoloadpaths']); |
|
312 | + } |
|
313 | + } |
|
314 | + return $paths; |
|
315 | + } |
|
316 | 316 | |
317 | 317 | |
318 | - /** |
|
319 | - * callback for FHEE__EE_messenger__get_default_message_types__default_types filter. |
|
320 | - * |
|
321 | - * @since 4.3.0 |
|
322 | - * @param array $default_types array of message types activated with messenger ( |
|
323 | - * corresponds to the $name property of message type) |
|
324 | - * @param EE_messenger $messenger The EE_messenger the filter is called from. |
|
325 | - * @return array |
|
326 | - */ |
|
327 | - public static function register_messengers_to_activate_mt_with($default_types, EE_messenger $messenger) |
|
328 | - { |
|
329 | - if (empty(self::$_ee_message_type_registry)) { |
|
330 | - return $default_types; |
|
331 | - } |
|
332 | - foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
|
333 | - if (empty($mt_reg['messengers_to_activate_with']) || empty($mt_reg['mtfilename'])) { |
|
334 | - continue; |
|
335 | - } |
|
336 | - // loop through each of the messengers and if it matches the loaded class |
|
337 | - // then we add this message type to the |
|
338 | - foreach ($mt_reg['messengers_to_activate_with'] as $msgr) { |
|
339 | - if ($messenger->name == $msgr) { |
|
340 | - $default_types[] = $message_type_name; |
|
341 | - } |
|
342 | - } |
|
343 | - } |
|
318 | + /** |
|
319 | + * callback for FHEE__EE_messenger__get_default_message_types__default_types filter. |
|
320 | + * |
|
321 | + * @since 4.3.0 |
|
322 | + * @param array $default_types array of message types activated with messenger ( |
|
323 | + * corresponds to the $name property of message type) |
|
324 | + * @param EE_messenger $messenger The EE_messenger the filter is called from. |
|
325 | + * @return array |
|
326 | + */ |
|
327 | + public static function register_messengers_to_activate_mt_with($default_types, EE_messenger $messenger) |
|
328 | + { |
|
329 | + if (empty(self::$_ee_message_type_registry)) { |
|
330 | + return $default_types; |
|
331 | + } |
|
332 | + foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
|
333 | + if (empty($mt_reg['messengers_to_activate_with']) || empty($mt_reg['mtfilename'])) { |
|
334 | + continue; |
|
335 | + } |
|
336 | + // loop through each of the messengers and if it matches the loaded class |
|
337 | + // then we add this message type to the |
|
338 | + foreach ($mt_reg['messengers_to_activate_with'] as $msgr) { |
|
339 | + if ($messenger->name == $msgr) { |
|
340 | + $default_types[] = $message_type_name; |
|
341 | + } |
|
342 | + } |
|
343 | + } |
|
344 | 344 | |
345 | - return $default_types; |
|
346 | - } |
|
345 | + return $default_types; |
|
346 | + } |
|
347 | 347 | |
348 | 348 | |
349 | - /** |
|
350 | - * callback for FHEE__EE_messenger__get_valid_message_types__default_types filter. |
|
351 | - * |
|
352 | - * @since 4.3.0 |
|
353 | - * @param array $valid_types array of message types valid with messenger ( |
|
354 | - * corresponds to the $name property of message type) |
|
355 | - * @param EE_messenger $messenger The EE_messenger the filter is called from. |
|
356 | - * @return array |
|
357 | - */ |
|
358 | - public static function register_messengers_to_validate_mt_with($valid_types, EE_messenger $messenger) |
|
359 | - { |
|
360 | - if (empty(self::$_ee_message_type_registry)) { |
|
361 | - return $valid_types; |
|
362 | - } |
|
363 | - foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
|
364 | - if (empty($mt_reg['messengers_to_validate_with']) || empty($mt_reg['mtfilename'])) { |
|
365 | - continue; |
|
366 | - } |
|
367 | - // loop through each of the messengers and if it matches the loaded class |
|
368 | - // then we add this message type to the |
|
369 | - foreach ($mt_reg['messengers_to_validate_with'] as $msgr) { |
|
370 | - if ($messenger->name == $msgr) { |
|
371 | - $valid_types[] = $message_type_name; |
|
372 | - } |
|
373 | - } |
|
374 | - } |
|
349 | + /** |
|
350 | + * callback for FHEE__EE_messenger__get_valid_message_types__default_types filter. |
|
351 | + * |
|
352 | + * @since 4.3.0 |
|
353 | + * @param array $valid_types array of message types valid with messenger ( |
|
354 | + * corresponds to the $name property of message type) |
|
355 | + * @param EE_messenger $messenger The EE_messenger the filter is called from. |
|
356 | + * @return array |
|
357 | + */ |
|
358 | + public static function register_messengers_to_validate_mt_with($valid_types, EE_messenger $messenger) |
|
359 | + { |
|
360 | + if (empty(self::$_ee_message_type_registry)) { |
|
361 | + return $valid_types; |
|
362 | + } |
|
363 | + foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
|
364 | + if (empty($mt_reg['messengers_to_validate_with']) || empty($mt_reg['mtfilename'])) { |
|
365 | + continue; |
|
366 | + } |
|
367 | + // loop through each of the messengers and if it matches the loaded class |
|
368 | + // then we add this message type to the |
|
369 | + foreach ($mt_reg['messengers_to_validate_with'] as $msgr) { |
|
370 | + if ($messenger->name == $msgr) { |
|
371 | + $valid_types[] = $message_type_name; |
|
372 | + } |
|
373 | + } |
|
374 | + } |
|
375 | 375 | |
376 | - return $valid_types; |
|
377 | - } |
|
376 | + return $valid_types; |
|
377 | + } |
|
378 | 378 | |
379 | 379 | |
380 | - /** |
|
381 | - * Callback for `FHEE__EE_Messages_Template_Pack_Default__get_supports` filter to register this message type as |
|
382 | - * supporting the default template pack |
|
383 | - * |
|
384 | - * @param array $supports |
|
385 | - * |
|
386 | - * @return array |
|
387 | - */ |
|
388 | - public static function register_default_template_pack_supports($supports) |
|
389 | - { |
|
390 | - foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
|
391 | - if (empty($mt_reg['messengers_supporting_default_template_pack_with'])) { |
|
392 | - continue; |
|
393 | - } |
|
394 | - foreach ($mt_reg['messengers_supporting_default_template_pack_with'] as $messenger_slug) { |
|
395 | - $supports[$messenger_slug][] = $message_type_name; |
|
396 | - } |
|
397 | - } |
|
398 | - return $supports; |
|
399 | - } |
|
380 | + /** |
|
381 | + * Callback for `FHEE__EE_Messages_Template_Pack_Default__get_supports` filter to register this message type as |
|
382 | + * supporting the default template pack |
|
383 | + * |
|
384 | + * @param array $supports |
|
385 | + * |
|
386 | + * @return array |
|
387 | + */ |
|
388 | + public static function register_default_template_pack_supports($supports) |
|
389 | + { |
|
390 | + foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
|
391 | + if (empty($mt_reg['messengers_supporting_default_template_pack_with'])) { |
|
392 | + continue; |
|
393 | + } |
|
394 | + foreach ($mt_reg['messengers_supporting_default_template_pack_with'] as $messenger_slug) { |
|
395 | + $supports[$messenger_slug][] = $message_type_name; |
|
396 | + } |
|
397 | + } |
|
398 | + return $supports; |
|
399 | + } |
|
400 | 400 | |
401 | 401 | |
402 | - /** |
|
403 | - * Callback for FHEE__EE_Template_Pack___get_specific_template__filtered_base_path |
|
404 | - * |
|
405 | - * @param string $base_path The original base path for message templates |
|
406 | - * @param EE_messenger $messenger |
|
407 | - * @param EE_message_type $message_type |
|
408 | - * @param string $field The field requesting a template |
|
409 | - * @param string $context The context requesting a template |
|
410 | - * @param EE_Messages_Template_Pack $template_pack |
|
411 | - * |
|
412 | - * @return string |
|
413 | - */ |
|
414 | - public static function register_base_template_path( |
|
415 | - $base_path, |
|
416 | - $messenger, |
|
417 | - $message_type, |
|
418 | - $field, |
|
419 | - $context, |
|
420 | - $template_pack |
|
421 | - ) { |
|
422 | - if (! $template_pack instanceof EE_Messages_Template_Pack_Default |
|
423 | - || ! $message_type instanceof EE_message_type |
|
424 | - ) { |
|
425 | - return $base_path; |
|
426 | - } |
|
427 | - foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
|
428 | - if ($message_type->name === $message_type_name |
|
429 | - && ! empty($mt_reg['base_path_for_default_templates']) |
|
430 | - ) { |
|
431 | - return $mt_reg['base_path_for_default_templates']; |
|
432 | - } |
|
433 | - } |
|
434 | - return $base_path; |
|
435 | - } |
|
402 | + /** |
|
403 | + * Callback for FHEE__EE_Template_Pack___get_specific_template__filtered_base_path |
|
404 | + * |
|
405 | + * @param string $base_path The original base path for message templates |
|
406 | + * @param EE_messenger $messenger |
|
407 | + * @param EE_message_type $message_type |
|
408 | + * @param string $field The field requesting a template |
|
409 | + * @param string $context The context requesting a template |
|
410 | + * @param EE_Messages_Template_Pack $template_pack |
|
411 | + * |
|
412 | + * @return string |
|
413 | + */ |
|
414 | + public static function register_base_template_path( |
|
415 | + $base_path, |
|
416 | + $messenger, |
|
417 | + $message_type, |
|
418 | + $field, |
|
419 | + $context, |
|
420 | + $template_pack |
|
421 | + ) { |
|
422 | + if (! $template_pack instanceof EE_Messages_Template_Pack_Default |
|
423 | + || ! $message_type instanceof EE_message_type |
|
424 | + ) { |
|
425 | + return $base_path; |
|
426 | + } |
|
427 | + foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
|
428 | + if ($message_type->name === $message_type_name |
|
429 | + && ! empty($mt_reg['base_path_for_default_templates']) |
|
430 | + ) { |
|
431 | + return $mt_reg['base_path_for_default_templates']; |
|
432 | + } |
|
433 | + } |
|
434 | + return $base_path; |
|
435 | + } |
|
436 | 436 | |
437 | 437 | |
438 | - /** |
|
439 | - * Callback for FHEE__EE_Messages_Template_Pack__get_variation__base_path and |
|
440 | - * FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url hooks |
|
441 | - * |
|
442 | - * @param string $base_path_or_url The original incoming base url or path |
|
443 | - * @param string $messenger_slug The slug of the messenger the template is being generated for. |
|
444 | - * @param string $message_type_slug The slug of the message type the template is being generated for. |
|
445 | - * @param string $type The "type" of css being requested. |
|
446 | - * @param string $variation The variation being requested. |
|
447 | - * @param string $file_extension What file extension is expected for the variation file. |
|
448 | - * @param bool $url whether a url or path is being requested. |
|
449 | - * @param EE_Messages_Template_Pack $template_pack |
|
450 | - * |
|
451 | - * @return string |
|
452 | - */ |
|
453 | - public static function register_variation_base_path_or_url( |
|
454 | - $base_path_or_url, |
|
455 | - $messenger_slug, |
|
456 | - $message_type_slug, |
|
457 | - $type, |
|
458 | - $variation, |
|
459 | - $url, |
|
460 | - $file_extension, |
|
461 | - $template_pack |
|
462 | - ) { |
|
463 | - if (! $template_pack instanceof EE_Messages_Template_Pack_Default) { |
|
464 | - return $base_path_or_url; |
|
465 | - } |
|
466 | - foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
|
467 | - if ($message_type_name === $message_type_slug |
|
468 | - ) { |
|
469 | - if ($url |
|
470 | - && ! empty($mt_reg['base_url_for_default_variation']) |
|
471 | - ) { |
|
472 | - return $mt_reg['base_url_for_default_variation']; |
|
473 | - } elseif (! $url |
|
474 | - && ! empty($mt_reg['base_path_for_default_variation']) |
|
475 | - ) { |
|
476 | - return $mt_reg['base_path_for_default_variation']; |
|
477 | - } |
|
478 | - } |
|
479 | - } |
|
480 | - return $base_path_or_url; |
|
481 | - } |
|
438 | + /** |
|
439 | + * Callback for FHEE__EE_Messages_Template_Pack__get_variation__base_path and |
|
440 | + * FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url hooks |
|
441 | + * |
|
442 | + * @param string $base_path_or_url The original incoming base url or path |
|
443 | + * @param string $messenger_slug The slug of the messenger the template is being generated for. |
|
444 | + * @param string $message_type_slug The slug of the message type the template is being generated for. |
|
445 | + * @param string $type The "type" of css being requested. |
|
446 | + * @param string $variation The variation being requested. |
|
447 | + * @param string $file_extension What file extension is expected for the variation file. |
|
448 | + * @param bool $url whether a url or path is being requested. |
|
449 | + * @param EE_Messages_Template_Pack $template_pack |
|
450 | + * |
|
451 | + * @return string |
|
452 | + */ |
|
453 | + public static function register_variation_base_path_or_url( |
|
454 | + $base_path_or_url, |
|
455 | + $messenger_slug, |
|
456 | + $message_type_slug, |
|
457 | + $type, |
|
458 | + $variation, |
|
459 | + $url, |
|
460 | + $file_extension, |
|
461 | + $template_pack |
|
462 | + ) { |
|
463 | + if (! $template_pack instanceof EE_Messages_Template_Pack_Default) { |
|
464 | + return $base_path_or_url; |
|
465 | + } |
|
466 | + foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
|
467 | + if ($message_type_name === $message_type_slug |
|
468 | + ) { |
|
469 | + if ($url |
|
470 | + && ! empty($mt_reg['base_url_for_default_variation']) |
|
471 | + ) { |
|
472 | + return $mt_reg['base_url_for_default_variation']; |
|
473 | + } elseif (! $url |
|
474 | + && ! empty($mt_reg['base_path_for_default_variation']) |
|
475 | + ) { |
|
476 | + return $mt_reg['base_path_for_default_variation']; |
|
477 | + } |
|
478 | + } |
|
479 | + } |
|
480 | + return $base_path_or_url; |
|
481 | + } |
|
482 | 482 | } |
@@ -20,33 +20,33 @@ |
||
20 | 20 | class Windows1252 extends FormatterBase |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * Converts the string to windows-1252 encoding. |
|
25 | - * |
|
26 | - * @param string|int|float $input anything easily cast into a string |
|
27 | - * @return string |
|
28 | - */ |
|
29 | - public function format($input) |
|
30 | - { |
|
31 | - //in case an int or float etc was passed in |
|
32 | - $input = (string)$input; |
|
33 | - if (function_exists('iconv')) { |
|
34 | - $input = iconv('utf-8', 'cp1252//TRANSLIT', $input); |
|
35 | - } elseif ( WP_DEBUG) { |
|
36 | - trigger_error( |
|
37 | - sprintf( |
|
38 | - // @codingStandardsIgnoreStart |
|
39 | - esc_html__('%1$s could not format the string "%2$s" because the function "%3$s" does not exist. Please verify PHP is installed with this function, see %4$s', 'event_espresso'), |
|
40 | - // @codingStandardsIgnoreEnd |
|
41 | - get_class($this), |
|
42 | - $input, |
|
43 | - 'iconv', |
|
44 | - '<a href="http://php.net/manual/en/iconv.installation.php">http://php.net/manual/en/iconv.installation.php</a>' |
|
45 | - ) |
|
46 | - ); |
|
47 | - } |
|
48 | - return $input; |
|
49 | - } |
|
23 | + /** |
|
24 | + * Converts the string to windows-1252 encoding. |
|
25 | + * |
|
26 | + * @param string|int|float $input anything easily cast into a string |
|
27 | + * @return string |
|
28 | + */ |
|
29 | + public function format($input) |
|
30 | + { |
|
31 | + //in case an int or float etc was passed in |
|
32 | + $input = (string)$input; |
|
33 | + if (function_exists('iconv')) { |
|
34 | + $input = iconv('utf-8', 'cp1252//TRANSLIT', $input); |
|
35 | + } elseif ( WP_DEBUG) { |
|
36 | + trigger_error( |
|
37 | + sprintf( |
|
38 | + // @codingStandardsIgnoreStart |
|
39 | + esc_html__('%1$s could not format the string "%2$s" because the function "%3$s" does not exist. Please verify PHP is installed with this function, see %4$s', 'event_espresso'), |
|
40 | + // @codingStandardsIgnoreEnd |
|
41 | + get_class($this), |
|
42 | + $input, |
|
43 | + 'iconv', |
|
44 | + '<a href="http://php.net/manual/en/iconv.installation.php">http://php.net/manual/en/iconv.installation.php</a>' |
|
45 | + ) |
|
46 | + ); |
|
47 | + } |
|
48 | + return $input; |
|
49 | + } |
|
50 | 50 | } |
51 | 51 | // End of file EmojiRemoval.php |
52 | 52 | // Location: core\services\formatters/EmojiRemoval.php |
@@ -29,10 +29,10 @@ |
||
29 | 29 | public function format($input) |
30 | 30 | { |
31 | 31 | //in case an int or float etc was passed in |
32 | - $input = (string)$input; |
|
32 | + $input = (string) $input; |
|
33 | 33 | if (function_exists('iconv')) { |
34 | 34 | $input = iconv('utf-8', 'cp1252//TRANSLIT', $input); |
35 | - } elseif ( WP_DEBUG) { |
|
35 | + } elseif (WP_DEBUG) { |
|
36 | 36 | trigger_error( |
37 | 37 | sprintf( |
38 | 38 | // @codingStandardsIgnoreStart |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -16,1142 +16,1142 @@ discard block |
||
16 | 16 | abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * the input's name attribute |
|
21 | - * |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - protected $_html_name; |
|
25 | - |
|
26 | - /** |
|
27 | - * id for the html label tag |
|
28 | - * |
|
29 | - * @var string |
|
30 | - */ |
|
31 | - protected $_html_label_id; |
|
32 | - |
|
33 | - /** |
|
34 | - * class for teh html label tag |
|
35 | - * |
|
36 | - * @var string |
|
37 | - */ |
|
38 | - protected $_html_label_class; |
|
39 | - |
|
40 | - /** |
|
41 | - * any additional html attributes that you may want to add |
|
42 | - * |
|
43 | - * @var string |
|
44 | - */ |
|
45 | - protected $_html_other_attributes; |
|
46 | - |
|
47 | - /** |
|
48 | - * style for teh html label tag |
|
49 | - * |
|
50 | - * @var string |
|
51 | - */ |
|
52 | - protected $_html_label_style; |
|
53 | - |
|
54 | - /** |
|
55 | - * text to be placed in the html label |
|
56 | - * |
|
57 | - * @var string |
|
58 | - */ |
|
59 | - protected $_html_label_text; |
|
60 | - |
|
61 | - /** |
|
62 | - * the full html label. If used, all other html_label_* properties are invalid |
|
63 | - * |
|
64 | - * @var string |
|
65 | - */ |
|
66 | - protected $_html_label; |
|
67 | - |
|
68 | - /** |
|
69 | - * HTML to use for help text (normally placed below form input), in a span which normally |
|
70 | - * has a class of 'description' |
|
71 | - * |
|
72 | - * @var string |
|
73 | - */ |
|
74 | - protected $_html_help_text; |
|
75 | - |
|
76 | - /** |
|
77 | - * CSS classes for displaying the help span |
|
78 | - * |
|
79 | - * @var string |
|
80 | - */ |
|
81 | - protected $_html_help_class = 'description'; |
|
82 | - |
|
83 | - /** |
|
84 | - * CSS to put in the style attribute on the help span |
|
85 | - * |
|
86 | - * @var string |
|
87 | - */ |
|
88 | - protected $_html_help_style; |
|
89 | - |
|
90 | - /** |
|
91 | - * Stores whether or not this input's response is required. |
|
92 | - * Because certain styling elements may also want to know that this |
|
93 | - * input is required etc. |
|
94 | - * |
|
95 | - * @var boolean |
|
96 | - */ |
|
97 | - protected $_required; |
|
98 | - |
|
99 | - /** |
|
100 | - * css class added to required inputs |
|
101 | - * |
|
102 | - * @var string |
|
103 | - */ |
|
104 | - protected $_required_css_class = 'ee-required'; |
|
105 | - |
|
106 | - /** |
|
107 | - * css styles applied to button type inputs |
|
108 | - * |
|
109 | - * @var string |
|
110 | - */ |
|
111 | - protected $_button_css_attributes; |
|
112 | - |
|
113 | - /** |
|
114 | - * The raw data submitted for this, like in the $_POST super global. |
|
115 | - * Generally unsafe for usage in client code |
|
116 | - * |
|
117 | - * @var mixed string or array |
|
118 | - */ |
|
119 | - protected $_raw_value; |
|
120 | - |
|
121 | - /** |
|
122 | - * Value normalized according to the input's normalization strategy. |
|
123 | - * The normalization strategy dictates whether this is a string, int, float, |
|
124 | - * boolean, or array of any of those. |
|
125 | - * |
|
126 | - * @var mixed |
|
127 | - */ |
|
128 | - protected $_normalized_value; |
|
129 | - |
|
130 | - /** |
|
131 | - * Strategy used for displaying this field. |
|
132 | - * Child classes must use _get_display_strategy to access it. |
|
133 | - * |
|
134 | - * @var EE_Display_Strategy_Base |
|
135 | - */ |
|
136 | - private $_display_strategy; |
|
137 | - |
|
138 | - /** |
|
139 | - * Gets all the validation strategies used on this field |
|
140 | - * |
|
141 | - * @var EE_Validation_Strategy_Base[] |
|
142 | - */ |
|
143 | - private $_validation_strategies = array(); |
|
144 | - |
|
145 | - /** |
|
146 | - * The normalization strategy for this field |
|
147 | - * |
|
148 | - * @var EE_Normalization_Strategy_Base |
|
149 | - */ |
|
150 | - private $_normalization_strategy; |
|
151 | - |
|
152 | - /** |
|
153 | - * Strategy for removing sensitive data after we're done with the form input |
|
154 | - * |
|
155 | - * @var EE_Sensitive_Data_Removal_Base |
|
156 | - */ |
|
157 | - protected $_sensitive_data_removal_strategy; |
|
158 | - |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * @param array $input_args { |
|
163 | - * @type string $html_name the html name for the input |
|
164 | - * @type string $html_label_id the id attribute to give to the html label tag |
|
165 | - * @type string $html_label_class the class attribute to give to the html label tag |
|
166 | - * @type string $html_label_style the style attribute to give ot teh label tag |
|
167 | - * @type string $html_label_text the text to put in the label tag |
|
168 | - * @type string $html_label the full html label. If used, |
|
169 | - * all other html_label_* args are invalid |
|
170 | - * @type string $html_help_text text to put in help element |
|
171 | - * @type string $html_help_style style attribute to give to teh help element |
|
172 | - * @type string $html_help_class class attribute to give to the help element |
|
173 | - * @type string $default default value NORMALIZED (eg, if providing the default |
|
174 | - * for a Yes_No_Input, you should provide TRUE or FALSE, not '1' or '0') |
|
175 | - * @type EE_Display_Strategy_Base $display strategy |
|
176 | - * @type EE_Normalization_Strategy_Base $normalization_strategy |
|
177 | - * @type EE_Validation_Strategy_Base[] $validation_strategies |
|
178 | - * } |
|
179 | - */ |
|
180 | - public function __construct($input_args = array()) |
|
181 | - { |
|
182 | - $input_args = (array)apply_filters('FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this); |
|
183 | - // the following properties must be cast as arrays |
|
184 | - if (isset($input_args['validation_strategies'])) { |
|
185 | - foreach ((array)$input_args['validation_strategies'] as $validation_strategy) { |
|
186 | - if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
187 | - $this->_validation_strategies[get_class($validation_strategy)] = $validation_strategy; |
|
188 | - } |
|
189 | - } |
|
190 | - unset($input_args['validation_strategies']); |
|
191 | - } |
|
192 | - // loop thru incoming options |
|
193 | - foreach ($input_args as $key => $value) { |
|
194 | - // add underscore to $key to match property names |
|
195 | - $_key = '_' . $key; |
|
196 | - if (property_exists($this, $_key)) { |
|
197 | - $this->{$_key} = $value; |
|
198 | - } |
|
199 | - } |
|
200 | - // ensure that "required" is set correctly |
|
201 | - $this->set_required( |
|
202 | - $this->_required, isset($input_args['required_validation_error_message']) |
|
203 | - ? $input_args['required_validation_error_message'] |
|
204 | - : null |
|
205 | - ); |
|
206 | - //$this->_html_name_specified = isset( $input_args['html_name'] ) ? TRUE : FALSE; |
|
207 | - $this->_display_strategy->_construct_finalize($this); |
|
208 | - foreach ($this->_validation_strategies as $validation_strategy) { |
|
209 | - $validation_strategy->_construct_finalize($this); |
|
210 | - } |
|
211 | - if (! $this->_normalization_strategy) { |
|
212 | - $this->_normalization_strategy = new EE_Text_Normalization(); |
|
213 | - } |
|
214 | - $this->_normalization_strategy->_construct_finalize($this); |
|
215 | - //at least we can use the normalization strategy to populate the default |
|
216 | - if (isset($input_args['default'])) { |
|
217 | - $this->set_default($input_args['default']); |
|
218 | - } |
|
219 | - if (! $this->_sensitive_data_removal_strategy) { |
|
220 | - $this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal(); |
|
221 | - } |
|
222 | - $this->_sensitive_data_removal_strategy->_construct_finalize($this); |
|
223 | - parent::__construct($input_args); |
|
224 | - } |
|
225 | - |
|
226 | - |
|
227 | - |
|
228 | - /** |
|
229 | - * Sets the html_name to its default value, if none was specified in teh constructor. |
|
230 | - * Calculation involves using the name and the parent's html_name |
|
231 | - * |
|
232 | - * @throws \EE_Error |
|
233 | - */ |
|
234 | - protected function _set_default_html_name_if_empty() |
|
235 | - { |
|
236 | - if (! $this->_html_name) { |
|
237 | - $this->_html_name = $this->name(); |
|
238 | - if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
|
239 | - $this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]"; |
|
240 | - } |
|
241 | - } |
|
242 | - } |
|
243 | - |
|
244 | - |
|
245 | - |
|
246 | - /** |
|
247 | - * @param $parent_form_section |
|
248 | - * @param $name |
|
249 | - * @throws \EE_Error |
|
250 | - */ |
|
251 | - public function _construct_finalize($parent_form_section, $name) |
|
252 | - { |
|
253 | - parent::_construct_finalize($parent_form_section, $name); |
|
254 | - if ($this->_html_label === null && $this->_html_label_text === null) { |
|
255 | - $this->_html_label_text = ucwords(str_replace("_", " ", $name)); |
|
256 | - } |
|
257 | - do_action('AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name); |
|
258 | - } |
|
259 | - |
|
260 | - |
|
261 | - |
|
262 | - /** |
|
263 | - * Returns the strategy for displaying this form input. If none is set, throws an exception. |
|
264 | - * |
|
265 | - * @return EE_Display_Strategy_Base |
|
266 | - * @throws EE_Error |
|
267 | - */ |
|
268 | - protected function _get_display_strategy() |
|
269 | - { |
|
270 | - $this->ensure_construct_finalized_called(); |
|
271 | - if (! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) { |
|
272 | - throw new EE_Error( |
|
273 | - sprintf( |
|
274 | - __( |
|
275 | - "Cannot get display strategy for form input with name %s and id %s, because it has not been set in the constructor", |
|
276 | - "event_espresso" |
|
277 | - ), |
|
278 | - $this->html_name(), |
|
279 | - $this->html_id() |
|
280 | - ) |
|
281 | - ); |
|
282 | - } else { |
|
283 | - return $this->_display_strategy; |
|
284 | - } |
|
285 | - } |
|
286 | - |
|
287 | - |
|
288 | - |
|
289 | - /** |
|
290 | - * Sets the display strategy. |
|
291 | - * |
|
292 | - * @param EE_Display_Strategy_Base $strategy |
|
293 | - */ |
|
294 | - protected function _set_display_strategy(EE_Display_Strategy_Base $strategy) |
|
295 | - { |
|
296 | - $this->_display_strategy = $strategy; |
|
297 | - } |
|
298 | - |
|
299 | - |
|
300 | - |
|
301 | - /** |
|
302 | - * Sets the sanitization strategy |
|
303 | - * |
|
304 | - * @param EE_Normalization_Strategy_Base $strategy |
|
305 | - */ |
|
306 | - protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy) |
|
307 | - { |
|
308 | - $this->_normalization_strategy = $strategy; |
|
309 | - } |
|
310 | - |
|
311 | - |
|
312 | - |
|
313 | - /** |
|
314 | - * Gets sensitive_data_removal_strategy |
|
315 | - * |
|
316 | - * @return EE_Sensitive_Data_Removal_Base |
|
317 | - */ |
|
318 | - public function get_sensitive_data_removal_strategy() |
|
319 | - { |
|
320 | - return $this->_sensitive_data_removal_strategy; |
|
321 | - } |
|
322 | - |
|
323 | - |
|
324 | - |
|
325 | - /** |
|
326 | - * Sets sensitive_data_removal_strategy |
|
327 | - * |
|
328 | - * @param EE_Sensitive_Data_Removal_Base $sensitive_data_removal_strategy |
|
329 | - * @return boolean |
|
330 | - */ |
|
331 | - public function set_sensitive_data_removal_strategy($sensitive_data_removal_strategy) |
|
332 | - { |
|
333 | - $this->_sensitive_data_removal_strategy = $sensitive_data_removal_strategy; |
|
334 | - } |
|
335 | - |
|
336 | - |
|
337 | - |
|
338 | - /** |
|
339 | - * Gets the display strategy for this input |
|
340 | - * |
|
341 | - * @return EE_Display_Strategy_Base |
|
342 | - */ |
|
343 | - public function get_display_strategy() |
|
344 | - { |
|
345 | - return $this->_display_strategy; |
|
346 | - } |
|
347 | - |
|
348 | - |
|
349 | - |
|
350 | - /** |
|
351 | - * Overwrites the display strategy |
|
352 | - * |
|
353 | - * @param EE_Display_Strategy_Base $display_strategy |
|
354 | - */ |
|
355 | - public function set_display_strategy($display_strategy) |
|
356 | - { |
|
357 | - $this->_display_strategy = $display_strategy; |
|
358 | - $this->_display_strategy->_construct_finalize($this); |
|
359 | - } |
|
360 | - |
|
361 | - |
|
362 | - |
|
363 | - /** |
|
364 | - * Gets the normalization strategy set on this input |
|
365 | - * |
|
366 | - * @return EE_Normalization_Strategy_Base |
|
367 | - */ |
|
368 | - public function get_normalization_strategy() |
|
369 | - { |
|
370 | - return $this->_normalization_strategy; |
|
371 | - } |
|
372 | - |
|
373 | - |
|
374 | - |
|
375 | - /** |
|
376 | - * Overwrites the normalization strategy |
|
377 | - * |
|
378 | - * @param EE_Normalization_Strategy_Base $normalization_strategy |
|
379 | - */ |
|
380 | - public function set_normalization_strategy($normalization_strategy) |
|
381 | - { |
|
382 | - $this->_normalization_strategy = $normalization_strategy; |
|
383 | - $this->_normalization_strategy->_construct_finalize($this); |
|
384 | - } |
|
385 | - |
|
386 | - |
|
387 | - |
|
388 | - /** |
|
389 | - * Returns all teh validation strategies which apply to this field, numerically indexed |
|
390 | - * |
|
391 | - * @return EE_Validation_Strategy_Base[] |
|
392 | - */ |
|
393 | - public function get_validation_strategies() |
|
394 | - { |
|
395 | - return $this->_validation_strategies; |
|
396 | - } |
|
397 | - |
|
398 | - |
|
399 | - |
|
400 | - /** |
|
401 | - * Adds this strategy to the field so it will be used in both JS validation and server-side validation |
|
402 | - * |
|
403 | - * @param EE_Validation_Strategy_Base $validation_strategy |
|
404 | - * @return void |
|
405 | - */ |
|
406 | - protected function _add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) |
|
407 | - { |
|
408 | - $validation_strategy->_construct_finalize($this); |
|
409 | - $this->_validation_strategies[] = $validation_strategy; |
|
410 | - } |
|
411 | - |
|
412 | - |
|
413 | - |
|
414 | - /** |
|
415 | - * Adds a new validation strategy onto the form input |
|
416 | - * |
|
417 | - * @param EE_Validation_Strategy_Base $validation_strategy |
|
418 | - * @return void |
|
419 | - */ |
|
420 | - public function add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) |
|
421 | - { |
|
422 | - $this->_add_validation_strategy($validation_strategy); |
|
423 | - } |
|
424 | - |
|
425 | - |
|
426 | - |
|
427 | - /** |
|
428 | - * The classname of the validation strategy to remove |
|
429 | - * |
|
430 | - * @param string $validation_strategy_classname |
|
431 | - */ |
|
432 | - public function remove_validation_strategy($validation_strategy_classname) |
|
433 | - { |
|
434 | - foreach ($this->_validation_strategies as $key => $validation_strategy) { |
|
435 | - if ( |
|
436 | - $validation_strategy instanceof $validation_strategy_classname |
|
437 | - || is_subclass_of($validation_strategy, $validation_strategy_classname) |
|
438 | - ) { |
|
439 | - unset($this->_validation_strategies[$key]); |
|
440 | - } |
|
441 | - } |
|
442 | - } |
|
443 | - |
|
444 | - |
|
445 | - |
|
446 | - /** |
|
447 | - * returns true if input employs any of the validation strategy defined by the supplied array of classnames |
|
448 | - * |
|
449 | - * @param array $validation_strategy_classnames |
|
450 | - * @return bool |
|
451 | - */ |
|
452 | - public function has_validation_strategy($validation_strategy_classnames) |
|
453 | - { |
|
454 | - $validation_strategy_classnames = is_array($validation_strategy_classnames) |
|
455 | - ? $validation_strategy_classnames |
|
456 | - : array($validation_strategy_classnames); |
|
457 | - foreach ($this->_validation_strategies as $key => $validation_strategy) { |
|
458 | - if (in_array($key, $validation_strategy_classnames)) { |
|
459 | - return true; |
|
460 | - } |
|
461 | - } |
|
462 | - return false; |
|
463 | - } |
|
464 | - |
|
465 | - |
|
466 | - |
|
467 | - /** |
|
468 | - * Gets the HTML |
|
469 | - * |
|
470 | - * @return string |
|
471 | - */ |
|
472 | - public function get_html() |
|
473 | - { |
|
474 | - return $this->_parent_section->get_html_for_input($this); |
|
475 | - } |
|
476 | - |
|
477 | - |
|
478 | - |
|
479 | - /** |
|
480 | - * Gets the HTML for the input itself (no label or errors) according to the |
|
481 | - * input's display strategy |
|
482 | - * Makes sure the JS and CSS are enqueued for it |
|
483 | - * |
|
484 | - * @return string |
|
485 | - * @throws \EE_Error |
|
486 | - */ |
|
487 | - public function get_html_for_input() |
|
488 | - { |
|
489 | - return $this->_form_html_filter |
|
490 | - ? $this->_form_html_filter->filterHtml( |
|
491 | - $this->_get_display_strategy()->display(), |
|
492 | - $this |
|
493 | - ) |
|
494 | - : $this->_get_display_strategy()->display(); |
|
495 | - } |
|
496 | - |
|
497 | - |
|
498 | - |
|
499 | - /** |
|
500 | - * @return string |
|
501 | - */ |
|
502 | - public function html_other_attributes() |
|
503 | - { |
|
504 | - return ! empty($this->_html_other_attributes) ? ' ' . $this->_html_other_attributes : ''; |
|
505 | - } |
|
506 | - |
|
507 | - |
|
508 | - |
|
509 | - /** |
|
510 | - * @param string $html_other_attributes |
|
511 | - */ |
|
512 | - public function set_html_other_attributes($html_other_attributes) |
|
513 | - { |
|
514 | - $this->_html_other_attributes = $html_other_attributes; |
|
515 | - } |
|
516 | - |
|
517 | - |
|
518 | - |
|
519 | - /** |
|
520 | - * Gets the HTML for displaying the label for this form input |
|
521 | - * according to the form section's layout strategy |
|
522 | - * |
|
523 | - * @return string |
|
524 | - */ |
|
525 | - public function get_html_for_label() |
|
526 | - { |
|
527 | - return $this->_parent_section->get_layout_strategy()->display_label($this); |
|
528 | - } |
|
529 | - |
|
530 | - |
|
531 | - |
|
532 | - /** |
|
533 | - * Gets the HTML for displaying the errors section for this form input |
|
534 | - * according to the form section's layout strategy |
|
535 | - * |
|
536 | - * @return string |
|
537 | - */ |
|
538 | - public function get_html_for_errors() |
|
539 | - { |
|
540 | - return $this->_parent_section->get_layout_strategy()->display_errors($this); |
|
541 | - } |
|
542 | - |
|
543 | - |
|
544 | - |
|
545 | - /** |
|
546 | - * Gets the HTML for displaying the help text for this form input |
|
547 | - * according to the form section's layout strategy |
|
548 | - * |
|
549 | - * @return string |
|
550 | - */ |
|
551 | - public function get_html_for_help() |
|
552 | - { |
|
553 | - return $this->_parent_section->get_layout_strategy()->display_help_text($this); |
|
554 | - } |
|
555 | - |
|
556 | - |
|
557 | - |
|
558 | - /** |
|
559 | - * Validates the input's sanitized value (assumes _sanitize() has already been called) |
|
560 | - * and returns whether or not the form input's submitted value is value |
|
561 | - * |
|
562 | - * @return boolean |
|
563 | - */ |
|
564 | - protected function _validate() |
|
565 | - { |
|
566 | - foreach ($this->_validation_strategies as $validation_strategy) { |
|
567 | - if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
568 | - try { |
|
569 | - $validation_strategy->validate($this->normalized_value()); |
|
570 | - } catch (EE_Validation_Error $e) { |
|
571 | - $this->add_validation_error($e); |
|
572 | - } |
|
573 | - } |
|
574 | - } |
|
575 | - if ($this->get_validation_errors()) { |
|
576 | - return false; |
|
577 | - } else { |
|
578 | - return true; |
|
579 | - } |
|
580 | - } |
|
581 | - |
|
582 | - |
|
583 | - |
|
584 | - /** |
|
585 | - * Performs basic sanitization on this value. But what sanitization can be performed anyways? |
|
586 | - * This value MIGHT be allowed to have tags, so we can't really remove them. |
|
587 | - * |
|
588 | - * @param string $value |
|
589 | - * @return null|string |
|
590 | - */ |
|
591 | - private function _sanitize($value) |
|
592 | - { |
|
593 | - return $value !== null ? stripslashes(html_entity_decode(trim($value))) : null; |
|
594 | - } |
|
595 | - |
|
596 | - |
|
597 | - |
|
598 | - /** |
|
599 | - * Picks out the form value that relates to this form input, |
|
600 | - * and stores it as the sanitized value on the form input, and sets the normalized value. |
|
601 | - * Returns whether or not any validation errors occurred |
|
602 | - * |
|
603 | - * @param array $req_data like $_POST |
|
604 | - * @return boolean whether or not there was an error |
|
605 | - * @throws \EE_Error |
|
606 | - */ |
|
607 | - protected function _normalize($req_data) |
|
608 | - { |
|
609 | - //any existing validation errors don't apply so clear them |
|
610 | - $this->_validation_errors = array(); |
|
611 | - try { |
|
612 | - $raw_input = $this->find_form_data_for_this_section($req_data); |
|
613 | - //super simple sanitization for now |
|
614 | - if (is_array($raw_input)) { |
|
615 | - $raw_value = array(); |
|
616 | - foreach ($raw_input as $key => $value) { |
|
617 | - $raw_value[$key] = $this->_sanitize($value); |
|
618 | - } |
|
619 | - $this->_set_raw_value($raw_value); |
|
620 | - } else { |
|
621 | - $this->_set_raw_value($this->_sanitize($raw_input)); |
|
622 | - } |
|
623 | - //we want to mostly leave the input alone in case we need to re-display it to the user |
|
624 | - $this->_set_normalized_value($this->_normalization_strategy->normalize($this->raw_value())); |
|
625 | - } catch (EE_Validation_Error $e) { |
|
626 | - $this->add_validation_error($e); |
|
627 | - } |
|
628 | - } |
|
629 | - |
|
630 | - |
|
631 | - |
|
632 | - /** |
|
633 | - * @return string |
|
634 | - */ |
|
635 | - public function html_name() |
|
636 | - { |
|
637 | - $this->_set_default_html_name_if_empty(); |
|
638 | - return $this->_html_name; |
|
639 | - } |
|
640 | - |
|
641 | - |
|
642 | - |
|
643 | - /** |
|
644 | - * @return string |
|
645 | - */ |
|
646 | - public function html_label_id() |
|
647 | - { |
|
648 | - return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->html_id() . '-lbl'; |
|
649 | - } |
|
650 | - |
|
651 | - |
|
652 | - |
|
653 | - /** |
|
654 | - * @return string |
|
655 | - */ |
|
656 | - public function html_label_class() |
|
657 | - { |
|
658 | - return $this->_html_label_class; |
|
659 | - } |
|
660 | - |
|
661 | - |
|
662 | - |
|
663 | - /** |
|
664 | - * @return string |
|
665 | - */ |
|
666 | - public function html_label_style() |
|
667 | - { |
|
668 | - return $this->_html_label_style; |
|
669 | - } |
|
670 | - |
|
671 | - |
|
672 | - |
|
673 | - /** |
|
674 | - * @return string |
|
675 | - */ |
|
676 | - public function html_label_text() |
|
677 | - { |
|
678 | - return $this->_html_label_text; |
|
679 | - } |
|
680 | - |
|
681 | - |
|
682 | - |
|
683 | - /** |
|
684 | - * @return string |
|
685 | - */ |
|
686 | - public function html_help_text() |
|
687 | - { |
|
688 | - return $this->_html_help_text; |
|
689 | - } |
|
690 | - |
|
691 | - |
|
692 | - |
|
693 | - /** |
|
694 | - * @return string |
|
695 | - */ |
|
696 | - public function html_help_class() |
|
697 | - { |
|
698 | - return $this->_html_help_class; |
|
699 | - } |
|
700 | - |
|
701 | - |
|
702 | - |
|
703 | - /** |
|
704 | - * @return string |
|
705 | - */ |
|
706 | - public function html_help_style() |
|
707 | - { |
|
708 | - return $this->_html_style; |
|
709 | - } |
|
710 | - |
|
711 | - |
|
712 | - |
|
713 | - /** |
|
714 | - * returns the raw, UNSAFE, input, almost exactly as the user submitted it. |
|
715 | - * Please note that almost all client code should instead use the normalized_value; |
|
716 | - * or possibly raw_value_in_form (which prepares the string for displaying in an HTML attribute on a tag, |
|
717 | - * mostly by escaping quotes) |
|
718 | - * Note, we do not store the exact original value sent in the user's request because |
|
719 | - * it may have malicious content, and we MIGHT want to store the form input in a transient or something... |
|
720 | - * in which case, we would have stored the malicious content to our database. |
|
721 | - * |
|
722 | - * @return string |
|
723 | - */ |
|
724 | - public function raw_value() |
|
725 | - { |
|
726 | - return $this->_raw_value; |
|
727 | - } |
|
728 | - |
|
729 | - |
|
730 | - |
|
731 | - /** |
|
732 | - * Returns a string safe to usage in form inputs when displaying, because |
|
733 | - * it escapes all html entities |
|
734 | - * |
|
735 | - * @return string |
|
736 | - */ |
|
737 | - public function raw_value_in_form() |
|
738 | - { |
|
739 | - return htmlentities($this->raw_value(), ENT_QUOTES, 'UTF-8'); |
|
740 | - } |
|
741 | - |
|
742 | - |
|
743 | - |
|
744 | - /** |
|
745 | - * returns the value after it's been sanitized, and then converted into it's proper type |
|
746 | - * in PHP. Eg, a string, an int, an array, |
|
747 | - * |
|
748 | - * @return mixed |
|
749 | - */ |
|
750 | - public function normalized_value() |
|
751 | - { |
|
752 | - return $this->_normalized_value; |
|
753 | - } |
|
754 | - |
|
755 | - |
|
756 | - |
|
757 | - /** |
|
758 | - * Returns the normalized value is a presentable way. By default this is just |
|
759 | - * the normalized value by itself, but it can be overridden for when that's not |
|
760 | - * the best thing to display |
|
761 | - * |
|
762 | - * @return string |
|
763 | - */ |
|
764 | - public function pretty_value() |
|
765 | - { |
|
766 | - return $this->_normalized_value; |
|
767 | - } |
|
768 | - |
|
769 | - |
|
770 | - |
|
771 | - /** |
|
772 | - * When generating the JS for the jquery validation rules like<br> |
|
773 | - * <code>$( "#myform" ).validate({ |
|
774 | - * rules: { |
|
775 | - * password: "required", |
|
776 | - * password_again: { |
|
777 | - * equalTo: "#password" |
|
778 | - * } |
|
779 | - * } |
|
780 | - * });</code> |
|
781 | - * if this field had the name 'password_again', it should return |
|
782 | - * <br><code>password_again: { |
|
783 | - * equalTo: "#password" |
|
784 | - * }</code> |
|
785 | - * |
|
786 | - * @return array |
|
787 | - */ |
|
788 | - public function get_jquery_validation_rules() |
|
789 | - { |
|
790 | - $jquery_validation_js = array(); |
|
791 | - $jquery_validation_rules = array(); |
|
792 | - foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
793 | - $jquery_validation_rules = array_replace_recursive( |
|
794 | - $jquery_validation_rules, |
|
795 | - $validation_strategy->get_jquery_validation_rule_array() |
|
796 | - ); |
|
797 | - } |
|
798 | - if (! empty($jquery_validation_rules)) { |
|
799 | - foreach ($this->get_display_strategy()->get_html_input_ids(true) as $html_id_with_pound_sign) { |
|
800 | - $jquery_validation_js[$html_id_with_pound_sign] = $jquery_validation_rules; |
|
801 | - } |
|
802 | - } |
|
803 | - return $jquery_validation_js; |
|
804 | - } |
|
805 | - |
|
806 | - |
|
807 | - |
|
808 | - /** |
|
809 | - * Sets the input's default value for use in displaying in the form. Note: value should be |
|
810 | - * normalized (Eg, if providing a default of ra Yes_NO_Input you would provide TRUE or FALSE, not '1' or '0') |
|
811 | - * |
|
812 | - * @param mixed $value |
|
813 | - * @return void |
|
814 | - */ |
|
815 | - public function set_default($value) |
|
816 | - { |
|
817 | - $this->_set_normalized_value($value); |
|
818 | - $this->_set_raw_value($value); |
|
819 | - } |
|
820 | - |
|
821 | - |
|
822 | - |
|
823 | - /** |
|
824 | - * Sets the normalized value on this input |
|
825 | - * |
|
826 | - * @param mixed $value |
|
827 | - */ |
|
828 | - protected function _set_normalized_value($value) |
|
829 | - { |
|
830 | - $this->_normalized_value = $value; |
|
831 | - } |
|
832 | - |
|
833 | - |
|
834 | - |
|
835 | - /** |
|
836 | - * Sets the raw value on this input (ie, exactly as the user submitted it) |
|
837 | - * |
|
838 | - * @param mixed $value |
|
839 | - */ |
|
840 | - protected function _set_raw_value($value) |
|
841 | - { |
|
842 | - $this->_raw_value = $this->_normalization_strategy->unnormalize($value); |
|
843 | - } |
|
844 | - |
|
845 | - |
|
846 | - |
|
847 | - /** |
|
848 | - * Sets the HTML label text after it has already been defined |
|
849 | - * |
|
850 | - * @param string $label |
|
851 | - * @return void |
|
852 | - */ |
|
853 | - public function set_html_label_text($label) |
|
854 | - { |
|
855 | - $this->_html_label_text = $label; |
|
856 | - } |
|
857 | - |
|
858 | - |
|
859 | - |
|
860 | - /** |
|
861 | - * Sets whether or not this field is required, and adjusts the validation strategy. |
|
862 | - * If you want to use the EE_Conditionally_Required_Validation_Strategy, |
|
863 | - * please add it as a validation strategy using add_validation_strategy as normal |
|
864 | - * |
|
865 | - * @param boolean $required boolean |
|
866 | - * @param null $required_text |
|
867 | - */ |
|
868 | - public function set_required($required = true, $required_text = null) |
|
869 | - { |
|
870 | - $required = filter_var($required, FILTER_VALIDATE_BOOLEAN); |
|
871 | - //whether $required is a string or a boolean, we want to add a required validation strategy |
|
872 | - if ($required) { |
|
873 | - $this->_add_validation_strategy(new EE_Required_Validation_Strategy($required_text)); |
|
874 | - } else { |
|
875 | - $this->remove_validation_strategy('EE_Required_Validation_Strategy'); |
|
876 | - } |
|
877 | - $this->_required = $required; |
|
878 | - } |
|
879 | - |
|
880 | - |
|
881 | - |
|
882 | - /** |
|
883 | - * Returns whether or not this field is required |
|
884 | - * |
|
885 | - * @return boolean |
|
886 | - */ |
|
887 | - public function required() |
|
888 | - { |
|
889 | - return $this->_required; |
|
890 | - } |
|
891 | - |
|
892 | - |
|
893 | - |
|
894 | - /** |
|
895 | - * @param string $required_css_class |
|
896 | - */ |
|
897 | - public function set_required_css_class($required_css_class) |
|
898 | - { |
|
899 | - $this->_required_css_class = $required_css_class; |
|
900 | - } |
|
901 | - |
|
902 | - |
|
903 | - |
|
904 | - /** |
|
905 | - * @return string |
|
906 | - */ |
|
907 | - public function required_css_class() |
|
908 | - { |
|
909 | - return $this->_required_css_class; |
|
910 | - } |
|
911 | - |
|
912 | - |
|
913 | - |
|
914 | - /** |
|
915 | - * @param bool $add_required |
|
916 | - * @return string |
|
917 | - */ |
|
918 | - public function html_class($add_required = false) |
|
919 | - { |
|
920 | - return $add_required && $this->required() |
|
921 | - ? $this->required_css_class() . ' ' . $this->_html_class |
|
922 | - : $this->_html_class; |
|
923 | - } |
|
924 | - |
|
925 | - |
|
926 | - /** |
|
927 | - * Sets the help text, in case |
|
928 | - * |
|
929 | - * @param string $text |
|
930 | - */ |
|
931 | - public function set_html_help_text($text) |
|
932 | - { |
|
933 | - $this->_html_help_text = $text; |
|
934 | - } |
|
935 | - |
|
936 | - |
|
937 | - |
|
938 | - /** |
|
939 | - * Uses the sensitive data removal strategy to remove the sensitive data from this |
|
940 | - * input. If there is any kind of sensitive data removal on this input, we clear |
|
941 | - * out the raw value completely |
|
942 | - * |
|
943 | - * @return void |
|
944 | - */ |
|
945 | - public function clean_sensitive_data() |
|
946 | - { |
|
947 | - //if we do ANY kind of sensitive data removal on this, then just clear out the raw value |
|
948 | - //if we need more logic than this we'll make a strategy for it |
|
949 | - if ($this->_sensitive_data_removal_strategy |
|
950 | - && ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal |
|
951 | - ) { |
|
952 | - $this->_set_raw_value(null); |
|
953 | - } |
|
954 | - //and clean the normalized value according to the appropriate strategy |
|
955 | - $this->_set_normalized_value( |
|
956 | - $this->get_sensitive_data_removal_strategy()->remove_sensitive_data( |
|
957 | - $this->_normalized_value |
|
958 | - ) |
|
959 | - ); |
|
960 | - } |
|
961 | - |
|
962 | - |
|
963 | - |
|
964 | - /** |
|
965 | - * @param bool $primary |
|
966 | - * @param string $button_size |
|
967 | - * @param string $other_attributes |
|
968 | - */ |
|
969 | - public function set_button_css_attributes($primary = true, $button_size = '', $other_attributes = '') |
|
970 | - { |
|
971 | - $button_css_attributes = 'button'; |
|
972 | - $button_css_attributes .= $primary === true ? ' button-primary' : ' button-secondary'; |
|
973 | - switch ($button_size) { |
|
974 | - case 'xs' : |
|
975 | - case 'extra-small' : |
|
976 | - $button_css_attributes .= ' button-xs'; |
|
977 | - break; |
|
978 | - case 'sm' : |
|
979 | - case 'small' : |
|
980 | - $button_css_attributes .= ' button-sm'; |
|
981 | - break; |
|
982 | - case 'lg' : |
|
983 | - case 'large' : |
|
984 | - $button_css_attributes .= ' button-lg'; |
|
985 | - break; |
|
986 | - case 'block' : |
|
987 | - $button_css_attributes .= ' button-block'; |
|
988 | - break; |
|
989 | - case 'md' : |
|
990 | - case 'medium' : |
|
991 | - default : |
|
992 | - $button_css_attributes .= ''; |
|
993 | - } |
|
994 | - $this->_button_css_attributes .= ! empty($other_attributes) |
|
995 | - ? $button_css_attributes . ' ' . $other_attributes |
|
996 | - : $button_css_attributes; |
|
997 | - } |
|
998 | - |
|
999 | - |
|
1000 | - |
|
1001 | - /** |
|
1002 | - * @return string |
|
1003 | - */ |
|
1004 | - public function button_css_attributes() |
|
1005 | - { |
|
1006 | - if (empty($this->_button_css_attributes)) { |
|
1007 | - $this->set_button_css_attributes(); |
|
1008 | - } |
|
1009 | - return $this->_button_css_attributes; |
|
1010 | - } |
|
1011 | - |
|
1012 | - |
|
1013 | - |
|
1014 | - /** |
|
1015 | - * find_form_data_for_this_section |
|
1016 | - * using this section's name and its parents, finds the value of the form data that corresponds to it. |
|
1017 | - * For example, if this form section's HTML name is my_form[subform][form_input_1], |
|
1018 | - * then it's value should be in $_REQUEST at $_REQUEST['my_form']['subform']['form_input_1']. |
|
1019 | - * (If that doesn't exist, we also check for this subsection's name |
|
1020 | - * at the TOP LEVEL of the request data. Eg $_REQUEST['form_input_1'].) |
|
1021 | - * This function finds its value in the form. |
|
1022 | - * |
|
1023 | - * @param array $req_data |
|
1024 | - * @return mixed whatever the raw value of this form section is in the request data |
|
1025 | - * @throws \EE_Error |
|
1026 | - */ |
|
1027 | - public function find_form_data_for_this_section($req_data) |
|
1028 | - { |
|
1029 | - // break up the html name by "[]" |
|
1030 | - if (strpos($this->html_name(), '[') !== false) { |
|
1031 | - $before_any_brackets = substr($this->html_name(), 0, strpos($this->html_name(), '[')); |
|
1032 | - } else { |
|
1033 | - $before_any_brackets = $this->html_name(); |
|
1034 | - } |
|
1035 | - // grab all of the segments |
|
1036 | - preg_match_all('~\[([^]]*)\]~', $this->html_name(), $matches); |
|
1037 | - if (isset($matches[1]) && is_array($matches[1])) { |
|
1038 | - $name_parts = $matches[1]; |
|
1039 | - array_unshift($name_parts, $before_any_brackets); |
|
1040 | - } else { |
|
1041 | - $name_parts = array($before_any_brackets); |
|
1042 | - } |
|
1043 | - // now get the value for the input |
|
1044 | - $value = $this->_find_form_data_for_this_section_using_name_parts($name_parts, $req_data); |
|
1045 | - // check if this thing's name is at the TOP level of the request data |
|
1046 | - if ($value === null && isset($req_data[$this->name()])) { |
|
1047 | - $value = $req_data[$this->name()]; |
|
1048 | - } |
|
1049 | - return $value; |
|
1050 | - } |
|
1051 | - |
|
1052 | - |
|
1053 | - |
|
1054 | - /** |
|
1055 | - * @param array $html_name_parts |
|
1056 | - * @param array $req_data |
|
1057 | - * @return array | NULL |
|
1058 | - */ |
|
1059 | - public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data) |
|
1060 | - { |
|
1061 | - $first_part_to_consider = array_shift($html_name_parts); |
|
1062 | - if (isset($req_data[$first_part_to_consider])) { |
|
1063 | - if (empty($html_name_parts)) { |
|
1064 | - return $req_data[$first_part_to_consider]; |
|
1065 | - } else { |
|
1066 | - return $this->_find_form_data_for_this_section_using_name_parts( |
|
1067 | - $html_name_parts, |
|
1068 | - $req_data[$first_part_to_consider] |
|
1069 | - ); |
|
1070 | - } |
|
1071 | - } else { |
|
1072 | - return null; |
|
1073 | - } |
|
1074 | - } |
|
1075 | - |
|
1076 | - |
|
1077 | - |
|
1078 | - /** |
|
1079 | - * Checks if this form input's data is in the request data |
|
1080 | - * |
|
1081 | - * @param array $req_data like $_POST |
|
1082 | - * @return boolean |
|
1083 | - * @throws \EE_Error |
|
1084 | - */ |
|
1085 | - public function form_data_present_in($req_data = null) |
|
1086 | - { |
|
1087 | - if ($req_data === null) { |
|
1088 | - $req_data = $_POST; |
|
1089 | - } |
|
1090 | - $checked_value = $this->find_form_data_for_this_section($req_data); |
|
1091 | - if ($checked_value !== null) { |
|
1092 | - return true; |
|
1093 | - } else { |
|
1094 | - return false; |
|
1095 | - } |
|
1096 | - } |
|
1097 | - |
|
1098 | - |
|
1099 | - |
|
1100 | - /** |
|
1101 | - * Overrides parent to add js data from validation and display strategies |
|
1102 | - * |
|
1103 | - * @param array $form_other_js_data |
|
1104 | - * @return array |
|
1105 | - */ |
|
1106 | - public function get_other_js_data($form_other_js_data = array()) |
|
1107 | - { |
|
1108 | - $form_other_js_data = $this->get_other_js_data_from_strategies($form_other_js_data); |
|
1109 | - return $form_other_js_data; |
|
1110 | - } |
|
1111 | - |
|
1112 | - |
|
1113 | - |
|
1114 | - /** |
|
1115 | - * Gets other JS data for localization from this input's strategies, like |
|
1116 | - * the validation strategies and the display strategy |
|
1117 | - * |
|
1118 | - * @param array $form_other_js_data |
|
1119 | - * @return array |
|
1120 | - */ |
|
1121 | - public function get_other_js_data_from_strategies($form_other_js_data = array()) |
|
1122 | - { |
|
1123 | - $form_other_js_data = $this->get_display_strategy()->get_other_js_data($form_other_js_data); |
|
1124 | - foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
1125 | - $form_other_js_data = $validation_strategy->get_other_js_data($form_other_js_data); |
|
1126 | - } |
|
1127 | - return $form_other_js_data; |
|
1128 | - } |
|
1129 | - |
|
1130 | - |
|
1131 | - |
|
1132 | - /** |
|
1133 | - * Override parent because we want to give our strategies an opportunity to enqueue some js and css |
|
1134 | - * |
|
1135 | - * @return void |
|
1136 | - */ |
|
1137 | - public function enqueue_js() |
|
1138 | - { |
|
1139 | - //ask our display strategy and validation strategies if they have js to enqueue |
|
1140 | - $this->enqueue_js_from_strategies(); |
|
1141 | - } |
|
1142 | - |
|
1143 | - |
|
1144 | - |
|
1145 | - /** |
|
1146 | - * Tells strategies when its ok to enqueue their js and css |
|
1147 | - * |
|
1148 | - * @return void |
|
1149 | - */ |
|
1150 | - public function enqueue_js_from_strategies() |
|
1151 | - { |
|
1152 | - $this->get_display_strategy()->enqueue_js(); |
|
1153 | - foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
1154 | - $validation_strategy->enqueue_js(); |
|
1155 | - } |
|
1156 | - } |
|
19 | + /** |
|
20 | + * the input's name attribute |
|
21 | + * |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + protected $_html_name; |
|
25 | + |
|
26 | + /** |
|
27 | + * id for the html label tag |
|
28 | + * |
|
29 | + * @var string |
|
30 | + */ |
|
31 | + protected $_html_label_id; |
|
32 | + |
|
33 | + /** |
|
34 | + * class for teh html label tag |
|
35 | + * |
|
36 | + * @var string |
|
37 | + */ |
|
38 | + protected $_html_label_class; |
|
39 | + |
|
40 | + /** |
|
41 | + * any additional html attributes that you may want to add |
|
42 | + * |
|
43 | + * @var string |
|
44 | + */ |
|
45 | + protected $_html_other_attributes; |
|
46 | + |
|
47 | + /** |
|
48 | + * style for teh html label tag |
|
49 | + * |
|
50 | + * @var string |
|
51 | + */ |
|
52 | + protected $_html_label_style; |
|
53 | + |
|
54 | + /** |
|
55 | + * text to be placed in the html label |
|
56 | + * |
|
57 | + * @var string |
|
58 | + */ |
|
59 | + protected $_html_label_text; |
|
60 | + |
|
61 | + /** |
|
62 | + * the full html label. If used, all other html_label_* properties are invalid |
|
63 | + * |
|
64 | + * @var string |
|
65 | + */ |
|
66 | + protected $_html_label; |
|
67 | + |
|
68 | + /** |
|
69 | + * HTML to use for help text (normally placed below form input), in a span which normally |
|
70 | + * has a class of 'description' |
|
71 | + * |
|
72 | + * @var string |
|
73 | + */ |
|
74 | + protected $_html_help_text; |
|
75 | + |
|
76 | + /** |
|
77 | + * CSS classes for displaying the help span |
|
78 | + * |
|
79 | + * @var string |
|
80 | + */ |
|
81 | + protected $_html_help_class = 'description'; |
|
82 | + |
|
83 | + /** |
|
84 | + * CSS to put in the style attribute on the help span |
|
85 | + * |
|
86 | + * @var string |
|
87 | + */ |
|
88 | + protected $_html_help_style; |
|
89 | + |
|
90 | + /** |
|
91 | + * Stores whether or not this input's response is required. |
|
92 | + * Because certain styling elements may also want to know that this |
|
93 | + * input is required etc. |
|
94 | + * |
|
95 | + * @var boolean |
|
96 | + */ |
|
97 | + protected $_required; |
|
98 | + |
|
99 | + /** |
|
100 | + * css class added to required inputs |
|
101 | + * |
|
102 | + * @var string |
|
103 | + */ |
|
104 | + protected $_required_css_class = 'ee-required'; |
|
105 | + |
|
106 | + /** |
|
107 | + * css styles applied to button type inputs |
|
108 | + * |
|
109 | + * @var string |
|
110 | + */ |
|
111 | + protected $_button_css_attributes; |
|
112 | + |
|
113 | + /** |
|
114 | + * The raw data submitted for this, like in the $_POST super global. |
|
115 | + * Generally unsafe for usage in client code |
|
116 | + * |
|
117 | + * @var mixed string or array |
|
118 | + */ |
|
119 | + protected $_raw_value; |
|
120 | + |
|
121 | + /** |
|
122 | + * Value normalized according to the input's normalization strategy. |
|
123 | + * The normalization strategy dictates whether this is a string, int, float, |
|
124 | + * boolean, or array of any of those. |
|
125 | + * |
|
126 | + * @var mixed |
|
127 | + */ |
|
128 | + protected $_normalized_value; |
|
129 | + |
|
130 | + /** |
|
131 | + * Strategy used for displaying this field. |
|
132 | + * Child classes must use _get_display_strategy to access it. |
|
133 | + * |
|
134 | + * @var EE_Display_Strategy_Base |
|
135 | + */ |
|
136 | + private $_display_strategy; |
|
137 | + |
|
138 | + /** |
|
139 | + * Gets all the validation strategies used on this field |
|
140 | + * |
|
141 | + * @var EE_Validation_Strategy_Base[] |
|
142 | + */ |
|
143 | + private $_validation_strategies = array(); |
|
144 | + |
|
145 | + /** |
|
146 | + * The normalization strategy for this field |
|
147 | + * |
|
148 | + * @var EE_Normalization_Strategy_Base |
|
149 | + */ |
|
150 | + private $_normalization_strategy; |
|
151 | + |
|
152 | + /** |
|
153 | + * Strategy for removing sensitive data after we're done with the form input |
|
154 | + * |
|
155 | + * @var EE_Sensitive_Data_Removal_Base |
|
156 | + */ |
|
157 | + protected $_sensitive_data_removal_strategy; |
|
158 | + |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * @param array $input_args { |
|
163 | + * @type string $html_name the html name for the input |
|
164 | + * @type string $html_label_id the id attribute to give to the html label tag |
|
165 | + * @type string $html_label_class the class attribute to give to the html label tag |
|
166 | + * @type string $html_label_style the style attribute to give ot teh label tag |
|
167 | + * @type string $html_label_text the text to put in the label tag |
|
168 | + * @type string $html_label the full html label. If used, |
|
169 | + * all other html_label_* args are invalid |
|
170 | + * @type string $html_help_text text to put in help element |
|
171 | + * @type string $html_help_style style attribute to give to teh help element |
|
172 | + * @type string $html_help_class class attribute to give to the help element |
|
173 | + * @type string $default default value NORMALIZED (eg, if providing the default |
|
174 | + * for a Yes_No_Input, you should provide TRUE or FALSE, not '1' or '0') |
|
175 | + * @type EE_Display_Strategy_Base $display strategy |
|
176 | + * @type EE_Normalization_Strategy_Base $normalization_strategy |
|
177 | + * @type EE_Validation_Strategy_Base[] $validation_strategies |
|
178 | + * } |
|
179 | + */ |
|
180 | + public function __construct($input_args = array()) |
|
181 | + { |
|
182 | + $input_args = (array)apply_filters('FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this); |
|
183 | + // the following properties must be cast as arrays |
|
184 | + if (isset($input_args['validation_strategies'])) { |
|
185 | + foreach ((array)$input_args['validation_strategies'] as $validation_strategy) { |
|
186 | + if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
187 | + $this->_validation_strategies[get_class($validation_strategy)] = $validation_strategy; |
|
188 | + } |
|
189 | + } |
|
190 | + unset($input_args['validation_strategies']); |
|
191 | + } |
|
192 | + // loop thru incoming options |
|
193 | + foreach ($input_args as $key => $value) { |
|
194 | + // add underscore to $key to match property names |
|
195 | + $_key = '_' . $key; |
|
196 | + if (property_exists($this, $_key)) { |
|
197 | + $this->{$_key} = $value; |
|
198 | + } |
|
199 | + } |
|
200 | + // ensure that "required" is set correctly |
|
201 | + $this->set_required( |
|
202 | + $this->_required, isset($input_args['required_validation_error_message']) |
|
203 | + ? $input_args['required_validation_error_message'] |
|
204 | + : null |
|
205 | + ); |
|
206 | + //$this->_html_name_specified = isset( $input_args['html_name'] ) ? TRUE : FALSE; |
|
207 | + $this->_display_strategy->_construct_finalize($this); |
|
208 | + foreach ($this->_validation_strategies as $validation_strategy) { |
|
209 | + $validation_strategy->_construct_finalize($this); |
|
210 | + } |
|
211 | + if (! $this->_normalization_strategy) { |
|
212 | + $this->_normalization_strategy = new EE_Text_Normalization(); |
|
213 | + } |
|
214 | + $this->_normalization_strategy->_construct_finalize($this); |
|
215 | + //at least we can use the normalization strategy to populate the default |
|
216 | + if (isset($input_args['default'])) { |
|
217 | + $this->set_default($input_args['default']); |
|
218 | + } |
|
219 | + if (! $this->_sensitive_data_removal_strategy) { |
|
220 | + $this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal(); |
|
221 | + } |
|
222 | + $this->_sensitive_data_removal_strategy->_construct_finalize($this); |
|
223 | + parent::__construct($input_args); |
|
224 | + } |
|
225 | + |
|
226 | + |
|
227 | + |
|
228 | + /** |
|
229 | + * Sets the html_name to its default value, if none was specified in teh constructor. |
|
230 | + * Calculation involves using the name and the parent's html_name |
|
231 | + * |
|
232 | + * @throws \EE_Error |
|
233 | + */ |
|
234 | + protected function _set_default_html_name_if_empty() |
|
235 | + { |
|
236 | + if (! $this->_html_name) { |
|
237 | + $this->_html_name = $this->name(); |
|
238 | + if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
|
239 | + $this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]"; |
|
240 | + } |
|
241 | + } |
|
242 | + } |
|
243 | + |
|
244 | + |
|
245 | + |
|
246 | + /** |
|
247 | + * @param $parent_form_section |
|
248 | + * @param $name |
|
249 | + * @throws \EE_Error |
|
250 | + */ |
|
251 | + public function _construct_finalize($parent_form_section, $name) |
|
252 | + { |
|
253 | + parent::_construct_finalize($parent_form_section, $name); |
|
254 | + if ($this->_html_label === null && $this->_html_label_text === null) { |
|
255 | + $this->_html_label_text = ucwords(str_replace("_", " ", $name)); |
|
256 | + } |
|
257 | + do_action('AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name); |
|
258 | + } |
|
259 | + |
|
260 | + |
|
261 | + |
|
262 | + /** |
|
263 | + * Returns the strategy for displaying this form input. If none is set, throws an exception. |
|
264 | + * |
|
265 | + * @return EE_Display_Strategy_Base |
|
266 | + * @throws EE_Error |
|
267 | + */ |
|
268 | + protected function _get_display_strategy() |
|
269 | + { |
|
270 | + $this->ensure_construct_finalized_called(); |
|
271 | + if (! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) { |
|
272 | + throw new EE_Error( |
|
273 | + sprintf( |
|
274 | + __( |
|
275 | + "Cannot get display strategy for form input with name %s and id %s, because it has not been set in the constructor", |
|
276 | + "event_espresso" |
|
277 | + ), |
|
278 | + $this->html_name(), |
|
279 | + $this->html_id() |
|
280 | + ) |
|
281 | + ); |
|
282 | + } else { |
|
283 | + return $this->_display_strategy; |
|
284 | + } |
|
285 | + } |
|
286 | + |
|
287 | + |
|
288 | + |
|
289 | + /** |
|
290 | + * Sets the display strategy. |
|
291 | + * |
|
292 | + * @param EE_Display_Strategy_Base $strategy |
|
293 | + */ |
|
294 | + protected function _set_display_strategy(EE_Display_Strategy_Base $strategy) |
|
295 | + { |
|
296 | + $this->_display_strategy = $strategy; |
|
297 | + } |
|
298 | + |
|
299 | + |
|
300 | + |
|
301 | + /** |
|
302 | + * Sets the sanitization strategy |
|
303 | + * |
|
304 | + * @param EE_Normalization_Strategy_Base $strategy |
|
305 | + */ |
|
306 | + protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy) |
|
307 | + { |
|
308 | + $this->_normalization_strategy = $strategy; |
|
309 | + } |
|
310 | + |
|
311 | + |
|
312 | + |
|
313 | + /** |
|
314 | + * Gets sensitive_data_removal_strategy |
|
315 | + * |
|
316 | + * @return EE_Sensitive_Data_Removal_Base |
|
317 | + */ |
|
318 | + public function get_sensitive_data_removal_strategy() |
|
319 | + { |
|
320 | + return $this->_sensitive_data_removal_strategy; |
|
321 | + } |
|
322 | + |
|
323 | + |
|
324 | + |
|
325 | + /** |
|
326 | + * Sets sensitive_data_removal_strategy |
|
327 | + * |
|
328 | + * @param EE_Sensitive_Data_Removal_Base $sensitive_data_removal_strategy |
|
329 | + * @return boolean |
|
330 | + */ |
|
331 | + public function set_sensitive_data_removal_strategy($sensitive_data_removal_strategy) |
|
332 | + { |
|
333 | + $this->_sensitive_data_removal_strategy = $sensitive_data_removal_strategy; |
|
334 | + } |
|
335 | + |
|
336 | + |
|
337 | + |
|
338 | + /** |
|
339 | + * Gets the display strategy for this input |
|
340 | + * |
|
341 | + * @return EE_Display_Strategy_Base |
|
342 | + */ |
|
343 | + public function get_display_strategy() |
|
344 | + { |
|
345 | + return $this->_display_strategy; |
|
346 | + } |
|
347 | + |
|
348 | + |
|
349 | + |
|
350 | + /** |
|
351 | + * Overwrites the display strategy |
|
352 | + * |
|
353 | + * @param EE_Display_Strategy_Base $display_strategy |
|
354 | + */ |
|
355 | + public function set_display_strategy($display_strategy) |
|
356 | + { |
|
357 | + $this->_display_strategy = $display_strategy; |
|
358 | + $this->_display_strategy->_construct_finalize($this); |
|
359 | + } |
|
360 | + |
|
361 | + |
|
362 | + |
|
363 | + /** |
|
364 | + * Gets the normalization strategy set on this input |
|
365 | + * |
|
366 | + * @return EE_Normalization_Strategy_Base |
|
367 | + */ |
|
368 | + public function get_normalization_strategy() |
|
369 | + { |
|
370 | + return $this->_normalization_strategy; |
|
371 | + } |
|
372 | + |
|
373 | + |
|
374 | + |
|
375 | + /** |
|
376 | + * Overwrites the normalization strategy |
|
377 | + * |
|
378 | + * @param EE_Normalization_Strategy_Base $normalization_strategy |
|
379 | + */ |
|
380 | + public function set_normalization_strategy($normalization_strategy) |
|
381 | + { |
|
382 | + $this->_normalization_strategy = $normalization_strategy; |
|
383 | + $this->_normalization_strategy->_construct_finalize($this); |
|
384 | + } |
|
385 | + |
|
386 | + |
|
387 | + |
|
388 | + /** |
|
389 | + * Returns all teh validation strategies which apply to this field, numerically indexed |
|
390 | + * |
|
391 | + * @return EE_Validation_Strategy_Base[] |
|
392 | + */ |
|
393 | + public function get_validation_strategies() |
|
394 | + { |
|
395 | + return $this->_validation_strategies; |
|
396 | + } |
|
397 | + |
|
398 | + |
|
399 | + |
|
400 | + /** |
|
401 | + * Adds this strategy to the field so it will be used in both JS validation and server-side validation |
|
402 | + * |
|
403 | + * @param EE_Validation_Strategy_Base $validation_strategy |
|
404 | + * @return void |
|
405 | + */ |
|
406 | + protected function _add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) |
|
407 | + { |
|
408 | + $validation_strategy->_construct_finalize($this); |
|
409 | + $this->_validation_strategies[] = $validation_strategy; |
|
410 | + } |
|
411 | + |
|
412 | + |
|
413 | + |
|
414 | + /** |
|
415 | + * Adds a new validation strategy onto the form input |
|
416 | + * |
|
417 | + * @param EE_Validation_Strategy_Base $validation_strategy |
|
418 | + * @return void |
|
419 | + */ |
|
420 | + public function add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) |
|
421 | + { |
|
422 | + $this->_add_validation_strategy($validation_strategy); |
|
423 | + } |
|
424 | + |
|
425 | + |
|
426 | + |
|
427 | + /** |
|
428 | + * The classname of the validation strategy to remove |
|
429 | + * |
|
430 | + * @param string $validation_strategy_classname |
|
431 | + */ |
|
432 | + public function remove_validation_strategy($validation_strategy_classname) |
|
433 | + { |
|
434 | + foreach ($this->_validation_strategies as $key => $validation_strategy) { |
|
435 | + if ( |
|
436 | + $validation_strategy instanceof $validation_strategy_classname |
|
437 | + || is_subclass_of($validation_strategy, $validation_strategy_classname) |
|
438 | + ) { |
|
439 | + unset($this->_validation_strategies[$key]); |
|
440 | + } |
|
441 | + } |
|
442 | + } |
|
443 | + |
|
444 | + |
|
445 | + |
|
446 | + /** |
|
447 | + * returns true if input employs any of the validation strategy defined by the supplied array of classnames |
|
448 | + * |
|
449 | + * @param array $validation_strategy_classnames |
|
450 | + * @return bool |
|
451 | + */ |
|
452 | + public function has_validation_strategy($validation_strategy_classnames) |
|
453 | + { |
|
454 | + $validation_strategy_classnames = is_array($validation_strategy_classnames) |
|
455 | + ? $validation_strategy_classnames |
|
456 | + : array($validation_strategy_classnames); |
|
457 | + foreach ($this->_validation_strategies as $key => $validation_strategy) { |
|
458 | + if (in_array($key, $validation_strategy_classnames)) { |
|
459 | + return true; |
|
460 | + } |
|
461 | + } |
|
462 | + return false; |
|
463 | + } |
|
464 | + |
|
465 | + |
|
466 | + |
|
467 | + /** |
|
468 | + * Gets the HTML |
|
469 | + * |
|
470 | + * @return string |
|
471 | + */ |
|
472 | + public function get_html() |
|
473 | + { |
|
474 | + return $this->_parent_section->get_html_for_input($this); |
|
475 | + } |
|
476 | + |
|
477 | + |
|
478 | + |
|
479 | + /** |
|
480 | + * Gets the HTML for the input itself (no label or errors) according to the |
|
481 | + * input's display strategy |
|
482 | + * Makes sure the JS and CSS are enqueued for it |
|
483 | + * |
|
484 | + * @return string |
|
485 | + * @throws \EE_Error |
|
486 | + */ |
|
487 | + public function get_html_for_input() |
|
488 | + { |
|
489 | + return $this->_form_html_filter |
|
490 | + ? $this->_form_html_filter->filterHtml( |
|
491 | + $this->_get_display_strategy()->display(), |
|
492 | + $this |
|
493 | + ) |
|
494 | + : $this->_get_display_strategy()->display(); |
|
495 | + } |
|
496 | + |
|
497 | + |
|
498 | + |
|
499 | + /** |
|
500 | + * @return string |
|
501 | + */ |
|
502 | + public function html_other_attributes() |
|
503 | + { |
|
504 | + return ! empty($this->_html_other_attributes) ? ' ' . $this->_html_other_attributes : ''; |
|
505 | + } |
|
506 | + |
|
507 | + |
|
508 | + |
|
509 | + /** |
|
510 | + * @param string $html_other_attributes |
|
511 | + */ |
|
512 | + public function set_html_other_attributes($html_other_attributes) |
|
513 | + { |
|
514 | + $this->_html_other_attributes = $html_other_attributes; |
|
515 | + } |
|
516 | + |
|
517 | + |
|
518 | + |
|
519 | + /** |
|
520 | + * Gets the HTML for displaying the label for this form input |
|
521 | + * according to the form section's layout strategy |
|
522 | + * |
|
523 | + * @return string |
|
524 | + */ |
|
525 | + public function get_html_for_label() |
|
526 | + { |
|
527 | + return $this->_parent_section->get_layout_strategy()->display_label($this); |
|
528 | + } |
|
529 | + |
|
530 | + |
|
531 | + |
|
532 | + /** |
|
533 | + * Gets the HTML for displaying the errors section for this form input |
|
534 | + * according to the form section's layout strategy |
|
535 | + * |
|
536 | + * @return string |
|
537 | + */ |
|
538 | + public function get_html_for_errors() |
|
539 | + { |
|
540 | + return $this->_parent_section->get_layout_strategy()->display_errors($this); |
|
541 | + } |
|
542 | + |
|
543 | + |
|
544 | + |
|
545 | + /** |
|
546 | + * Gets the HTML for displaying the help text for this form input |
|
547 | + * according to the form section's layout strategy |
|
548 | + * |
|
549 | + * @return string |
|
550 | + */ |
|
551 | + public function get_html_for_help() |
|
552 | + { |
|
553 | + return $this->_parent_section->get_layout_strategy()->display_help_text($this); |
|
554 | + } |
|
555 | + |
|
556 | + |
|
557 | + |
|
558 | + /** |
|
559 | + * Validates the input's sanitized value (assumes _sanitize() has already been called) |
|
560 | + * and returns whether or not the form input's submitted value is value |
|
561 | + * |
|
562 | + * @return boolean |
|
563 | + */ |
|
564 | + protected function _validate() |
|
565 | + { |
|
566 | + foreach ($this->_validation_strategies as $validation_strategy) { |
|
567 | + if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
568 | + try { |
|
569 | + $validation_strategy->validate($this->normalized_value()); |
|
570 | + } catch (EE_Validation_Error $e) { |
|
571 | + $this->add_validation_error($e); |
|
572 | + } |
|
573 | + } |
|
574 | + } |
|
575 | + if ($this->get_validation_errors()) { |
|
576 | + return false; |
|
577 | + } else { |
|
578 | + return true; |
|
579 | + } |
|
580 | + } |
|
581 | + |
|
582 | + |
|
583 | + |
|
584 | + /** |
|
585 | + * Performs basic sanitization on this value. But what sanitization can be performed anyways? |
|
586 | + * This value MIGHT be allowed to have tags, so we can't really remove them. |
|
587 | + * |
|
588 | + * @param string $value |
|
589 | + * @return null|string |
|
590 | + */ |
|
591 | + private function _sanitize($value) |
|
592 | + { |
|
593 | + return $value !== null ? stripslashes(html_entity_decode(trim($value))) : null; |
|
594 | + } |
|
595 | + |
|
596 | + |
|
597 | + |
|
598 | + /** |
|
599 | + * Picks out the form value that relates to this form input, |
|
600 | + * and stores it as the sanitized value on the form input, and sets the normalized value. |
|
601 | + * Returns whether or not any validation errors occurred |
|
602 | + * |
|
603 | + * @param array $req_data like $_POST |
|
604 | + * @return boolean whether or not there was an error |
|
605 | + * @throws \EE_Error |
|
606 | + */ |
|
607 | + protected function _normalize($req_data) |
|
608 | + { |
|
609 | + //any existing validation errors don't apply so clear them |
|
610 | + $this->_validation_errors = array(); |
|
611 | + try { |
|
612 | + $raw_input = $this->find_form_data_for_this_section($req_data); |
|
613 | + //super simple sanitization for now |
|
614 | + if (is_array($raw_input)) { |
|
615 | + $raw_value = array(); |
|
616 | + foreach ($raw_input as $key => $value) { |
|
617 | + $raw_value[$key] = $this->_sanitize($value); |
|
618 | + } |
|
619 | + $this->_set_raw_value($raw_value); |
|
620 | + } else { |
|
621 | + $this->_set_raw_value($this->_sanitize($raw_input)); |
|
622 | + } |
|
623 | + //we want to mostly leave the input alone in case we need to re-display it to the user |
|
624 | + $this->_set_normalized_value($this->_normalization_strategy->normalize($this->raw_value())); |
|
625 | + } catch (EE_Validation_Error $e) { |
|
626 | + $this->add_validation_error($e); |
|
627 | + } |
|
628 | + } |
|
629 | + |
|
630 | + |
|
631 | + |
|
632 | + /** |
|
633 | + * @return string |
|
634 | + */ |
|
635 | + public function html_name() |
|
636 | + { |
|
637 | + $this->_set_default_html_name_if_empty(); |
|
638 | + return $this->_html_name; |
|
639 | + } |
|
640 | + |
|
641 | + |
|
642 | + |
|
643 | + /** |
|
644 | + * @return string |
|
645 | + */ |
|
646 | + public function html_label_id() |
|
647 | + { |
|
648 | + return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->html_id() . '-lbl'; |
|
649 | + } |
|
650 | + |
|
651 | + |
|
652 | + |
|
653 | + /** |
|
654 | + * @return string |
|
655 | + */ |
|
656 | + public function html_label_class() |
|
657 | + { |
|
658 | + return $this->_html_label_class; |
|
659 | + } |
|
660 | + |
|
661 | + |
|
662 | + |
|
663 | + /** |
|
664 | + * @return string |
|
665 | + */ |
|
666 | + public function html_label_style() |
|
667 | + { |
|
668 | + return $this->_html_label_style; |
|
669 | + } |
|
670 | + |
|
671 | + |
|
672 | + |
|
673 | + /** |
|
674 | + * @return string |
|
675 | + */ |
|
676 | + public function html_label_text() |
|
677 | + { |
|
678 | + return $this->_html_label_text; |
|
679 | + } |
|
680 | + |
|
681 | + |
|
682 | + |
|
683 | + /** |
|
684 | + * @return string |
|
685 | + */ |
|
686 | + public function html_help_text() |
|
687 | + { |
|
688 | + return $this->_html_help_text; |
|
689 | + } |
|
690 | + |
|
691 | + |
|
692 | + |
|
693 | + /** |
|
694 | + * @return string |
|
695 | + */ |
|
696 | + public function html_help_class() |
|
697 | + { |
|
698 | + return $this->_html_help_class; |
|
699 | + } |
|
700 | + |
|
701 | + |
|
702 | + |
|
703 | + /** |
|
704 | + * @return string |
|
705 | + */ |
|
706 | + public function html_help_style() |
|
707 | + { |
|
708 | + return $this->_html_style; |
|
709 | + } |
|
710 | + |
|
711 | + |
|
712 | + |
|
713 | + /** |
|
714 | + * returns the raw, UNSAFE, input, almost exactly as the user submitted it. |
|
715 | + * Please note that almost all client code should instead use the normalized_value; |
|
716 | + * or possibly raw_value_in_form (which prepares the string for displaying in an HTML attribute on a tag, |
|
717 | + * mostly by escaping quotes) |
|
718 | + * Note, we do not store the exact original value sent in the user's request because |
|
719 | + * it may have malicious content, and we MIGHT want to store the form input in a transient or something... |
|
720 | + * in which case, we would have stored the malicious content to our database. |
|
721 | + * |
|
722 | + * @return string |
|
723 | + */ |
|
724 | + public function raw_value() |
|
725 | + { |
|
726 | + return $this->_raw_value; |
|
727 | + } |
|
728 | + |
|
729 | + |
|
730 | + |
|
731 | + /** |
|
732 | + * Returns a string safe to usage in form inputs when displaying, because |
|
733 | + * it escapes all html entities |
|
734 | + * |
|
735 | + * @return string |
|
736 | + */ |
|
737 | + public function raw_value_in_form() |
|
738 | + { |
|
739 | + return htmlentities($this->raw_value(), ENT_QUOTES, 'UTF-8'); |
|
740 | + } |
|
741 | + |
|
742 | + |
|
743 | + |
|
744 | + /** |
|
745 | + * returns the value after it's been sanitized, and then converted into it's proper type |
|
746 | + * in PHP. Eg, a string, an int, an array, |
|
747 | + * |
|
748 | + * @return mixed |
|
749 | + */ |
|
750 | + public function normalized_value() |
|
751 | + { |
|
752 | + return $this->_normalized_value; |
|
753 | + } |
|
754 | + |
|
755 | + |
|
756 | + |
|
757 | + /** |
|
758 | + * Returns the normalized value is a presentable way. By default this is just |
|
759 | + * the normalized value by itself, but it can be overridden for when that's not |
|
760 | + * the best thing to display |
|
761 | + * |
|
762 | + * @return string |
|
763 | + */ |
|
764 | + public function pretty_value() |
|
765 | + { |
|
766 | + return $this->_normalized_value; |
|
767 | + } |
|
768 | + |
|
769 | + |
|
770 | + |
|
771 | + /** |
|
772 | + * When generating the JS for the jquery validation rules like<br> |
|
773 | + * <code>$( "#myform" ).validate({ |
|
774 | + * rules: { |
|
775 | + * password: "required", |
|
776 | + * password_again: { |
|
777 | + * equalTo: "#password" |
|
778 | + * } |
|
779 | + * } |
|
780 | + * });</code> |
|
781 | + * if this field had the name 'password_again', it should return |
|
782 | + * <br><code>password_again: { |
|
783 | + * equalTo: "#password" |
|
784 | + * }</code> |
|
785 | + * |
|
786 | + * @return array |
|
787 | + */ |
|
788 | + public function get_jquery_validation_rules() |
|
789 | + { |
|
790 | + $jquery_validation_js = array(); |
|
791 | + $jquery_validation_rules = array(); |
|
792 | + foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
793 | + $jquery_validation_rules = array_replace_recursive( |
|
794 | + $jquery_validation_rules, |
|
795 | + $validation_strategy->get_jquery_validation_rule_array() |
|
796 | + ); |
|
797 | + } |
|
798 | + if (! empty($jquery_validation_rules)) { |
|
799 | + foreach ($this->get_display_strategy()->get_html_input_ids(true) as $html_id_with_pound_sign) { |
|
800 | + $jquery_validation_js[$html_id_with_pound_sign] = $jquery_validation_rules; |
|
801 | + } |
|
802 | + } |
|
803 | + return $jquery_validation_js; |
|
804 | + } |
|
805 | + |
|
806 | + |
|
807 | + |
|
808 | + /** |
|
809 | + * Sets the input's default value for use in displaying in the form. Note: value should be |
|
810 | + * normalized (Eg, if providing a default of ra Yes_NO_Input you would provide TRUE or FALSE, not '1' or '0') |
|
811 | + * |
|
812 | + * @param mixed $value |
|
813 | + * @return void |
|
814 | + */ |
|
815 | + public function set_default($value) |
|
816 | + { |
|
817 | + $this->_set_normalized_value($value); |
|
818 | + $this->_set_raw_value($value); |
|
819 | + } |
|
820 | + |
|
821 | + |
|
822 | + |
|
823 | + /** |
|
824 | + * Sets the normalized value on this input |
|
825 | + * |
|
826 | + * @param mixed $value |
|
827 | + */ |
|
828 | + protected function _set_normalized_value($value) |
|
829 | + { |
|
830 | + $this->_normalized_value = $value; |
|
831 | + } |
|
832 | + |
|
833 | + |
|
834 | + |
|
835 | + /** |
|
836 | + * Sets the raw value on this input (ie, exactly as the user submitted it) |
|
837 | + * |
|
838 | + * @param mixed $value |
|
839 | + */ |
|
840 | + protected function _set_raw_value($value) |
|
841 | + { |
|
842 | + $this->_raw_value = $this->_normalization_strategy->unnormalize($value); |
|
843 | + } |
|
844 | + |
|
845 | + |
|
846 | + |
|
847 | + /** |
|
848 | + * Sets the HTML label text after it has already been defined |
|
849 | + * |
|
850 | + * @param string $label |
|
851 | + * @return void |
|
852 | + */ |
|
853 | + public function set_html_label_text($label) |
|
854 | + { |
|
855 | + $this->_html_label_text = $label; |
|
856 | + } |
|
857 | + |
|
858 | + |
|
859 | + |
|
860 | + /** |
|
861 | + * Sets whether or not this field is required, and adjusts the validation strategy. |
|
862 | + * If you want to use the EE_Conditionally_Required_Validation_Strategy, |
|
863 | + * please add it as a validation strategy using add_validation_strategy as normal |
|
864 | + * |
|
865 | + * @param boolean $required boolean |
|
866 | + * @param null $required_text |
|
867 | + */ |
|
868 | + public function set_required($required = true, $required_text = null) |
|
869 | + { |
|
870 | + $required = filter_var($required, FILTER_VALIDATE_BOOLEAN); |
|
871 | + //whether $required is a string or a boolean, we want to add a required validation strategy |
|
872 | + if ($required) { |
|
873 | + $this->_add_validation_strategy(new EE_Required_Validation_Strategy($required_text)); |
|
874 | + } else { |
|
875 | + $this->remove_validation_strategy('EE_Required_Validation_Strategy'); |
|
876 | + } |
|
877 | + $this->_required = $required; |
|
878 | + } |
|
879 | + |
|
880 | + |
|
881 | + |
|
882 | + /** |
|
883 | + * Returns whether or not this field is required |
|
884 | + * |
|
885 | + * @return boolean |
|
886 | + */ |
|
887 | + public function required() |
|
888 | + { |
|
889 | + return $this->_required; |
|
890 | + } |
|
891 | + |
|
892 | + |
|
893 | + |
|
894 | + /** |
|
895 | + * @param string $required_css_class |
|
896 | + */ |
|
897 | + public function set_required_css_class($required_css_class) |
|
898 | + { |
|
899 | + $this->_required_css_class = $required_css_class; |
|
900 | + } |
|
901 | + |
|
902 | + |
|
903 | + |
|
904 | + /** |
|
905 | + * @return string |
|
906 | + */ |
|
907 | + public function required_css_class() |
|
908 | + { |
|
909 | + return $this->_required_css_class; |
|
910 | + } |
|
911 | + |
|
912 | + |
|
913 | + |
|
914 | + /** |
|
915 | + * @param bool $add_required |
|
916 | + * @return string |
|
917 | + */ |
|
918 | + public function html_class($add_required = false) |
|
919 | + { |
|
920 | + return $add_required && $this->required() |
|
921 | + ? $this->required_css_class() . ' ' . $this->_html_class |
|
922 | + : $this->_html_class; |
|
923 | + } |
|
924 | + |
|
925 | + |
|
926 | + /** |
|
927 | + * Sets the help text, in case |
|
928 | + * |
|
929 | + * @param string $text |
|
930 | + */ |
|
931 | + public function set_html_help_text($text) |
|
932 | + { |
|
933 | + $this->_html_help_text = $text; |
|
934 | + } |
|
935 | + |
|
936 | + |
|
937 | + |
|
938 | + /** |
|
939 | + * Uses the sensitive data removal strategy to remove the sensitive data from this |
|
940 | + * input. If there is any kind of sensitive data removal on this input, we clear |
|
941 | + * out the raw value completely |
|
942 | + * |
|
943 | + * @return void |
|
944 | + */ |
|
945 | + public function clean_sensitive_data() |
|
946 | + { |
|
947 | + //if we do ANY kind of sensitive data removal on this, then just clear out the raw value |
|
948 | + //if we need more logic than this we'll make a strategy for it |
|
949 | + if ($this->_sensitive_data_removal_strategy |
|
950 | + && ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal |
|
951 | + ) { |
|
952 | + $this->_set_raw_value(null); |
|
953 | + } |
|
954 | + //and clean the normalized value according to the appropriate strategy |
|
955 | + $this->_set_normalized_value( |
|
956 | + $this->get_sensitive_data_removal_strategy()->remove_sensitive_data( |
|
957 | + $this->_normalized_value |
|
958 | + ) |
|
959 | + ); |
|
960 | + } |
|
961 | + |
|
962 | + |
|
963 | + |
|
964 | + /** |
|
965 | + * @param bool $primary |
|
966 | + * @param string $button_size |
|
967 | + * @param string $other_attributes |
|
968 | + */ |
|
969 | + public function set_button_css_attributes($primary = true, $button_size = '', $other_attributes = '') |
|
970 | + { |
|
971 | + $button_css_attributes = 'button'; |
|
972 | + $button_css_attributes .= $primary === true ? ' button-primary' : ' button-secondary'; |
|
973 | + switch ($button_size) { |
|
974 | + case 'xs' : |
|
975 | + case 'extra-small' : |
|
976 | + $button_css_attributes .= ' button-xs'; |
|
977 | + break; |
|
978 | + case 'sm' : |
|
979 | + case 'small' : |
|
980 | + $button_css_attributes .= ' button-sm'; |
|
981 | + break; |
|
982 | + case 'lg' : |
|
983 | + case 'large' : |
|
984 | + $button_css_attributes .= ' button-lg'; |
|
985 | + break; |
|
986 | + case 'block' : |
|
987 | + $button_css_attributes .= ' button-block'; |
|
988 | + break; |
|
989 | + case 'md' : |
|
990 | + case 'medium' : |
|
991 | + default : |
|
992 | + $button_css_attributes .= ''; |
|
993 | + } |
|
994 | + $this->_button_css_attributes .= ! empty($other_attributes) |
|
995 | + ? $button_css_attributes . ' ' . $other_attributes |
|
996 | + : $button_css_attributes; |
|
997 | + } |
|
998 | + |
|
999 | + |
|
1000 | + |
|
1001 | + /** |
|
1002 | + * @return string |
|
1003 | + */ |
|
1004 | + public function button_css_attributes() |
|
1005 | + { |
|
1006 | + if (empty($this->_button_css_attributes)) { |
|
1007 | + $this->set_button_css_attributes(); |
|
1008 | + } |
|
1009 | + return $this->_button_css_attributes; |
|
1010 | + } |
|
1011 | + |
|
1012 | + |
|
1013 | + |
|
1014 | + /** |
|
1015 | + * find_form_data_for_this_section |
|
1016 | + * using this section's name and its parents, finds the value of the form data that corresponds to it. |
|
1017 | + * For example, if this form section's HTML name is my_form[subform][form_input_1], |
|
1018 | + * then it's value should be in $_REQUEST at $_REQUEST['my_form']['subform']['form_input_1']. |
|
1019 | + * (If that doesn't exist, we also check for this subsection's name |
|
1020 | + * at the TOP LEVEL of the request data. Eg $_REQUEST['form_input_1'].) |
|
1021 | + * This function finds its value in the form. |
|
1022 | + * |
|
1023 | + * @param array $req_data |
|
1024 | + * @return mixed whatever the raw value of this form section is in the request data |
|
1025 | + * @throws \EE_Error |
|
1026 | + */ |
|
1027 | + public function find_form_data_for_this_section($req_data) |
|
1028 | + { |
|
1029 | + // break up the html name by "[]" |
|
1030 | + if (strpos($this->html_name(), '[') !== false) { |
|
1031 | + $before_any_brackets = substr($this->html_name(), 0, strpos($this->html_name(), '[')); |
|
1032 | + } else { |
|
1033 | + $before_any_brackets = $this->html_name(); |
|
1034 | + } |
|
1035 | + // grab all of the segments |
|
1036 | + preg_match_all('~\[([^]]*)\]~', $this->html_name(), $matches); |
|
1037 | + if (isset($matches[1]) && is_array($matches[1])) { |
|
1038 | + $name_parts = $matches[1]; |
|
1039 | + array_unshift($name_parts, $before_any_brackets); |
|
1040 | + } else { |
|
1041 | + $name_parts = array($before_any_brackets); |
|
1042 | + } |
|
1043 | + // now get the value for the input |
|
1044 | + $value = $this->_find_form_data_for_this_section_using_name_parts($name_parts, $req_data); |
|
1045 | + // check if this thing's name is at the TOP level of the request data |
|
1046 | + if ($value === null && isset($req_data[$this->name()])) { |
|
1047 | + $value = $req_data[$this->name()]; |
|
1048 | + } |
|
1049 | + return $value; |
|
1050 | + } |
|
1051 | + |
|
1052 | + |
|
1053 | + |
|
1054 | + /** |
|
1055 | + * @param array $html_name_parts |
|
1056 | + * @param array $req_data |
|
1057 | + * @return array | NULL |
|
1058 | + */ |
|
1059 | + public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data) |
|
1060 | + { |
|
1061 | + $first_part_to_consider = array_shift($html_name_parts); |
|
1062 | + if (isset($req_data[$first_part_to_consider])) { |
|
1063 | + if (empty($html_name_parts)) { |
|
1064 | + return $req_data[$first_part_to_consider]; |
|
1065 | + } else { |
|
1066 | + return $this->_find_form_data_for_this_section_using_name_parts( |
|
1067 | + $html_name_parts, |
|
1068 | + $req_data[$first_part_to_consider] |
|
1069 | + ); |
|
1070 | + } |
|
1071 | + } else { |
|
1072 | + return null; |
|
1073 | + } |
|
1074 | + } |
|
1075 | + |
|
1076 | + |
|
1077 | + |
|
1078 | + /** |
|
1079 | + * Checks if this form input's data is in the request data |
|
1080 | + * |
|
1081 | + * @param array $req_data like $_POST |
|
1082 | + * @return boolean |
|
1083 | + * @throws \EE_Error |
|
1084 | + */ |
|
1085 | + public function form_data_present_in($req_data = null) |
|
1086 | + { |
|
1087 | + if ($req_data === null) { |
|
1088 | + $req_data = $_POST; |
|
1089 | + } |
|
1090 | + $checked_value = $this->find_form_data_for_this_section($req_data); |
|
1091 | + if ($checked_value !== null) { |
|
1092 | + return true; |
|
1093 | + } else { |
|
1094 | + return false; |
|
1095 | + } |
|
1096 | + } |
|
1097 | + |
|
1098 | + |
|
1099 | + |
|
1100 | + /** |
|
1101 | + * Overrides parent to add js data from validation and display strategies |
|
1102 | + * |
|
1103 | + * @param array $form_other_js_data |
|
1104 | + * @return array |
|
1105 | + */ |
|
1106 | + public function get_other_js_data($form_other_js_data = array()) |
|
1107 | + { |
|
1108 | + $form_other_js_data = $this->get_other_js_data_from_strategies($form_other_js_data); |
|
1109 | + return $form_other_js_data; |
|
1110 | + } |
|
1111 | + |
|
1112 | + |
|
1113 | + |
|
1114 | + /** |
|
1115 | + * Gets other JS data for localization from this input's strategies, like |
|
1116 | + * the validation strategies and the display strategy |
|
1117 | + * |
|
1118 | + * @param array $form_other_js_data |
|
1119 | + * @return array |
|
1120 | + */ |
|
1121 | + public function get_other_js_data_from_strategies($form_other_js_data = array()) |
|
1122 | + { |
|
1123 | + $form_other_js_data = $this->get_display_strategy()->get_other_js_data($form_other_js_data); |
|
1124 | + foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
1125 | + $form_other_js_data = $validation_strategy->get_other_js_data($form_other_js_data); |
|
1126 | + } |
|
1127 | + return $form_other_js_data; |
|
1128 | + } |
|
1129 | + |
|
1130 | + |
|
1131 | + |
|
1132 | + /** |
|
1133 | + * Override parent because we want to give our strategies an opportunity to enqueue some js and css |
|
1134 | + * |
|
1135 | + * @return void |
|
1136 | + */ |
|
1137 | + public function enqueue_js() |
|
1138 | + { |
|
1139 | + //ask our display strategy and validation strategies if they have js to enqueue |
|
1140 | + $this->enqueue_js_from_strategies(); |
|
1141 | + } |
|
1142 | + |
|
1143 | + |
|
1144 | + |
|
1145 | + /** |
|
1146 | + * Tells strategies when its ok to enqueue their js and css |
|
1147 | + * |
|
1148 | + * @return void |
|
1149 | + */ |
|
1150 | + public function enqueue_js_from_strategies() |
|
1151 | + { |
|
1152 | + $this->get_display_strategy()->enqueue_js(); |
|
1153 | + foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
1154 | + $validation_strategy->enqueue_js(); |
|
1155 | + } |
|
1156 | + } |
|
1157 | 1157 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | 2 | exit('No direct script access allowed'); |
3 | 3 | } |
4 | 4 | |
@@ -179,10 +179,10 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public function __construct($input_args = array()) |
181 | 181 | { |
182 | - $input_args = (array)apply_filters('FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this); |
|
182 | + $input_args = (array) apply_filters('FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this); |
|
183 | 183 | // the following properties must be cast as arrays |
184 | 184 | if (isset($input_args['validation_strategies'])) { |
185 | - foreach ((array)$input_args['validation_strategies'] as $validation_strategy) { |
|
185 | + foreach ((array) $input_args['validation_strategies'] as $validation_strategy) { |
|
186 | 186 | if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
187 | 187 | $this->_validation_strategies[get_class($validation_strategy)] = $validation_strategy; |
188 | 188 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | // loop thru incoming options |
193 | 193 | foreach ($input_args as $key => $value) { |
194 | 194 | // add underscore to $key to match property names |
195 | - $_key = '_' . $key; |
|
195 | + $_key = '_'.$key; |
|
196 | 196 | if (property_exists($this, $_key)) { |
197 | 197 | $this->{$_key} = $value; |
198 | 198 | } |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | foreach ($this->_validation_strategies as $validation_strategy) { |
209 | 209 | $validation_strategy->_construct_finalize($this); |
210 | 210 | } |
211 | - if (! $this->_normalization_strategy) { |
|
211 | + if ( ! $this->_normalization_strategy) { |
|
212 | 212 | $this->_normalization_strategy = new EE_Text_Normalization(); |
213 | 213 | } |
214 | 214 | $this->_normalization_strategy->_construct_finalize($this); |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | if (isset($input_args['default'])) { |
217 | 217 | $this->set_default($input_args['default']); |
218 | 218 | } |
219 | - if (! $this->_sensitive_data_removal_strategy) { |
|
219 | + if ( ! $this->_sensitive_data_removal_strategy) { |
|
220 | 220 | $this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal(); |
221 | 221 | } |
222 | 222 | $this->_sensitive_data_removal_strategy->_construct_finalize($this); |
@@ -233,10 +233,10 @@ discard block |
||
233 | 233 | */ |
234 | 234 | protected function _set_default_html_name_if_empty() |
235 | 235 | { |
236 | - if (! $this->_html_name) { |
|
236 | + if ( ! $this->_html_name) { |
|
237 | 237 | $this->_html_name = $this->name(); |
238 | 238 | if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
239 | - $this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]"; |
|
239 | + $this->_html_name = $this->_parent_section->html_name_prefix()."[{$this->name()}]"; |
|
240 | 240 | } |
241 | 241 | } |
242 | 242 | } |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | protected function _get_display_strategy() |
269 | 269 | { |
270 | 270 | $this->ensure_construct_finalized_called(); |
271 | - if (! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) { |
|
271 | + if ( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) { |
|
272 | 272 | throw new EE_Error( |
273 | 273 | sprintf( |
274 | 274 | __( |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | */ |
502 | 502 | public function html_other_attributes() |
503 | 503 | { |
504 | - return ! empty($this->_html_other_attributes) ? ' ' . $this->_html_other_attributes : ''; |
|
504 | + return ! empty($this->_html_other_attributes) ? ' '.$this->_html_other_attributes : ''; |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | |
@@ -645,7 +645,7 @@ discard block |
||
645 | 645 | */ |
646 | 646 | public function html_label_id() |
647 | 647 | { |
648 | - return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->html_id() . '-lbl'; |
|
648 | + return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->html_id().'-lbl'; |
|
649 | 649 | } |
650 | 650 | |
651 | 651 | |
@@ -795,7 +795,7 @@ discard block |
||
795 | 795 | $validation_strategy->get_jquery_validation_rule_array() |
796 | 796 | ); |
797 | 797 | } |
798 | - if (! empty($jquery_validation_rules)) { |
|
798 | + if ( ! empty($jquery_validation_rules)) { |
|
799 | 799 | foreach ($this->get_display_strategy()->get_html_input_ids(true) as $html_id_with_pound_sign) { |
800 | 800 | $jquery_validation_js[$html_id_with_pound_sign] = $jquery_validation_rules; |
801 | 801 | } |
@@ -918,7 +918,7 @@ discard block |
||
918 | 918 | public function html_class($add_required = false) |
919 | 919 | { |
920 | 920 | return $add_required && $this->required() |
921 | - ? $this->required_css_class() . ' ' . $this->_html_class |
|
921 | + ? $this->required_css_class().' '.$this->_html_class |
|
922 | 922 | : $this->_html_class; |
923 | 923 | } |
924 | 924 | |
@@ -992,7 +992,7 @@ discard block |
||
992 | 992 | $button_css_attributes .= ''; |
993 | 993 | } |
994 | 994 | $this->_button_css_attributes .= ! empty($other_attributes) |
995 | - ? $button_css_attributes . ' ' . $other_attributes |
|
995 | + ? $button_css_attributes.' '.$other_attributes |
|
996 | 996 | : $button_css_attributes; |
997 | 997 | } |
998 | 998 |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | namespace EventEspresso\core\libraries\rest_api\controllers\config; |
3 | 3 | |
4 | 4 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
5 | - exit('No direct script access allowed'); |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -18,74 +18,74 @@ discard block |
||
18 | 18 | class Read |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @param \WP_REST_Request $request |
|
23 | - * @return \EE_Config|\WP_Error |
|
24 | - */ |
|
25 | - public static function handle_request(\WP_REST_Request $request) |
|
26 | - { |
|
27 | - $cap = \EE_Restriction_Generator_Base::get_default_restrictions_cap(); |
|
28 | - if (\EE_Capabilities::instance()->current_user_can($cap, 'read_over_api')) { |
|
29 | - return \EE_Config::instance(); |
|
30 | - } else { |
|
31 | - return new \WP_Error( |
|
32 | - 'cannot_read_config', |
|
33 | - sprintf( |
|
34 | - __( |
|
35 | - 'You do not have the necessary capabilities (%s) to read Event Espresso Configuration data', |
|
36 | - 'event_espresso' |
|
37 | - ), |
|
38 | - $cap |
|
39 | - ), |
|
40 | - array('status' => 403) |
|
41 | - ); |
|
42 | - } |
|
43 | - } |
|
21 | + /** |
|
22 | + * @param \WP_REST_Request $request |
|
23 | + * @return \EE_Config|\WP_Error |
|
24 | + */ |
|
25 | + public static function handle_request(\WP_REST_Request $request) |
|
26 | + { |
|
27 | + $cap = \EE_Restriction_Generator_Base::get_default_restrictions_cap(); |
|
28 | + if (\EE_Capabilities::instance()->current_user_can($cap, 'read_over_api')) { |
|
29 | + return \EE_Config::instance(); |
|
30 | + } else { |
|
31 | + return new \WP_Error( |
|
32 | + 'cannot_read_config', |
|
33 | + sprintf( |
|
34 | + __( |
|
35 | + 'You do not have the necessary capabilities (%s) to read Event Espresso Configuration data', |
|
36 | + 'event_espresso' |
|
37 | + ), |
|
38 | + $cap |
|
39 | + ), |
|
40 | + array('status' => 403) |
|
41 | + ); |
|
42 | + } |
|
43 | + } |
|
44 | 44 | |
45 | 45 | |
46 | 46 | |
47 | - /** |
|
48 | - * Handles the request for public site info |
|
49 | - * |
|
50 | - * @global $wp_json_basic_auth_success boolean set by the basic auth plugin, indicates if the |
|
51 | - * current user could be authenticated using basic auth data |
|
52 | - * @global $wp_json_basic_auth_received_data boolean set by the basic auth plugin, indicates if |
|
53 | - * basic auth data was somehow received |
|
54 | - * @param \WP_REST_Request $request |
|
55 | - * @return \EE_Config|\WP_Error |
|
56 | - */ |
|
57 | - public static function handle_request_site_info(\WP_REST_Request $request) |
|
58 | - { |
|
59 | - global $wp_json_basic_auth_success, $wp_json_basic_auth_received_data; |
|
60 | - $insecure_usage_of_basic_auth = apply_filters( |
|
61 | - 'EventEspresso__core__libraries__rest_api__controllers__config__handle_request_site_info__insecure_usage_of_basic_auth', |
|
62 | - $wp_json_basic_auth_success && ! is_ssl(), |
|
63 | - $request |
|
64 | - ); |
|
65 | - if ($insecure_usage_of_basic_auth) { |
|
66 | - $warning = sprintf( |
|
67 | - esc_html__('Notice: We strongly recommend installing an SSL Certificate on your website to keep your data secure. %1$sPlease see our recommendations.%2$s', |
|
68 | - 'event_espresso'), |
|
69 | - '<a href="https://eventespresso.com/wiki/rest-api-security-recommendations/">', |
|
70 | - '</a>' |
|
71 | - ); |
|
72 | - } else { |
|
73 | - $warning = ''; |
|
74 | - } |
|
75 | - return array( |
|
76 | - 'default_timezone' => array( |
|
77 | - 'pretty' => \EEH_DTT_Helper::get_timezone_string_for_display(), |
|
78 | - 'string' => get_option('timezone_string'), |
|
79 | - 'offset' => \EEH_DTT_Helper::get_site_timezone_gmt_offset(), |
|
80 | - ), |
|
81 | - 'default_currency' => \EE_Config::instance()->currency, |
|
82 | - 'authentication' => array( |
|
83 | - 'received_basic_auth_data' => (bool)$wp_json_basic_auth_received_data, |
|
84 | - 'insecure_usage_of_basic_auth' => (bool)$insecure_usage_of_basic_auth, |
|
85 | - 'warning' => $warning |
|
86 | - ) |
|
87 | - ); |
|
88 | - } |
|
47 | + /** |
|
48 | + * Handles the request for public site info |
|
49 | + * |
|
50 | + * @global $wp_json_basic_auth_success boolean set by the basic auth plugin, indicates if the |
|
51 | + * current user could be authenticated using basic auth data |
|
52 | + * @global $wp_json_basic_auth_received_data boolean set by the basic auth plugin, indicates if |
|
53 | + * basic auth data was somehow received |
|
54 | + * @param \WP_REST_Request $request |
|
55 | + * @return \EE_Config|\WP_Error |
|
56 | + */ |
|
57 | + public static function handle_request_site_info(\WP_REST_Request $request) |
|
58 | + { |
|
59 | + global $wp_json_basic_auth_success, $wp_json_basic_auth_received_data; |
|
60 | + $insecure_usage_of_basic_auth = apply_filters( |
|
61 | + 'EventEspresso__core__libraries__rest_api__controllers__config__handle_request_site_info__insecure_usage_of_basic_auth', |
|
62 | + $wp_json_basic_auth_success && ! is_ssl(), |
|
63 | + $request |
|
64 | + ); |
|
65 | + if ($insecure_usage_of_basic_auth) { |
|
66 | + $warning = sprintf( |
|
67 | + esc_html__('Notice: We strongly recommend installing an SSL Certificate on your website to keep your data secure. %1$sPlease see our recommendations.%2$s', |
|
68 | + 'event_espresso'), |
|
69 | + '<a href="https://eventespresso.com/wiki/rest-api-security-recommendations/">', |
|
70 | + '</a>' |
|
71 | + ); |
|
72 | + } else { |
|
73 | + $warning = ''; |
|
74 | + } |
|
75 | + return array( |
|
76 | + 'default_timezone' => array( |
|
77 | + 'pretty' => \EEH_DTT_Helper::get_timezone_string_for_display(), |
|
78 | + 'string' => get_option('timezone_string'), |
|
79 | + 'offset' => \EEH_DTT_Helper::get_site_timezone_gmt_offset(), |
|
80 | + ), |
|
81 | + 'default_currency' => \EE_Config::instance()->currency, |
|
82 | + 'authentication' => array( |
|
83 | + 'received_basic_auth_data' => (bool)$wp_json_basic_auth_received_data, |
|
84 | + 'insecure_usage_of_basic_auth' => (bool)$insecure_usage_of_basic_auth, |
|
85 | + 'warning' => $warning |
|
86 | + ) |
|
87 | + ); |
|
88 | + } |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | // End of file Read.php |
92 | 92 | \ No newline at end of file |
@@ -13,386 +13,386 @@ |
||
13 | 13 | { |
14 | 14 | |
15 | 15 | |
16 | - /** |
|
17 | - * Creates the array for the tips |
|
18 | - */ |
|
19 | - protected function _set_tips_array() |
|
20 | - { |
|
21 | - $this->_qtipsa = array( |
|
22 | - 2 => array( |
|
23 | - 'content_id' => 'dtt-evt-name-label', |
|
24 | - 'target' => '.DTT_name_label', |
|
25 | - 'content' => $this->_get_event_name_label_info(), |
|
26 | - ), |
|
27 | - 3 => array( |
|
28 | - 'content_id' => 'dtt-evt-start-label', |
|
29 | - 'target' => '.DTT_EVT_start_label', |
|
30 | - 'content' => $this->_get_event_start_label_info(), |
|
31 | - ), |
|
32 | - 5 => array( |
|
33 | - 'content_id' => 'dtt-evt-end-label', |
|
34 | - 'target' => '.DTT_EVT_end_label', |
|
35 | - 'content' => $this->_get_event_end_label_info(), |
|
36 | - ), |
|
37 | - 10 => array( |
|
38 | - 'content_id' => 'dtt-reg-limit-label', |
|
39 | - 'target' => '.DTT_reg_limit_label', |
|
40 | - 'content' => $this->_get_event_datetime_DTT_reg_limit_label_info(), |
|
41 | - ), |
|
42 | - 15 => array( |
|
43 | - 'content_id' => 'dtt-sold-label', |
|
44 | - 'target' => '.DTT_sold_label', |
|
45 | - 'content' => $this->_get_event_datetime_DTT_sold_label_info(), |
|
46 | - ), |
|
47 | - 17 => array( |
|
48 | - 'content_id' => 'dtt-reserved-label', |
|
49 | - 'target' => '.DTT_reserved_label', |
|
50 | - 'content' => $this->_get_event_datetime_DTT_reserved_label_info(), |
|
51 | - ), |
|
52 | - 20 => array( |
|
53 | - 'content_id' => 'tkt-name-label', |
|
54 | - 'target' => '.TKT_name_label', |
|
55 | - 'content' => $this->_get_event_ticket_TKT_name_label_info(), |
|
56 | - ), |
|
57 | - 25 => array( |
|
58 | - 'content_id' => 'tkt-goes-on-sale-label', |
|
59 | - 'target' => '.TKT_goes_on_sale_label', |
|
60 | - 'content' => $this->_get_event_ticket_TKT_goes_on_sale_label_info(), |
|
61 | - ), |
|
62 | - 30 => array( |
|
63 | - 'content_id' => 'tkt-sell-until-label', |
|
64 | - 'target' => '.TKT_sell_until_label', |
|
65 | - 'content' => $this->_get_event_ticket_TKT_sell_until_label_info(), |
|
66 | - ), |
|
67 | - 35 => array( |
|
68 | - 'content_id' => 'tkt-price-label', |
|
69 | - 'target' => '.TKT_price_label', |
|
70 | - 'content' => $this->_get_event_ticket_TKT_price_label_info(), |
|
71 | - ), |
|
72 | - 40 => array( |
|
73 | - 'content_id' => 'tkt-qty-label', |
|
74 | - 'target' => '.TKT_qty_label', |
|
75 | - 'content' => $this->_get_event_ticket_TKT_qty_label_info(), |
|
76 | - ), |
|
77 | - 45 => array( |
|
78 | - 'content_id' => 'tkt-sold-label', |
|
79 | - 'target' => '.TKT_sold_label', |
|
80 | - 'content' => $this->_get_event_ticket_TKT_sold_label_info(), |
|
81 | - ), |
|
82 | - 47 => array( |
|
83 | - 'content_id' => 'tkt-reserved-label', |
|
84 | - 'target' => '.TKT_reserved_label', |
|
85 | - 'content' => $this->_get_event_ticket_TKT_reserved_label_info(), |
|
86 | - ), |
|
87 | - 50 => array( |
|
88 | - 'content_id' => 'tkt-regs-label', |
|
89 | - 'target' => '.TKT_regs_label', |
|
90 | - 'content' => $this->_get_event_ticket_TKT_regs_label_info(), |
|
91 | - ), |
|
92 | - 55 => array( |
|
93 | - 'content_id' => 'ant-tkt-name-label', |
|
94 | - 'target' => '.ANT_TKT_name_label', |
|
95 | - 'content' => $this->_get_event_ticket_ANT_TKT_name_label_info(), |
|
96 | - ), |
|
97 | - 60 => array( |
|
98 | - 'content_id' => 'ant-tkt-goes-on-sale-label', |
|
99 | - 'target' => '.ANT_TKT_goes_on_sale_label', |
|
100 | - 'content' => $this->_get_event_ticket_ANT_TKT_goes_on_sale_label_info(), |
|
101 | - ), |
|
102 | - 65 => array( |
|
103 | - 'content_id' => 'ant-tkt-sell-until-label', |
|
104 | - 'target' => '.ANT_TKT_sell_until_label', |
|
105 | - 'content' => $this->_get_event_ticket_ANT_TKT_sell_until_label_info(), |
|
106 | - ), |
|
107 | - 70 => array( |
|
108 | - 'content_id' => 'ant-tkt-price-label', |
|
109 | - 'target' => '.ANT_TKT_price_label', |
|
110 | - 'content' => $this->_get_event_ticket_ANT_TKT_price_label_info(), |
|
111 | - ), |
|
112 | - 75 => array( |
|
113 | - 'content_id' => 'ant-tkt-qty-label', |
|
114 | - 'target' => '.ANT_TKT_qty_label', |
|
115 | - 'content' => $this->_get_event_ticket_ANT_TKT_qty_label_info(), |
|
116 | - ), |
|
117 | - 80 => array( |
|
118 | - 'content_id' => 'ane-dtt-evt-start-label', |
|
119 | - 'target' => '.add-new-event-datetime-DTT_EVT_start_label', |
|
120 | - 'content' => $this->_get_add_new_event_start_label_info(), |
|
121 | - ), |
|
122 | - 85 => array( |
|
123 | - 'content_id' => 'ane-dtt-evt-end-label', |
|
124 | - 'target' => '.add-new-event-datetime-DTT_EVT_end_label', |
|
125 | - 'content' => $this->_get_add_new_event_end_label_info(), |
|
126 | - ), |
|
127 | - 90 => array( |
|
128 | - 'content_id' => 'ane_dtt-reg-limit-label', |
|
129 | - 'target' => '.add-new-event-datetime-DTT_reg_limit_label', |
|
130 | - 'content' => $this->_get_add_new_event_datetime_DTT_reg_limit_label_info(), |
|
131 | - ), |
|
132 | - 100 => array( |
|
133 | - 'content_id' => 'td-tkt-number-datetimes-label', |
|
134 | - 'target' => '.TD_TKT_number_datetimes_label', |
|
135 | - 'content' => $this->_get_event_ticket_TD_TKT_number_datetimes_label_info(), |
|
136 | - ), |
|
137 | - 110 => array( |
|
138 | - 'content_id' => 'td-tkt-min-qty-label', |
|
139 | - 'target' => '.TD_TKT_min_qty_label', |
|
140 | - 'content' => $this->_get_event_ticket_TD_TKT_min_qty_label_info(), |
|
141 | - ), |
|
142 | - 120 => array( |
|
143 | - 'content_id' => 'td-tkt-max-qty-label', |
|
144 | - 'target' => '.TD_TKT_max_qty_label', |
|
145 | - 'content' => $this->_get_event_ticket_TD_TKT_max_qty_label_info(), |
|
146 | - ), |
|
147 | - 130 => array( |
|
148 | - 'content_id' => 'ticket-lock-icon', |
|
149 | - 'target' => '.ticket-archived .ee-lock-icon', |
|
150 | - 'content' => esc_html__( |
|
151 | - 'This ticket was automatically locked and archived because it has a sold quantity and the price was modified. Existing ticket holders will still be verified using these ticket details. However, Event Espresso has automatically created a new active ticket with the modified price for new registrants. This lock is meant to prevent accidental trashing of this ticket. Certain details of this ticket can still be edited (non disabled inputs).', |
|
152 | - 'event_espresso' |
|
153 | - ), |
|
154 | - ), |
|
155 | - 135 => array( |
|
156 | - 'content_id' => 'ticket-lock-icon-event-editor', |
|
157 | - 'target' => '.ee-lock-icon', |
|
158 | - 'content' => esc_html__( |
|
159 | - 'This datetime can no longer be duplicated or deleted because tickets associated with this datetime have already been sold.', |
|
160 | - 'event_espresso' |
|
161 | - ), |
|
162 | - ), |
|
163 | - ); |
|
164 | - } |
|
16 | + /** |
|
17 | + * Creates the array for the tips |
|
18 | + */ |
|
19 | + protected function _set_tips_array() |
|
20 | + { |
|
21 | + $this->_qtipsa = array( |
|
22 | + 2 => array( |
|
23 | + 'content_id' => 'dtt-evt-name-label', |
|
24 | + 'target' => '.DTT_name_label', |
|
25 | + 'content' => $this->_get_event_name_label_info(), |
|
26 | + ), |
|
27 | + 3 => array( |
|
28 | + 'content_id' => 'dtt-evt-start-label', |
|
29 | + 'target' => '.DTT_EVT_start_label', |
|
30 | + 'content' => $this->_get_event_start_label_info(), |
|
31 | + ), |
|
32 | + 5 => array( |
|
33 | + 'content_id' => 'dtt-evt-end-label', |
|
34 | + 'target' => '.DTT_EVT_end_label', |
|
35 | + 'content' => $this->_get_event_end_label_info(), |
|
36 | + ), |
|
37 | + 10 => array( |
|
38 | + 'content_id' => 'dtt-reg-limit-label', |
|
39 | + 'target' => '.DTT_reg_limit_label', |
|
40 | + 'content' => $this->_get_event_datetime_DTT_reg_limit_label_info(), |
|
41 | + ), |
|
42 | + 15 => array( |
|
43 | + 'content_id' => 'dtt-sold-label', |
|
44 | + 'target' => '.DTT_sold_label', |
|
45 | + 'content' => $this->_get_event_datetime_DTT_sold_label_info(), |
|
46 | + ), |
|
47 | + 17 => array( |
|
48 | + 'content_id' => 'dtt-reserved-label', |
|
49 | + 'target' => '.DTT_reserved_label', |
|
50 | + 'content' => $this->_get_event_datetime_DTT_reserved_label_info(), |
|
51 | + ), |
|
52 | + 20 => array( |
|
53 | + 'content_id' => 'tkt-name-label', |
|
54 | + 'target' => '.TKT_name_label', |
|
55 | + 'content' => $this->_get_event_ticket_TKT_name_label_info(), |
|
56 | + ), |
|
57 | + 25 => array( |
|
58 | + 'content_id' => 'tkt-goes-on-sale-label', |
|
59 | + 'target' => '.TKT_goes_on_sale_label', |
|
60 | + 'content' => $this->_get_event_ticket_TKT_goes_on_sale_label_info(), |
|
61 | + ), |
|
62 | + 30 => array( |
|
63 | + 'content_id' => 'tkt-sell-until-label', |
|
64 | + 'target' => '.TKT_sell_until_label', |
|
65 | + 'content' => $this->_get_event_ticket_TKT_sell_until_label_info(), |
|
66 | + ), |
|
67 | + 35 => array( |
|
68 | + 'content_id' => 'tkt-price-label', |
|
69 | + 'target' => '.TKT_price_label', |
|
70 | + 'content' => $this->_get_event_ticket_TKT_price_label_info(), |
|
71 | + ), |
|
72 | + 40 => array( |
|
73 | + 'content_id' => 'tkt-qty-label', |
|
74 | + 'target' => '.TKT_qty_label', |
|
75 | + 'content' => $this->_get_event_ticket_TKT_qty_label_info(), |
|
76 | + ), |
|
77 | + 45 => array( |
|
78 | + 'content_id' => 'tkt-sold-label', |
|
79 | + 'target' => '.TKT_sold_label', |
|
80 | + 'content' => $this->_get_event_ticket_TKT_sold_label_info(), |
|
81 | + ), |
|
82 | + 47 => array( |
|
83 | + 'content_id' => 'tkt-reserved-label', |
|
84 | + 'target' => '.TKT_reserved_label', |
|
85 | + 'content' => $this->_get_event_ticket_TKT_reserved_label_info(), |
|
86 | + ), |
|
87 | + 50 => array( |
|
88 | + 'content_id' => 'tkt-regs-label', |
|
89 | + 'target' => '.TKT_regs_label', |
|
90 | + 'content' => $this->_get_event_ticket_TKT_regs_label_info(), |
|
91 | + ), |
|
92 | + 55 => array( |
|
93 | + 'content_id' => 'ant-tkt-name-label', |
|
94 | + 'target' => '.ANT_TKT_name_label', |
|
95 | + 'content' => $this->_get_event_ticket_ANT_TKT_name_label_info(), |
|
96 | + ), |
|
97 | + 60 => array( |
|
98 | + 'content_id' => 'ant-tkt-goes-on-sale-label', |
|
99 | + 'target' => '.ANT_TKT_goes_on_sale_label', |
|
100 | + 'content' => $this->_get_event_ticket_ANT_TKT_goes_on_sale_label_info(), |
|
101 | + ), |
|
102 | + 65 => array( |
|
103 | + 'content_id' => 'ant-tkt-sell-until-label', |
|
104 | + 'target' => '.ANT_TKT_sell_until_label', |
|
105 | + 'content' => $this->_get_event_ticket_ANT_TKT_sell_until_label_info(), |
|
106 | + ), |
|
107 | + 70 => array( |
|
108 | + 'content_id' => 'ant-tkt-price-label', |
|
109 | + 'target' => '.ANT_TKT_price_label', |
|
110 | + 'content' => $this->_get_event_ticket_ANT_TKT_price_label_info(), |
|
111 | + ), |
|
112 | + 75 => array( |
|
113 | + 'content_id' => 'ant-tkt-qty-label', |
|
114 | + 'target' => '.ANT_TKT_qty_label', |
|
115 | + 'content' => $this->_get_event_ticket_ANT_TKT_qty_label_info(), |
|
116 | + ), |
|
117 | + 80 => array( |
|
118 | + 'content_id' => 'ane-dtt-evt-start-label', |
|
119 | + 'target' => '.add-new-event-datetime-DTT_EVT_start_label', |
|
120 | + 'content' => $this->_get_add_new_event_start_label_info(), |
|
121 | + ), |
|
122 | + 85 => array( |
|
123 | + 'content_id' => 'ane-dtt-evt-end-label', |
|
124 | + 'target' => '.add-new-event-datetime-DTT_EVT_end_label', |
|
125 | + 'content' => $this->_get_add_new_event_end_label_info(), |
|
126 | + ), |
|
127 | + 90 => array( |
|
128 | + 'content_id' => 'ane_dtt-reg-limit-label', |
|
129 | + 'target' => '.add-new-event-datetime-DTT_reg_limit_label', |
|
130 | + 'content' => $this->_get_add_new_event_datetime_DTT_reg_limit_label_info(), |
|
131 | + ), |
|
132 | + 100 => array( |
|
133 | + 'content_id' => 'td-tkt-number-datetimes-label', |
|
134 | + 'target' => '.TD_TKT_number_datetimes_label', |
|
135 | + 'content' => $this->_get_event_ticket_TD_TKT_number_datetimes_label_info(), |
|
136 | + ), |
|
137 | + 110 => array( |
|
138 | + 'content_id' => 'td-tkt-min-qty-label', |
|
139 | + 'target' => '.TD_TKT_min_qty_label', |
|
140 | + 'content' => $this->_get_event_ticket_TD_TKT_min_qty_label_info(), |
|
141 | + ), |
|
142 | + 120 => array( |
|
143 | + 'content_id' => 'td-tkt-max-qty-label', |
|
144 | + 'target' => '.TD_TKT_max_qty_label', |
|
145 | + 'content' => $this->_get_event_ticket_TD_TKT_max_qty_label_info(), |
|
146 | + ), |
|
147 | + 130 => array( |
|
148 | + 'content_id' => 'ticket-lock-icon', |
|
149 | + 'target' => '.ticket-archived .ee-lock-icon', |
|
150 | + 'content' => esc_html__( |
|
151 | + 'This ticket was automatically locked and archived because it has a sold quantity and the price was modified. Existing ticket holders will still be verified using these ticket details. However, Event Espresso has automatically created a new active ticket with the modified price for new registrants. This lock is meant to prevent accidental trashing of this ticket. Certain details of this ticket can still be edited (non disabled inputs).', |
|
152 | + 'event_espresso' |
|
153 | + ), |
|
154 | + ), |
|
155 | + 135 => array( |
|
156 | + 'content_id' => 'ticket-lock-icon-event-editor', |
|
157 | + 'target' => '.ee-lock-icon', |
|
158 | + 'content' => esc_html__( |
|
159 | + 'This datetime can no longer be duplicated or deleted because tickets associated with this datetime have already been sold.', |
|
160 | + 'event_espresso' |
|
161 | + ), |
|
162 | + ), |
|
163 | + ); |
|
164 | + } |
|
165 | 165 | |
166 | - /** |
|
167 | - * @return string |
|
168 | - */ |
|
169 | - private function _get_event_name_label_info() |
|
170 | - { |
|
171 | - return esc_html__( |
|
172 | - 'This is the name or title for an event datetime.', |
|
173 | - 'event_espresso' |
|
174 | - ); |
|
175 | - } |
|
166 | + /** |
|
167 | + * @return string |
|
168 | + */ |
|
169 | + private function _get_event_name_label_info() |
|
170 | + { |
|
171 | + return esc_html__( |
|
172 | + 'This is the name or title for an event datetime.', |
|
173 | + 'event_espresso' |
|
174 | + ); |
|
175 | + } |
|
176 | 176 | |
177 | - /** |
|
178 | - * @return string |
|
179 | - */ |
|
180 | - private function _get_event_start_label_info() |
|
181 | - { |
|
182 | - return esc_html__( |
|
183 | - 'This shows when this event datetime starts.', |
|
184 | - 'event_espresso' |
|
185 | - ); |
|
186 | - } |
|
177 | + /** |
|
178 | + * @return string |
|
179 | + */ |
|
180 | + private function _get_event_start_label_info() |
|
181 | + { |
|
182 | + return esc_html__( |
|
183 | + 'This shows when this event datetime starts.', |
|
184 | + 'event_espresso' |
|
185 | + ); |
|
186 | + } |
|
187 | 187 | |
188 | - /** |
|
189 | - * @return string |
|
190 | - */ |
|
191 | - private function _get_event_end_label_info() |
|
192 | - { |
|
193 | - return esc_html__('This shows when this event datetime ends.', 'event_espresso'); |
|
194 | - } |
|
188 | + /** |
|
189 | + * @return string |
|
190 | + */ |
|
191 | + private function _get_event_end_label_info() |
|
192 | + { |
|
193 | + return esc_html__('This shows when this event datetime ends.', 'event_espresso'); |
|
194 | + } |
|
195 | 195 | |
196 | - /** |
|
197 | - * @return string |
|
198 | - */ |
|
199 | - private function _get_event_datetime_DTT_reg_limit_label_info() |
|
200 | - { |
|
201 | - return esc_html__( |
|
202 | - 'This field allows you to set a maximum number of tickets that you want to make available for an event datetime.', |
|
203 | - 'event_espresso' |
|
204 | - ); |
|
205 | - } |
|
196 | + /** |
|
197 | + * @return string |
|
198 | + */ |
|
199 | + private function _get_event_datetime_DTT_reg_limit_label_info() |
|
200 | + { |
|
201 | + return esc_html__( |
|
202 | + 'This field allows you to set a maximum number of tickets that you want to make available for an event datetime.', |
|
203 | + 'event_espresso' |
|
204 | + ); |
|
205 | + } |
|
206 | 206 | |
207 | - /** |
|
208 | - * @return string |
|
209 | - */ |
|
210 | - private function _get_event_datetime_DTT_sold_label_info() |
|
211 | - { |
|
212 | - return esc_html__( |
|
213 | - 'This shows the number of tickets that have been sold that have access to this event datetime.', |
|
214 | - 'event_espresso' |
|
215 | - ); |
|
216 | - } |
|
207 | + /** |
|
208 | + * @return string |
|
209 | + */ |
|
210 | + private function _get_event_datetime_DTT_sold_label_info() |
|
211 | + { |
|
212 | + return esc_html__( |
|
213 | + 'This shows the number of tickets that have been sold that have access to this event datetime.', |
|
214 | + 'event_espresso' |
|
215 | + ); |
|
216 | + } |
|
217 | 217 | |
218 | - /** |
|
219 | - * @return string |
|
220 | - */ |
|
221 | - private function _get_event_datetime_DTT_reserved_label_info() |
|
222 | - { |
|
223 | - return esc_html__( |
|
224 | - 'This shows the number of reserved tickets that have access to this event datetime.', |
|
225 | - 'event_espresso' |
|
226 | - ); |
|
227 | - } |
|
218 | + /** |
|
219 | + * @return string |
|
220 | + */ |
|
221 | + private function _get_event_datetime_DTT_reserved_label_info() |
|
222 | + { |
|
223 | + return esc_html__( |
|
224 | + 'This shows the number of reserved tickets that have access to this event datetime.', |
|
225 | + 'event_espresso' |
|
226 | + ); |
|
227 | + } |
|
228 | 228 | |
229 | - /** |
|
230 | - * @return string |
|
231 | - */ |
|
232 | - private function _get_event_ticket_TKT_name_label_info() |
|
233 | - { |
|
234 | - return esc_html__('This is the name of this ticket option.', 'event_espresso'); |
|
235 | - } |
|
229 | + /** |
|
230 | + * @return string |
|
231 | + */ |
|
232 | + private function _get_event_ticket_TKT_name_label_info() |
|
233 | + { |
|
234 | + return esc_html__('This is the name of this ticket option.', 'event_espresso'); |
|
235 | + } |
|
236 | 236 | |
237 | - /** |
|
238 | - * @return string |
|
239 | - */ |
|
240 | - private function _get_event_ticket_TKT_goes_on_sale_label_info() |
|
241 | - { |
|
242 | - return esc_html__('This shows when the first ticket is available for sale.', 'event_espresso'); |
|
243 | - } |
|
237 | + /** |
|
238 | + * @return string |
|
239 | + */ |
|
240 | + private function _get_event_ticket_TKT_goes_on_sale_label_info() |
|
241 | + { |
|
242 | + return esc_html__('This shows when the first ticket is available for sale.', 'event_espresso'); |
|
243 | + } |
|
244 | 244 | |
245 | - /** |
|
246 | - * @return string |
|
247 | - */ |
|
248 | - private function _get_event_ticket_TKT_sell_until_label_info() |
|
249 | - { |
|
250 | - return esc_html__('This shows the date that ticket sales end for this ticket.', 'event_espresso'); |
|
251 | - } |
|
245 | + /** |
|
246 | + * @return string |
|
247 | + */ |
|
248 | + private function _get_event_ticket_TKT_sell_until_label_info() |
|
249 | + { |
|
250 | + return esc_html__('This shows the date that ticket sales end for this ticket.', 'event_espresso'); |
|
251 | + } |
|
252 | 252 | |
253 | - /** |
|
254 | - * @return string |
|
255 | - */ |
|
256 | - private function _get_event_ticket_TKT_price_label_info() |
|
257 | - { |
|
258 | - return esc_html__('This is the price for this ticket.', 'event_espresso'); |
|
259 | - } |
|
253 | + /** |
|
254 | + * @return string |
|
255 | + */ |
|
256 | + private function _get_event_ticket_TKT_price_label_info() |
|
257 | + { |
|
258 | + return esc_html__('This is the price for this ticket.', 'event_espresso'); |
|
259 | + } |
|
260 | 260 | |
261 | - /** |
|
262 | - * @return string |
|
263 | - */ |
|
264 | - private function _get_event_ticket_TKT_qty_label_info() |
|
265 | - { |
|
266 | - return esc_html__( |
|
267 | - 'This field shows the quantity of tickets that are available for this type of ticket.', |
|
268 | - 'event_espresso' |
|
269 | - ); |
|
270 | - } |
|
261 | + /** |
|
262 | + * @return string |
|
263 | + */ |
|
264 | + private function _get_event_ticket_TKT_qty_label_info() |
|
265 | + { |
|
266 | + return esc_html__( |
|
267 | + 'This field shows the quantity of tickets that are available for this type of ticket.', |
|
268 | + 'event_espresso' |
|
269 | + ); |
|
270 | + } |
|
271 | 271 | |
272 | - /** |
|
273 | - * @return string |
|
274 | - */ |
|
275 | - private function _get_event_ticket_TKT_sold_label_info() |
|
276 | - { |
|
277 | - return esc_html__('This shows the number of tickets that have been sold for this ticket.', 'event_espresso'); |
|
278 | - } |
|
272 | + /** |
|
273 | + * @return string |
|
274 | + */ |
|
275 | + private function _get_event_ticket_TKT_sold_label_info() |
|
276 | + { |
|
277 | + return esc_html__('This shows the number of tickets that have been sold for this ticket.', 'event_espresso'); |
|
278 | + } |
|
279 | 279 | |
280 | - /** |
|
281 | - * @return string |
|
282 | - */ |
|
283 | - private function _get_event_ticket_TKT_reserved_label_info() |
|
284 | - { |
|
285 | - return esc_html__('This shows the number of tickets that are reserved for this ticket.', 'event_espresso'); |
|
286 | - } |
|
280 | + /** |
|
281 | + * @return string |
|
282 | + */ |
|
283 | + private function _get_event_ticket_TKT_reserved_label_info() |
|
284 | + { |
|
285 | + return esc_html__('This shows the number of tickets that are reserved for this ticket.', 'event_espresso'); |
|
286 | + } |
|
287 | 287 | |
288 | - /** |
|
289 | - * @return string |
|
290 | - */ |
|
291 | - private function _get_event_ticket_TKT_regs_label_info() |
|
292 | - { |
|
293 | - return esc_html__( |
|
294 | - 'This shows the number of registrations that have occurred from ticket sales.', |
|
295 | - 'event_espresso' |
|
296 | - ); |
|
297 | - } |
|
288 | + /** |
|
289 | + * @return string |
|
290 | + */ |
|
291 | + private function _get_event_ticket_TKT_regs_label_info() |
|
292 | + { |
|
293 | + return esc_html__( |
|
294 | + 'This shows the number of registrations that have occurred from ticket sales.', |
|
295 | + 'event_espresso' |
|
296 | + ); |
|
297 | + } |
|
298 | 298 | |
299 | - /** |
|
300 | - * @return string |
|
301 | - */ |
|
302 | - private function _get_event_ticket_ANT_TKT_name_label_info() |
|
303 | - { |
|
304 | - return esc_html__('This is the name of this ticket option.', 'event_espresso'); |
|
305 | - } |
|
299 | + /** |
|
300 | + * @return string |
|
301 | + */ |
|
302 | + private function _get_event_ticket_ANT_TKT_name_label_info() |
|
303 | + { |
|
304 | + return esc_html__('This is the name of this ticket option.', 'event_espresso'); |
|
305 | + } |
|
306 | 306 | |
307 | - /** |
|
308 | - * @return string |
|
309 | - */ |
|
310 | - private function _get_event_ticket_ANT_TKT_goes_on_sale_label_info() |
|
311 | - { |
|
312 | - return esc_html__('This shows when the first ticket is available for sale.', 'event_espresso'); |
|
313 | - } |
|
307 | + /** |
|
308 | + * @return string |
|
309 | + */ |
|
310 | + private function _get_event_ticket_ANT_TKT_goes_on_sale_label_info() |
|
311 | + { |
|
312 | + return esc_html__('This shows when the first ticket is available for sale.', 'event_espresso'); |
|
313 | + } |
|
314 | 314 | |
315 | - /** |
|
316 | - * @return string |
|
317 | - */ |
|
318 | - private function _get_event_ticket_ANT_TKT_sell_until_label_info() |
|
319 | - { |
|
320 | - return esc_html__('This shows the date that ticket sales end for this ticket.', 'event_espresso'); |
|
321 | - } |
|
315 | + /** |
|
316 | + * @return string |
|
317 | + */ |
|
318 | + private function _get_event_ticket_ANT_TKT_sell_until_label_info() |
|
319 | + { |
|
320 | + return esc_html__('This shows the date that ticket sales end for this ticket.', 'event_espresso'); |
|
321 | + } |
|
322 | 322 | |
323 | - /** |
|
324 | - * @return string |
|
325 | - */ |
|
326 | - private function _get_event_ticket_ANT_TKT_price_label_info() |
|
327 | - { |
|
328 | - return esc_html__('This is the price for this ticket.', 'event_espresso'); |
|
329 | - } |
|
323 | + /** |
|
324 | + * @return string |
|
325 | + */ |
|
326 | + private function _get_event_ticket_ANT_TKT_price_label_info() |
|
327 | + { |
|
328 | + return esc_html__('This is the price for this ticket.', 'event_espresso'); |
|
329 | + } |
|
330 | 330 | |
331 | - /** |
|
332 | - * @return string |
|
333 | - */ |
|
334 | - private function _get_event_ticket_ANT_TKT_qty_label_info() |
|
335 | - { |
|
336 | - return esc_html__( |
|
337 | - 'This field shows the quantity of tickets that are available for this type of ticket.', |
|
338 | - 'event_espresso' |
|
339 | - ); |
|
340 | - } |
|
331 | + /** |
|
332 | + * @return string |
|
333 | + */ |
|
334 | + private function _get_event_ticket_ANT_TKT_qty_label_info() |
|
335 | + { |
|
336 | + return esc_html__( |
|
337 | + 'This field shows the quantity of tickets that are available for this type of ticket.', |
|
338 | + 'event_espresso' |
|
339 | + ); |
|
340 | + } |
|
341 | 341 | |
342 | - /** |
|
343 | - * @return string |
|
344 | - */ |
|
345 | - private function _get_add_new_event_start_label_info() |
|
346 | - { |
|
347 | - return esc_html__('This shows when this event datetime starts.', 'event_espresso'); |
|
348 | - } |
|
342 | + /** |
|
343 | + * @return string |
|
344 | + */ |
|
345 | + private function _get_add_new_event_start_label_info() |
|
346 | + { |
|
347 | + return esc_html__('This shows when this event datetime starts.', 'event_espresso'); |
|
348 | + } |
|
349 | 349 | |
350 | - /** |
|
351 | - * @return string |
|
352 | - */ |
|
353 | - private function _get_add_new_event_end_label_info() |
|
354 | - { |
|
355 | - return esc_html__('This shows when this event datetime ends.', 'event_espresso'); |
|
356 | - } |
|
350 | + /** |
|
351 | + * @return string |
|
352 | + */ |
|
353 | + private function _get_add_new_event_end_label_info() |
|
354 | + { |
|
355 | + return esc_html__('This shows when this event datetime ends.', 'event_espresso'); |
|
356 | + } |
|
357 | 357 | |
358 | - /** |
|
359 | - * @return string |
|
360 | - */ |
|
361 | - private function _get_add_new_event_datetime_DTT_reg_limit_label_info() |
|
362 | - { |
|
363 | - return esc_html__( |
|
364 | - 'This field allows you to set a maximum number of tickets that you want to make available for an event datetime.', |
|
365 | - 'event_espresso' |
|
366 | - ); |
|
367 | - } |
|
358 | + /** |
|
359 | + * @return string |
|
360 | + */ |
|
361 | + private function _get_add_new_event_datetime_DTT_reg_limit_label_info() |
|
362 | + { |
|
363 | + return esc_html__( |
|
364 | + 'This field allows you to set a maximum number of tickets that you want to make available for an event datetime.', |
|
365 | + 'event_espresso' |
|
366 | + ); |
|
367 | + } |
|
368 | 368 | |
369 | - /** |
|
370 | - * @return string |
|
371 | - */ |
|
372 | - private function _get_event_ticket_TD_TKT_number_datetimes_label_info() |
|
373 | - { |
|
374 | - return esc_html__( |
|
375 | - 'This field allows you to set the number of datetimes that a ticket should have access to.', |
|
376 | - 'event_espresso' |
|
377 | - ); |
|
378 | - } |
|
369 | + /** |
|
370 | + * @return string |
|
371 | + */ |
|
372 | + private function _get_event_ticket_TD_TKT_number_datetimes_label_info() |
|
373 | + { |
|
374 | + return esc_html__( |
|
375 | + 'This field allows you to set the number of datetimes that a ticket should have access to.', |
|
376 | + 'event_espresso' |
|
377 | + ); |
|
378 | + } |
|
379 | 379 | |
380 | - /** |
|
381 | - * @return string |
|
382 | - */ |
|
383 | - private function _get_event_ticket_TD_TKT_min_qty_label_info() |
|
384 | - { |
|
385 | - return esc_html__( |
|
386 | - 'This shows the minimum quantity that can be purchased for this ticket.', |
|
387 | - 'event_espresso' |
|
388 | - ); |
|
389 | - } |
|
380 | + /** |
|
381 | + * @return string |
|
382 | + */ |
|
383 | + private function _get_event_ticket_TD_TKT_min_qty_label_info() |
|
384 | + { |
|
385 | + return esc_html__( |
|
386 | + 'This shows the minimum quantity that can be purchased for this ticket.', |
|
387 | + 'event_espresso' |
|
388 | + ); |
|
389 | + } |
|
390 | 390 | |
391 | - /** |
|
392 | - * @return string |
|
393 | - */ |
|
394 | - private function _get_event_ticket_TD_TKT_max_qty_label_info() |
|
395 | - { |
|
396 | - return esc_html__('This shows the maximum quantity that can be purchased for this ticket.', 'event_espresso'); |
|
397 | - } |
|
391 | + /** |
|
392 | + * @return string |
|
393 | + */ |
|
394 | + private function _get_event_ticket_TD_TKT_max_qty_label_info() |
|
395 | + { |
|
396 | + return esc_html__('This shows the maximum quantity that can be purchased for this ticket.', 'event_espresso'); |
|
397 | + } |
|
398 | 398 | } |
399 | 399 | \ No newline at end of file |
@@ -1,9 +1,9 @@ discard block |
||
1 | - <tr valign="top" class="ee-ticket-sortable ticket-row<?php echo $ticket_archive_class; if(WP_DEBUG){ echo ' ee-wp-debug'; } ?>" id="display-ticketrow-<?php echo $tkt_row; ?>"> |
|
1 | + <tr valign="top" class="ee-ticket-sortable ticket-row<?php echo $ticket_archive_class; if (WP_DEBUG) { echo ' ee-wp-debug'; } ?>" id="display-ticketrow-<?php echo $tkt_row; ?>"> |
|
2 | 2 | <!--<td class="ee-tkt-order-field"><span class="dashicons dashicons-sort<?php echo $tkt_status_class; ?>"><input type="hidden" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_order]" class="edit-ticket-TKT_order" value ="<?php echo $TKT_order; ?>" ></span></td>--> |
3 | 3 | <td class="ee-tkt-order-field"><span class="ee-status-strip-td ee-status-strip<?php echo $tkt_status_class; ?>"></span><input type="hidden" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_order]" class="edit-ticket-TKT_order" value ="<?php echo $TKT_order; ?>"></td> |
4 | 4 | <td><input maxlength="245" type="text" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_name]" class="edit-ticket-TKT_name ee-large-text-inp" placeholder="Ticket Title" value="<?php echo $TKT_name; ?>"></td> |
5 | 5 | <td> |
6 | - <?php if ( $disabled ) : ?> |
|
6 | + <?php if ($disabled) : ?> |
|
7 | 7 | <input type="hidden" id="edit-ticket-TKT_start_date-<?php echo $tkt_row; ?>" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_start_date]" class="edit-ticket-TKT_start_date ee-text-inp" value="<?php echo $TKT_start_date; ?>" > |
8 | 8 | <input type="text" name="archived_ticket[TKT_start_date]" class="edit-ticket-TKT_start_date ee-text-inp" value="<?php echo $TKT_start_date; ?>" disabled> |
9 | 9 | <?php else : ?> |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | <?php endif; ?> |
12 | 12 | </td> |
13 | 13 | <td> |
14 | - <?php if ( $disabled ) : ?> |
|
14 | + <?php if ($disabled) : ?> |
|
15 | 15 | <input type="hidden" id="edit-ticket-TKT_end_date-<?php echo $tkt_row; ?>" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_end_date]" class="edit-ticket-TKT_end_date ee-text-inp" value="<?php echo $TKT_end_date; ?>" > |
16 | 16 | <input type="text" name="archived_ticket[TKT_end_date]" class="edit-ticket-TKT_end_date ee-text-inp" value="<?php echo $TKT_end_date; ?>" disabled> |
17 | 17 | <?php else : ?> |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | <?php endif; ?> |
20 | 20 | </td> |
21 | 21 | <td> |
22 | - <?php if ( $disabled ) : ?> |
|
22 | + <?php if ($disabled) : ?> |
|
23 | 23 | <input id="edit-ticket-TKT_base_price-<?php echo $tkt_row; ?>" type="hidden" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_base_price]" class="edit-ticket-TKT_base_price ee-small-text-inp edit-price-PRC_amount ee-numeric" value="<?php echo $TKT_base_price; ?>"> |
24 | 24 | <input type="text" name="archived_ticket[<?php echo $tkt_row; ?>][TKT_base_price]" class="edit-ticket-TKT_base_price ee-small-text-inp edit-price-PRC_amount ee-numeric" value="<?php echo $TKT_base_price; ?>" disabled> |
25 | 25 | <?php else : ?> |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | <input type="hidden" id="edit-ticket-TKT_base_price_ID-<?php echo $tkt_row; ?>" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_base_price_ID]" value="<?php echo $TKT_base_price_ID; ?>"> |
29 | 29 | </td> |
30 | 30 | <td> |
31 | - <?php if ( $disabled ) : ?> |
|
31 | + <?php if ($disabled) : ?> |
|
32 | 32 | <input type="hidden" class="edit-ticket-TKT_qty ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_qty]" value="<?php echo $TKT_qty_for_input; ?>"> |
33 | 33 | <input type="text" class="edit-ticket-TKT_qty ee-small-text-inp ee-numeric" name="archived_ticket[<?php echo $tkt_row; ?>][TKT_qty]" value="<?php echo $TKT_qty_for_input; ?>" disabled> |
34 | 34 | <?php else : ?> |
@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | <input type="hidden" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_ID]" class="edit-ticket-TKT_ID" value="<?php echo $TKT_ID; ?>"> |
57 | 57 | <input type="hidden" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_row]" class="edit-ticket-TKT_row" value="<?php echo $tkt_row; ?>"> |
58 | 58 | |
59 | - <!--<div class="total-price-container"><?php printf( esc_html__('Total Final Price: %s', 'event_espresso'), '<span class="ticket-price-amount">' . $TKT_price . '</span>'); ?> </div>--> |
|
59 | + <!--<div class="total-price-container"><?php printf(esc_html__('Total Final Price: %s', 'event_espresso'), '<span class="ticket-price-amount">'.$TKT_price.'</span>'); ?> </div>--> |
|
60 | 60 | <textarea name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_description]" class="edit-ticket-TKT_description ee-full-textarea-inp" placeholder="Ticket Description"><?php echo $TKT_description; ?></textarea> |
61 | 61 | |
62 | - <?php do_action( 'AHEE__event_tickets_datetime_ticket_row_template_after_desc', $tkt_row, $TKT_ID ); ?> |
|
62 | + <?php do_action('AHEE__event_tickets_datetime_ticket_row_template_after_desc', $tkt_row, $TKT_ID); ?> |
|
63 | 63 | |
64 | 64 | <div class="basic-ticket-container"> |
65 | 65 | <h4 class="tickets-heading"><?php esc_html_e('Ticket Details', 'event_espresso'); ?></h4> |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | <tbody> |
76 | 76 | <tr> |
77 | 77 | <td> |
78 | - <?php if ( $disabled ) : ?> |
|
78 | + <?php if ($disabled) : ?> |
|
79 | 79 | <input type="hidden" class="edit-ticket-TKT_uses ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_uses]" value="<?php echo $TKT_uses; ?>"> |
80 | 80 | <input type="text" class="edit-ticket-TKT_uses ee-small-text-inp ee-numeric" name="archived_ticket[<?php echo $tkt_row; ?>][TKT_uses]" value="<?php echo $TKT_uses; ?>" disabled> |
81 | 81 | <?php else : ?> |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | <?php endif; ?> |
84 | 84 | </td> |
85 | 85 | <td> |
86 | - <?php if ( $disabled ) : ?> |
|
86 | + <?php if ($disabled) : ?> |
|
87 | 87 | <input type="hidden" class="edit-ticket-TKT_min ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_min]" value="<?php echo $TKT_min; ?>"> |
88 | 88 | <input type="text" class="edit-ticket-TKT_min ee-small-text-inp ee-numeric" name="archived_ticket[<?php echo $tkt_row; ?>][TKT_min]" value="<?php echo $TKT_min; ?>" disabled> |
89 | 89 | <?php else: ?> |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | <?php endif; ?> |
92 | 92 | </td> |
93 | 93 | <td> |
94 | - <?php if ( $disabled ) : ?> |
|
94 | + <?php if ($disabled) : ?> |
|
95 | 95 | <input type="hidden" class="edit-ticket-TKT_max ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_max]" value="<?php echo $TKT_max; ?>"> |
96 | 96 | <input type="text" class="edit-ticket-TKT_max ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_max]" value="<?php echo $TKT_max; ?>" disabled> |
97 | 97 | <?php else : ?> |
@@ -109,15 +109,15 @@ discard block |
||
109 | 109 | <label for="edit-ticket-TKT_required"><?php esc_html_e('This ticket is required (will appear first in frontend ticket lists).', 'event_espresso'); ?></label> |
110 | 110 | </div> |
111 | 111 | <div class="ticket-is-taxable-container"> |
112 | - <?php if ( !empty($tax_rows) ) { ?> |
|
113 | - <?php if ( $disabled ) : ?> |
|
112 | + <?php if ( ! empty($tax_rows)) { ?> |
|
113 | + <?php if ($disabled) : ?> |
|
114 | 114 | <?php |
115 | - $tax_value = !empty( $TKT_taxable ) ? 1 : 0; |
|
115 | + $tax_value = ! empty($TKT_taxable) ? 1 : 0; |
|
116 | 116 | ?> |
117 | - <input class="TKT-taxable-checkbox" type="hidden" name="<?php echo $edit_tickets_name;?>[<?php echo $tkt_row; ?>][TKT_taxable]" value="<?php echo $tax_value; ?>"> |
|
117 | + <input class="TKT-taxable-checkbox" type="hidden" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_taxable]" value="<?php echo $tax_value; ?>"> |
|
118 | 118 | <input class="TKT-taxable-checkbox" id="edit-ticket-TKT_taxable-<?php echo $tkt_row; ?>" type="checkbox" name="archived_ticket[<?php echo $tkt_row; ?>][TKT_taxable]" value="1"<?php echo $TKT_taxable; ?> disabled> |
119 | 119 | <?php else : ?> |
120 | - <input class="TKT-taxable-checkbox" id="edit-ticket-TKT_taxable-<?php echo $tkt_row; ?>" type="checkbox" name="<?php echo $edit_tickets_name;?>[<?php echo $tkt_row; ?>][TKT_taxable]" value="1"<?php echo $TKT_taxable; ?>> |
|
120 | + <input class="TKT-taxable-checkbox" id="edit-ticket-TKT_taxable-<?php echo $tkt_row; ?>" type="checkbox" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_taxable]" value="1"<?php echo $TKT_taxable; ?>> |
|
121 | 121 | <?php endif; ?> |
122 | 122 | <label for="edit-ticket-TKT_taxable-<?php echo $tkt_row; ?>"> <?php esc_html_e('This ticket is taxable.', 'event_espresso'); ?> |
123 | 123 | <?php } //end tax_rows check ?> |
@@ -174,10 +174,10 @@ discard block |
||
174 | 174 | <?php echo $ticket_datetimes_list; ?> |
175 | 175 | </ul> |
176 | 176 | |
177 | - <?php do_action( 'AHEE__event_tickets_datetime_ticket_row_template__advanced_details_end', $tkt_row, $TKT_ID ); ?> |
|
177 | + <?php do_action('AHEE__event_tickets_datetime_ticket_row_template__advanced_details_end', $tkt_row, $TKT_ID); ?> |
|
178 | 178 | <div class="ee-editor-footer-container"> |
179 | 179 | <div class="ee-editor-id-container"> |
180 | - <span class="ee-item-id"><?php echo $TKT_ID ? sprintf( esc_html__( 'Ticket ID: %d', 'event_espresso' ), $TKT_ID ) : ''; ?></span> |
|
180 | + <span class="ee-item-id"><?php echo $TKT_ID ? sprintf(esc_html__('Ticket ID: %d', 'event_espresso'), $TKT_ID) : ''; ?></span> |
|
181 | 181 | </div> |
182 | 182 | <div class="save-cancel-button-container"> |
183 | 183 | <label for="edit-ticket-TKT_is_default_selector"><?php esc_html_e('use this new ticket as a default ticket for any new events', 'event_espresso'); ?></label> |
@@ -6,24 +6,33 @@ discard block |
||
6 | 6 | <?php if ( $disabled ) : ?> |
7 | 7 | <input type="hidden" id="edit-ticket-TKT_start_date-<?php echo $tkt_row; ?>" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_start_date]" class="edit-ticket-TKT_start_date ee-text-inp" value="<?php echo $TKT_start_date; ?>" > |
8 | 8 | <input type="text" name="archived_ticket[TKT_start_date]" class="edit-ticket-TKT_start_date ee-text-inp" value="<?php echo $TKT_start_date; ?>" disabled> |
9 | - <?php else : ?> |
|
10 | - <input id="edit-ticket-TKT_start_date-<?php echo $tkt_row; ?>" type="text" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_start_date]" class="edit-ticket-TKT_start_date ee-text-inp ee-datepicker" value="<?php echo $TKT_start_date; ?>" data-context="start-ticket" data-date-field-context="#display-ticketrow-<?php echo $tkt_row; ?>" data-related-field=".edit-ticket-TKT_end_date" data-next-field=".edit-ticket-TKT_end_date"> |
|
9 | + <?php else { |
|
10 | + : ?> |
|
11 | + <input id="edit-ticket-TKT_start_date-<?php echo $tkt_row; |
|
12 | +} |
|
13 | +?>" type="text" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_start_date]" class="edit-ticket-TKT_start_date ee-text-inp ee-datepicker" value="<?php echo $TKT_start_date; ?>" data-context="start-ticket" data-date-field-context="#display-ticketrow-<?php echo $tkt_row; ?>" data-related-field=".edit-ticket-TKT_end_date" data-next-field=".edit-ticket-TKT_end_date"> |
|
11 | 14 | <?php endif; ?> |
12 | 15 | </td> |
13 | 16 | <td> |
14 | 17 | <?php if ( $disabled ) : ?> |
15 | 18 | <input type="hidden" id="edit-ticket-TKT_end_date-<?php echo $tkt_row; ?>" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_end_date]" class="edit-ticket-TKT_end_date ee-text-inp" value="<?php echo $TKT_end_date; ?>" > |
16 | 19 | <input type="text" name="archived_ticket[TKT_end_date]" class="edit-ticket-TKT_end_date ee-text-inp" value="<?php echo $TKT_end_date; ?>" disabled> |
17 | - <?php else : ?> |
|
18 | - <input id="edit-ticket-TKT_end_date-<?php echo $tkt_row; ?>" type="text" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_end_date]" class="edit-ticket-TKT_end_date ee-text-inp ee-datepicker" value="<?php echo $TKT_end_date; ?>" data-context="end-ticket" data-date-field-context="#display-ticketrow-<?php echo $tkt_row; ?>" data-related-field=".edit-ticket-TKT_start_date" data-next-field=".edit-ticket-TKT_qty"> |
|
20 | + <?php else { |
|
21 | + : ?> |
|
22 | + <input id="edit-ticket-TKT_end_date-<?php echo $tkt_row; |
|
23 | +} |
|
24 | +?>" type="text" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_end_date]" class="edit-ticket-TKT_end_date ee-text-inp ee-datepicker" value="<?php echo $TKT_end_date; ?>" data-context="end-ticket" data-date-field-context="#display-ticketrow-<?php echo $tkt_row; ?>" data-related-field=".edit-ticket-TKT_start_date" data-next-field=".edit-ticket-TKT_qty"> |
|
19 | 25 | <?php endif; ?> |
20 | 26 | </td> |
21 | 27 | <td> |
22 | 28 | <?php if ( $disabled ) : ?> |
23 | 29 | <input id="edit-ticket-TKT_base_price-<?php echo $tkt_row; ?>" type="hidden" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_base_price]" class="edit-ticket-TKT_base_price ee-small-text-inp edit-price-PRC_amount ee-numeric" value="<?php echo $TKT_base_price; ?>"> |
24 | 30 | <input type="text" name="archived_ticket[<?php echo $tkt_row; ?>][TKT_base_price]" class="edit-ticket-TKT_base_price ee-small-text-inp edit-price-PRC_amount ee-numeric" value="<?php echo $TKT_base_price; ?>" disabled> |
25 | - <?php else : ?> |
|
26 | - <input id="edit-ticket-TKT_base_price-<?php echo $tkt_row; ?>" type="text" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_base_price]" class="edit-ticket-TKT_base_price ee-small-text-inp edit-price-PRC_amount ee-numeric" value="<?php echo $TKT_base_price; ?>"> |
|
31 | + <?php else { |
|
32 | + : ?> |
|
33 | + <input id="edit-ticket-TKT_base_price-<?php echo $tkt_row; |
|
34 | +} |
|
35 | +?>" type="text" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_base_price]" class="edit-ticket-TKT_base_price ee-small-text-inp edit-price-PRC_amount ee-numeric" value="<?php echo $TKT_base_price; ?>"> |
|
27 | 36 | <?php endif; ?> |
28 | 37 | <input type="hidden" id="edit-ticket-TKT_base_price_ID-<?php echo $tkt_row; ?>" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_base_price_ID]" value="<?php echo $TKT_base_price_ID; ?>"> |
29 | 38 | </td> |
@@ -31,8 +40,11 @@ discard block |
||
31 | 40 | <?php if ( $disabled ) : ?> |
32 | 41 | <input type="hidden" class="edit-ticket-TKT_qty ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_qty]" value="<?php echo $TKT_qty_for_input; ?>"> |
33 | 42 | <input type="text" class="edit-ticket-TKT_qty ee-small-text-inp ee-numeric" name="archived_ticket[<?php echo $tkt_row; ?>][TKT_qty]" value="<?php echo $TKT_qty_for_input; ?>" disabled> |
34 | - <?php else : ?> |
|
35 | - <input type="text" id="edit-ticket-TKT_qty-<?php echo $tkt_row; ?>" class="edit-ticket-TKT_qty ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_qty]" value="<?php echo $TKT_qty_for_input; ?>"> |
|
43 | + <?php else { |
|
44 | + : ?> |
|
45 | + <input type="text" id="edit-ticket-TKT_qty-<?php echo $tkt_row; |
|
46 | +} |
|
47 | +?>" class="edit-ticket-TKT_qty ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_qty]" value="<?php echo $TKT_qty_for_input; ?>"> |
|
36 | 48 | <?php endif; ?> |
37 | 49 | </td> |
38 | 50 | <!--<td><span class="ticket-display-row-TKT_price"><?php //echo $TKT_price; ?></span></td>--> |
@@ -78,24 +90,33 @@ discard block |
||
78 | 90 | <?php if ( $disabled ) : ?> |
79 | 91 | <input type="hidden" class="edit-ticket-TKT_uses ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_uses]" value="<?php echo $TKT_uses; ?>"> |
80 | 92 | <input type="text" class="edit-ticket-TKT_uses ee-small-text-inp ee-numeric" name="archived_ticket[<?php echo $tkt_row; ?>][TKT_uses]" value="<?php echo $TKT_uses; ?>" disabled> |
81 | - <?php else : ?> |
|
82 | - <input type="text" class="edit-ticket-TKT_uses ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_uses]" value="<?php echo $TKT_uses; ?>"> |
|
93 | + <?php else { |
|
94 | + : ?> |
|
95 | + <input type="text" class="edit-ticket-TKT_uses ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; |
|
96 | +} |
|
97 | +?>[<?php echo $tkt_row; ?>][TKT_uses]" value="<?php echo $TKT_uses; ?>"> |
|
83 | 98 | <?php endif; ?> |
84 | 99 | </td> |
85 | 100 | <td> |
86 | 101 | <?php if ( $disabled ) : ?> |
87 | 102 | <input type="hidden" class="edit-ticket-TKT_min ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_min]" value="<?php echo $TKT_min; ?>"> |
88 | 103 | <input type="text" class="edit-ticket-TKT_min ee-small-text-inp ee-numeric" name="archived_ticket[<?php echo $tkt_row; ?>][TKT_min]" value="<?php echo $TKT_min; ?>" disabled> |
89 | - <?php else: ?> |
|
90 | - <input type="text" class="edit-ticket-TKT_min ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_min]" value="<?php echo $TKT_min; ?>"> |
|
104 | + <?php else { |
|
105 | + : ?> |
|
106 | + <input type="text" class="edit-ticket-TKT_min ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; |
|
107 | +} |
|
108 | +?>[<?php echo $tkt_row; ?>][TKT_min]" value="<?php echo $TKT_min; ?>"> |
|
91 | 109 | <?php endif; ?> |
92 | 110 | </td> |
93 | 111 | <td> |
94 | 112 | <?php if ( $disabled ) : ?> |
95 | 113 | <input type="hidden" class="edit-ticket-TKT_max ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_max]" value="<?php echo $TKT_max; ?>"> |
96 | 114 | <input type="text" class="edit-ticket-TKT_max ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_max]" value="<?php echo $TKT_max; ?>" disabled> |
97 | - <?php else : ?> |
|
98 | - <input type="text" class="edit-ticket-TKT_max ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_max]" value="<?php echo $TKT_max; ?>"> |
|
115 | + <?php else { |
|
116 | + : ?> |
|
117 | + <input type="text" class="edit-ticket-TKT_max ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; |
|
118 | +} |
|
119 | +?>[<?php echo $tkt_row; ?>][TKT_max]" value="<?php echo $TKT_max; ?>"> |
|
99 | 120 | <?php endif; ?> |
100 | 121 | </td> |
101 | 122 | </tr> |
@@ -116,8 +137,11 @@ discard block |
||
116 | 137 | ?> |
117 | 138 | <input class="TKT-taxable-checkbox" type="hidden" name="<?php echo $edit_tickets_name;?>[<?php echo $tkt_row; ?>][TKT_taxable]" value="<?php echo $tax_value; ?>"> |
118 | 139 | <input class="TKT-taxable-checkbox" id="edit-ticket-TKT_taxable-<?php echo $tkt_row; ?>" type="checkbox" name="archived_ticket[<?php echo $tkt_row; ?>][TKT_taxable]" value="1"<?php echo $TKT_taxable; ?> disabled> |
119 | - <?php else : ?> |
|
120 | - <input class="TKT-taxable-checkbox" id="edit-ticket-TKT_taxable-<?php echo $tkt_row; ?>" type="checkbox" name="<?php echo $edit_tickets_name;?>[<?php echo $tkt_row; ?>][TKT_taxable]" value="1"<?php echo $TKT_taxable; ?>> |
|
140 | + <?php else { |
|
141 | + : ?> |
|
142 | + <input class="TKT-taxable-checkbox" id="edit-ticket-TKT_taxable-<?php echo $tkt_row; |
|
143 | +} |
|
144 | +?>" type="checkbox" name="<?php echo $edit_tickets_name;?>[<?php echo $tkt_row; ?>][TKT_taxable]" value="1"<?php echo $TKT_taxable; ?>> |
|
121 | 145 | <?php endif; ?> |
122 | 146 | <label for="edit-ticket-TKT_taxable-<?php echo $tkt_row; ?>"> <?php esc_html_e('This ticket is taxable.', 'event_espresso'); ?> |
123 | 147 | <?php } //end tax_rows check ?> |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <p> |
2 | 2 | <?php esc_html_e( |
3 | - 'Use this to control what the default will be for maximum tickets on an order when creating a new event.', |
|
4 | - 'event_espresso' |
|
5 | - ); ?> |
|
3 | + 'Use this to control what the default will be for maximum tickets on an order when creating a new event.', |
|
4 | + 'event_espresso' |
|
5 | + ); ?> |
|
6 | 6 | </p> |
7 | 7 | \ No newline at end of file |
@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | namespace EventEspresso\core\services\commands; |
4 | 4 | |
5 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
6 | 6 | exit('No direct script access allowed'); |
7 | 7 | } |
8 | 8 |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | namespace EventEspresso\core\services\commands; |
4 | 4 | |
5 | 5 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
6 | - exit('No direct script access allowed'); |
|
6 | + exit('No direct script access allowed'); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | |
@@ -16,22 +16,22 @@ discard block |
||
16 | 16 | interface CommandHandlerManagerInterface |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @param CommandHandlerInterface $command_handler |
|
21 | - * @param string $fqcn_for_command Fully Qualified ClassName for Command |
|
22 | - * @return void |
|
23 | - * @throws InvalidCommandHandlerException |
|
24 | - */ |
|
25 | - public function addCommandHandler(CommandHandlerInterface $command_handler, $fqcn_for_command = ''); |
|
19 | + /** |
|
20 | + * @param CommandHandlerInterface $command_handler |
|
21 | + * @param string $fqcn_for_command Fully Qualified ClassName for Command |
|
22 | + * @return void |
|
23 | + * @throws InvalidCommandHandlerException |
|
24 | + */ |
|
25 | + public function addCommandHandler(CommandHandlerInterface $command_handler, $fqcn_for_command = ''); |
|
26 | 26 | |
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * @param CommandInterface $command |
|
31 | - * @param CommandBusInterface $command_bus |
|
32 | - * @return mixed |
|
33 | - */ |
|
34 | - public function getCommandHandler(CommandInterface $command, CommandBusInterface $command_bus = null); |
|
29 | + /** |
|
30 | + * @param CommandInterface $command |
|
31 | + * @param CommandBusInterface $command_bus |
|
32 | + * @return mixed |
|
33 | + */ |
|
34 | + public function getCommandHandler(CommandInterface $command, CommandBusInterface $command_bus = null); |
|
35 | 35 | |
36 | 36 | } |
37 | 37 | // End of file CommandHandlerManagerInterface.php |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | use EventEspresso\core\services\commands\CommandInterface; |
6 | 6 | |
7 | 7 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
8 | - exit('No direct script access allowed'); |
|
8 | + exit('No direct script access allowed'); |
|
9 | 9 | } |
10 | 10 | |
11 | 11 | |
@@ -18,12 +18,12 @@ discard block |
||
18 | 18 | interface CommandBusMiddlewareInterface |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @param CommandInterface $command |
|
23 | - * @param Closure $next |
|
24 | - * @return mixed |
|
25 | - */ |
|
26 | - public function handle(CommandInterface $command, Closure $next); |
|
21 | + /** |
|
22 | + * @param CommandInterface $command |
|
23 | + * @param Closure $next |
|
24 | + * @return mixed |
|
25 | + */ |
|
26 | + public function handle(CommandInterface $command, Closure $next); |
|
27 | 27 | |
28 | 28 | } |
29 | 29 | // End of file CommandBusMiddlewareInterface.php |