@@ -17,67 +17,67 @@ discard block |
||
17 | 17 | class EEH_Schema { |
18 | 18 | |
19 | 19 | |
20 | - /** |
|
21 | - * generates JSON-based linked data for an event |
|
22 | - * |
|
23 | - * @param \EE_Event $event |
|
24 | - */ |
|
25 | - public static function add_json_linked_data_for_event(\EE_Event $event) |
|
26 | - { |
|
27 | - //Check we have a valid datetime for the event |
|
28 | - if(! $event->primary_datetime() instanceof EE_Datetime) { |
|
29 | - return; |
|
30 | - } |
|
31 | - |
|
32 | - $template_args = array( |
|
33 | - 'event_permalink' => '', |
|
34 | - 'event_name' => '', |
|
35 | - 'event_description' => '', |
|
36 | - 'event_start' => '', |
|
37 | - 'event_end' => '', |
|
38 | - 'currency' => '', |
|
39 | - 'event_tickets' => array(), |
|
40 | - 'venue_name' => '', |
|
41 | - 'venue_url' => '', |
|
42 | - 'venue_locality' => '', |
|
43 | - 'venue_region' => '', |
|
44 | - 'event_image' => '', |
|
45 | - ); |
|
46 | - $template_args['event_permalink'] = $event->get_permalink(); |
|
47 | - $template_args['event_name'] = $event->name(); |
|
48 | - $template_args['event_description'] = wp_strip_all_tags($event->short_description(200)); |
|
49 | - $template_args['event_start'] = $event->primary_datetime()->start_date(DateTime::ATOM); |
|
50 | - $template_args['event_end'] = $event->primary_datetime()->end_date(DateTime::ATOM); |
|
51 | - $template_args['currency'] = EE_Registry::instance()->CFG->currency->code; |
|
52 | - foreach ($event->tickets() as $ticket) { |
|
53 | - $ID = $ticket->ID(); |
|
54 | - $template_args['event_tickets'][$ID]['start_date'] = $ticket->start_date(DateTime::ATOM, null); |
|
55 | - $template_args['event_tickets'][$ID]['end_date'] = $ticket->end_date(DateTime::ATOM, null); |
|
56 | - $template_args['event_tickets'][$ID]['price'] = number_format( |
|
57 | - $ticket->price(), |
|
58 | - EE_Registry::instance()->CFG->currency->dec_plc, |
|
59 | - EE_Registry::instance()->CFG->currency->dec_mrk, |
|
60 | - EE_Registry::instance()->CFG->currency->thsnds |
|
61 | - ); |
|
62 | - } |
|
63 | - $VNU_ID = espresso_venue_id(); |
|
64 | - if ( ! empty($VNU_ID) && ! espresso_is_venue_private($VNU_ID)) { |
|
65 | - $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
66 | - $template_args['venue_name'] = get_the_title($VNU_ID); |
|
67 | - $template_args['venue_url'] = get_permalink($VNU_ID); |
|
68 | - $template_args['venue_locality'] = $venue->city(); |
|
69 | - $template_args['venue_region'] = $venue->state_name(); |
|
70 | - } |
|
71 | - $template_args['event_image'] = $event->feature_image_url(); |
|
72 | - $template_args = apply_filters( |
|
73 | - 'FHEE__EEH_Schema__add_json_linked_data_for_event__template_args', |
|
74 | - $template_args, |
|
75 | - $event, |
|
76 | - $VNU_ID |
|
77 | - ); |
|
78 | - extract($template_args, EXTR_OVERWRITE); |
|
79 | - include EE_TEMPLATES . 'json_linked_data_for_event.template.php'; |
|
80 | - } |
|
20 | + /** |
|
21 | + * generates JSON-based linked data for an event |
|
22 | + * |
|
23 | + * @param \EE_Event $event |
|
24 | + */ |
|
25 | + public static function add_json_linked_data_for_event(\EE_Event $event) |
|
26 | + { |
|
27 | + //Check we have a valid datetime for the event |
|
28 | + if(! $event->primary_datetime() instanceof EE_Datetime) { |
|
29 | + return; |
|
30 | + } |
|
31 | + |
|
32 | + $template_args = array( |
|
33 | + 'event_permalink' => '', |
|
34 | + 'event_name' => '', |
|
35 | + 'event_description' => '', |
|
36 | + 'event_start' => '', |
|
37 | + 'event_end' => '', |
|
38 | + 'currency' => '', |
|
39 | + 'event_tickets' => array(), |
|
40 | + 'venue_name' => '', |
|
41 | + 'venue_url' => '', |
|
42 | + 'venue_locality' => '', |
|
43 | + 'venue_region' => '', |
|
44 | + 'event_image' => '', |
|
45 | + ); |
|
46 | + $template_args['event_permalink'] = $event->get_permalink(); |
|
47 | + $template_args['event_name'] = $event->name(); |
|
48 | + $template_args['event_description'] = wp_strip_all_tags($event->short_description(200)); |
|
49 | + $template_args['event_start'] = $event->primary_datetime()->start_date(DateTime::ATOM); |
|
50 | + $template_args['event_end'] = $event->primary_datetime()->end_date(DateTime::ATOM); |
|
51 | + $template_args['currency'] = EE_Registry::instance()->CFG->currency->code; |
|
52 | + foreach ($event->tickets() as $ticket) { |
|
53 | + $ID = $ticket->ID(); |
|
54 | + $template_args['event_tickets'][$ID]['start_date'] = $ticket->start_date(DateTime::ATOM, null); |
|
55 | + $template_args['event_tickets'][$ID]['end_date'] = $ticket->end_date(DateTime::ATOM, null); |
|
56 | + $template_args['event_tickets'][$ID]['price'] = number_format( |
|
57 | + $ticket->price(), |
|
58 | + EE_Registry::instance()->CFG->currency->dec_plc, |
|
59 | + EE_Registry::instance()->CFG->currency->dec_mrk, |
|
60 | + EE_Registry::instance()->CFG->currency->thsnds |
|
61 | + ); |
|
62 | + } |
|
63 | + $VNU_ID = espresso_venue_id(); |
|
64 | + if ( ! empty($VNU_ID) && ! espresso_is_venue_private($VNU_ID)) { |
|
65 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
66 | + $template_args['venue_name'] = get_the_title($VNU_ID); |
|
67 | + $template_args['venue_url'] = get_permalink($VNU_ID); |
|
68 | + $template_args['venue_locality'] = $venue->city(); |
|
69 | + $template_args['venue_region'] = $venue->state_name(); |
|
70 | + } |
|
71 | + $template_args['event_image'] = $event->feature_image_url(); |
|
72 | + $template_args = apply_filters( |
|
73 | + 'FHEE__EEH_Schema__add_json_linked_data_for_event__template_args', |
|
74 | + $template_args, |
|
75 | + $event, |
|
76 | + $VNU_ID |
|
77 | + ); |
|
78 | + extract($template_args, EXTR_OVERWRITE); |
|
79 | + include EE_TEMPLATES . 'json_linked_data_for_event.template.php'; |
|
80 | + } |
|
81 | 81 | |
82 | 82 | |
83 | 83 | /** |
@@ -91,8 +91,8 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public static function location( $location = null ) { |
93 | 93 | return ! empty( $location ) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">' |
94 | - . $location |
|
95 | - . '</div>' : ''; |
|
94 | + . $location |
|
95 | + . '</div>' : ''; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | |
@@ -212,8 +212,8 @@ discard block |
||
212 | 212 | */ |
213 | 213 | public static function postalCode( EEI_Address $obj_with_address = null ) { |
214 | 214 | return $obj_with_address->zip() !== null && $obj_with_address->zip() !== '' ? '<span itemprop="postalCode">' |
215 | - . $obj_with_address->zip() |
|
216 | - . '</span>' : ''; |
|
215 | + . $obj_with_address->zip() |
|
216 | + . '</span>' : ''; |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | //Check the URL includes a scheme |
248 | 248 | $parsed_url = parse_url($url); |
249 | 249 | if ( empty($parsed_url['scheme']) ) { |
250 | - $url = 'http://' . ltrim($url, '/'); |
|
250 | + $url = 'http://' . ltrim($url, '/'); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | $atts = ''; |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
4 | - exit( 'No direct script access allowed' ); |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | + exit('No direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | public static function add_json_linked_data_for_event(\EE_Event $event) |
26 | 26 | { |
27 | 27 | //Check we have a valid datetime for the event |
28 | - if(! $event->primary_datetime() instanceof EE_Datetime) { |
|
28 | + if ( ! $event->primary_datetime() instanceof EE_Datetime) { |
|
29 | 29 | return; |
30 | 30 | } |
31 | 31 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $VNU_ID |
77 | 77 | ); |
78 | 78 | extract($template_args, EXTR_OVERWRITE); |
79 | - include EE_TEMPLATES . 'json_linked_data_for_event.template.php'; |
|
79 | + include EE_TEMPLATES.'json_linked_data_for_event.template.php'; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | * @param string $location |
90 | 90 | * @return string |
91 | 91 | */ |
92 | - public static function location( $location = null ) { |
|
93 | - return ! empty( $location ) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">' |
|
92 | + public static function location($location = null) { |
|
93 | + return ! empty($location) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">' |
|
94 | 94 | . $location |
95 | 95 | . '</div>' : ''; |
96 | 96 | } |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | * @param string $name |
106 | 106 | * @return string |
107 | 107 | */ |
108 | - public static function name( $name = null ) { |
|
109 | - return ! empty( $name ) ? '<span itemprop="name">' . $name . '</span>' : ''; |
|
108 | + public static function name($name = null) { |
|
109 | + return ! empty($name) ? '<span itemprop="name">'.$name.'</span>' : ''; |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | * @param EEI_Address $obj_with_address |
120 | 120 | * @return string |
121 | 121 | */ |
122 | - public static function streetAddress( EEI_Address $obj_with_address = null ) { |
|
122 | + public static function streetAddress(EEI_Address $obj_with_address = null) { |
|
123 | 123 | return $obj_with_address->address() !== null && $obj_with_address->address() !== '' |
124 | - ? '<span itemprop="streetAddress">' . $obj_with_address->address() . '</span>' : ''; |
|
124 | + ? '<span itemprop="streetAddress">'.$obj_with_address->address().'</span>' : ''; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | |
@@ -134,14 +134,14 @@ discard block |
||
134 | 134 | * @param EEI_Address $obj_with_address |
135 | 135 | * @return string |
136 | 136 | */ |
137 | - public static function postOfficeBoxNumber( EEI_Address $obj_with_address = null ) { |
|
137 | + public static function postOfficeBoxNumber(EEI_Address $obj_with_address = null) { |
|
138 | 138 | // regex check for some form of PO Box or P.O. Box, etc, etc, etc |
139 | - if ( preg_match( |
|
139 | + if (preg_match( |
|
140 | 140 | "/^\s*((P(OST)?.?\s*(O(FF(ICE)?)?)?.?\s+(B(IN|OX))?)|B(IN|OX))/i", |
141 | 141 | $obj_with_address->address2() |
142 | - ) ) { |
|
142 | + )) { |
|
143 | 143 | return $obj_with_address->address2() !== null && $obj_with_address->address2() !== '' |
144 | - ? '<span itemprop="postOfficeBoxNumber">' . $obj_with_address->address2() . '</span>' : ''; |
|
144 | + ? '<span itemprop="postOfficeBoxNumber">'.$obj_with_address->address2().'</span>' : ''; |
|
145 | 145 | } else { |
146 | 146 | return $obj_with_address->address2(); |
147 | 147 | } |
@@ -157,9 +157,9 @@ discard block |
||
157 | 157 | * @param EEI_Address $obj_with_address |
158 | 158 | * @return string |
159 | 159 | */ |
160 | - public static function addressLocality( EEI_Address $obj_with_address = null ) { |
|
160 | + public static function addressLocality(EEI_Address $obj_with_address = null) { |
|
161 | 161 | return $obj_with_address->city() !== null && $obj_with_address->city() !== '' |
162 | - ? '<span itemprop="addressLocality">' . $obj_with_address->city() . '</span>' : ''; |
|
162 | + ? '<span itemprop="addressLocality">'.$obj_with_address->city().'</span>' : ''; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | |
@@ -172,10 +172,10 @@ discard block |
||
172 | 172 | * @param EEI_Address $obj_with_address |
173 | 173 | * @return string |
174 | 174 | */ |
175 | - public static function addressRegion( EEI_Address $obj_with_address = null ) { |
|
175 | + public static function addressRegion(EEI_Address $obj_with_address = null) { |
|
176 | 176 | $state = $obj_with_address->state_name(); |
177 | - if ( ! empty( $state ) ) { |
|
178 | - return '<span itemprop="addressRegion">' . $state . '</span>'; |
|
177 | + if ( ! empty($state)) { |
|
178 | + return '<span itemprop="addressRegion">'.$state.'</span>'; |
|
179 | 179 | } else { |
180 | 180 | return ''; |
181 | 181 | } |
@@ -191,10 +191,10 @@ discard block |
||
191 | 191 | * @param EEI_Address $obj_with_address |
192 | 192 | * @return string |
193 | 193 | */ |
194 | - public static function addressCountry( EEI_Address $obj_with_address = null ) { |
|
194 | + public static function addressCountry(EEI_Address $obj_with_address = null) { |
|
195 | 195 | $country = $obj_with_address->country_name(); |
196 | - if ( ! empty( $country ) ) { |
|
197 | - return '<span itemprop="addressCountry">' . $country . '</span>'; |
|
196 | + if ( ! empty($country)) { |
|
197 | + return '<span itemprop="addressCountry">'.$country.'</span>'; |
|
198 | 198 | } else { |
199 | 199 | return ''; |
200 | 200 | } |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | * @param EEI_Address $obj_with_address |
211 | 211 | * @return string |
212 | 212 | */ |
213 | - public static function postalCode( EEI_Address $obj_with_address = null ) { |
|
213 | + public static function postalCode(EEI_Address $obj_with_address = null) { |
|
214 | 214 | return $obj_with_address->zip() !== null && $obj_with_address->zip() !== '' ? '<span itemprop="postalCode">' |
215 | 215 | . $obj_with_address->zip() |
216 | 216 | . '</span>' : ''; |
@@ -226,8 +226,8 @@ discard block |
||
226 | 226 | * @param string $phone_nmbr |
227 | 227 | * @return string |
228 | 228 | */ |
229 | - public static function telephone( $phone_nmbr = null ) { |
|
230 | - return $phone_nmbr !== null && $phone_nmbr !== '' ? '<span itemprop="telephone">' . $phone_nmbr . '</span>' |
|
229 | + public static function telephone($phone_nmbr = null) { |
|
230 | + return $phone_nmbr !== null && $phone_nmbr !== '' ? '<span itemprop="telephone">'.$phone_nmbr.'</span>' |
|
231 | 231 | : ''; |
232 | 232 | } |
233 | 233 | |
@@ -243,19 +243,19 @@ discard block |
||
243 | 243 | * @param array $attributes - array of additional link attributes in attribute_name => value pairs. ie: array( 'title' => 'click here', 'class' => 'link-class' ) |
244 | 244 | * @return string (link) |
245 | 245 | */ |
246 | - public static function url( $url = null, $text = null, $attributes = array() ) { |
|
246 | + public static function url($url = null, $text = null, $attributes = array()) { |
|
247 | 247 | //Check the URL includes a scheme |
248 | 248 | $parsed_url = parse_url($url); |
249 | - if ( empty($parsed_url['scheme']) ) { |
|
250 | - $url = 'http://' . ltrim($url, '/'); |
|
249 | + if (empty($parsed_url['scheme'])) { |
|
250 | + $url = 'http://'.ltrim($url, '/'); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | $atts = ''; |
254 | - foreach ( $attributes as $attribute => $value ) { |
|
255 | - $atts .= ' ' . $attribute . '="' . $value . '"'; |
|
254 | + foreach ($attributes as $attribute => $value) { |
|
255 | + $atts .= ' '.$attribute.'="'.$value.'"'; |
|
256 | 256 | } |
257 | 257 | $text = $text !== null && $text !== '' ? $text : $url; |
258 | - return $url !== null && $url !== '' ? '<a itemprop="url" href="' . $url . '"' . $atts . '>' . $text . '</a>' |
|
258 | + return $url !== null && $url !== '' ? '<a itemprop="url" href="'.$url.'"'.$atts.'>'.$text.'</a>' |
|
259 | 259 | : ''; |
260 | 260 | } |
261 | 261 |
@@ -7,8 +7,7 @@ discard block |
||
7 | 7 | * the interaction of EE_Transaction and EE_Registration model objects |
8 | 8 | * Provides methods for manipulating and processing changes to an EE_Transaction |
9 | 9 | * and it's related EE_Registrations with regards to the checkout/registration process |
10 | - |
|
11 | -* |
|
10 | + * |
|
12 | 11 | *@package Event Espresso |
13 | 12 | * @subpackage core |
14 | 13 | * @author Brent Christensen |
@@ -177,24 +176,24 @@ discard block |
||
177 | 176 | |
178 | 177 | |
179 | 178 | |
180 | - /** |
|
181 | - * update_transaction_and_registrations_after_checkout_or_payment |
|
182 | - * cycles thru related registrations and calls update_registration_after_checkout_or_payment() on each |
|
183 | - * |
|
184 | - * @param EE_Transaction $transaction |
|
185 | - * @param \EE_Payment | NULL $payment |
|
186 | - * @param array $registration_query_params array of query WHERE params to use |
|
187 | - * when retrieving cached registrations from a transaction |
|
188 | - * @param bool $trigger_notifications whether or not to call |
|
189 | - * \EE_Registration_Processor::trigger_registration_update_notifications() |
|
190 | - * @return array |
|
191 | - * @throws \EE_Error |
|
192 | - */ |
|
179 | + /** |
|
180 | + * update_transaction_and_registrations_after_checkout_or_payment |
|
181 | + * cycles thru related registrations and calls update_registration_after_checkout_or_payment() on each |
|
182 | + * |
|
183 | + * @param EE_Transaction $transaction |
|
184 | + * @param \EE_Payment | NULL $payment |
|
185 | + * @param array $registration_query_params array of query WHERE params to use |
|
186 | + * when retrieving cached registrations from a transaction |
|
187 | + * @param bool $trigger_notifications whether or not to call |
|
188 | + * \EE_Registration_Processor::trigger_registration_update_notifications() |
|
189 | + * @return array |
|
190 | + * @throws \EE_Error |
|
191 | + */ |
|
193 | 192 | public function update_transaction_and_registrations_after_checkout_or_payment( |
194 | 193 | EE_Transaction $transaction, |
195 | 194 | $payment = null, |
196 | 195 | $registration_query_params = array(), |
197 | - $trigger_notifications = true |
|
196 | + $trigger_notifications = true |
|
198 | 197 | ) { |
199 | 198 | // make sure some query params are set for retrieving registrations |
200 | 199 | $this->_set_registration_query_params( $registration_query_params ); |
@@ -224,15 +223,15 @@ discard block |
||
224 | 223 | $update_params |
225 | 224 | ); |
226 | 225 | if ($trigger_notifications) { |
227 | - // send messages |
|
228 | - /** @type EE_Registration_Processor $registration_processor */ |
|
229 | - $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
230 | - $registration_processor->trigger_registration_update_notifications( |
|
231 | - $transaction->primary_registration(), |
|
232 | - $update_params |
|
233 | - ); |
|
234 | - } |
|
235 | - do_action( |
|
226 | + // send messages |
|
227 | + /** @type EE_Registration_Processor $registration_processor */ |
|
228 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
229 | + $registration_processor->trigger_registration_update_notifications( |
|
230 | + $transaction->primary_registration(), |
|
231 | + $update_params |
|
232 | + ); |
|
233 | + } |
|
234 | + do_action( |
|
236 | 235 | 'AHEE__EE_Transaction_Processor__update_transaction_and_registrations_after_checkout_or_payment', |
237 | 236 | $transaction, |
238 | 237 | $update_params |
@@ -242,17 +241,17 @@ discard block |
||
242 | 241 | |
243 | 242 | |
244 | 243 | |
245 | - /** |
|
246 | - * update_transaction_after_registration_reopened |
|
247 | - * readjusts TXN and Line Item totals after a registration is changed from |
|
248 | - * cancelled or declined to another reg status such as pending payment or approved |
|
249 | - * |
|
250 | - * @param \EE_Registration $registration |
|
251 | - * @param array $closed_reg_statuses |
|
252 | - * @param bool $update_txn |
|
253 | - * @return bool |
|
254 | - * @throws \EE_Error |
|
255 | - */ |
|
244 | + /** |
|
245 | + * update_transaction_after_registration_reopened |
|
246 | + * readjusts TXN and Line Item totals after a registration is changed from |
|
247 | + * cancelled or declined to another reg status such as pending payment or approved |
|
248 | + * |
|
249 | + * @param \EE_Registration $registration |
|
250 | + * @param array $closed_reg_statuses |
|
251 | + * @param bool $update_txn |
|
252 | + * @return bool |
|
253 | + * @throws \EE_Error |
|
254 | + */ |
|
256 | 255 | public function update_transaction_after_reinstating_canceled_registration( |
257 | 256 | EE_Registration $registration, |
258 | 257 | $closed_reg_statuses = array(), |
@@ -314,15 +313,15 @@ discard block |
||
314 | 313 | try { |
315 | 314 | $transaction = $this->get_transaction_for_registration( $registration ); |
316 | 315 | if ( |
317 | - apply_filters( |
|
318 | - 'FHEE__EE_Transaction_Processor__update_transaction_after_canceled_or_declined_registration__cancel_ticket_line_item', |
|
319 | - true, |
|
320 | - $registration, |
|
321 | - $transaction |
|
322 | - ) |
|
323 | - ){ |
|
324 | - $ticket_line_item = $this->get_ticket_line_item_for_transaction_registration( $transaction, $registration ); |
|
325 | - EEH_Line_Item::cancel_ticket_line_item( $ticket_line_item ); |
|
316 | + apply_filters( |
|
317 | + 'FHEE__EE_Transaction_Processor__update_transaction_after_canceled_or_declined_registration__cancel_ticket_line_item', |
|
318 | + true, |
|
319 | + $registration, |
|
320 | + $transaction |
|
321 | + ) |
|
322 | + ){ |
|
323 | + $ticket_line_item = $this->get_ticket_line_item_for_transaction_registration( $transaction, $registration ); |
|
324 | + EEH_Line_Item::cancel_ticket_line_item( $ticket_line_item ); |
|
326 | 325 | } |
327 | 326 | } catch ( EE_Error $e ) { |
328 | 327 | EE_Error::add_error( |
@@ -532,7 +531,7 @@ discard block |
||
532 | 531 | foreach ( $available_payment_methods as $available_payment_method ) { |
533 | 532 | if ( |
534 | 533 | $available_payment_method instanceof EE_Payment_Method |
535 | - && $available_payment_method->open_by_default() |
|
534 | + && $available_payment_method->open_by_default() |
|
536 | 535 | ) { |
537 | 536 | $PMD_ID = $available_payment_method->ID(); |
538 | 537 | break; |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | -EE_Registry::instance()->load_class( 'Processor_Base' ); |
|
2 | +EE_Registry::instance()->load_class('Processor_Base'); |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Class EE_Transaction_Processor |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | * @param array $registration_query_params |
51 | 51 | *@return EE_Transaction_Processor instance |
52 | 52 | */ |
53 | - public static function instance( $registration_query_params = array() ) { |
|
53 | + public static function instance($registration_query_params = array()) { |
|
54 | 54 | // check if class object is instantiated |
55 | - if ( ! self::$_instance instanceof EE_Transaction_Processor ) { |
|
56 | - self::$_instance = new self( $registration_query_params ); |
|
55 | + if ( ! self::$_instance instanceof EE_Transaction_Processor) { |
|
56 | + self::$_instance = new self($registration_query_params); |
|
57 | 57 | } |
58 | 58 | return self::$_instance; |
59 | 59 | } |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | /** |
64 | 64 | * @param array $registration_query_params |
65 | 65 | */ |
66 | - private function __construct( $registration_query_params = array() ) { |
|
66 | + private function __construct($registration_query_params = array()) { |
|
67 | 67 | // make sure some query params are set for retrieving registrations |
68 | - $this->_set_registration_query_params( $registration_query_params ); |
|
68 | + $this->_set_registration_query_params($registration_query_params); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | |
@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | * @access private |
75 | 75 | * @param array $registration_query_params |
76 | 76 | */ |
77 | - private function _set_registration_query_params( $registration_query_params ) { |
|
78 | - $this->_registration_query_params = ! empty( $registration_query_params ) ? $registration_query_params : array( 'order_by' => array( 'REG_count' => 'ASC' )); |
|
77 | + private function _set_registration_query_params($registration_query_params) { |
|
78 | + $this->_registration_query_params = ! empty($registration_query_params) ? $registration_query_params : array('order_by' => array('REG_count' => 'ASC')); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | |
@@ -104,10 +104,10 @@ discard block |
||
104 | 104 | ); |
105 | 105 | // send messages |
106 | 106 | /** @type EE_Registration_Processor $registration_processor */ |
107 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
107 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
108 | 108 | $registration_processor->trigger_registration_update_notifications( |
109 | 109 | $transaction->primary_registration(), |
110 | - array( 'manually_updated' => true ) |
|
110 | + array('manually_updated' => true) |
|
111 | 111 | ); |
112 | 112 | do_action( |
113 | 113 | 'AHEE__EE_Transaction_Processor__manually_update_registration_statuses', |
@@ -197,13 +197,13 @@ discard block |
||
197 | 197 | $trigger_notifications = true |
198 | 198 | ) { |
199 | 199 | // make sure some query params are set for retrieving registrations |
200 | - $this->_set_registration_query_params( $registration_query_params ); |
|
200 | + $this->_set_registration_query_params($registration_query_params); |
|
201 | 201 | // get final reg step status |
202 | 202 | $finalized = $transaction->final_reg_step_completed(); |
203 | 203 | // if the 'finalize_registration' step has been initiated (has a timestamp) |
204 | 204 | // but has not yet been fully completed (TRUE) |
205 | - if ( is_int( $finalized ) && $finalized !== false && $finalized !== true ) { |
|
206 | - $transaction->set_reg_step_completed( 'finalize_registration' ); |
|
205 | + if (is_int($finalized) && $finalized !== false && $finalized !== true) { |
|
206 | + $transaction->set_reg_step_completed('finalize_registration'); |
|
207 | 207 | $finalized = true; |
208 | 208 | } |
209 | 209 | $transaction->save(); |
@@ -259,22 +259,22 @@ discard block |
||
259 | 259 | $update_txn = true |
260 | 260 | ) { |
261 | 261 | // these reg statuses should not be considered in any calculations involving monies owing |
262 | - $closed_reg_statuses = ! empty( $closed_reg_statuses ) ? $closed_reg_statuses : EEM_Registration::closed_reg_statuses(); |
|
263 | - if ( in_array( $registration->status_ID(), $closed_reg_statuses, true ) ) { |
|
262 | + $closed_reg_statuses = ! empty($closed_reg_statuses) ? $closed_reg_statuses : EEM_Registration::closed_reg_statuses(); |
|
263 | + if (in_array($registration->status_ID(), $closed_reg_statuses, true)) { |
|
264 | 264 | return false; |
265 | 265 | } |
266 | 266 | try { |
267 | - $transaction = $this->get_transaction_for_registration( $registration ); |
|
267 | + $transaction = $this->get_transaction_for_registration($registration); |
|
268 | 268 | $ticket_line_item = $this->get_ticket_line_item_for_transaction_registration( |
269 | 269 | $transaction, |
270 | 270 | $registration |
271 | 271 | ); |
272 | 272 | // un-cancel the ticket |
273 | - $success = EEH_Line_Item::reinstate_canceled_ticket_line_item( $ticket_line_item ); |
|
274 | - } catch ( EE_Error $e ) { |
|
273 | + $success = EEH_Line_Item::reinstate_canceled_ticket_line_item($ticket_line_item); |
|
274 | + } catch (EE_Error $e) { |
|
275 | 275 | EE_Error::add_error( |
276 | 276 | sprintf( |
277 | - __( 'The Ticket Line Item for Registration %1$d could not be reinstated because :%2$s%3$s', 'event_espresso' ), |
|
277 | + __('The Ticket Line Item for Registration %1$d could not be reinstated because :%2$s%3$s', 'event_espresso'), |
|
278 | 278 | $registration->ID(), |
279 | 279 | '<br />', |
280 | 280 | $e->getMessage() |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | ); |
284 | 284 | return false; |
285 | 285 | } |
286 | - if ( $update_txn ) { |
|
286 | + if ($update_txn) { |
|
287 | 287 | return $transaction->save() ? $success : false; |
288 | 288 | } |
289 | 289 | return $success; |
@@ -307,12 +307,12 @@ discard block |
||
307 | 307 | $update_txn = true |
308 | 308 | ) { |
309 | 309 | // these reg statuses should not be considered in any calculations involving monies owing |
310 | - $closed_reg_statuses = ! empty( $closed_reg_statuses ) ? $closed_reg_statuses : EEM_Registration::closed_reg_statuses(); |
|
311 | - if ( ! in_array( $registration->status_ID(), $closed_reg_statuses, true ) ) { |
|
310 | + $closed_reg_statuses = ! empty($closed_reg_statuses) ? $closed_reg_statuses : EEM_Registration::closed_reg_statuses(); |
|
311 | + if ( ! in_array($registration->status_ID(), $closed_reg_statuses, true)) { |
|
312 | 312 | return false; |
313 | 313 | } |
314 | 314 | try { |
315 | - $transaction = $this->get_transaction_for_registration( $registration ); |
|
315 | + $transaction = $this->get_transaction_for_registration($registration); |
|
316 | 316 | if ( |
317 | 317 | apply_filters( |
318 | 318 | 'FHEE__EE_Transaction_Processor__update_transaction_after_canceled_or_declined_registration__cancel_ticket_line_item', |
@@ -320,14 +320,14 @@ discard block |
||
320 | 320 | $registration, |
321 | 321 | $transaction |
322 | 322 | ) |
323 | - ){ |
|
324 | - $ticket_line_item = $this->get_ticket_line_item_for_transaction_registration( $transaction, $registration ); |
|
325 | - EEH_Line_Item::cancel_ticket_line_item( $ticket_line_item ); |
|
323 | + ) { |
|
324 | + $ticket_line_item = $this->get_ticket_line_item_for_transaction_registration($transaction, $registration); |
|
325 | + EEH_Line_Item::cancel_ticket_line_item($ticket_line_item); |
|
326 | 326 | } |
327 | - } catch ( EE_Error $e ) { |
|
327 | + } catch (EE_Error $e) { |
|
328 | 328 | EE_Error::add_error( |
329 | 329 | sprintf( |
330 | - __( 'The Ticket Line Item for Registration %1$d could not be cancelled because :%2$s%3$s', 'event_espresso' ), |
|
330 | + __('The Ticket Line Item for Registration %1$d could not be cancelled because :%2$s%3$s', 'event_espresso'), |
|
331 | 331 | $registration->ID(), |
332 | 332 | '<br />', |
333 | 333 | $e->getMessage() |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | ); |
337 | 337 | return false; |
338 | 338 | } |
339 | - if ( $update_txn ) { |
|
339 | + if ($update_txn) { |
|
340 | 340 | return $transaction->save() ? true : false; |
341 | 341 | } |
342 | 342 | return true; |
@@ -352,12 +352,12 @@ discard block |
||
352 | 352 | * @return EE_Transaction |
353 | 353 | * @throws EE_Error |
354 | 354 | */ |
355 | - public function get_transaction_for_registration( EE_Registration $registration ) { |
|
355 | + public function get_transaction_for_registration(EE_Registration $registration) { |
|
356 | 356 | $transaction = $registration->transaction(); |
357 | - if ( ! $transaction instanceof EE_Transaction ) { |
|
357 | + if ( ! $transaction instanceof EE_Transaction) { |
|
358 | 358 | throw new EE_Error( |
359 | 359 | sprintf( |
360 | - __( 'The Transaction for Registration %1$d was not found or is invalid.', 'event_espresso' ), |
|
360 | + __('The Transaction for Registration %1$d was not found or is invalid.', 'event_espresso'), |
|
361 | 361 | $registration->ID() |
362 | 362 | ) |
363 | 363 | ); |
@@ -380,16 +380,16 @@ discard block |
||
380 | 380 | EE_Transaction $transaction, |
381 | 381 | EE_Registration $registration |
382 | 382 | ) { |
383 | - EE_Registry::instance()->load_helper( 'Line_Item' ); |
|
383 | + EE_Registry::instance()->load_helper('Line_Item'); |
|
384 | 384 | $ticket_line_item = EEM_Line_Item::instance()->get_ticket_line_item_for_transaction( |
385 | 385 | $transaction->ID(), |
386 | 386 | $registration->ticket_ID() |
387 | 387 | ); |
388 | - if ( ! $ticket_line_item instanceof EE_Line_Item ) { |
|
388 | + if ( ! $ticket_line_item instanceof EE_Line_Item) { |
|
389 | 389 | throw new EE_Error( |
390 | 390 | sprintf( |
391 | - __( 'The Line Item for Transaction %1$d and Ticket %2$d was not found or is invalid.', |
|
392 | - 'event_espresso' ), |
|
391 | + __('The Line Item for Transaction %1$d and Ticket %2$d was not found or is invalid.', |
|
392 | + 'event_espresso'), |
|
393 | 393 | $transaction->ID(), |
394 | 394 | $registration->ticket_ID() |
395 | 395 | ) |
@@ -422,22 +422,22 @@ discard block |
||
422 | 422 | $update_txn = true |
423 | 423 | ) { |
424 | 424 | // make sure some query params are set for retrieving registrations |
425 | - $this->_set_registration_query_params( $registration_query_params ); |
|
425 | + $this->_set_registration_query_params($registration_query_params); |
|
426 | 426 | // these reg statuses should not be considered in any calculations involving monies owing |
427 | - $closed_reg_statuses = ! empty( $closed_reg_statuses ) ? $closed_reg_statuses : EEM_Registration::closed_reg_statuses(); |
|
427 | + $closed_reg_statuses = ! empty($closed_reg_statuses) ? $closed_reg_statuses : EEM_Registration::closed_reg_statuses(); |
|
428 | 428 | // loop through cached registrations |
429 | - foreach ( $transaction->registrations( $this->_registration_query_params ) as $registration ) { |
|
429 | + foreach ($transaction->registrations($this->_registration_query_params) as $registration) { |
|
430 | 430 | if ( |
431 | 431 | $registration instanceof EE_Registration |
432 | - && ! in_array( $registration->status_ID(), $closed_reg_statuses ) |
|
432 | + && ! in_array($registration->status_ID(), $closed_reg_statuses) |
|
433 | 433 | ) { |
434 | 434 | return false; |
435 | 435 | } |
436 | 436 | } |
437 | - if ( in_array( $new_TXN_status, EEM_Transaction::txn_status_array() ) ) { |
|
438 | - $transaction->set_status( $new_TXN_status ); |
|
437 | + if (in_array($new_TXN_status, EEM_Transaction::txn_status_array())) { |
|
438 | + $transaction->set_status($new_TXN_status); |
|
439 | 439 | } |
440 | - if ( $update_txn ) { |
|
440 | + if ($update_txn) { |
|
441 | 441 | return $transaction->save() ? true : false; |
442 | 442 | } |
443 | 443 | return true; |
@@ -466,22 +466,22 @@ discard block |
||
466 | 466 | ) { |
467 | 467 | $response = false; |
468 | 468 | /** @type EE_Registration_Processor $registration_processor */ |
469 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
469 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
470 | 470 | // check that method exists |
471 | - if ( ! method_exists( $registration_processor, $method_name )) { |
|
472 | - throw new EE_Error( __( 'Method does not exist.', 'event_espresso' )); |
|
471 | + if ( ! method_exists($registration_processor, $method_name)) { |
|
472 | + throw new EE_Error(__('Method does not exist.', 'event_espresso')); |
|
473 | 473 | } |
474 | 474 | // make sure some query params are set for retrieving registrations |
475 | - $this->_set_registration_query_params( $registration_query_params ); |
|
475 | + $this->_set_registration_query_params($registration_query_params); |
|
476 | 476 | // loop through cached registrations |
477 | - foreach ( $transaction->registrations( $this->_registration_query_params ) as $registration ) { |
|
478 | - if ( $registration instanceof EE_Registration ) { |
|
479 | - if ( $additional_param ) { |
|
480 | - $response = $registration_processor->{$method_name}( $registration, $additional_param ) |
|
477 | + foreach ($transaction->registrations($this->_registration_query_params) as $registration) { |
|
478 | + if ($registration instanceof EE_Registration) { |
|
479 | + if ($additional_param) { |
|
480 | + $response = $registration_processor->{$method_name}($registration, $additional_param) |
|
481 | 481 | ? true |
482 | 482 | : $response; |
483 | 483 | } else { |
484 | - $response = $registration_processor->{$method_name}( $registration ) |
|
484 | + $response = $registration_processor->{$method_name}($registration) |
|
485 | 485 | ? true |
486 | 486 | : $response; |
487 | 487 | } |
@@ -508,28 +508,28 @@ discard block |
||
508 | 508 | public function set_transaction_payment_method_based_on_registration_statuses( |
509 | 509 | EE_Registration $edited_registration |
510 | 510 | ) { |
511 | - if ( $edited_registration instanceof EE_Registration ) { |
|
511 | + if ($edited_registration instanceof EE_Registration) { |
|
512 | 512 | $transaction = $edited_registration->transaction(); |
513 | - if ( $transaction instanceof EE_Transaction ) { |
|
513 | + if ($transaction instanceof EE_Transaction) { |
|
514 | 514 | $all_not_approved = true; |
515 | - foreach ( $transaction->registrations() as $registration ) { |
|
516 | - if ( $registration instanceof EE_Registration ) { |
|
515 | + foreach ($transaction->registrations() as $registration) { |
|
516 | + if ($registration instanceof EE_Registration) { |
|
517 | 517 | // if any REG != "Not Approved" then toggle to false |
518 | 518 | $all_not_approved = $registration->is_not_approved() ? $all_not_approved : false; |
519 | 519 | } |
520 | 520 | } |
521 | 521 | // if ALL Registrations are "Not Approved" |
522 | - if ( $all_not_approved ) { |
|
523 | - $transaction->set_payment_method_ID( null ); |
|
522 | + if ($all_not_approved) { |
|
523 | + $transaction->set_payment_method_ID(null); |
|
524 | 524 | $transaction->save(); |
525 | 525 | } else { |
526 | 526 | $available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction( |
527 | 527 | $transaction, |
528 | 528 | EEM_Payment_Method::scope_cart |
529 | 529 | ); |
530 | - if ( ! empty( $available_payment_methods ) ) { |
|
530 | + if ( ! empty($available_payment_methods)) { |
|
531 | 531 | $PMD_ID = 0; |
532 | - foreach ( $available_payment_methods as $available_payment_method ) { |
|
532 | + foreach ($available_payment_methods as $available_payment_method) { |
|
533 | 533 | if ( |
534 | 534 | $available_payment_method instanceof EE_Payment_Method |
535 | 535 | && $available_payment_method->open_by_default() |
@@ -538,22 +538,22 @@ discard block |
||
538 | 538 | break; |
539 | 539 | } |
540 | 540 | } |
541 | - if ( ! $PMD_ID ) { |
|
542 | - $first_payment_method = reset( $available_payment_methods ); |
|
543 | - if ( $first_payment_method instanceof EE_Payment_Method ) { |
|
541 | + if ( ! $PMD_ID) { |
|
542 | + $first_payment_method = reset($available_payment_methods); |
|
543 | + if ($first_payment_method instanceof EE_Payment_Method) { |
|
544 | 544 | $PMD_ID = $first_payment_method->ID(); |
545 | 545 | } else { |
546 | 546 | EE_Error::add_error( |
547 | - __( 'A valid Payment Method could not be determined. Please ensure that at least one Payment Method is activated.', 'event_espresso' ), |
|
547 | + __('A valid Payment Method could not be determined. Please ensure that at least one Payment Method is activated.', 'event_espresso'), |
|
548 | 548 | __FILE__, __LINE__, __FUNCTION__ |
549 | 549 | ); |
550 | 550 | } |
551 | 551 | } |
552 | - $transaction->set_payment_method_ID( $PMD_ID ); |
|
552 | + $transaction->set_payment_method_ID($PMD_ID); |
|
553 | 553 | $transaction->save(); |
554 | 554 | } else { |
555 | 555 | EE_Error::add_error( |
556 | - __( 'Please activate at least one Payment Method in order for things to operate correctly.', 'event_espresso' ), |
|
556 | + __('Please activate at least one Payment Method in order for things to operate correctly.', 'event_espresso'), |
|
557 | 557 | __FILE__, __LINE__, __FUNCTION__ |
558 | 558 | ); |
559 | 559 | } |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | * @deprecated 4.9.12 |
591 | 591 | * @param string $old_txn_status |
592 | 592 | */ |
593 | - public function set_old_txn_status( $old_txn_status ) { |
|
593 | + public function set_old_txn_status($old_txn_status) { |
|
594 | 594 | EE_Error::doing_it_wrong( |
595 | 595 | __METHOD__, |
596 | 596 | esc_html__( |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | '4.9.12' |
601 | 601 | ); |
602 | 602 | // only set the first time |
603 | - if ( $this->_old_txn_status === null ) { |
|
603 | + if ($this->_old_txn_status === null) { |
|
604 | 604 | $this->_old_txn_status = $old_txn_status; |
605 | 605 | } |
606 | 606 | } |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | * @deprecated 4.9.12 |
630 | 630 | * @param string $new_txn_status |
631 | 631 | */ |
632 | - public function set_new_txn_status( $new_txn_status ) { |
|
632 | + public function set_new_txn_status($new_txn_status) { |
|
633 | 633 | EE_Error::doing_it_wrong( |
634 | 634 | __METHOD__, |
635 | 635 | esc_html__( |
@@ -673,7 +673,7 @@ discard block |
||
673 | 673 | * @param EE_Transaction $transaction |
674 | 674 | * @return boolean |
675 | 675 | */ |
676 | - public function all_reg_steps_completed( EE_Transaction $transaction ) { |
|
676 | + public function all_reg_steps_completed(EE_Transaction $transaction) { |
|
677 | 677 | EE_Error::doing_it_wrong( |
678 | 678 | __METHOD__, |
679 | 679 | esc_html__( |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | * @param string $exception |
701 | 701 | * @return boolean |
702 | 702 | */ |
703 | - public function all_reg_steps_completed_except( EE_Transaction $transaction, $exception = '' ) { |
|
703 | + public function all_reg_steps_completed_except(EE_Transaction $transaction, $exception = '') { |
|
704 | 704 | EE_Error::doing_it_wrong( |
705 | 705 | __METHOD__, |
706 | 706 | esc_html__( |
@@ -710,7 +710,7 @@ discard block |
||
710 | 710 | '4.9.12', |
711 | 711 | '5.0.0' |
712 | 712 | ); |
713 | - return $transaction->all_reg_steps_completed_except( $exception ); |
|
713 | + return $transaction->all_reg_steps_completed_except($exception); |
|
714 | 714 | } |
715 | 715 | |
716 | 716 | |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | * @param EE_Transaction $transaction |
727 | 727 | * @return boolean |
728 | 728 | */ |
729 | - public function all_reg_steps_completed_except_final_step( EE_Transaction $transaction ) { |
|
729 | + public function all_reg_steps_completed_except_final_step(EE_Transaction $transaction) { |
|
730 | 730 | EE_Error::doing_it_wrong( |
731 | 731 | __METHOD__, |
732 | 732 | esc_html__( |
@@ -753,7 +753,7 @@ discard block |
||
753 | 753 | * @param string $reg_step_slug |
754 | 754 | * @return boolean | int |
755 | 755 | */ |
756 | - public function reg_step_completed( EE_Transaction $transaction, $reg_step_slug ) { |
|
756 | + public function reg_step_completed(EE_Transaction $transaction, $reg_step_slug) { |
|
757 | 757 | EE_Error::doing_it_wrong( |
758 | 758 | __METHOD__, |
759 | 759 | esc_html__( |
@@ -763,7 +763,7 @@ discard block |
||
763 | 763 | '4.9.12', |
764 | 764 | '5.0.0' |
765 | 765 | ); |
766 | - return $transaction->reg_step_completed( $reg_step_slug ); |
|
766 | + return $transaction->reg_step_completed($reg_step_slug); |
|
767 | 767 | } |
768 | 768 | |
769 | 769 | |
@@ -779,7 +779,7 @@ discard block |
||
779 | 779 | * @param EE_Transaction $transaction |
780 | 780 | * @return boolean | int |
781 | 781 | */ |
782 | - public function final_reg_step_completed( EE_Transaction $transaction ) { |
|
782 | + public function final_reg_step_completed(EE_Transaction $transaction) { |
|
783 | 783 | EE_Error::doing_it_wrong( |
784 | 784 | __METHOD__, |
785 | 785 | esc_html__( |
@@ -805,7 +805,7 @@ discard block |
||
805 | 805 | * @return boolean |
806 | 806 | * @throws \EE_Error |
807 | 807 | */ |
808 | - public function set_reg_step_initiated( EE_Transaction $transaction, $reg_step_slug ) { |
|
808 | + public function set_reg_step_initiated(EE_Transaction $transaction, $reg_step_slug) { |
|
809 | 809 | EE_Error::doing_it_wrong( |
810 | 810 | __METHOD__, |
811 | 811 | esc_html__( |
@@ -815,7 +815,7 @@ discard block |
||
815 | 815 | '4.9.12', |
816 | 816 | '5.0.0' |
817 | 817 | ); |
818 | - return $transaction->set_reg_step_initiated( $reg_step_slug ); |
|
818 | + return $transaction->set_reg_step_initiated($reg_step_slug); |
|
819 | 819 | } |
820 | 820 | |
821 | 821 | |
@@ -831,7 +831,7 @@ discard block |
||
831 | 831 | * @return boolean |
832 | 832 | * @throws \EE_Error |
833 | 833 | */ |
834 | - public function set_reg_step_completed( EE_Transaction $transaction, $reg_step_slug ) { |
|
834 | + public function set_reg_step_completed(EE_Transaction $transaction, $reg_step_slug) { |
|
835 | 835 | EE_Error::doing_it_wrong( |
836 | 836 | __METHOD__, |
837 | 837 | esc_html__( |
@@ -841,7 +841,7 @@ discard block |
||
841 | 841 | '4.9.12', |
842 | 842 | '5.0.0' |
843 | 843 | ); |
844 | - return $transaction->set_reg_step_completed( $reg_step_slug ); |
|
844 | + return $transaction->set_reg_step_completed($reg_step_slug); |
|
845 | 845 | } |
846 | 846 | |
847 | 847 | |
@@ -857,7 +857,7 @@ discard block |
||
857 | 857 | * @return boolean |
858 | 858 | * @throws \EE_Error |
859 | 859 | */ |
860 | - public function set_reg_step_not_completed( EE_Transaction $transaction, $reg_step_slug ) { |
|
860 | + public function set_reg_step_not_completed(EE_Transaction $transaction, $reg_step_slug) { |
|
861 | 861 | EE_Error::doing_it_wrong( |
862 | 862 | __METHOD__, |
863 | 863 | esc_html__( |
@@ -867,7 +867,7 @@ discard block |
||
867 | 867 | '4.9.12', |
868 | 868 | '5.0.0' |
869 | 869 | ); |
870 | - return $transaction->set_reg_step_not_completed( $reg_step_slug ); |
|
870 | + return $transaction->set_reg_step_not_completed($reg_step_slug); |
|
871 | 871 | } |
872 | 872 | |
873 | 873 | |
@@ -884,7 +884,7 @@ discard block |
||
884 | 884 | * @param string $reg_step_slug |
885 | 885 | * @return void |
886 | 886 | */ |
887 | - public function remove_reg_step( EE_Transaction $transaction, $reg_step_slug ) { |
|
887 | + public function remove_reg_step(EE_Transaction $transaction, $reg_step_slug) { |
|
888 | 888 | EE_Error::doing_it_wrong( |
889 | 889 | __METHOD__, |
890 | 890 | esc_html__( |
@@ -894,7 +894,7 @@ discard block |
||
894 | 894 | '4.9.12', |
895 | 895 | '5.0.0' |
896 | 896 | ); |
897 | - $transaction->remove_reg_step( $reg_step_slug ); |
|
897 | + $transaction->remove_reg_step($reg_step_slug); |
|
898 | 898 | } |
899 | 899 | |
900 | 900 | |
@@ -910,7 +910,7 @@ discard block |
||
910 | 910 | * @return boolean |
911 | 911 | * @throws \EE_Error |
912 | 912 | */ |
913 | - public function toggle_failed_transaction_status( EE_Transaction $transaction ) { |
|
913 | + public function toggle_failed_transaction_status(EE_Transaction $transaction) { |
|
914 | 914 | EE_Error::doing_it_wrong( |
915 | 915 | __METHOD__, |
916 | 916 | esc_html__( |
@@ -934,7 +934,7 @@ discard block |
||
934 | 934 | * @param EE_Transaction $transaction |
935 | 935 | * @return boolean |
936 | 936 | */ |
937 | - public function toggle_abandoned_transaction_status( EE_Transaction $transaction ) { |
|
937 | + public function toggle_abandoned_transaction_status(EE_Transaction $transaction) { |
|
938 | 938 | EE_Error::doing_it_wrong( |
939 | 939 | __METHOD__, |
940 | 940 | esc_html__( |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | use EventEspresso\core\libraries\form_sections\strategies\filter\FormHtmlFilter; |
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 | |
@@ -19,462 +19,462 @@ discard block |
||
19 | 19 | abstract class EE_Form_Section_Base |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * the URL the form is submitted to |
|
24 | - * |
|
25 | - * @var string |
|
26 | - */ |
|
27 | - protected $_action; |
|
28 | - |
|
29 | - /** |
|
30 | - * POST (default) or GET |
|
31 | - * |
|
32 | - * @var string |
|
33 | - */ |
|
34 | - protected $_method; |
|
35 | - |
|
36 | - /** |
|
37 | - * html_id and html_name are derived from this by default |
|
38 | - * |
|
39 | - * @var string |
|
40 | - */ |
|
41 | - protected $_name; |
|
42 | - |
|
43 | - /** |
|
44 | - * $_html_id |
|
45 | - * @var string |
|
46 | - */ |
|
47 | - protected $_html_id; |
|
48 | - |
|
49 | - /** |
|
50 | - * $_html_class |
|
51 | - * @var string |
|
52 | - */ |
|
53 | - protected $_html_class; |
|
54 | - |
|
55 | - /** |
|
56 | - * $_html_style |
|
57 | - * @var string |
|
58 | - */ |
|
59 | - protected $_html_style; |
|
60 | - |
|
61 | - /** |
|
62 | - * $_other_html_attributes |
|
63 | - * @var string |
|
64 | - */ |
|
65 | - protected $_other_html_attributes; |
|
66 | - |
|
67 | - /** |
|
68 | - * The form section of which this form section is a part |
|
69 | - * |
|
70 | - * @var EE_Form_Section_Proper |
|
71 | - */ |
|
72 | - protected $_parent_section; |
|
73 | - |
|
74 | - /** |
|
75 | - * flag indicating that _construct_finalize has been called. |
|
76 | - * If it hasn't been called and we try to use functions which require it, we call it |
|
77 | - * with no parameters. But normally, _construct_finalize should be called by the instantiating class |
|
78 | - * |
|
79 | - * @var boolean |
|
80 | - */ |
|
81 | - protected $_construction_finalized; |
|
82 | - |
|
83 | - /** |
|
84 | - * Strategy for parsing the form HTML upon display |
|
85 | - * |
|
86 | - * @var FormHtmlFilter |
|
87 | - */ |
|
88 | - protected $_form_html_filter; |
|
89 | - |
|
90 | - |
|
91 | - |
|
92 | - /** |
|
93 | - * @param array $options_array { |
|
94 | - * @type $name string the name for this form section, if you want to explicitly define it |
|
95 | - * } |
|
96 | - */ |
|
97 | - public function __construct($options_array = array()) |
|
98 | - { |
|
99 | - // used by display strategies |
|
100 | - // assign incoming values to properties |
|
101 | - foreach ($options_array as $key => $value) { |
|
102 | - $key = '_' . $key; |
|
103 | - if (property_exists($this, $key) && empty($this->{$key})) { |
|
104 | - $this->{$key} = $value; |
|
105 | - } |
|
106 | - } |
|
107 | - // set parser which allows the form section's rendered HTML to be filtered |
|
108 | - if (isset($options_array['form_html_filter']) && $options_array['form_html_filter'] instanceof FormHtmlFilter) { |
|
109 | - $this->_form_html_filter = $options_array['form_html_filter']; |
|
110 | - } |
|
111 | - } |
|
112 | - |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * @param $parent_form_section |
|
117 | - * @param $name |
|
118 | - * @throws \EE_Error |
|
119 | - */ |
|
120 | - protected function _construct_finalize($parent_form_section, $name) |
|
121 | - { |
|
122 | - $this->_construction_finalized = true; |
|
123 | - $this->_parent_section = $parent_form_section; |
|
124 | - if ($name !== null) { |
|
125 | - $this->_name = $name; |
|
126 | - } |
|
127 | - } |
|
128 | - |
|
129 | - |
|
130 | - |
|
131 | - /** |
|
132 | - * make sure construction finalized was called, otherwise children might not be ready |
|
133 | - * |
|
134 | - * @return void |
|
135 | - * @throws \EE_Error |
|
136 | - */ |
|
137 | - public function ensure_construct_finalized_called() |
|
138 | - { |
|
139 | - if (! $this->_construction_finalized) { |
|
140 | - $this->_construct_finalize($this->_parent_section, $this->_name); |
|
141 | - } |
|
142 | - } |
|
143 | - |
|
144 | - |
|
145 | - |
|
146 | - /** |
|
147 | - * @return string |
|
148 | - */ |
|
149 | - public function action() |
|
150 | - { |
|
151 | - return $this->_action; |
|
152 | - } |
|
153 | - |
|
154 | - |
|
155 | - |
|
156 | - /** |
|
157 | - * @param string $action |
|
158 | - */ |
|
159 | - public function set_action($action) |
|
160 | - { |
|
161 | - $this->_action = $action; |
|
162 | - } |
|
163 | - |
|
164 | - |
|
165 | - |
|
166 | - /** |
|
167 | - * @return string |
|
168 | - */ |
|
169 | - public function method() |
|
170 | - { |
|
171 | - return ! empty($this->_method) ? $this->_method : 'POST'; |
|
172 | - } |
|
173 | - |
|
174 | - |
|
175 | - |
|
176 | - /** |
|
177 | - * @param string $method |
|
178 | - */ |
|
179 | - public function set_method($method) |
|
180 | - { |
|
181 | - switch ($method) { |
|
182 | - case 'get' : |
|
183 | - case 'GET' : |
|
184 | - $this->_method = 'GET'; |
|
185 | - break; |
|
186 | - default : |
|
187 | - $this->_method = 'POST'; |
|
188 | - } |
|
189 | - } |
|
190 | - |
|
191 | - |
|
192 | - |
|
193 | - /** |
|
194 | - * Sets the html_id to its default value, if none was specified in the constructor. |
|
195 | - * Calculation involves using the name and the parent's html id |
|
196 | - * return void |
|
197 | - * |
|
198 | - * @throws \EE_Error |
|
199 | - */ |
|
200 | - protected function _set_default_html_id_if_empty() |
|
201 | - { |
|
202 | - if (! $this->_html_id) { |
|
203 | - if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
|
204 | - $this->_html_id = $this->_parent_section->html_id() |
|
205 | - . '-' |
|
206 | - . $this->_prep_name_for_html_id($this->name()); |
|
207 | - } else { |
|
208 | - $this->_html_id = $this->_prep_name_for_html_id($this->name()); |
|
209 | - } |
|
210 | - } |
|
211 | - } |
|
212 | - |
|
213 | - |
|
214 | - |
|
215 | - /** |
|
216 | - * _prep_name_for_html_id |
|
217 | - * |
|
218 | - * @param $name |
|
219 | - * @return string |
|
220 | - */ |
|
221 | - private function _prep_name_for_html_id($name) |
|
222 | - { |
|
223 | - return sanitize_key(str_replace(array(' ', ' ', '_'), '-', $name)); |
|
224 | - } |
|
22 | + /** |
|
23 | + * the URL the form is submitted to |
|
24 | + * |
|
25 | + * @var string |
|
26 | + */ |
|
27 | + protected $_action; |
|
28 | + |
|
29 | + /** |
|
30 | + * POST (default) or GET |
|
31 | + * |
|
32 | + * @var string |
|
33 | + */ |
|
34 | + protected $_method; |
|
35 | + |
|
36 | + /** |
|
37 | + * html_id and html_name are derived from this by default |
|
38 | + * |
|
39 | + * @var string |
|
40 | + */ |
|
41 | + protected $_name; |
|
42 | + |
|
43 | + /** |
|
44 | + * $_html_id |
|
45 | + * @var string |
|
46 | + */ |
|
47 | + protected $_html_id; |
|
48 | + |
|
49 | + /** |
|
50 | + * $_html_class |
|
51 | + * @var string |
|
52 | + */ |
|
53 | + protected $_html_class; |
|
54 | + |
|
55 | + /** |
|
56 | + * $_html_style |
|
57 | + * @var string |
|
58 | + */ |
|
59 | + protected $_html_style; |
|
60 | + |
|
61 | + /** |
|
62 | + * $_other_html_attributes |
|
63 | + * @var string |
|
64 | + */ |
|
65 | + protected $_other_html_attributes; |
|
66 | + |
|
67 | + /** |
|
68 | + * The form section of which this form section is a part |
|
69 | + * |
|
70 | + * @var EE_Form_Section_Proper |
|
71 | + */ |
|
72 | + protected $_parent_section; |
|
73 | + |
|
74 | + /** |
|
75 | + * flag indicating that _construct_finalize has been called. |
|
76 | + * If it hasn't been called and we try to use functions which require it, we call it |
|
77 | + * with no parameters. But normally, _construct_finalize should be called by the instantiating class |
|
78 | + * |
|
79 | + * @var boolean |
|
80 | + */ |
|
81 | + protected $_construction_finalized; |
|
82 | + |
|
83 | + /** |
|
84 | + * Strategy for parsing the form HTML upon display |
|
85 | + * |
|
86 | + * @var FormHtmlFilter |
|
87 | + */ |
|
88 | + protected $_form_html_filter; |
|
89 | + |
|
90 | + |
|
91 | + |
|
92 | + /** |
|
93 | + * @param array $options_array { |
|
94 | + * @type $name string the name for this form section, if you want to explicitly define it |
|
95 | + * } |
|
96 | + */ |
|
97 | + public function __construct($options_array = array()) |
|
98 | + { |
|
99 | + // used by display strategies |
|
100 | + // assign incoming values to properties |
|
101 | + foreach ($options_array as $key => $value) { |
|
102 | + $key = '_' . $key; |
|
103 | + if (property_exists($this, $key) && empty($this->{$key})) { |
|
104 | + $this->{$key} = $value; |
|
105 | + } |
|
106 | + } |
|
107 | + // set parser which allows the form section's rendered HTML to be filtered |
|
108 | + if (isset($options_array['form_html_filter']) && $options_array['form_html_filter'] instanceof FormHtmlFilter) { |
|
109 | + $this->_form_html_filter = $options_array['form_html_filter']; |
|
110 | + } |
|
111 | + } |
|
112 | + |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * @param $parent_form_section |
|
117 | + * @param $name |
|
118 | + * @throws \EE_Error |
|
119 | + */ |
|
120 | + protected function _construct_finalize($parent_form_section, $name) |
|
121 | + { |
|
122 | + $this->_construction_finalized = true; |
|
123 | + $this->_parent_section = $parent_form_section; |
|
124 | + if ($name !== null) { |
|
125 | + $this->_name = $name; |
|
126 | + } |
|
127 | + } |
|
128 | + |
|
129 | + |
|
130 | + |
|
131 | + /** |
|
132 | + * make sure construction finalized was called, otherwise children might not be ready |
|
133 | + * |
|
134 | + * @return void |
|
135 | + * @throws \EE_Error |
|
136 | + */ |
|
137 | + public function ensure_construct_finalized_called() |
|
138 | + { |
|
139 | + if (! $this->_construction_finalized) { |
|
140 | + $this->_construct_finalize($this->_parent_section, $this->_name); |
|
141 | + } |
|
142 | + } |
|
143 | + |
|
144 | + |
|
145 | + |
|
146 | + /** |
|
147 | + * @return string |
|
148 | + */ |
|
149 | + public function action() |
|
150 | + { |
|
151 | + return $this->_action; |
|
152 | + } |
|
153 | + |
|
154 | + |
|
155 | + |
|
156 | + /** |
|
157 | + * @param string $action |
|
158 | + */ |
|
159 | + public function set_action($action) |
|
160 | + { |
|
161 | + $this->_action = $action; |
|
162 | + } |
|
163 | + |
|
164 | + |
|
165 | + |
|
166 | + /** |
|
167 | + * @return string |
|
168 | + */ |
|
169 | + public function method() |
|
170 | + { |
|
171 | + return ! empty($this->_method) ? $this->_method : 'POST'; |
|
172 | + } |
|
173 | + |
|
174 | + |
|
175 | + |
|
176 | + /** |
|
177 | + * @param string $method |
|
178 | + */ |
|
179 | + public function set_method($method) |
|
180 | + { |
|
181 | + switch ($method) { |
|
182 | + case 'get' : |
|
183 | + case 'GET' : |
|
184 | + $this->_method = 'GET'; |
|
185 | + break; |
|
186 | + default : |
|
187 | + $this->_method = 'POST'; |
|
188 | + } |
|
189 | + } |
|
190 | + |
|
191 | + |
|
192 | + |
|
193 | + /** |
|
194 | + * Sets the html_id to its default value, if none was specified in the constructor. |
|
195 | + * Calculation involves using the name and the parent's html id |
|
196 | + * return void |
|
197 | + * |
|
198 | + * @throws \EE_Error |
|
199 | + */ |
|
200 | + protected function _set_default_html_id_if_empty() |
|
201 | + { |
|
202 | + if (! $this->_html_id) { |
|
203 | + if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
|
204 | + $this->_html_id = $this->_parent_section->html_id() |
|
205 | + . '-' |
|
206 | + . $this->_prep_name_for_html_id($this->name()); |
|
207 | + } else { |
|
208 | + $this->_html_id = $this->_prep_name_for_html_id($this->name()); |
|
209 | + } |
|
210 | + } |
|
211 | + } |
|
212 | + |
|
213 | + |
|
214 | + |
|
215 | + /** |
|
216 | + * _prep_name_for_html_id |
|
217 | + * |
|
218 | + * @param $name |
|
219 | + * @return string |
|
220 | + */ |
|
221 | + private function _prep_name_for_html_id($name) |
|
222 | + { |
|
223 | + return sanitize_key(str_replace(array(' ', ' ', '_'), '-', $name)); |
|
224 | + } |
|
225 | 225 | |
226 | 226 | |
227 | 227 | |
228 | - /** |
|
229 | - * Returns the HTML, JS, and CSS necessary to display this form section on a page. |
|
230 | - * Note however, it's recommended that you instead call enqueue_js on the "wp_enqueue_scripts" action, |
|
231 | - * and call get_html when you want to output the html. Calling get_html_and_js after |
|
232 | - * "wp_enqueue_scripts" has already fired seems to work for now, but is contrary |
|
233 | - * to the instructions on https://developer.wordpress.org/reference/functions/wp_enqueue_script/ |
|
234 | - * and so might stop working anytime. |
|
235 | - * |
|
236 | - * @return string |
|
237 | - */ |
|
238 | - public function get_html_and_js() |
|
239 | - { |
|
240 | - return $this->get_html(); |
|
241 | - } |
|
228 | + /** |
|
229 | + * Returns the HTML, JS, and CSS necessary to display this form section on a page. |
|
230 | + * Note however, it's recommended that you instead call enqueue_js on the "wp_enqueue_scripts" action, |
|
231 | + * and call get_html when you want to output the html. Calling get_html_and_js after |
|
232 | + * "wp_enqueue_scripts" has already fired seems to work for now, but is contrary |
|
233 | + * to the instructions on https://developer.wordpress.org/reference/functions/wp_enqueue_script/ |
|
234 | + * and so might stop working anytime. |
|
235 | + * |
|
236 | + * @return string |
|
237 | + */ |
|
238 | + public function get_html_and_js() |
|
239 | + { |
|
240 | + return $this->get_html(); |
|
241 | + } |
|
242 | 242 | |
243 | 243 | |
244 | 244 | |
245 | - /** |
|
246 | - * Gets the HTML for displaying this form section |
|
247 | - * |
|
248 | - * @return string |
|
249 | - */ |
|
250 | - public abstract function get_html(); |
|
245 | + /** |
|
246 | + * Gets the HTML for displaying this form section |
|
247 | + * |
|
248 | + * @return string |
|
249 | + */ |
|
250 | + public abstract function get_html(); |
|
251 | 251 | |
252 | 252 | |
253 | 253 | |
254 | - /** |
|
255 | - * @param bool $add_pound_sign |
|
256 | - * @return string |
|
257 | - */ |
|
258 | - public function html_id($add_pound_sign = false) |
|
259 | - { |
|
260 | - $this->_set_default_html_id_if_empty(); |
|
261 | - return $add_pound_sign ? '#' . $this->_html_id : $this->_html_id; |
|
262 | - } |
|
254 | + /** |
|
255 | + * @param bool $add_pound_sign |
|
256 | + * @return string |
|
257 | + */ |
|
258 | + public function html_id($add_pound_sign = false) |
|
259 | + { |
|
260 | + $this->_set_default_html_id_if_empty(); |
|
261 | + return $add_pound_sign ? '#' . $this->_html_id : $this->_html_id; |
|
262 | + } |
|
263 | 263 | |
264 | 264 | |
265 | - |
|
266 | - /** |
|
267 | - * @return string |
|
268 | - */ |
|
269 | - public function html_class() |
|
270 | - { |
|
271 | - return $this->_html_class; |
|
272 | - } |
|
273 | - |
|
274 | - |
|
275 | - |
|
276 | - /** |
|
277 | - * @return string |
|
278 | - */ |
|
279 | - public function html_style() |
|
280 | - { |
|
281 | - return $this->_html_style; |
|
282 | - } |
|
283 | - |
|
284 | - |
|
285 | - |
|
286 | - /** |
|
287 | - * @param mixed $html_class |
|
288 | - */ |
|
289 | - public function set_html_class($html_class) |
|
290 | - { |
|
291 | - $this->_html_class = $html_class; |
|
292 | - } |
|
293 | - |
|
294 | - |
|
295 | - |
|
296 | - /** |
|
297 | - * @param mixed $html_id |
|
298 | - */ |
|
299 | - public function set_html_id($html_id) |
|
300 | - { |
|
301 | - $this->_html_id = $html_id; |
|
302 | - } |
|
303 | - |
|
304 | - |
|
305 | - |
|
306 | - /** |
|
307 | - * @param mixed $html_style |
|
308 | - */ |
|
309 | - public function set_html_style($html_style) |
|
310 | - { |
|
311 | - $this->_html_style = $html_style; |
|
312 | - } |
|
313 | - |
|
314 | - |
|
315 | - |
|
316 | - /** |
|
317 | - * @param string $other_html_attributes |
|
318 | - */ |
|
319 | - public function set_other_html_attributes($other_html_attributes) |
|
320 | - { |
|
321 | - $this->_other_html_attributes = $other_html_attributes; |
|
322 | - } |
|
323 | - |
|
324 | - |
|
325 | - |
|
326 | - /** |
|
327 | - * @return string |
|
328 | - */ |
|
329 | - public function other_html_attributes() |
|
330 | - { |
|
331 | - return $this->_other_html_attributes; |
|
332 | - } |
|
333 | - |
|
334 | - |
|
335 | - |
|
336 | - /** |
|
337 | - * Gets the name of the form section. This is not the same as the HTML name. |
|
338 | - * |
|
339 | - * @throws EE_Error |
|
340 | - * @return string |
|
341 | - */ |
|
342 | - public function name() |
|
343 | - { |
|
344 | - if (! $this->_construction_finalized) { |
|
345 | - throw new EE_Error(sprintf(__('You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'', |
|
346 | - 'event_espresso'), get_class($this))); |
|
347 | - } |
|
348 | - return $this->_name; |
|
349 | - } |
|
350 | - |
|
351 | - |
|
352 | - |
|
353 | - /** |
|
354 | - * Gets the parent section |
|
355 | - * |
|
356 | - * @return EE_Form_Section_Proper |
|
357 | - */ |
|
358 | - public function parent_section() |
|
359 | - { |
|
360 | - return $this->_parent_section; |
|
361 | - } |
|
362 | - |
|
363 | - |
|
364 | - |
|
365 | - /** |
|
366 | - * returns HTML for generating the opening form HTML tag (<form>) |
|
367 | - * |
|
368 | - * @param string $action the URL the form is submitted to |
|
369 | - * @param string $method POST (default) or GET |
|
370 | - * @param string $other_attributes anything else added to the form open tag, MUST BE VALID HTML |
|
371 | - * @return string |
|
372 | - */ |
|
373 | - public function form_open($action = '', $method = '', $other_attributes = '') |
|
374 | - { |
|
375 | - if (! empty($action)) { |
|
376 | - $this->set_action($action); |
|
377 | - } |
|
378 | - if (! empty($method)) { |
|
379 | - $this->set_method($method); |
|
380 | - } |
|
381 | - $html = EEH_HTML::nl(1, 'form') . '<form'; |
|
382 | - $html .= $this->html_id() !== '' ? ' id="' . $this->html_id() . '"' : ''; |
|
383 | - $html .= ' action="' . $this->action() . '"'; |
|
384 | - $html .= ' method="' . $this->method() . '"'; |
|
385 | - $html .= $other_attributes . '>'; |
|
386 | - return $html; |
|
387 | - } |
|
388 | - |
|
389 | - |
|
390 | - |
|
391 | - /** |
|
392 | - * returns HTML for generating the closing form HTML tag (</form>) |
|
393 | - * |
|
394 | - * @return string |
|
395 | - */ |
|
396 | - public function form_close() |
|
397 | - { |
|
398 | - return EEH_HTML::nl(-1, 'form') |
|
399 | - . '</form>' |
|
400 | - . EEH_HTML::nl() |
|
401 | - . '<!-- end of ee-' |
|
402 | - . $this->html_id() |
|
403 | - . '-form -->' |
|
404 | - . EEH_HTML::nl(); |
|
405 | - } |
|
406 | - |
|
407 | - |
|
408 | - |
|
409 | - /** |
|
410 | - * enqueues JS (and CSS) for the form (ie immediately call wp_enqueue_script and |
|
411 | - * wp_enqueue_style; the scripts could have optionally been registered earlier) |
|
412 | - * Default does nothing, but child classes can override |
|
413 | - * |
|
414 | - * @return void |
|
415 | - */ |
|
416 | - public function enqueue_js() |
|
417 | - { |
|
418 | - //defaults to enqueue NO js or css |
|
419 | - } |
|
420 | - |
|
421 | - |
|
422 | - |
|
423 | - /** |
|
424 | - * Adds any extra data needed by js. Eventually we'll call wp_localize_script |
|
425 | - * with it, and it will be on each form section's 'other_data' property. |
|
426 | - * By default nothing is added, but child classes can extend this method to add something. |
|
427 | - * Eg, if you have an input that will cause a modal dialog to appear, |
|
428 | - * here you could add an entry like 'modal_dialog_inputs' to this array |
|
429 | - * to map between the input's html ID and the modal dialogue's ID, so that |
|
430 | - * your JS code will know where to find the modal dialog when the input is pressed. |
|
431 | - * Eg $form_other_js_data['modal_dialog_inputs']['some-input-id']='modal-dialog-id'; |
|
432 | - * |
|
433 | - * @param array $form_other_js_data |
|
434 | - * @return array |
|
435 | - */ |
|
436 | - public function get_other_js_data($form_other_js_data = array()) |
|
437 | - { |
|
438 | - return $form_other_js_data; |
|
439 | - } |
|
440 | - |
|
441 | - |
|
442 | - |
|
443 | - /** |
|
444 | - * This isn't just the name of an input, it's a path pointing to an input. The |
|
445 | - * path is similar to a folder path: slash (/) means to descend into a subsection, |
|
446 | - * dot-dot-slash (../) means to ascend into the parent section. |
|
447 | - * After a series of slashes and dot-dot-slashes, there should be the name of an input, |
|
448 | - * which will be returned. |
|
449 | - * Eg, if you want the related input to be conditional on a sibling input name 'foobar' |
|
450 | - * just use 'foobar'. If you want it to be conditional on an aunt/uncle input name |
|
451 | - * 'baz', use '../baz'. If you want it to be conditional on a cousin input, |
|
452 | - * the child of 'baz_section' named 'baz_child', use '../baz_section/baz_child'. |
|
453 | - * Etc |
|
454 | - * |
|
455 | - * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false |
|
456 | - * @return EE_Form_Section_Base |
|
457 | - */ |
|
458 | - public function find_section_from_path($form_section_path) |
|
459 | - { |
|
460 | - if (strpos($form_section_path, '/') === 0) { |
|
461 | - $form_section_path = substr($form_section_path, strlen('/')); |
|
462 | - } |
|
463 | - if (empty($form_section_path)) { |
|
464 | - return $this; |
|
465 | - } |
|
466 | - if (strpos($form_section_path, '../') === 0) { |
|
467 | - $parent = $this->parent_section(); |
|
468 | - $form_section_path = substr($form_section_path, strlen('../')); |
|
469 | - if ($parent instanceof EE_Form_Section_Base) { |
|
470 | - return $parent->find_section_from_path($form_section_path); |
|
471 | - } elseif (empty($form_section_path)) { |
|
472 | - return $this; |
|
473 | - } |
|
474 | - } |
|
475 | - //couldn't find it using simple parent following |
|
476 | - return null; |
|
477 | - } |
|
265 | + |
|
266 | + /** |
|
267 | + * @return string |
|
268 | + */ |
|
269 | + public function html_class() |
|
270 | + { |
|
271 | + return $this->_html_class; |
|
272 | + } |
|
273 | + |
|
274 | + |
|
275 | + |
|
276 | + /** |
|
277 | + * @return string |
|
278 | + */ |
|
279 | + public function html_style() |
|
280 | + { |
|
281 | + return $this->_html_style; |
|
282 | + } |
|
283 | + |
|
284 | + |
|
285 | + |
|
286 | + /** |
|
287 | + * @param mixed $html_class |
|
288 | + */ |
|
289 | + public function set_html_class($html_class) |
|
290 | + { |
|
291 | + $this->_html_class = $html_class; |
|
292 | + } |
|
293 | + |
|
294 | + |
|
295 | + |
|
296 | + /** |
|
297 | + * @param mixed $html_id |
|
298 | + */ |
|
299 | + public function set_html_id($html_id) |
|
300 | + { |
|
301 | + $this->_html_id = $html_id; |
|
302 | + } |
|
303 | + |
|
304 | + |
|
305 | + |
|
306 | + /** |
|
307 | + * @param mixed $html_style |
|
308 | + */ |
|
309 | + public function set_html_style($html_style) |
|
310 | + { |
|
311 | + $this->_html_style = $html_style; |
|
312 | + } |
|
313 | + |
|
314 | + |
|
315 | + |
|
316 | + /** |
|
317 | + * @param string $other_html_attributes |
|
318 | + */ |
|
319 | + public function set_other_html_attributes($other_html_attributes) |
|
320 | + { |
|
321 | + $this->_other_html_attributes = $other_html_attributes; |
|
322 | + } |
|
323 | + |
|
324 | + |
|
325 | + |
|
326 | + /** |
|
327 | + * @return string |
|
328 | + */ |
|
329 | + public function other_html_attributes() |
|
330 | + { |
|
331 | + return $this->_other_html_attributes; |
|
332 | + } |
|
333 | + |
|
334 | + |
|
335 | + |
|
336 | + /** |
|
337 | + * Gets the name of the form section. This is not the same as the HTML name. |
|
338 | + * |
|
339 | + * @throws EE_Error |
|
340 | + * @return string |
|
341 | + */ |
|
342 | + public function name() |
|
343 | + { |
|
344 | + if (! $this->_construction_finalized) { |
|
345 | + throw new EE_Error(sprintf(__('You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'', |
|
346 | + 'event_espresso'), get_class($this))); |
|
347 | + } |
|
348 | + return $this->_name; |
|
349 | + } |
|
350 | + |
|
351 | + |
|
352 | + |
|
353 | + /** |
|
354 | + * Gets the parent section |
|
355 | + * |
|
356 | + * @return EE_Form_Section_Proper |
|
357 | + */ |
|
358 | + public function parent_section() |
|
359 | + { |
|
360 | + return $this->_parent_section; |
|
361 | + } |
|
362 | + |
|
363 | + |
|
364 | + |
|
365 | + /** |
|
366 | + * returns HTML for generating the opening form HTML tag (<form>) |
|
367 | + * |
|
368 | + * @param string $action the URL the form is submitted to |
|
369 | + * @param string $method POST (default) or GET |
|
370 | + * @param string $other_attributes anything else added to the form open tag, MUST BE VALID HTML |
|
371 | + * @return string |
|
372 | + */ |
|
373 | + public function form_open($action = '', $method = '', $other_attributes = '') |
|
374 | + { |
|
375 | + if (! empty($action)) { |
|
376 | + $this->set_action($action); |
|
377 | + } |
|
378 | + if (! empty($method)) { |
|
379 | + $this->set_method($method); |
|
380 | + } |
|
381 | + $html = EEH_HTML::nl(1, 'form') . '<form'; |
|
382 | + $html .= $this->html_id() !== '' ? ' id="' . $this->html_id() . '"' : ''; |
|
383 | + $html .= ' action="' . $this->action() . '"'; |
|
384 | + $html .= ' method="' . $this->method() . '"'; |
|
385 | + $html .= $other_attributes . '>'; |
|
386 | + return $html; |
|
387 | + } |
|
388 | + |
|
389 | + |
|
390 | + |
|
391 | + /** |
|
392 | + * returns HTML for generating the closing form HTML tag (</form>) |
|
393 | + * |
|
394 | + * @return string |
|
395 | + */ |
|
396 | + public function form_close() |
|
397 | + { |
|
398 | + return EEH_HTML::nl(-1, 'form') |
|
399 | + . '</form>' |
|
400 | + . EEH_HTML::nl() |
|
401 | + . '<!-- end of ee-' |
|
402 | + . $this->html_id() |
|
403 | + . '-form -->' |
|
404 | + . EEH_HTML::nl(); |
|
405 | + } |
|
406 | + |
|
407 | + |
|
408 | + |
|
409 | + /** |
|
410 | + * enqueues JS (and CSS) for the form (ie immediately call wp_enqueue_script and |
|
411 | + * wp_enqueue_style; the scripts could have optionally been registered earlier) |
|
412 | + * Default does nothing, but child classes can override |
|
413 | + * |
|
414 | + * @return void |
|
415 | + */ |
|
416 | + public function enqueue_js() |
|
417 | + { |
|
418 | + //defaults to enqueue NO js or css |
|
419 | + } |
|
420 | + |
|
421 | + |
|
422 | + |
|
423 | + /** |
|
424 | + * Adds any extra data needed by js. Eventually we'll call wp_localize_script |
|
425 | + * with it, and it will be on each form section's 'other_data' property. |
|
426 | + * By default nothing is added, but child classes can extend this method to add something. |
|
427 | + * Eg, if you have an input that will cause a modal dialog to appear, |
|
428 | + * here you could add an entry like 'modal_dialog_inputs' to this array |
|
429 | + * to map between the input's html ID and the modal dialogue's ID, so that |
|
430 | + * your JS code will know where to find the modal dialog when the input is pressed. |
|
431 | + * Eg $form_other_js_data['modal_dialog_inputs']['some-input-id']='modal-dialog-id'; |
|
432 | + * |
|
433 | + * @param array $form_other_js_data |
|
434 | + * @return array |
|
435 | + */ |
|
436 | + public function get_other_js_data($form_other_js_data = array()) |
|
437 | + { |
|
438 | + return $form_other_js_data; |
|
439 | + } |
|
440 | + |
|
441 | + |
|
442 | + |
|
443 | + /** |
|
444 | + * This isn't just the name of an input, it's a path pointing to an input. The |
|
445 | + * path is similar to a folder path: slash (/) means to descend into a subsection, |
|
446 | + * dot-dot-slash (../) means to ascend into the parent section. |
|
447 | + * After a series of slashes and dot-dot-slashes, there should be the name of an input, |
|
448 | + * which will be returned. |
|
449 | + * Eg, if you want the related input to be conditional on a sibling input name 'foobar' |
|
450 | + * just use 'foobar'. If you want it to be conditional on an aunt/uncle input name |
|
451 | + * 'baz', use '../baz'. If you want it to be conditional on a cousin input, |
|
452 | + * the child of 'baz_section' named 'baz_child', use '../baz_section/baz_child'. |
|
453 | + * Etc |
|
454 | + * |
|
455 | + * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false |
|
456 | + * @return EE_Form_Section_Base |
|
457 | + */ |
|
458 | + public function find_section_from_path($form_section_path) |
|
459 | + { |
|
460 | + if (strpos($form_section_path, '/') === 0) { |
|
461 | + $form_section_path = substr($form_section_path, strlen('/')); |
|
462 | + } |
|
463 | + if (empty($form_section_path)) { |
|
464 | + return $this; |
|
465 | + } |
|
466 | + if (strpos($form_section_path, '../') === 0) { |
|
467 | + $parent = $this->parent_section(); |
|
468 | + $form_section_path = substr($form_section_path, strlen('../')); |
|
469 | + if ($parent instanceof EE_Form_Section_Base) { |
|
470 | + return $parent->find_section_from_path($form_section_path); |
|
471 | + } elseif (empty($form_section_path)) { |
|
472 | + return $this; |
|
473 | + } |
|
474 | + } |
|
475 | + //couldn't find it using simple parent following |
|
476 | + return null; |
|
477 | + } |
|
478 | 478 | |
479 | 479 | |
480 | 480 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | use EventEspresso\core\libraries\form_sections\strategies\filter\FormHtmlFilter; |
3 | 3 | |
4 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | 5 | exit('No direct script access allowed'); |
6 | 6 | } |
7 | 7 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | // used by display strategies |
100 | 100 | // assign incoming values to properties |
101 | 101 | foreach ($options_array as $key => $value) { |
102 | - $key = '_' . $key; |
|
102 | + $key = '_'.$key; |
|
103 | 103 | if (property_exists($this, $key) && empty($this->{$key})) { |
104 | 104 | $this->{$key} = $value; |
105 | 105 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | */ |
137 | 137 | public function ensure_construct_finalized_called() |
138 | 138 | { |
139 | - if (! $this->_construction_finalized) { |
|
139 | + if ( ! $this->_construction_finalized) { |
|
140 | 140 | $this->_construct_finalize($this->_parent_section, $this->_name); |
141 | 141 | } |
142 | 142 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | */ |
200 | 200 | protected function _set_default_html_id_if_empty() |
201 | 201 | { |
202 | - if (! $this->_html_id) { |
|
202 | + if ( ! $this->_html_id) { |
|
203 | 203 | if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
204 | 204 | $this->_html_id = $this->_parent_section->html_id() |
205 | 205 | . '-' |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | public function html_id($add_pound_sign = false) |
259 | 259 | { |
260 | 260 | $this->_set_default_html_id_if_empty(); |
261 | - return $add_pound_sign ? '#' . $this->_html_id : $this->_html_id; |
|
261 | + return $add_pound_sign ? '#'.$this->_html_id : $this->_html_id; |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | */ |
342 | 342 | public function name() |
343 | 343 | { |
344 | - if (! $this->_construction_finalized) { |
|
344 | + if ( ! $this->_construction_finalized) { |
|
345 | 345 | throw new EE_Error(sprintf(__('You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'', |
346 | 346 | 'event_espresso'), get_class($this))); |
347 | 347 | } |
@@ -372,17 +372,17 @@ discard block |
||
372 | 372 | */ |
373 | 373 | public function form_open($action = '', $method = '', $other_attributes = '') |
374 | 374 | { |
375 | - if (! empty($action)) { |
|
375 | + if ( ! empty($action)) { |
|
376 | 376 | $this->set_action($action); |
377 | 377 | } |
378 | - if (! empty($method)) { |
|
378 | + if ( ! empty($method)) { |
|
379 | 379 | $this->set_method($method); |
380 | 380 | } |
381 | - $html = EEH_HTML::nl(1, 'form') . '<form'; |
|
382 | - $html .= $this->html_id() !== '' ? ' id="' . $this->html_id() . '"' : ''; |
|
383 | - $html .= ' action="' . $this->action() . '"'; |
|
384 | - $html .= ' method="' . $this->method() . '"'; |
|
385 | - $html .= $other_attributes . '>'; |
|
381 | + $html = EEH_HTML::nl(1, 'form').'<form'; |
|
382 | + $html .= $this->html_id() !== '' ? ' id="'.$this->html_id().'"' : ''; |
|
383 | + $html .= ' action="'.$this->action().'"'; |
|
384 | + $html .= ' method="'.$this->method().'"'; |
|
385 | + $html .= $other_attributes.'>'; |
|
386 | 386 | return $html; |
387 | 387 | } |
388 | 388 |
@@ -13,110 +13,110 @@ |
||
13 | 13 | { |
14 | 14 | |
15 | 15 | |
16 | - /** |
|
17 | - * This is a flag indicating whether to use '<br>' tags after each input in the layout |
|
18 | - * strategy. |
|
19 | - * |
|
20 | - * @var bool |
|
21 | - */ |
|
22 | - protected $_use_break_tags = true; |
|
16 | + /** |
|
17 | + * This is a flag indicating whether to use '<br>' tags after each input in the layout |
|
18 | + * strategy. |
|
19 | + * |
|
20 | + * @var bool |
|
21 | + */ |
|
22 | + protected $_use_break_tags = true; |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * EE_No_Layout constructor. |
|
27 | - * |
|
28 | - * @param array $options Currently if this has a 'use_break_tags' key that is used to set the _use_break_tags |
|
29 | - * property on the class. |
|
30 | - */ |
|
31 | - public function __construct($options = array()) |
|
32 | - { |
|
33 | - $this->_use_break_tags = is_array($options) && isset($options['use_break_tags']) |
|
34 | - ? filter_var($options['use_break_tags'], FILTER_VALIDATE_BOOLEAN) |
|
35 | - : $this->_use_break_tags; |
|
36 | - parent::__construct(); |
|
37 | - } |
|
25 | + /** |
|
26 | + * EE_No_Layout constructor. |
|
27 | + * |
|
28 | + * @param array $options Currently if this has a 'use_break_tags' key that is used to set the _use_break_tags |
|
29 | + * property on the class. |
|
30 | + */ |
|
31 | + public function __construct($options = array()) |
|
32 | + { |
|
33 | + $this->_use_break_tags = is_array($options) && isset($options['use_break_tags']) |
|
34 | + ? filter_var($options['use_break_tags'], FILTER_VALIDATE_BOOLEAN) |
|
35 | + : $this->_use_break_tags; |
|
36 | + parent::__construct(); |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * Add line break at beginning of form |
|
41 | - * |
|
42 | - * @return string |
|
43 | - */ |
|
44 | - public function layout_form_begin() |
|
45 | - { |
|
46 | - return EEH_HTML::nl(1); |
|
47 | - } |
|
39 | + /** |
|
40 | + * Add line break at beginning of form |
|
41 | + * |
|
42 | + * @return string |
|
43 | + */ |
|
44 | + public function layout_form_begin() |
|
45 | + { |
|
46 | + return EEH_HTML::nl(1); |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * Lays out the row for the input, including label and errors |
|
52 | - * |
|
53 | - * @param EE_Form_Input_Base $input |
|
54 | - * @return string |
|
55 | - * @throws \EE_Error |
|
56 | - */ |
|
57 | - public function layout_input($input) |
|
58 | - { |
|
59 | - $html = ''; |
|
60 | - if ($input instanceof EE_Hidden_Input) { |
|
61 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
62 | - } else if ($input instanceof EE_Submit_Input) { |
|
63 | - $html .= $this->br(); |
|
64 | - $html .= $input->get_html_for_input(); |
|
65 | - } else if ($input instanceof EE_Select_Input) { |
|
66 | - $html .= $this->br(); |
|
67 | - $html .= EEH_HTML::nl(1) . $input->get_html_for_label(); |
|
68 | - $html .= EEH_HTML::nl() . $input->get_html_for_errors(); |
|
69 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
70 | - $html .= EEH_HTML::nl() . $input->get_html_for_help(); |
|
71 | - $html .= $this->br(); |
|
72 | - } else if ($input instanceof EE_Form_Input_With_Options_Base) { |
|
73 | - $html .= $this->br(); |
|
74 | - $html .= EEH_HTML::nl() . $input->get_html_for_errors(); |
|
75 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
76 | - $html .= EEH_HTML::nl() . $input->get_html_for_help(); |
|
77 | - } else { |
|
78 | - $html .= $this->br(); |
|
79 | - $html .= EEH_HTML::nl(1) . $input->get_html_for_label(); |
|
80 | - $html .= EEH_HTML::nl() . $input->get_html_for_errors(); |
|
81 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
82 | - $html .= EEH_HTML::nl() . $input->get_html_for_help(); |
|
83 | - } |
|
84 | - $html .= EEH_HTML::nl(-1); |
|
85 | - return $html; |
|
86 | - } |
|
50 | + /** |
|
51 | + * Lays out the row for the input, including label and errors |
|
52 | + * |
|
53 | + * @param EE_Form_Input_Base $input |
|
54 | + * @return string |
|
55 | + * @throws \EE_Error |
|
56 | + */ |
|
57 | + public function layout_input($input) |
|
58 | + { |
|
59 | + $html = ''; |
|
60 | + if ($input instanceof EE_Hidden_Input) { |
|
61 | + $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
62 | + } else if ($input instanceof EE_Submit_Input) { |
|
63 | + $html .= $this->br(); |
|
64 | + $html .= $input->get_html_for_input(); |
|
65 | + } else if ($input instanceof EE_Select_Input) { |
|
66 | + $html .= $this->br(); |
|
67 | + $html .= EEH_HTML::nl(1) . $input->get_html_for_label(); |
|
68 | + $html .= EEH_HTML::nl() . $input->get_html_for_errors(); |
|
69 | + $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
70 | + $html .= EEH_HTML::nl() . $input->get_html_for_help(); |
|
71 | + $html .= $this->br(); |
|
72 | + } else if ($input instanceof EE_Form_Input_With_Options_Base) { |
|
73 | + $html .= $this->br(); |
|
74 | + $html .= EEH_HTML::nl() . $input->get_html_for_errors(); |
|
75 | + $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
76 | + $html .= EEH_HTML::nl() . $input->get_html_for_help(); |
|
77 | + } else { |
|
78 | + $html .= $this->br(); |
|
79 | + $html .= EEH_HTML::nl(1) . $input->get_html_for_label(); |
|
80 | + $html .= EEH_HTML::nl() . $input->get_html_for_errors(); |
|
81 | + $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
82 | + $html .= EEH_HTML::nl() . $input->get_html_for_help(); |
|
83 | + } |
|
84 | + $html .= EEH_HTML::nl(-1); |
|
85 | + return $html; |
|
86 | + } |
|
87 | 87 | |
88 | 88 | |
89 | - /** |
|
90 | - * Lays out a row for the subsection |
|
91 | - * |
|
92 | - * @param EE_Form_Section_Proper $form_section |
|
93 | - * @return string |
|
94 | - */ |
|
95 | - public function layout_subsection($form_section) |
|
96 | - { |
|
89 | + /** |
|
90 | + * Lays out a row for the subsection |
|
91 | + * |
|
92 | + * @param EE_Form_Section_Proper $form_section |
|
93 | + * @return string |
|
94 | + */ |
|
95 | + public function layout_subsection($form_section) |
|
96 | + { |
|
97 | 97 | // d( $form_section ); |
98 | - return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1); |
|
99 | - } |
|
98 | + return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1); |
|
99 | + } |
|
100 | 100 | |
101 | 101 | |
102 | - /** |
|
103 | - * Add line break at end of form. |
|
104 | - * |
|
105 | - * @return string |
|
106 | - */ |
|
107 | - public function layout_form_end() |
|
108 | - { |
|
109 | - return EEH_HTML::nl(-1); |
|
110 | - } |
|
102 | + /** |
|
103 | + * Add line break at end of form. |
|
104 | + * |
|
105 | + * @return string |
|
106 | + */ |
|
107 | + public function layout_form_end() |
|
108 | + { |
|
109 | + return EEH_HTML::nl(-1); |
|
110 | + } |
|
111 | 111 | |
112 | 112 | |
113 | - /** |
|
114 | - * This returns a break tag or an empty string depending on the value of the `_use_break_tags` property. |
|
115 | - * |
|
116 | - * @return string |
|
117 | - */ |
|
118 | - protected function br() |
|
119 | - { |
|
120 | - return $this->_use_break_tags ? EEH_HTML::br() : ''; |
|
121 | - } |
|
113 | + /** |
|
114 | + * This returns a break tag or an empty string depending on the value of the `_use_break_tags` property. |
|
115 | + * |
|
116 | + * @return string |
|
117 | + */ |
|
118 | + protected function br() |
|
119 | + { |
|
120 | + return $this->_use_break_tags ? EEH_HTML::br() : ''; |
|
121 | + } |
|
122 | 122 | } |
123 | 123 | \ No newline at end of file |
@@ -58,28 +58,28 @@ discard block |
||
58 | 58 | { |
59 | 59 | $html = ''; |
60 | 60 | if ($input instanceof EE_Hidden_Input) { |
61 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
61 | + $html .= EEH_HTML::nl().$input->get_html_for_input(); |
|
62 | 62 | } else if ($input instanceof EE_Submit_Input) { |
63 | 63 | $html .= $this->br(); |
64 | 64 | $html .= $input->get_html_for_input(); |
65 | 65 | } else if ($input instanceof EE_Select_Input) { |
66 | 66 | $html .= $this->br(); |
67 | - $html .= EEH_HTML::nl(1) . $input->get_html_for_label(); |
|
68 | - $html .= EEH_HTML::nl() . $input->get_html_for_errors(); |
|
69 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
70 | - $html .= EEH_HTML::nl() . $input->get_html_for_help(); |
|
67 | + $html .= EEH_HTML::nl(1).$input->get_html_for_label(); |
|
68 | + $html .= EEH_HTML::nl().$input->get_html_for_errors(); |
|
69 | + $html .= EEH_HTML::nl().$input->get_html_for_input(); |
|
70 | + $html .= EEH_HTML::nl().$input->get_html_for_help(); |
|
71 | 71 | $html .= $this->br(); |
72 | 72 | } else if ($input instanceof EE_Form_Input_With_Options_Base) { |
73 | 73 | $html .= $this->br(); |
74 | - $html .= EEH_HTML::nl() . $input->get_html_for_errors(); |
|
75 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
76 | - $html .= EEH_HTML::nl() . $input->get_html_for_help(); |
|
74 | + $html .= EEH_HTML::nl().$input->get_html_for_errors(); |
|
75 | + $html .= EEH_HTML::nl().$input->get_html_for_input(); |
|
76 | + $html .= EEH_HTML::nl().$input->get_html_for_help(); |
|
77 | 77 | } else { |
78 | 78 | $html .= $this->br(); |
79 | - $html .= EEH_HTML::nl(1) . $input->get_html_for_label(); |
|
80 | - $html .= EEH_HTML::nl() . $input->get_html_for_errors(); |
|
81 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
82 | - $html .= EEH_HTML::nl() . $input->get_html_for_help(); |
|
79 | + $html .= EEH_HTML::nl(1).$input->get_html_for_label(); |
|
80 | + $html .= EEH_HTML::nl().$input->get_html_for_errors(); |
|
81 | + $html .= EEH_HTML::nl().$input->get_html_for_input(); |
|
82 | + $html .= EEH_HTML::nl().$input->get_html_for_help(); |
|
83 | 83 | } |
84 | 84 | $html .= EEH_HTML::nl(-1); |
85 | 85 | return $html; |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | public function layout_subsection($form_section) |
96 | 96 | { |
97 | 97 | // d( $form_section ); |
98 | - return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1); |
|
98 | + return EEH_HTML::nl(1).$form_section->get_html().EEH_HTML::nl(-1); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 |
@@ -18,12 +18,12 @@ |
||
18 | 18 | abstract class FormHtmlFilter |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @param $html |
|
23 | - * @param EE_Form_Section_Validatable $form_section |
|
24 | - * @return string |
|
25 | - */ |
|
26 | - abstract public function filterHtml($html, EE_Form_Section_Validatable $form_section); |
|
21 | + /** |
|
22 | + * @param $html |
|
23 | + * @param EE_Form_Section_Validatable $form_section |
|
24 | + * @return string |
|
25 | + */ |
|
26 | + abstract public function filterHtml($html, EE_Form_Section_Validatable $form_section); |
|
27 | 27 | |
28 | 28 | } |
29 | 29 | // End of file FormHtmlFilter.php |
@@ -15,37 +15,37 @@ |
||
15 | 15 | { |
16 | 16 | |
17 | 17 | |
18 | - /** |
|
19 | - * @param array $input_settings |
|
20 | - */ |
|
21 | - public function __construct($input_settings = array()) |
|
22 | - { |
|
23 | - $this->_set_display_strategy( |
|
24 | - new EE_Number_Input_Display_Strategy( |
|
25 | - isset($input_settings['min_value']) |
|
26 | - ? $input_settings['min_value'] |
|
27 | - : null, |
|
28 | - isset($input_settings['max_value']) |
|
29 | - ? $input_settings['max_value'] |
|
30 | - : null |
|
31 | - ) |
|
32 | - ); |
|
33 | - $this->_set_normalization_strategy( |
|
34 | - new EE_Int_Normalization( |
|
35 | - isset($input_settings['validation_error_message']) |
|
36 | - ? $input_settings['validation_error_message'] |
|
37 | - : null |
|
38 | - ) |
|
39 | - ); |
|
40 | - $this->_add_validation_strategy( |
|
41 | - new EE_Int_Validation_Strategy( |
|
42 | - isset($input_settings['validation_error_message']) |
|
43 | - ? $input_settings['validation_error_message'] |
|
44 | - : null |
|
45 | - ) |
|
46 | - ); |
|
47 | - parent::__construct($input_settings); |
|
48 | - } |
|
18 | + /** |
|
19 | + * @param array $input_settings |
|
20 | + */ |
|
21 | + public function __construct($input_settings = array()) |
|
22 | + { |
|
23 | + $this->_set_display_strategy( |
|
24 | + new EE_Number_Input_Display_Strategy( |
|
25 | + isset($input_settings['min_value']) |
|
26 | + ? $input_settings['min_value'] |
|
27 | + : null, |
|
28 | + isset($input_settings['max_value']) |
|
29 | + ? $input_settings['max_value'] |
|
30 | + : null |
|
31 | + ) |
|
32 | + ); |
|
33 | + $this->_set_normalization_strategy( |
|
34 | + new EE_Int_Normalization( |
|
35 | + isset($input_settings['validation_error_message']) |
|
36 | + ? $input_settings['validation_error_message'] |
|
37 | + : null |
|
38 | + ) |
|
39 | + ); |
|
40 | + $this->_add_validation_strategy( |
|
41 | + new EE_Int_Validation_Strategy( |
|
42 | + isset($input_settings['validation_error_message']) |
|
43 | + ? $input_settings['validation_error_message'] |
|
44 | + : null |
|
45 | + ) |
|
46 | + ); |
|
47 | + parent::__construct($input_settings); |
|
48 | + } |
|
49 | 49 | |
50 | 50 | } |
51 | 51 | // End of file EE_Integer_Input.php |
@@ -16,6 +16,6 @@ |
||
16 | 16 | $this->_set_normalization_strategy(new EE_Float_Normalization( isset( $input_settings[ 'validation_error_message' ] ) ? $input_settings[ 'validation_error_message' ] : NULL ) ); |
17 | 17 | $this->_add_validation_strategy( new EE_Float_Validation_Strategy( isset( $input_settings[ 'validation_error_message' ] ) ? $input_settings[ 'validation_error_message' ] : NULL ) ); |
18 | 18 | parent::__construct($input_settings); |
19 | - $this->_other_html_attributes .= ' step="any"'; |
|
19 | + $this->_other_html_attributes .= ' step="any"'; |
|
20 | 20 | } |
21 | 21 | } |
22 | 22 | \ No newline at end of file |
@@ -6,15 +6,15 @@ |
||
6 | 6 | * @subpackage |
7 | 7 | * @author Mike Nelson |
8 | 8 | */ |
9 | -class EE_Float_Input extends EE_Form_Input_Base{ |
|
9 | +class EE_Float_Input extends EE_Form_Input_Base { |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * @param array $input_settings |
13 | 13 | */ |
14 | - function __construct($input_settings = array()){ |
|
14 | + function __construct($input_settings = array()) { |
|
15 | 15 | $this->_set_display_strategy(new EE_Number_Input_Display_Strategy()); |
16 | - $this->_set_normalization_strategy(new EE_Float_Normalization( isset( $input_settings[ 'validation_error_message' ] ) ? $input_settings[ 'validation_error_message' ] : NULL ) ); |
|
17 | - $this->_add_validation_strategy( new EE_Float_Validation_Strategy( isset( $input_settings[ 'validation_error_message' ] ) ? $input_settings[ 'validation_error_message' ] : NULL ) ); |
|
16 | + $this->_set_normalization_strategy(new EE_Float_Normalization(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : NULL)); |
|
17 | + $this->_add_validation_strategy(new EE_Float_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : NULL)); |
|
18 | 18 | parent::__construct($input_settings); |
19 | 19 | $this->_other_html_attributes .= ' step="any"'; |
20 | 20 | } |
@@ -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 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | */ |
62 | 62 | protected function _append_chars($string = '', $chars = '-') |
63 | 63 | { |
64 | - return $this->_remove_chars($string, $chars) . $chars; |
|
64 | + return $this->_remove_chars($string, $chars).$chars; |
|
65 | 65 | } |
66 | 66 | |
67 | 67 |
@@ -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,229 +16,229 @@ discard block |
||
16 | 16 | { |
17 | 17 | |
18 | 18 | |
19 | - /** |
|
20 | - * @var string $_tag |
|
21 | - */ |
|
22 | - protected $_tag = ''; |
|
19 | + /** |
|
20 | + * @var string $_tag |
|
21 | + */ |
|
22 | + protected $_tag = ''; |
|
23 | 23 | |
24 | 24 | |
25 | 25 | |
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * returns HTML and javascript related to the displaying of this input |
|
30 | - * |
|
31 | - * @return string |
|
32 | - */ |
|
33 | - abstract public function display(); |
|
28 | + /** |
|
29 | + * returns HTML and javascript related to the displaying of this input |
|
30 | + * |
|
31 | + * @return string |
|
32 | + */ |
|
33 | + abstract public function display(); |
|
34 | 34 | |
35 | 35 | |
36 | 36 | |
37 | - /** |
|
38 | - * _remove_chars - takes an incoming string, and removes the string $chars from the end of it, but only if $chars |
|
39 | - * is already there |
|
40 | - * |
|
41 | - * @param string $string - the string being processed |
|
42 | - * @param string $chars - exact string of characters to remove |
|
43 | - * @return string |
|
44 | - */ |
|
45 | - protected function _remove_chars($string = '', $chars = '-') |
|
46 | - { |
|
47 | - $char_length = strlen($chars) * -1; |
|
48 | - // if last three characters of string is " - ", then remove it |
|
49 | - return substr($string, $char_length) === $chars ? substr($string, 0, $char_length) : $string; |
|
50 | - } |
|
37 | + /** |
|
38 | + * _remove_chars - takes an incoming string, and removes the string $chars from the end of it, but only if $chars |
|
39 | + * is already there |
|
40 | + * |
|
41 | + * @param string $string - the string being processed |
|
42 | + * @param string $chars - exact string of characters to remove |
|
43 | + * @return string |
|
44 | + */ |
|
45 | + protected function _remove_chars($string = '', $chars = '-') |
|
46 | + { |
|
47 | + $char_length = strlen($chars) * -1; |
|
48 | + // if last three characters of string is " - ", then remove it |
|
49 | + return substr($string, $char_length) === $chars ? substr($string, 0, $char_length) : $string; |
|
50 | + } |
|
51 | 51 | |
52 | 52 | |
53 | 53 | |
54 | - /** |
|
55 | - * _append_chars - takes an incoming string, and adds the string $chars to the end of it, but only if $chars is not |
|
56 | - * already there |
|
57 | - * |
|
58 | - * @param string $string - the string being processed |
|
59 | - * @param string $chars - exact string of characters to be added to end of string |
|
60 | - * @return string |
|
61 | - */ |
|
62 | - protected function _append_chars($string = '', $chars = '-') |
|
63 | - { |
|
64 | - return $this->_remove_chars($string, $chars) . $chars; |
|
65 | - } |
|
54 | + /** |
|
55 | + * _append_chars - takes an incoming string, and adds the string $chars to the end of it, but only if $chars is not |
|
56 | + * already there |
|
57 | + * |
|
58 | + * @param string $string - the string being processed |
|
59 | + * @param string $chars - exact string of characters to be added to end of string |
|
60 | + * @return string |
|
61 | + */ |
|
62 | + protected function _append_chars($string = '', $chars = '-') |
|
63 | + { |
|
64 | + return $this->_remove_chars($string, $chars) . $chars; |
|
65 | + } |
|
66 | 66 | |
67 | 67 | |
68 | - |
|
69 | - /** |
|
70 | - * Gets the HTML IDs of all the inputs |
|
71 | - * |
|
72 | - * @param bool $add_pound_sign |
|
73 | - * @return array |
|
74 | - */ |
|
75 | - public function get_html_input_ids($add_pound_sign = false) |
|
76 | - { |
|
77 | - return array($this->get_input()->html_id($add_pound_sign)); |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - |
|
82 | - /** |
|
83 | - * Adds js variables for localization to the $other_js_data. These should be put |
|
84 | - * in each form's "other_data" javascript object. |
|
85 | - * |
|
86 | - * @param array $other_js_data |
|
87 | - * @return array |
|
88 | - */ |
|
89 | - public function get_other_js_data($other_js_data = array()) |
|
90 | - { |
|
91 | - return $other_js_data; |
|
92 | - } |
|
93 | - |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * Opportunity for this display strategy to call wp_enqueue_script and wp_enqueue_style. |
|
98 | - * This should be called during wp_enqueue_scripts |
|
99 | - */ |
|
100 | - public function enqueue_js() |
|
101 | - { |
|
102 | - } |
|
103 | - |
|
104 | - |
|
105 | - |
|
106 | - /** |
|
107 | - * returns string like: '<tag' |
|
108 | - * |
|
109 | - * @param string $tag |
|
110 | - * @return string |
|
111 | - */ |
|
112 | - protected function _opening_tag($tag) |
|
113 | - { |
|
114 | - $this->_tag = $tag; |
|
115 | - return "<{$this->_tag}"; |
|
116 | - } |
|
117 | - |
|
118 | - |
|
119 | - |
|
120 | - /** |
|
121 | - * returns string like: '</tag> |
|
122 | - * |
|
123 | - * @return string |
|
124 | - */ |
|
125 | - protected function _closing_tag() |
|
126 | - { |
|
127 | - return "</{$this->_tag}>"; |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - |
|
132 | - /** |
|
133 | - * returns string like: '/>' |
|
134 | - * |
|
135 | - * @return string |
|
136 | - */ |
|
137 | - protected function _close_tag() |
|
138 | - { |
|
139 | - return '/>'; |
|
140 | - } |
|
141 | - |
|
142 | - |
|
143 | - |
|
144 | - /** |
|
145 | - * returns an array of standard HTML attributes that get added to nearly all inputs, |
|
146 | - * where string keys represent named attributes like id, class, etc |
|
147 | - * and numeric keys represent single attributes like 'required'. |
|
148 | - * Note: this does not include "value" because many inputs (like dropdowns, textareas, and checkboxes) don't use |
|
149 | - * it. |
|
150 | - * |
|
151 | - * @return array |
|
152 | - */ |
|
153 | - protected function _standard_attributes_array() |
|
154 | - { |
|
155 | - return array( |
|
156 | - 'name' => $this->_input->html_name(), |
|
157 | - 'id' => $this->_input->html_id(), |
|
158 | - 'class' => $this->_input->html_class(true), |
|
159 | - 0 => array('required', $this->_input->required()), |
|
160 | - 1 => $this->_input->other_html_attributes(), |
|
161 | - 'style' => $this->_input->html_style(), |
|
162 | - ); |
|
163 | - } |
|
164 | - |
|
165 | - |
|
166 | - |
|
167 | - /** |
|
168 | - * sets the attributes using the incoming array |
|
169 | - * and returns a string of all attributes rendered as valid HTML |
|
170 | - * |
|
171 | - * @param array $attributes |
|
172 | - * @return string |
|
173 | - */ |
|
174 | - protected function _attributes_string($attributes = array()) |
|
175 | - { |
|
176 | - $attributes = apply_filters( |
|
177 | - 'FHEE__EE_Display_Strategy_Base__attributes_string__attributes', |
|
178 | - $attributes, |
|
179 | - $this, |
|
180 | - $this->_input |
|
181 | - ); |
|
182 | - $attributes_string = ''; |
|
183 | - foreach ($attributes as $attribute => $value) { |
|
184 | - if (is_numeric($attribute)) { |
|
185 | - $add = true; |
|
186 | - if (is_array($value)) { |
|
187 | - $attribute = isset($value[0]) ? $value[0] : ''; |
|
188 | - $add = isset($value[1]) ? $value[1] : false; |
|
189 | - } else { |
|
190 | - $attribute = $value; |
|
191 | - } |
|
192 | - $attributes_string .= $this->_single_attribute($attribute, $add); |
|
193 | - } else { |
|
194 | - $attributes_string .= $this->_attribute($attribute, $value); |
|
195 | - } |
|
196 | - } |
|
197 | - return $attributes_string; |
|
198 | - } |
|
199 | - |
|
200 | - |
|
201 | - |
|
202 | - /** |
|
203 | - * returns string like: ' attribute="value"' |
|
204 | - * returns an empty string if $value is null |
|
205 | - * |
|
206 | - * @param string $attribute |
|
207 | - * @param string $value |
|
208 | - * @return string |
|
209 | - */ |
|
210 | - protected function _attribute($attribute, $value = '') |
|
211 | - { |
|
212 | - return $value !== null ? " {$attribute}=\"{$value}\"" : ''; |
|
213 | - } |
|
214 | - |
|
215 | - |
|
216 | - |
|
217 | - /** |
|
218 | - * returns string like: ' data-attribute="value"' |
|
219 | - * returns an empty string if $value is null |
|
220 | - * |
|
221 | - * @param string $attribute |
|
222 | - * @param string $value |
|
223 | - * @return string |
|
224 | - */ |
|
225 | - protected function _data_attribute($attribute, $value = '') |
|
226 | - { |
|
227 | - return $value !== null ? " data-{$attribute}=\"{$value}\"" : ''; |
|
228 | - } |
|
229 | - |
|
230 | - |
|
231 | - |
|
232 | - /** |
|
233 | - * returns string like: ' attribute' if $add is true |
|
234 | - * |
|
235 | - * @param string $attribute |
|
236 | - * @param boolean $add |
|
237 | - * @return string |
|
238 | - */ |
|
239 | - protected function _single_attribute($attribute, $add = true) |
|
240 | - { |
|
241 | - return $add ? " {$attribute}" : ''; |
|
242 | - } |
|
68 | + |
|
69 | + /** |
|
70 | + * Gets the HTML IDs of all the inputs |
|
71 | + * |
|
72 | + * @param bool $add_pound_sign |
|
73 | + * @return array |
|
74 | + */ |
|
75 | + public function get_html_input_ids($add_pound_sign = false) |
|
76 | + { |
|
77 | + return array($this->get_input()->html_id($add_pound_sign)); |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + |
|
82 | + /** |
|
83 | + * Adds js variables for localization to the $other_js_data. These should be put |
|
84 | + * in each form's "other_data" javascript object. |
|
85 | + * |
|
86 | + * @param array $other_js_data |
|
87 | + * @return array |
|
88 | + */ |
|
89 | + public function get_other_js_data($other_js_data = array()) |
|
90 | + { |
|
91 | + return $other_js_data; |
|
92 | + } |
|
93 | + |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * Opportunity for this display strategy to call wp_enqueue_script and wp_enqueue_style. |
|
98 | + * This should be called during wp_enqueue_scripts |
|
99 | + */ |
|
100 | + public function enqueue_js() |
|
101 | + { |
|
102 | + } |
|
103 | + |
|
104 | + |
|
105 | + |
|
106 | + /** |
|
107 | + * returns string like: '<tag' |
|
108 | + * |
|
109 | + * @param string $tag |
|
110 | + * @return string |
|
111 | + */ |
|
112 | + protected function _opening_tag($tag) |
|
113 | + { |
|
114 | + $this->_tag = $tag; |
|
115 | + return "<{$this->_tag}"; |
|
116 | + } |
|
117 | + |
|
118 | + |
|
119 | + |
|
120 | + /** |
|
121 | + * returns string like: '</tag> |
|
122 | + * |
|
123 | + * @return string |
|
124 | + */ |
|
125 | + protected function _closing_tag() |
|
126 | + { |
|
127 | + return "</{$this->_tag}>"; |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + |
|
132 | + /** |
|
133 | + * returns string like: '/>' |
|
134 | + * |
|
135 | + * @return string |
|
136 | + */ |
|
137 | + protected function _close_tag() |
|
138 | + { |
|
139 | + return '/>'; |
|
140 | + } |
|
141 | + |
|
142 | + |
|
143 | + |
|
144 | + /** |
|
145 | + * returns an array of standard HTML attributes that get added to nearly all inputs, |
|
146 | + * where string keys represent named attributes like id, class, etc |
|
147 | + * and numeric keys represent single attributes like 'required'. |
|
148 | + * Note: this does not include "value" because many inputs (like dropdowns, textareas, and checkboxes) don't use |
|
149 | + * it. |
|
150 | + * |
|
151 | + * @return array |
|
152 | + */ |
|
153 | + protected function _standard_attributes_array() |
|
154 | + { |
|
155 | + return array( |
|
156 | + 'name' => $this->_input->html_name(), |
|
157 | + 'id' => $this->_input->html_id(), |
|
158 | + 'class' => $this->_input->html_class(true), |
|
159 | + 0 => array('required', $this->_input->required()), |
|
160 | + 1 => $this->_input->other_html_attributes(), |
|
161 | + 'style' => $this->_input->html_style(), |
|
162 | + ); |
|
163 | + } |
|
164 | + |
|
165 | + |
|
166 | + |
|
167 | + /** |
|
168 | + * sets the attributes using the incoming array |
|
169 | + * and returns a string of all attributes rendered as valid HTML |
|
170 | + * |
|
171 | + * @param array $attributes |
|
172 | + * @return string |
|
173 | + */ |
|
174 | + protected function _attributes_string($attributes = array()) |
|
175 | + { |
|
176 | + $attributes = apply_filters( |
|
177 | + 'FHEE__EE_Display_Strategy_Base__attributes_string__attributes', |
|
178 | + $attributes, |
|
179 | + $this, |
|
180 | + $this->_input |
|
181 | + ); |
|
182 | + $attributes_string = ''; |
|
183 | + foreach ($attributes as $attribute => $value) { |
|
184 | + if (is_numeric($attribute)) { |
|
185 | + $add = true; |
|
186 | + if (is_array($value)) { |
|
187 | + $attribute = isset($value[0]) ? $value[0] : ''; |
|
188 | + $add = isset($value[1]) ? $value[1] : false; |
|
189 | + } else { |
|
190 | + $attribute = $value; |
|
191 | + } |
|
192 | + $attributes_string .= $this->_single_attribute($attribute, $add); |
|
193 | + } else { |
|
194 | + $attributes_string .= $this->_attribute($attribute, $value); |
|
195 | + } |
|
196 | + } |
|
197 | + return $attributes_string; |
|
198 | + } |
|
199 | + |
|
200 | + |
|
201 | + |
|
202 | + /** |
|
203 | + * returns string like: ' attribute="value"' |
|
204 | + * returns an empty string if $value is null |
|
205 | + * |
|
206 | + * @param string $attribute |
|
207 | + * @param string $value |
|
208 | + * @return string |
|
209 | + */ |
|
210 | + protected function _attribute($attribute, $value = '') |
|
211 | + { |
|
212 | + return $value !== null ? " {$attribute}=\"{$value}\"" : ''; |
|
213 | + } |
|
214 | + |
|
215 | + |
|
216 | + |
|
217 | + /** |
|
218 | + * returns string like: ' data-attribute="value"' |
|
219 | + * returns an empty string if $value is null |
|
220 | + * |
|
221 | + * @param string $attribute |
|
222 | + * @param string $value |
|
223 | + * @return string |
|
224 | + */ |
|
225 | + protected function _data_attribute($attribute, $value = '') |
|
226 | + { |
|
227 | + return $value !== null ? " data-{$attribute}=\"{$value}\"" : ''; |
|
228 | + } |
|
229 | + |
|
230 | + |
|
231 | + |
|
232 | + /** |
|
233 | + * returns string like: ' attribute' if $add is true |
|
234 | + * |
|
235 | + * @param string $attribute |
|
236 | + * @param boolean $add |
|
237 | + * @return string |
|
238 | + */ |
|
239 | + protected function _single_attribute($attribute, $add = true) |
|
240 | + { |
|
241 | + return $add ? " {$attribute}" : ''; |
|
242 | + } |
|
243 | 243 | |
244 | 244 | } |
245 | 245 | \ No newline at end of file |
@@ -9,40 +9,40 @@ |
||
9 | 9 | abstract class EE_Form_Input_Strategy_Base |
10 | 10 | { |
11 | 11 | |
12 | - /** |
|
13 | - * Form Input to display |
|
14 | - * |
|
15 | - * @var EE_Form_Input_Base |
|
16 | - */ |
|
17 | - protected $_input; |
|
12 | + /** |
|
13 | + * Form Input to display |
|
14 | + * |
|
15 | + * @var EE_Form_Input_Base |
|
16 | + */ |
|
17 | + protected $_input; |
|
18 | 18 | |
19 | 19 | |
20 | 20 | |
21 | - public function __construct() |
|
22 | - { |
|
23 | - } |
|
21 | + public function __construct() |
|
22 | + { |
|
23 | + } |
|
24 | 24 | |
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * The form input on which this strategy is to perform |
|
29 | - * |
|
30 | - * @param EE_Form_Input_Base $form_input |
|
31 | - */ |
|
32 | - public function _construct_finalize(EE_Form_Input_Base $form_input) |
|
33 | - { |
|
34 | - $this->_input = $form_input; |
|
35 | - } |
|
27 | + /** |
|
28 | + * The form input on which this strategy is to perform |
|
29 | + * |
|
30 | + * @param EE_Form_Input_Base $form_input |
|
31 | + */ |
|
32 | + public function _construct_finalize(EE_Form_Input_Base $form_input) |
|
33 | + { |
|
34 | + $this->_input = $form_input; |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * Gets this strategy's input |
|
41 | - * |
|
42 | - * @return EE_Form_Input_Base |
|
43 | - */ |
|
44 | - public function get_input() |
|
45 | - { |
|
46 | - return $this->_input; |
|
47 | - } |
|
39 | + /** |
|
40 | + * Gets this strategy's input |
|
41 | + * |
|
42 | + * @return EE_Form_Input_Base |
|
43 | + */ |
|
44 | + public function get_input() |
|
45 | + { |
|
46 | + return $this->_input; |
|
47 | + } |
|
48 | 48 | } |
49 | 49 | \ No newline at end of file |