@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * Event Espresso |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @subpackage includes/classes/EE_Transaction.class.php |
27 | 27 | * @author Brent Christensen |
28 | 28 | */ |
29 | -class EE_Transaction extends EE_Base_Class implements EEI_Transaction{ |
|
29 | +class EE_Transaction extends EE_Base_Class implements EEI_Transaction { |
|
30 | 30 | |
31 | 31 | |
32 | 32 | /** |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | * date_format and the second value is the time format |
39 | 39 | * @return EE_Transaction |
40 | 40 | */ |
41 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
42 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
|
43 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
41 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
42 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
43 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | * the website will be used. |
52 | 52 | * @return EE_Attendee |
53 | 53 | */ |
54 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
55 | - return new self( $props_n_values, TRUE, $timezone ); |
|
54 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
55 | + return new self($props_n_values, TRUE, $timezone); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | |
@@ -67,9 +67,9 @@ discard block |
||
67 | 67 | * @return void |
68 | 68 | */ |
69 | 69 | public function lock() { |
70 | - $locked_transactions = get_option( 'ee_locked_transactions', array() ); |
|
71 | - $locked_transactions[ $this->ID() ] = true; |
|
72 | - update_option( 'ee_locked_transactions', $locked_transactions ); |
|
70 | + $locked_transactions = get_option('ee_locked_transactions', array()); |
|
71 | + $locked_transactions[$this->ID()] = true; |
|
72 | + update_option('ee_locked_transactions', $locked_transactions); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | * @return void |
84 | 84 | */ |
85 | 85 | public function unlock() { |
86 | - $locked_transactions = get_option( 'ee_locked_transactions', array() ); |
|
87 | - unset( $locked_transactions[ $this->ID() ] ); |
|
88 | - update_option( 'ee_locked_transactions', $locked_transactions ); |
|
86 | + $locked_transactions = get_option('ee_locked_transactions', array()); |
|
87 | + unset($locked_transactions[$this->ID()]); |
|
88 | + update_option('ee_locked_transactions', $locked_transactions); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | * @return boolean |
103 | 103 | */ |
104 | 104 | public function is_locked() { |
105 | - $locked_transactions = get_option( 'ee_locked_transactions', array() ); |
|
106 | - return isset( $locked_transactions[ $this->ID() ] ) ? true : false; |
|
105 | + $locked_transactions = get_option('ee_locked_transactions', array()); |
|
106 | + return isset($locked_transactions[$this->ID()]) ? true : false; |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | * @access public |
115 | 115 | * @param float $total total value of transaction |
116 | 116 | */ |
117 | - public function set_total( $total = 0.00 ) { |
|
118 | - $this->set( 'TXN_total', $total ); |
|
117 | + public function set_total($total = 0.00) { |
|
118 | + $this->set('TXN_total', $total); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | * @access public |
127 | 127 | * @param float $total_paid total amount paid to date (sum of all payments) |
128 | 128 | */ |
129 | - public function set_paid( $total_paid = 0.00 ) { |
|
130 | - $this->set( 'TXN_paid', $total_paid ); |
|
129 | + public function set_paid($total_paid = 0.00) { |
|
130 | + $this->set('TXN_paid', $total_paid); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | |
@@ -138,8 +138,8 @@ discard block |
||
138 | 138 | * @access public |
139 | 139 | * @param string $status whether the transaction is open, declined, accepted, or any number of custom values that can be set |
140 | 140 | */ |
141 | - public function set_status( $status = '' ) { |
|
142 | - $this->set( 'STS_ID', $status ); |
|
141 | + public function set_status($status = '') { |
|
142 | + $this->set('STS_ID', $status); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | |
@@ -150,8 +150,8 @@ discard block |
||
150 | 150 | * @access public |
151 | 151 | * @param string $hash_salt required for some payment gateways |
152 | 152 | */ |
153 | - public function set_hash_salt( $hash_salt = '' ) { |
|
154 | - $this->set( 'TXN_hash_salt', $hash_salt ); |
|
153 | + public function set_hash_salt($hash_salt = '') { |
|
154 | + $this->set('TXN_hash_salt', $hash_salt); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | |
@@ -160,8 +160,8 @@ discard block |
||
160 | 160 | * Sets TXN_reg_steps array |
161 | 161 | * @param array $txn_reg_steps |
162 | 162 | */ |
163 | - function set_reg_steps( $txn_reg_steps ) { |
|
164 | - $this->set( 'TXN_reg_steps', $txn_reg_steps ); |
|
163 | + function set_reg_steps($txn_reg_steps) { |
|
164 | + $this->set('TXN_reg_steps', $txn_reg_steps); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | |
@@ -171,8 +171,8 @@ discard block |
||
171 | 171 | * @return array |
172 | 172 | */ |
173 | 173 | function reg_steps() { |
174 | - $TXN_reg_steps = $this->get( 'TXN_reg_steps' ); |
|
175 | - return is_array( $TXN_reg_steps ) ? $TXN_reg_steps : array(); |
|
174 | + $TXN_reg_steps = $this->get('TXN_reg_steps'); |
|
175 | + return is_array($TXN_reg_steps) ? $TXN_reg_steps : array(); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * @return string of transaction's total cost, with currency symbol and decimal |
183 | 183 | */ |
184 | 184 | public function pretty_total() { |
185 | - return $this->get_pretty( 'TXN_total' ); |
|
185 | + return $this->get_pretty('TXN_total'); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * @return string |
193 | 193 | */ |
194 | 194 | public function pretty_paid() { |
195 | - return $this->get_pretty( 'TXN_paid' ); |
|
195 | + return $this->get_pretty('TXN_paid'); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | * @return float amount remaining |
205 | 205 | */ |
206 | 206 | public function remaining() { |
207 | - return (float)( $this->total() - $this->paid() ); |
|
207 | + return (float) ($this->total() - $this->paid()); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * @return float |
216 | 216 | */ |
217 | 217 | public function total() { |
218 | - return $this->get( 'TXN_total' ); |
|
218 | + return $this->get('TXN_total'); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | * @return float |
227 | 227 | */ |
228 | 228 | public function paid() { |
229 | - return $this->get( 'TXN_paid' ); |
|
229 | + return $this->get('TXN_paid'); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | |
@@ -236,8 +236,8 @@ discard block |
||
236 | 236 | * @access public |
237 | 237 | */ |
238 | 238 | public function get_cart_session() { |
239 | - $session_data = $this->get( 'TXN_session_data' ); |
|
240 | - return isset( $session_data[ 'cart' ] ) && $session_data[ 'cart' ] instanceof EE_Cart ? $session_data[ 'cart' ] : NULL; |
|
239 | + $session_data = $this->get('TXN_session_data'); |
|
240 | + return isset($session_data['cart']) && $session_data['cart'] instanceof EE_Cart ? $session_data['cart'] : NULL; |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | |
@@ -247,9 +247,9 @@ discard block |
||
247 | 247 | * @access public |
248 | 248 | */ |
249 | 249 | public function session_data() { |
250 | - $session_data = $this->get( 'TXN_session_data' ); |
|
251 | - if ( empty( $session_data ) ) { |
|
252 | - $session_data = array( 'id' => NULL, 'user_id' => NULL, 'ip_address' => NULL, 'user_agent' => NULL, 'init_access' => NULL, 'last_access' => NULL, 'pages_visited' => array() ); |
|
250 | + $session_data = $this->get('TXN_session_data'); |
|
251 | + if (empty($session_data)) { |
|
252 | + $session_data = array('id' => NULL, 'user_id' => NULL, 'ip_address' => NULL, 'user_agent' => NULL, 'init_access' => NULL, 'last_access' => NULL, 'pages_visited' => array()); |
|
253 | 253 | } |
254 | 254 | return $session_data; |
255 | 255 | } |
@@ -262,11 +262,11 @@ discard block |
||
262 | 262 | * @access public |
263 | 263 | * @param EE_Session|array $session_data |
264 | 264 | */ |
265 | - public function set_txn_session_data( $session_data ) { |
|
266 | - if ( $session_data instanceof EE_Session ) { |
|
267 | - $this->set( 'TXN_session_data', $session_data->get_session_data( NULL, TRUE )); |
|
265 | + public function set_txn_session_data($session_data) { |
|
266 | + if ($session_data instanceof EE_Session) { |
|
267 | + $this->set('TXN_session_data', $session_data->get_session_data(NULL, TRUE)); |
|
268 | 268 | } else { |
269 | - $this->set( 'TXN_session_data', $session_data ); |
|
269 | + $this->set('TXN_session_data', $session_data); |
|
270 | 270 | } |
271 | 271 | } |
272 | 272 | |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | * @access public |
278 | 278 | */ |
279 | 279 | public function hash_salt_() { |
280 | - return $this->get( 'TXN_hash_salt' ); |
|
280 | + return $this->get('TXN_hash_salt'); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | |
@@ -297,13 +297,13 @@ discard block |
||
297 | 297 | * @param boolean $gmt - whether to return a unix timestamp with UTC offset applied (default) or no UTC offset applied |
298 | 298 | * @return string | int |
299 | 299 | */ |
300 | - public function datetime( $format = FALSE, $gmt = FALSE ) { |
|
301 | - if ( $format ) { |
|
302 | - return $this->get_pretty( 'TXN_timestamp' ); |
|
303 | - } else if ( $gmt ) { |
|
304 | - return $this->get_raw( 'TXN_timestamp' ); |
|
300 | + public function datetime($format = FALSE, $gmt = FALSE) { |
|
301 | + if ($format) { |
|
302 | + return $this->get_pretty('TXN_timestamp'); |
|
303 | + } else if ($gmt) { |
|
304 | + return $this->get_raw('TXN_timestamp'); |
|
305 | 305 | } else { |
306 | - return $this->get( 'TXN_timestamp' ); |
|
306 | + return $this->get('TXN_timestamp'); |
|
307 | 307 | } |
308 | 308 | } |
309 | 309 | |
@@ -315,10 +315,10 @@ discard block |
||
315 | 315 | * @param boolean $get_cached TRUE to retrieve cached registrations or FALSE to pull from the db |
316 | 316 | * @return EE_Registration[] |
317 | 317 | */ |
318 | - public function registrations( $query_params = array(), $get_cached = FALSE ) { |
|
319 | - $query_params = ( empty( $query_params ) || ! is_array( $query_params ) ) ? array( 'order_by' => array( 'Event.EVT_name' => 'ASC', 'Attendee.ATT_lname' => 'ASC', 'Attendee.ATT_fname' => 'ASC' ) ) : $query_params; |
|
318 | + public function registrations($query_params = array(), $get_cached = FALSE) { |
|
319 | + $query_params = (empty($query_params) || ! is_array($query_params)) ? array('order_by' => array('Event.EVT_name' => 'ASC', 'Attendee.ATT_lname' => 'ASC', 'Attendee.ATT_fname' => 'ASC')) : $query_params; |
|
320 | 320 | $query_params = $get_cached ? array() : $query_params; |
321 | - return $this->get_many_related( 'Registration', $query_params ); |
|
321 | + return $this->get_many_related('Registration', $query_params); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | * @return mixed EE_Attendee[] by default, int if $output is set to 'COUNT' |
330 | 330 | */ |
331 | 331 | public function attendees() { |
332 | - return $this->get_many_related( 'Attendee', array( array( 'Registration.Transaction.TXN_ID' => $this->ID() ) ) ); |
|
332 | + return $this->get_many_related('Attendee', array(array('Registration.Transaction.TXN_ID' => $this->ID()))); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | |
@@ -339,8 +339,8 @@ discard block |
||
339 | 339 | * @param array $query_params like EEM_Base::get_all |
340 | 340 | * @return EE_Payment[] |
341 | 341 | */ |
342 | - public function payments( $query_params = array() ) { |
|
343 | - return $this->get_many_related( 'Payment', $query_params ); |
|
342 | + public function payments($query_params = array()) { |
|
343 | + return $this->get_many_related('Payment', $query_params); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | |
@@ -350,8 +350,8 @@ discard block |
||
350 | 350 | * @return EE_Payment[] |
351 | 351 | */ |
352 | 352 | public function approved_payments() { |
353 | - EE_Registry::instance()->load_model( 'Payment' ); |
|
354 | - return $this->get_many_related( 'Payment', array( array( 'STS_ID' => EEM_Payment::status_id_approved ), 'order_by' => array( 'PAY_timestamp' => 'DESC' ) ) ); |
|
353 | + EE_Registry::instance()->load_model('Payment'); |
|
354 | + return $this->get_many_related('Payment', array(array('STS_ID' => EEM_Payment::status_id_approved), 'order_by' => array('PAY_timestamp' => 'DESC'))); |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | |
@@ -361,8 +361,8 @@ discard block |
||
361 | 361 | * @param bool $show_icons |
362 | 362 | * @return string |
363 | 363 | */ |
364 | - public function e_pretty_status( $show_icons = FALSE ) { |
|
365 | - echo $this->pretty_status( $show_icons ); |
|
364 | + public function e_pretty_status($show_icons = FALSE) { |
|
365 | + echo $this->pretty_status($show_icons); |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | |
@@ -372,10 +372,10 @@ discard block |
||
372 | 372 | * @param bool $show_icons |
373 | 373 | * @return string |
374 | 374 | */ |
375 | - public function pretty_status( $show_icons = FALSE ) { |
|
376 | - $status = EEM_Status::instance()->localized_status( array( $this->status_ID() => __( 'unknown', 'event_espresso' ) ), FALSE, 'sentence' ); |
|
375 | + public function pretty_status($show_icons = FALSE) { |
|
376 | + $status = EEM_Status::instance()->localized_status(array($this->status_ID() => __('unknown', 'event_espresso')), FALSE, 'sentence'); |
|
377 | 377 | $icon = ''; |
378 | - switch ( $this->status_ID() ) { |
|
378 | + switch ($this->status_ID()) { |
|
379 | 379 | case EEM_Transaction::complete_status_code: |
380 | 380 | $icon = $show_icons ? '<span class="dashicons dashicons-yes ee-icon-size-24 green-text"></span>' : ''; |
381 | 381 | break; |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | $icon = $show_icons ? '<span class="dashicons dashicons-plus ee-icon-size-16 orange-text"></span>' : ''; |
393 | 393 | break; |
394 | 394 | } |
395 | - return $icon . $status[ $this->status_ID() ]; |
|
395 | + return $icon.$status[$this->status_ID()]; |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | * @access public |
403 | 403 | */ |
404 | 404 | public function status_ID() { |
405 | - return $this->get( 'STS_ID' ); |
|
405 | + return $this->get('STS_ID'); |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | * @return boolean |
413 | 413 | */ |
414 | 414 | public function is_free() { |
415 | - return (float)$this->get( 'TXN_total' ) == 0 ? TRUE : FALSE; |
|
415 | + return (float) $this->get('TXN_total') == 0 ? TRUE : FALSE; |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | |
@@ -480,12 +480,12 @@ discard block |
||
480 | 480 | * @access public |
481 | 481 | * @return string |
482 | 482 | */ |
483 | - public function invoice_url( $type = 'html' ) { |
|
483 | + public function invoice_url($type = 'html') { |
|
484 | 484 | $REG = $this->primary_registration(); |
485 | - if ( ! $REG instanceof EE_Registration ) { |
|
485 | + if ( ! $REG instanceof EE_Registration) { |
|
486 | 486 | return ''; |
487 | 487 | } |
488 | - return $REG->invoice_url( $type ); |
|
488 | + return $REG->invoice_url($type); |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | * @return EE_Registration |
496 | 496 | */ |
497 | 497 | public function primary_registration() { |
498 | - return $this->get_first_related( 'Registration', array( array( 'REG_count' => EEM_Registration::PRIMARY_REGISTRANT_COUNT ) ) ); |
|
498 | + return $this->get_first_related('Registration', array(array('REG_count' => EEM_Registration::PRIMARY_REGISTRANT_COUNT))); |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | |
@@ -505,12 +505,12 @@ discard block |
||
505 | 505 | * @param string $type 'pdf' or 'html' (default is 'html') |
506 | 506 | * @return string |
507 | 507 | */ |
508 | - public function receipt_url( $type = 'html' ) { |
|
508 | + public function receipt_url($type = 'html') { |
|
509 | 509 | $REG = $this->primary_registration(); |
510 | - if ( ! $REG instanceof EE_Registration ) { |
|
510 | + if ( ! $REG instanceof EE_Registration) { |
|
511 | 511 | return ''; |
512 | 512 | } |
513 | - return $REG->receipt_url( $type ); |
|
513 | + return $REG->receipt_url($type); |
|
514 | 514 | } |
515 | 515 | |
516 | 516 | |
@@ -535,15 +535,15 @@ discard block |
||
535 | 535 | * @deprecated |
536 | 536 | * @return boolean |
537 | 537 | */ |
538 | - public function update_based_on_payments(){ |
|
538 | + public function update_based_on_payments() { |
|
539 | 539 | EE_Error::doing_it_wrong( |
540 | - __CLASS__ . '::' . __FUNCTION__, |
|
541 | - sprintf( __( 'This method is deprecated. Please use "%s" instead', 'event_espresso' ), 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()' ), |
|
540 | + __CLASS__.'::'.__FUNCTION__, |
|
541 | + sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'), |
|
542 | 542 | '4.6.0' |
543 | 543 | ); |
544 | 544 | /** @type EE_Transaction_Processor $transaction_processor */ |
545 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
546 | - return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( $this ); |
|
545 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
546 | + return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment($this); |
|
547 | 547 | } |
548 | 548 | |
549 | 549 | |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | * @return string |
553 | 553 | */ |
554 | 554 | public function gateway_response_on_transaction() { |
555 | - $payment = $this->get_first_related( 'Payment' ); |
|
555 | + $payment = $this->get_first_related('Payment'); |
|
556 | 556 | return $payment instanceof EE_Payment ? $payment->gateway_response() : ''; |
557 | 557 | } |
558 | 558 | |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | * @return EE_Status |
564 | 564 | */ |
565 | 565 | public function status_obj() { |
566 | - return $this->get_first_related( 'Status' ); |
|
566 | + return $this->get_first_related('Status'); |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | |
@@ -573,8 +573,8 @@ discard block |
||
573 | 573 | * @param array $query_params like EEM_Base::get_all |
574 | 574 | * @return EE_Extra_Meta |
575 | 575 | */ |
576 | - public function extra_meta( $query_params = array() ) { |
|
577 | - return $this->get_many_related( 'Extra_Meta', $query_params ); |
|
576 | + public function extra_meta($query_params = array()) { |
|
577 | + return $this->get_many_related('Extra_Meta', $query_params); |
|
578 | 578 | } |
579 | 579 | |
580 | 580 | |
@@ -584,8 +584,8 @@ discard block |
||
584 | 584 | * @param EE_Registration $registration |
585 | 585 | * @return EE_Base_Class the relation was added to |
586 | 586 | */ |
587 | - public function add_registration( EE_Registration $registration ) { |
|
588 | - return $this->_add_relation_to( $registration, 'Registration' ); |
|
587 | + public function add_registration(EE_Registration $registration) { |
|
588 | + return $this->_add_relation_to($registration, 'Registration'); |
|
589 | 589 | } |
590 | 590 | |
591 | 591 | |
@@ -596,8 +596,8 @@ discard block |
||
596 | 596 | * @param int $registration_or_id |
597 | 597 | * @return EE_Base_Class that was removed from being related |
598 | 598 | */ |
599 | - public function remove_registration_with_id( $registration_or_id ) { |
|
600 | - return $this->_remove_relation_to( $registration_or_id, 'Registration' ); |
|
599 | + public function remove_registration_with_id($registration_or_id) { |
|
600 | + return $this->_remove_relation_to($registration_or_id, 'Registration'); |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | * @return EE_Line_Item[] |
608 | 608 | */ |
609 | 609 | public function items_purchased() { |
610 | - return $this->line_items( array( array( 'LIN_type' => EEM_Line_Item::type_line_item ) ) ); |
|
610 | + return $this->line_items(array(array('LIN_type' => EEM_Line_Item::type_line_item))); |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | |
@@ -617,8 +617,8 @@ discard block |
||
617 | 617 | * @param EE_Line_Item $line_item |
618 | 618 | * @return EE_Base_Class the relation was added to |
619 | 619 | */ |
620 | - public function add_line_item( EE_Line_Item $line_item ) { |
|
621 | - return $this->_add_relation_to( $line_item, 'Line_Item' ); |
|
620 | + public function add_line_item(EE_Line_Item $line_item) { |
|
621 | + return $this->_add_relation_to($line_item, 'Line_Item'); |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | |
@@ -628,8 +628,8 @@ discard block |
||
628 | 628 | * @param array $query_params |
629 | 629 | * @return EE_Line_Item[] |
630 | 630 | */ |
631 | - public function line_items( $query_params = array() ) { |
|
632 | - return $this->get_many_related( 'Line_Item', $query_params ); |
|
631 | + public function line_items($query_params = array()) { |
|
632 | + return $this->get_many_related('Line_Item', $query_params); |
|
633 | 633 | } |
634 | 634 | |
635 | 635 | |
@@ -639,7 +639,7 @@ discard block |
||
639 | 639 | * @return EE_Line_Item[] |
640 | 640 | */ |
641 | 641 | public function tax_items() { |
642 | - return $this->line_items( array( array( 'LIN_type' => EEM_Line_Item::type_tax ) ) ); |
|
642 | + return $this->line_items(array(array('LIN_type' => EEM_Line_Item::type_tax))); |
|
643 | 643 | } |
644 | 644 | |
645 | 645 | |
@@ -650,10 +650,10 @@ discard block |
||
650 | 650 | * @return EE_Line_Item |
651 | 651 | */ |
652 | 652 | public function total_line_item() { |
653 | - $item = $this->get_first_related( 'Line_Item', array( array( 'LIN_type' => EEM_Line_Item::type_total ) ) ); |
|
654 | - if( ! $item ){ |
|
655 | - EE_Registry::instance()->load_helper( 'Line_Item' ); |
|
656 | - $item = EEH_Line_Item::create_total_line_item( $this ); |
|
653 | + $item = $this->get_first_related('Line_Item', array(array('LIN_type' => EEM_Line_Item::type_total))); |
|
654 | + if ( ! $item) { |
|
655 | + EE_Registry::instance()->load_helper('Line_Item'); |
|
656 | + $item = EEH_Line_Item::create_total_line_item($this); |
|
657 | 657 | } |
658 | 658 | return $item; |
659 | 659 | } |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | */ |
668 | 668 | public function tax_total() { |
669 | 669 | $tax_line_item = $this->tax_total_line_item(); |
670 | - if ( $tax_line_item ) { |
|
670 | + if ($tax_line_item) { |
|
671 | 671 | return $tax_line_item->total(); |
672 | 672 | } else { |
673 | 673 | return 0; |
@@ -681,7 +681,7 @@ discard block |
||
681 | 681 | * @return EE_Line_Item |
682 | 682 | */ |
683 | 683 | public function tax_total_line_item() { |
684 | - return EEH_Line_Item::get_taxes_subtotal( $this->total_line_item() ); |
|
684 | + return EEH_Line_Item::get_taxes_subtotal($this->total_line_item()); |
|
685 | 685 | } |
686 | 686 | |
687 | 687 | |
@@ -690,20 +690,20 @@ discard block |
||
690 | 690 | * Gets the array of billing info for the gateway and for this transaction's primary registration's attendee. |
691 | 691 | * @return EE_Form_Section_Proper |
692 | 692 | */ |
693 | - public function billing_info(){ |
|
693 | + public function billing_info() { |
|
694 | 694 | $payment_method = $this->payment_method(); |
695 | - if ( !$payment_method){ |
|
695 | + if ( ! $payment_method) { |
|
696 | 696 | EE_Error::add_error(__("Could not find billing info for transaction because no gateway has been used for it yet", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
697 | 697 | return false; |
698 | 698 | } |
699 | 699 | $primary_reg = $this->primary_registration(); |
700 | - if ( ! $primary_reg ) { |
|
701 | - EE_Error::add_error( __( "Cannot get billing info for gateway %s on transaction because no primary registration exists", "event_espresso" ), __FILE__, __FUNCTION__, __LINE__ ); |
|
700 | + if ( ! $primary_reg) { |
|
701 | + EE_Error::add_error(__("Cannot get billing info for gateway %s on transaction because no primary registration exists", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
|
702 | 702 | return FALSE; |
703 | 703 | } |
704 | 704 | $attendee = $primary_reg->attendee(); |
705 | - if ( ! $attendee ) { |
|
706 | - EE_Error::add_error( __( "Cannot get billing info for gateway %s on transaction because the primary registration has no attendee exists", "event_espresso" ), __FILE__, __FUNCTION__, __LINE__ ); |
|
705 | + if ( ! $attendee) { |
|
706 | + EE_Error::add_error(__("Cannot get billing info for gateway %s on transaction because the primary registration has no attendee exists", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
|
707 | 707 | return FALSE; |
708 | 708 | } |
709 | 709 | return $attendee->billing_info_for_payment_method($payment_method); |
@@ -738,15 +738,15 @@ discard block |
||
738 | 738 | * offline ones, dont' create payments) |
739 | 739 | * @return EE_Payment_Method |
740 | 740 | */ |
741 | - function payment_method(){ |
|
741 | + function payment_method() { |
|
742 | 742 | $pm = $this->get_first_related('Payment_Method'); |
743 | - if( $pm instanceof EE_Payment_Method ){ |
|
743 | + if ($pm instanceof EE_Payment_Method) { |
|
744 | 744 | return $pm; |
745 | - }else{ |
|
745 | + } else { |
|
746 | 746 | $last_payment = $this->last_payment(); |
747 | - if( $last_payment instanceof EE_Payment && $last_payment->payment_method() ){ |
|
747 | + if ($last_payment instanceof EE_Payment && $last_payment->payment_method()) { |
|
748 | 748 | return $last_payment->payment_method(); |
749 | - }else{ |
|
749 | + } else { |
|
750 | 750 | return NULL; |
751 | 751 | } |
752 | 752 | } |
@@ -757,15 +757,15 @@ discard block |
||
757 | 757 | * @return EE_Payment |
758 | 758 | */ |
759 | 759 | public function last_payment() { |
760 | - return $this->get_first_related( 'Payment', array( 'order_by' => array( 'PAY_ID' => 'desc' ) ) ); |
|
760 | + return $this->get_first_related('Payment', array('order_by' => array('PAY_ID' => 'desc'))); |
|
761 | 761 | } |
762 | 762 | |
763 | 763 | /** |
764 | 764 | * Gets all the line items which are unrelated to tickets on this transaction |
765 | 765 | * @return EE_Line_Item[] |
766 | 766 | */ |
767 | - public function non_ticket_line_items(){ |
|
768 | - return EEM_Line_Item::instance()->get_all_non_ticket_line_items_for_transaction( $this->ID() ); |
|
767 | + public function non_ticket_line_items() { |
|
768 | + return EEM_Line_Item::instance()->get_all_non_ticket_line_items_for_transaction($this->ID()); |
|
769 | 769 | } |
770 | 770 | |
771 | 771 |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * Event Espresso |
@@ -37,9 +37,9 @@ discard block |
||
37 | 37 | * date_format and the second value is the time format |
38 | 38 | * @return EE_Attendee |
39 | 39 | */ |
40 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
41 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
|
42 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
40 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
41 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
42 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | * the website will be used. |
51 | 51 | * @return EE_Attendee |
52 | 52 | */ |
53 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
54 | - return new self( $props_n_values, TRUE, $timezone ); |
|
53 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
54 | + return new self($props_n_values, TRUE, $timezone); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * @return string |
62 | 62 | */ |
63 | 63 | function name() { |
64 | - return $this->get( 'VNU_name' ); |
|
64 | + return $this->get('VNU_name'); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @return string |
71 | 71 | */ |
72 | 72 | function phone() { |
73 | - return $this->get( 'VNU_phone' ); |
|
73 | + return $this->get('VNU_phone'); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @return string |
81 | 81 | */ |
82 | 82 | function venue_url() { |
83 | - return $this->get( 'VNU_url' ); |
|
83 | + return $this->get('VNU_url'); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * @return string |
90 | 90 | */ |
91 | 91 | function description() { |
92 | - return $this->get( 'VNU_desc' ); |
|
92 | + return $this->get('VNU_desc'); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @return string |
100 | 100 | */ |
101 | 101 | function excerpt() { |
102 | - return $this->get( 'VNU_short_desc' ); |
|
102 | + return $this->get('VNU_short_desc'); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @return string |
110 | 110 | */ |
111 | 111 | function identifier() { |
112 | - return $this->get( 'VNU_identifier' ); |
|
112 | + return $this->get('VNU_identifier'); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @return string |
120 | 120 | */ |
121 | 121 | function address() { |
122 | - return $this->get( 'VNU_address' ); |
|
122 | + return $this->get('VNU_address'); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * @return string |
130 | 130 | */ |
131 | 131 | function address2() { |
132 | - return $this->get( 'VNU_address2' ); |
|
132 | + return $this->get('VNU_address2'); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @return string |
141 | 141 | */ |
142 | 142 | function city() { |
143 | - return $this->get( 'VNU_city' ); |
|
143 | + return $this->get('VNU_city'); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * @return int |
149 | 149 | */ |
150 | 150 | function state_ID() { |
151 | - return $this->get( 'STA_ID' ); |
|
151 | + return $this->get('STA_ID'); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @return string |
158 | 158 | */ |
159 | 159 | public function state_abbrev() { |
160 | - return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : __( 'Unknown', 'event_espresso' ); |
|
160 | + return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : __('Unknown', 'event_espresso'); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * @return string |
167 | 167 | */ |
168 | 168 | public function state_name() { |
169 | - return $this->state_obj() instanceof EE_State ? $this->state_obj()->name() : __( 'Unknown', 'event_espresso' ); |
|
169 | + return $this->state_obj() instanceof EE_State ? $this->state_obj()->name() : __('Unknown', 'event_espresso'); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * @return EE_State |
177 | 177 | */ |
178 | 178 | function state_obj() { |
179 | - return $this->get_first_related( 'State' ); |
|
179 | + return $this->get_first_related('State'); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | * @return string |
189 | 189 | */ |
190 | 190 | public function state() { |
191 | - if ( apply_filters( 'FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj() ) ) { |
|
191 | + if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) { |
|
192 | 192 | return $this->state_abbrev(); |
193 | 193 | } else { |
194 | 194 | return $this->state_name(); |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * @return string |
203 | 203 | */ |
204 | 204 | function country_ID() { |
205 | - return $this->get( 'CNT_ISO' ); |
|
205 | + return $this->get('CNT_ISO'); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | * @return string |
212 | 212 | */ |
213 | 213 | public function country_name() { |
214 | - return $this->country_obj() instanceof EE_Country ? $this->country_obj()->name() : __( 'Unknown', 'event_espresso' ); |
|
214 | + return $this->country_obj() instanceof EE_Country ? $this->country_obj()->name() : __('Unknown', 'event_espresso'); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * @return EE_Country |
222 | 222 | */ |
223 | 223 | function country_obj() { |
224 | - return $this->get_first_related( 'Country' ); |
|
224 | + return $this->get_first_related('Country'); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | * @return string |
234 | 234 | */ |
235 | 235 | public function country() { |
236 | - if ( apply_filters( 'FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj() ) ) { |
|
236 | + if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) { |
|
237 | 237 | return $this->country_ID(); |
238 | 238 | } else { |
239 | 239 | return $this->country_name(); |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | * @return string |
248 | 248 | */ |
249 | 249 | function zip() { |
250 | - return $this->get( 'VNU_zip' ); |
|
250 | + return $this->get('VNU_zip'); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * @return int |
258 | 258 | */ |
259 | 259 | function capacity() { |
260 | - return $this->get_pretty( 'VNU_capacity', 'symbol' ); |
|
260 | + return $this->get_pretty('VNU_capacity', 'symbol'); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | * @return string |
268 | 268 | */ |
269 | 269 | function created() { |
270 | - return $this->get( 'VNU_created' ); |
|
270 | + return $this->get('VNU_created'); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | * @return string |
278 | 278 | */ |
279 | 279 | function modified() { |
280 | - return $this->get( 'VNU_modified' ); |
|
280 | + return $this->get('VNU_modified'); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | * @return int |
288 | 288 | */ |
289 | 289 | function order() { |
290 | - return $this->get( 'VNU_order' ); |
|
290 | + return $this->get('VNU_order'); |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | * @return int |
298 | 298 | */ |
299 | 299 | function wp_user() { |
300 | - return $this->get( 'VNU_wp_user' ); |
|
300 | + return $this->get('VNU_wp_user'); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | * @return string |
307 | 307 | */ |
308 | 308 | function virtual_phone() { |
309 | - return $this->get( 'VNU_virtual_phone' ); |
|
309 | + return $this->get('VNU_virtual_phone'); |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * @return string |
316 | 316 | */ |
317 | 317 | function virtual_url() { |
318 | - return $this->get( 'VNU_virtual_url' ); |
|
318 | + return $this->get('VNU_virtual_url'); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | * @return bool |
325 | 325 | */ |
326 | 326 | function enable_for_gmap() { |
327 | - return $this->get( 'VNU_enable_for_gmap' ); |
|
327 | + return $this->get('VNU_enable_for_gmap'); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | * @return string |
334 | 334 | */ |
335 | 335 | function google_map_link() { |
336 | - return $this->get( 'VNU_google_map_link' ); |
|
336 | + return $this->get('VNU_google_map_link'); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | |
@@ -345,16 +345,16 @@ discard block |
||
345 | 345 | * @param bool $upcoming |
346 | 346 | * @return EE_Event[] |
347 | 347 | */ |
348 | - function events( $query_params = array(), $upcoming = FALSE ) { |
|
349 | - if ( $upcoming ) { |
|
348 | + function events($query_params = array(), $upcoming = FALSE) { |
|
349 | + if ($upcoming) { |
|
350 | 350 | $query_params = array( |
351 | 351 | array( |
352 | 352 | 'status' => 'publish', |
353 | - 'Datetime.DTT_EVT_start' => array( '>', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_start' ) ) |
|
353 | + 'Datetime.DTT_EVT_start' => array('>', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start')) |
|
354 | 354 | ) |
355 | 355 | ); |
356 | 356 | } |
357 | - return $this->get_many_related( 'Event', $query_params ); |
|
357 | + return $this->get_many_related('Event', $query_params); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | |
@@ -372,8 +372,8 @@ discard block |
||
372 | 372 | /** |
373 | 373 | * Sets address |
374 | 374 | */ |
375 | - function set_address( $address = '' ) { |
|
376 | - $this->set( 'VNU_address', $address ); |
|
375 | + function set_address($address = '') { |
|
376 | + $this->set('VNU_address', $address); |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | |
@@ -381,8 +381,8 @@ discard block |
||
381 | 381 | /** |
382 | 382 | * @param string $address2 |
383 | 383 | */ |
384 | - function set_address2( $address2 = '' ) { |
|
385 | - $this->set( 'VNU_address2', $address2 ); |
|
384 | + function set_address2($address2 = '') { |
|
385 | + $this->set('VNU_address2', $address2); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | |
@@ -390,8 +390,8 @@ discard block |
||
390 | 390 | /** |
391 | 391 | * @param string $city |
392 | 392 | */ |
393 | - function set_city( $city = '' ) { |
|
394 | - $this->set( 'VNU_city', $city ); |
|
393 | + function set_city($city = '') { |
|
394 | + $this->set('VNU_city', $city); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | |
@@ -399,8 +399,8 @@ discard block |
||
399 | 399 | /** |
400 | 400 | * @param int $state |
401 | 401 | */ |
402 | - function set_state_ID( $state = 0 ) { |
|
403 | - $this->set( 'STA_ID', $state ); |
|
402 | + function set_state_ID($state = 0) { |
|
403 | + $this->set('STA_ID', $state); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | |
@@ -411,8 +411,8 @@ discard block |
||
411 | 411 | * @param EE_State /int $state_id_or_obj |
412 | 412 | * @return EE_State |
413 | 413 | */ |
414 | - function set_state_obj( $state_id_or_obj ) { |
|
415 | - return $this->_add_relation_to( $state_id_or_obj, 'State' ); |
|
414 | + function set_state_obj($state_id_or_obj) { |
|
415 | + return $this->_add_relation_to($state_id_or_obj, 'State'); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | |
@@ -420,8 +420,8 @@ discard block |
||
420 | 420 | /** |
421 | 421 | * @param int $country_ID |
422 | 422 | */ |
423 | - function set_country_ID( $country_ID = 0 ) { |
|
424 | - $this->set( 'CNT_ISO', $country_ID ); |
|
423 | + function set_country_ID($country_ID = 0) { |
|
424 | + $this->set('CNT_ISO', $country_ID); |
|
425 | 425 | } |
426 | 426 | |
427 | 427 | |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | * @param EE_Country /string $country_id_or_obj |
431 | 431 | * @return EE_Country |
432 | 432 | */ |
433 | - function set_country_obj( $country_id_or_obj ) { |
|
433 | + function set_country_obj($country_id_or_obj) { |
|
434 | 434 | return $this->_add_relation_to($country_id_or_obj, 'Country'); |
435 | 435 | } |
436 | 436 | |
@@ -439,8 +439,8 @@ discard block |
||
439 | 439 | /** |
440 | 440 | * @param string $zip |
441 | 441 | */ |
442 | - function set_zip( $zip = '' ) { |
|
443 | - $this->set( 'VNU_zip', $zip ); |
|
442 | + function set_zip($zip = '') { |
|
443 | + $this->set('VNU_zip', $zip); |
|
444 | 444 | } |
445 | 445 | |
446 | 446 | |
@@ -448,8 +448,8 @@ discard block |
||
448 | 448 | /** |
449 | 449 | * @param int $capacity |
450 | 450 | */ |
451 | - function set_capacity( $capacity = 0 ) { |
|
452 | - $this->set( 'VNU_capacity', $capacity ); |
|
451 | + function set_capacity($capacity = 0) { |
|
452 | + $this->set('VNU_capacity', $capacity); |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | |
@@ -457,8 +457,8 @@ discard block |
||
457 | 457 | /** |
458 | 458 | * @param string $created |
459 | 459 | */ |
460 | - function set_created( $created = '' ) { |
|
461 | - $this->set( 'VNU_created', $created ); |
|
460 | + function set_created($created = '') { |
|
461 | + $this->set('VNU_created', $created); |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | |
@@ -466,8 +466,8 @@ discard block |
||
466 | 466 | /** |
467 | 467 | * @param string $desc |
468 | 468 | */ |
469 | - function set_description( $desc = '' ) { |
|
470 | - $this->set( 'VNU_desc', $desc ); |
|
469 | + function set_description($desc = '') { |
|
470 | + $this->set('VNU_desc', $desc); |
|
471 | 471 | } |
472 | 472 | |
473 | 473 | |
@@ -475,8 +475,8 @@ discard block |
||
475 | 475 | /** |
476 | 476 | * @param string $identifier |
477 | 477 | */ |
478 | - function set_identifier( $identifier = '' ) { |
|
479 | - $this->set( 'VNU_identifier', $identifier ); |
|
478 | + function set_identifier($identifier = '') { |
|
479 | + $this->set('VNU_identifier', $identifier); |
|
480 | 480 | } |
481 | 481 | |
482 | 482 | |
@@ -484,8 +484,8 @@ discard block |
||
484 | 484 | /** |
485 | 485 | * @param string $modified |
486 | 486 | */ |
487 | - function set_modified( $modified = '' ) { |
|
488 | - $this->set( 'VNU_modified', $modified ); |
|
487 | + function set_modified($modified = '') { |
|
488 | + $this->set('VNU_modified', $modified); |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | |
@@ -493,8 +493,8 @@ discard block |
||
493 | 493 | /** |
494 | 494 | * @param string $name |
495 | 495 | */ |
496 | - function set_name( $name = '' ) { |
|
497 | - $this->set( 'VNU_name', $name ); |
|
496 | + function set_name($name = '') { |
|
497 | + $this->set('VNU_name', $name); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | |
@@ -502,8 +502,8 @@ discard block |
||
502 | 502 | /** |
503 | 503 | * @param int $order |
504 | 504 | */ |
505 | - function set_order( $order = 0 ) { |
|
506 | - $this->set( 'VNU_order', $order ); |
|
505 | + function set_order($order = 0) { |
|
506 | + $this->set('VNU_order', $order); |
|
507 | 507 | } |
508 | 508 | |
509 | 509 | |
@@ -511,8 +511,8 @@ discard block |
||
511 | 511 | /** |
512 | 512 | * @param string $phone |
513 | 513 | */ |
514 | - function set_phone( $phone = '' ) { |
|
515 | - $this->set( 'VNU_phone', $phone ); |
|
514 | + function set_phone($phone = '') { |
|
515 | + $this->set('VNU_phone', $phone); |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | |
@@ -520,8 +520,8 @@ discard block |
||
520 | 520 | /** |
521 | 521 | * @param int $wp_user |
522 | 522 | */ |
523 | - function set_wp_user( $wp_user = 1 ) { |
|
524 | - $this->set( 'VNU_wp_user', $wp_user ); |
|
523 | + function set_wp_user($wp_user = 1) { |
|
524 | + $this->set('VNU_wp_user', $wp_user); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | |
@@ -529,8 +529,8 @@ discard block |
||
529 | 529 | /** |
530 | 530 | * @param string $url |
531 | 531 | */ |
532 | - function set_venue_url( $url = '' ) { |
|
533 | - $this->set( 'VNU_url', $url ); |
|
532 | + function set_venue_url($url = '') { |
|
533 | + $this->set('VNU_url', $url); |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | |
@@ -538,8 +538,8 @@ discard block |
||
538 | 538 | /** |
539 | 539 | * @param string $phone |
540 | 540 | */ |
541 | - function set_virtual_phone( $phone = '' ) { |
|
542 | - $this->set( 'VNU_virtual_phone', $phone ); |
|
541 | + function set_virtual_phone($phone = '') { |
|
542 | + $this->set('VNU_virtual_phone', $phone); |
|
543 | 543 | } |
544 | 544 | |
545 | 545 | |
@@ -547,8 +547,8 @@ discard block |
||
547 | 547 | /** |
548 | 548 | * @param string $url |
549 | 549 | */ |
550 | - function set_virtual_url( $url = '' ) { |
|
551 | - $this->set( 'VNU_virtual_url', $url ); |
|
550 | + function set_virtual_url($url = '') { |
|
551 | + $this->set('VNU_virtual_url', $url); |
|
552 | 552 | } |
553 | 553 | |
554 | 554 | |
@@ -556,8 +556,8 @@ discard block |
||
556 | 556 | /** |
557 | 557 | * @param string $enable |
558 | 558 | */ |
559 | - function set_enable_for_gmap( $enable = '' ) { |
|
560 | - $this->set( 'VNU_enable_for_gmap', $enable ); |
|
559 | + function set_enable_for_gmap($enable = '') { |
|
560 | + $this->set('VNU_enable_for_gmap', $enable); |
|
561 | 561 | } |
562 | 562 | |
563 | 563 | |
@@ -565,8 +565,8 @@ discard block |
||
565 | 565 | /** |
566 | 566 | * @param string $google_map_link |
567 | 567 | */ |
568 | - function set_google_map_link( $google_map_link = '' ) { |
|
569 | - $this->set( 'VNU_google_map_link', $google_map_link ); |
|
568 | + function set_google_map_link($google_map_link = '') { |
|
569 | + $this->set('VNU_google_map_link', $google_map_link); |
|
570 | 570 | } |
571 | 571 | |
572 | 572 |
@@ -35,35 +35,35 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public static function get_called_class() { |
37 | 37 | $backtrace = debug_backtrace(); |
38 | - if ( isset( $backtrace[2] ) && is_array( $backtrace[2] ) && isset( $backtrace[2]['class'] ) && ! isset( $backtrace[2]['file'] )) { |
|
38 | + if (isset($backtrace[2]) && is_array($backtrace[2]) && isset($backtrace[2]['class']) && ! isset($backtrace[2]['file'])) { |
|
39 | 39 | return $backtrace[2]['class']; |
40 | - } else if ( isset( $backtrace[3] ) && is_array( $backtrace[3] ) && isset( $backtrace[3]['class'] ) && ! isset( $backtrace[3]['file'] )) { |
|
40 | + } else if (isset($backtrace[3]) && is_array($backtrace[3]) && isset($backtrace[3]['class']) && ! isset($backtrace[3]['file'])) { |
|
41 | 41 | return $backtrace[3]['class']; |
42 | - } else if ( isset( $backtrace[2] ) && is_array( $backtrace[2] ) && isset( $backtrace[2]['file'] ) && isset( $backtrace[2]['line'] )) { |
|
43 | - if ( self::$file_line == $backtrace[2]['file'] . $backtrace[2]['line'] ) { |
|
42 | + } else if (isset($backtrace[2]) && is_array($backtrace[2]) && isset($backtrace[2]['file']) && isset($backtrace[2]['line'])) { |
|
43 | + if (self::$file_line == $backtrace[2]['file'].$backtrace[2]['line']) { |
|
44 | 44 | self::$i++; |
45 | 45 | } else { |
46 | 46 | self::$i = 0; |
47 | - self::$file_line = $backtrace[2]['file'] . $backtrace[2]['line']; |
|
47 | + self::$file_line = $backtrace[2]['file'].$backtrace[2]['line']; |
|
48 | 48 | } |
49 | 49 | // was class method called via call_user_func ? |
50 | - if ( $backtrace[2]['function'] == 'call_user_func' && isset( $backtrace[2]['args'] ) && is_array( $backtrace[2]['args'] )){ |
|
51 | - if ( isset( $backtrace[2]['args'][0] ) && isset( $backtrace[2]['args'][0][0] )) { |
|
50 | + if ($backtrace[2]['function'] == 'call_user_func' && isset($backtrace[2]['args']) && is_array($backtrace[2]['args'])) { |
|
51 | + if (isset($backtrace[2]['args'][0]) && isset($backtrace[2]['args'][0][0])) { |
|
52 | 52 | $called_class = $backtrace[2]['args'][0][0]; |
53 | 53 | // is it an EE function ? |
54 | - if ( strpos( $called_class, 'EE' ) === 0 ) { |
|
55 | - $prefix_chars = strpos( $called_class, '_' ) + 1; |
|
56 | - $prefix = substr( $called_class, 0, $prefix_chars ); |
|
57 | - $classname = substr( $called_class, $prefix_chars, strlen( $called_class )); |
|
58 | - $classname = $prefix . str_replace( ' ', '_', ucwords( strtolower( str_replace( '_', ' ', $classname )))); |
|
54 | + if (strpos($called_class, 'EE') === 0) { |
|
55 | + $prefix_chars = strpos($called_class, '_') + 1; |
|
56 | + $prefix = substr($called_class, 0, $prefix_chars); |
|
57 | + $classname = substr($called_class, $prefix_chars, strlen($called_class)); |
|
58 | + $classname = $prefix.str_replace(' ', '_', ucwords(strtolower(str_replace('_', ' ', $classname)))); |
|
59 | 59 | return $classname; |
60 | 60 | } |
61 | 61 | } |
62 | 62 | } else { |
63 | - $lines = file( $backtrace[2]['file'] ); |
|
64 | - preg_match_all( '/([a-zA-Z0-9\_]+)::' . $backtrace[2]['function'] . '/', $lines[$backtrace[2]['line']-1], $matches ); |
|
65 | - if ( isset( $matches[1] ) && isset( $matches[1][ self::$i ] )) { |
|
66 | - return $matches[1][ self::$i ]; |
|
63 | + $lines = file($backtrace[2]['file']); |
|
64 | + preg_match_all('/([a-zA-Z0-9\_]+)::'.$backtrace[2]['function'].'/', $lines[$backtrace[2]['line'] - 1], $matches); |
|
65 | + if (isset($matches[1]) && isset($matches[1][self::$i])) { |
|
66 | + return $matches[1][self::$i]; |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 | } |
@@ -80,22 +80,22 @@ discard block |
||
80 | 80 | * @param string $hook |
81 | 81 | * @return array |
82 | 82 | */ |
83 | - public static function get_class_names_for_all_callbacks_on_hook( $hook = NULL ) { |
|
83 | + public static function get_class_names_for_all_callbacks_on_hook($hook = NULL) { |
|
84 | 84 | global $wp_filter; |
85 | 85 | $class_names = array(); |
86 | 86 | // are any callbacks registered for this hook ? |
87 | - if ( isset( $wp_filter[ $hook ] )) { |
|
87 | + if (isset($wp_filter[$hook])) { |
|
88 | 88 | // loop thru all of the callbacks attached to the deprecated hookpoint |
89 | - foreach( $wp_filter[ $hook ] as $priority ) { |
|
90 | - foreach( $priority as $callback ) { |
|
89 | + foreach ($wp_filter[$hook] as $priority) { |
|
90 | + foreach ($priority as $callback) { |
|
91 | 91 | // is the callback a non-static class method ? |
92 | - if ( isset( $callback['function'] ) && is_array( $callback['function'] )) { |
|
93 | - if ( isset( $callback['function'][0] ) && is_object( $callback['function'][0] )) { |
|
94 | - $class_names[] = get_class( $callback['function'][0] ); |
|
92 | + if (isset($callback['function']) && is_array($callback['function'])) { |
|
93 | + if (isset($callback['function'][0]) && is_object($callback['function'][0])) { |
|
94 | + $class_names[] = get_class($callback['function'][0]); |
|
95 | 95 | } |
96 | 96 | // test for static method |
97 | - } else if ( strpos( $callback['function'], '::' ) !== FALSE ) { |
|
98 | - $class = explode( '::', $callback['function'] ); |
|
97 | + } else if (strpos($callback['function'], '::') !== FALSE) { |
|
98 | + $class = explode('::', $callback['function']); |
|
99 | 99 | $class_names[] = $class[0]; |
100 | 100 | } else { |
101 | 101 | // just a function |
@@ -116,24 +116,24 @@ discard block |
||
116 | 116 | * @param string $property |
117 | 117 | * @return boolean |
118 | 118 | */ |
119 | - public static function has_property( $class = NULL, $property = NULL ) { |
|
119 | + public static function has_property($class = NULL, $property = NULL) { |
|
120 | 120 | // if $class or $property don't exist, then get out, cuz that would be like... fatal dude |
121 | - if ( empty( $class ) || empty( $property )) { |
|
121 | + if (empty($class) || empty($property)) { |
|
122 | 122 | return FALSE; |
123 | 123 | } |
124 | 124 | // if your hosting company doesn't cut the mustard |
125 | - if ( version_compare( PHP_VERSION, '5.3.0' ) < 0 ) { |
|
125 | + if (version_compare(PHP_VERSION, '5.3.0') < 0) { |
|
126 | 126 | // just in case $class is an actual instantiated object |
127 | - if ( is_object( $class )) { |
|
128 | - return isset( $class->{$property} ) ? TRUE : FALSE; |
|
127 | + if (is_object($class)) { |
|
128 | + return isset($class->{$property} ) ? TRUE : FALSE; |
|
129 | 129 | } else { |
130 | 130 | // use reflection for < PHP 5.3 to get details using just the class name |
131 | - $reflector = new ReflectionClass( $class ); |
|
132 | - return $reflector->hasProperty( $property ); |
|
131 | + $reflector = new ReflectionClass($class); |
|
132 | + return $reflector->hasProperty($property); |
|
133 | 133 | } |
134 | 134 | } else { |
135 | 135 | // or try regular property exists method which works as expected in PHP 5.3+ |
136 | - return property_exists( $class, $property ); |
|
136 | + return property_exists($class, $property); |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | |
144 | 144 | |
145 | 145 | // if PHP version < 5.3 |
146 | -if ( ! function_exists( 'get_called_class' )) { |
|
146 | +if ( ! function_exists('get_called_class')) { |
|
147 | 147 | /** |
148 | 148 | * @return bool|string |
149 | 149 | */ |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * |
21 | 21 | * ------------------------------------------------------------------------ |
22 | 22 | */ |
23 | -class EEH_Money extends EEH_Base { |
|
23 | +class EEH_Money extends EEH_Base { |
|
24 | 24 | |
25 | 25 | |
26 | 26 | /** |
@@ -29,15 +29,15 @@ discard block |
||
29 | 29 | * @param int|string $incoming_value |
30 | 30 | * @return float |
31 | 31 | */ |
32 | - public static function convert_to_float_from_localized_money( $incoming_value ) { |
|
32 | + public static function convert_to_float_from_localized_money($incoming_value) { |
|
33 | 33 | //remove thousands separator |
34 | - $money_value = str_replace( EE_Registry::instance()->CFG->currency->thsnds, '', $incoming_value ); |
|
34 | + $money_value = str_replace(EE_Registry::instance()->CFG->currency->thsnds, '', $incoming_value); |
|
35 | 35 | |
36 | 36 | //replace decimal place with standard decimal. |
37 | - $money_value = str_replace( EE_Registry::instance()->CFG->currency->dec_mrk, '.', $money_value ); |
|
37 | + $money_value = str_replace(EE_Registry::instance()->CFG->currency->dec_mrk, '.', $money_value); |
|
38 | 38 | |
39 | 39 | //float it! and round to three decimal places |
40 | - $money_value = round ( (float) $money_value, 3 ); |
|
40 | + $money_value = round((float) $money_value, 3); |
|
41 | 41 | return $money_value; |
42 | 42 | } |
43 | 43 | |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | * @throws \EE_Error |
58 | 58 | */ |
59 | 59 | |
60 | - public static function compare_floats( $float1, $float2, $operator='=' ) { |
|
60 | + public static function compare_floats($float1, $float2, $operator = '=') { |
|
61 | 61 | // Check numbers to 5 digits of precision |
62 | 62 | $epsilon = 0.00001; |
63 | 63 | |
64 | - $float1 = (float)$float1; |
|
65 | - $float2 = (float)$float2; |
|
64 | + $float1 = (float) $float1; |
|
65 | + $float2 = (float) $float2; |
|
66 | 66 | |
67 | 67 | switch ($operator) { |
68 | 68 | // equal |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | } |
117 | 117 | break; |
118 | 118 | default: |
119 | - throw new EE_Error(__( "Unknown operator '" . $operator . "' in EEH_Money::compare_floats()", 'event_espresso' ) ); |
|
119 | + throw new EE_Error(__("Unknown operator '".$operator."' in EEH_Money::compare_floats()", 'event_espresso')); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | return false; |
@@ -131,21 +131,21 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @return string |
133 | 133 | */ |
134 | - public static function get_format_for_jqplot( $CNT_ISO = '') { |
|
134 | + public static function get_format_for_jqplot($CNT_ISO = '') { |
|
135 | 135 | //default format |
136 | 136 | $format = 'f'; |
137 | 137 | //if CNT_ISO passed lets try to get currency settings for it. |
138 | - $currency_config = $CNT_ISO !== '' ? new EE_Currency_Config( $CNT_ISO ) : null; |
|
138 | + $currency_config = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null; |
|
139 | 139 | //default currency settings for site if not set |
140 | - if ( ! $currency_config instanceof EE_Currency_Config ) { |
|
140 | + if ( ! $currency_config instanceof EE_Currency_Config) { |
|
141 | 141 | $currency_config = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config ? EE_Registry::instance()->CFG->currency : new EE_Currency_Config(); |
142 | 142 | } |
143 | 143 | |
144 | 144 | //first get the decimal place and number of places |
145 | - $format = "%'." . $currency_config->dec_plc . $format; |
|
145 | + $format = "%'.".$currency_config->dec_plc.$format; |
|
146 | 146 | |
147 | 147 | //currency symbol on right side. |
148 | - $format = $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign; |
|
148 | + $format = $currency_config->sign_b4 ? $currency_config->sign.$format : $format.$currency_config->sign; |
|
149 | 149 | return $format; |
150 | 150 | } |
151 | 151 | |
@@ -160,27 +160,27 @@ discard block |
||
160 | 160 | * |
161 | 161 | * @return string |
162 | 162 | */ |
163 | - public static function get_format_for_google_charts( $CNT_ISO = '' ) { |
|
163 | + public static function get_format_for_google_charts($CNT_ISO = '') { |
|
164 | 164 | //if CNT_ISO passed lets try to get currency settings for it. |
165 | - $currency_config = $CNT_ISO !== '' ? new EE_Currency_Config( $CNT_ISO ) : null; |
|
165 | + $currency_config = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null; |
|
166 | 166 | //default currency settings for site if not set |
167 | - if ( ! $currency_config instanceof EE_Currency_Config ) { |
|
167 | + if ( ! $currency_config instanceof EE_Currency_Config) { |
|
168 | 168 | $currency_config = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config ? EE_Registry::instance()->CFG->currency : new EE_Currency_Config(); |
169 | 169 | } |
170 | 170 | |
171 | - $decimal_places_placeholder = str_pad( '', $currency_config->dec_plc, '0' ); |
|
171 | + $decimal_places_placeholder = str_pad('', $currency_config->dec_plc, '0'); |
|
172 | 172 | |
173 | 173 | //first get the decimal place and number of places |
174 | - $format = '#,##0.' . $decimal_places_placeholder; |
|
174 | + $format = '#,##0.'.$decimal_places_placeholder; |
|
175 | 175 | |
176 | 176 | //currency symbol on right side. |
177 | - $format = $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign; |
|
177 | + $format = $currency_config->sign_b4 ? $currency_config->sign.$format : $format.$currency_config->sign; |
|
178 | 178 | $formatterObject = array( |
179 | 179 | 'decimalSymbol' => $currency_config->dec_mrk, |
180 | 180 | 'groupingSymbol' => $currency_config->thsnds, |
181 | 181 | 'fractionDigits' => $currency_config->dec_plc, |
182 | 182 | ); |
183 | - if ( $currency_config->sign_b4 ) { |
|
183 | + if ($currency_config->sign_b4) { |
|
184 | 184 | $formatterObject['prefix'] = $currency_config->sign; |
185 | 185 | } else { |
186 | 186 | $formatterObject['suffix'] = $currency_config->sign; |
@@ -96,12 +96,12 @@ discard block |
||
96 | 96 | * @param array $request_data |
97 | 97 | * @param array $extra_data |
98 | 98 | */ |
99 | - function __construct( $job_id, $classname, $request_data, $extra_data = array() ) { |
|
100 | - $this->set_job_id( $job_id ); |
|
101 | - $this->set_classname( $classname ); |
|
102 | - $this->set_request_data( $request_data ); |
|
103 | - $this->set_extra_data( $extra_data ); |
|
104 | - $this->set_status( JobParameters::status_continue ); |
|
99 | + function __construct($job_id, $classname, $request_data, $extra_data = array()) { |
|
100 | + $this->set_job_id($job_id); |
|
101 | + $this->set_classname($classname); |
|
102 | + $this->set_request_data($request_data); |
|
103 | + $this->set_extra_data($extra_data); |
|
104 | + $this->set_status(JobParameters::status_continue); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | |
@@ -126,12 +126,12 @@ discard block |
||
126 | 126 | * @param boolean $first |
127 | 127 | * @return boolean success |
128 | 128 | */ |
129 | - function save( $first = false ) { |
|
130 | - $object_vars = wp_json_encode( get_object_vars( $this ) ); |
|
131 | - if( $first ) { |
|
132 | - return add_option( $this->option_name(), $object_vars, null, 'no' ); |
|
133 | - } else{ |
|
134 | - return update_option( $this->option_name(), $object_vars ); |
|
129 | + function save($first = false) { |
|
130 | + $object_vars = wp_json_encode(get_object_vars($this)); |
|
131 | + if ($first) { |
|
132 | + return add_option($this->option_name(), $object_vars, null, 'no'); |
|
133 | + } else { |
|
134 | + return update_option($this->option_name(), $object_vars); |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @return boolean |
144 | 144 | */ |
145 | 145 | function delete() { |
146 | - return delete_option( $this->option_name() ); |
|
146 | + return delete_option($this->option_name()); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | |
@@ -154,26 +154,26 @@ discard block |
||
154 | 154 | * @return JobParameters |
155 | 155 | * @throws BatchRequestException |
156 | 156 | */ |
157 | - static function load( $job_id ) { |
|
158 | - $job_parameter_vars = json_decode( get_option( JobParameters::wp_option_prefix . $job_id ), true ); |
|
159 | - if( |
|
160 | - ! is_array( $job_parameter_vars ) || |
|
161 | - ! isset( $job_parameter_vars[ '_classname' ] ) || |
|
162 | - ! isset( $job_parameter_vars[ '_request_data' ] ) |
|
157 | + static function load($job_id) { |
|
158 | + $job_parameter_vars = json_decode(get_option(JobParameters::wp_option_prefix.$job_id), true); |
|
159 | + if ( |
|
160 | + ! is_array($job_parameter_vars) || |
|
161 | + ! isset($job_parameter_vars['_classname']) || |
|
162 | + ! isset($job_parameter_vars['_request_data']) |
|
163 | 163 | ) { |
164 | 164 | throw new BatchRequestException( |
165 | 165 | sprintf( |
166 | 166 | __('Could not retrieve job %1$s from the Wordpress options table, and so the job could not continue. The wordpress option was %2$s', 'event_espresso'), |
167 | 167 | $job_id, |
168 | - get_option( JobParameters::wp_option_prefix . $job_id ) |
|
168 | + get_option(JobParameters::wp_option_prefix.$job_id) |
|
169 | 169 | ) |
170 | 170 | ); |
171 | 171 | } |
172 | 172 | $job_parameters = new JobParameters( |
173 | 173 | $job_id, |
174 | - $job_parameter_vars[ '_classname' ], |
|
175 | - $job_parameter_vars[ '_request_data'] ); |
|
176 | - foreach( $job_parameter_vars as $key => $value ) { |
|
174 | + $job_parameter_vars['_classname'], |
|
175 | + $job_parameter_vars['_request_data'] ); |
|
176 | + foreach ($job_parameter_vars as $key => $value) { |
|
177 | 177 | $job_parameters->{$key} = $value; |
178 | 178 | } |
179 | 179 | return $job_parameters; |
@@ -217,9 +217,9 @@ discard block |
||
217 | 217 | * @param string|array $default |
218 | 218 | * @return string|array |
219 | 219 | */ |
220 | - function request_datum( $key, $default = '' ) { |
|
221 | - if( isset( $this->_request_data[ $key ] ) ) { |
|
222 | - return $this->_request_data[ $key ]; |
|
220 | + function request_datum($key, $default = '') { |
|
221 | + if (isset($this->_request_data[$key])) { |
|
222 | + return $this->_request_data[$key]; |
|
223 | 223 | } else { |
224 | 224 | return $default; |
225 | 225 | } |
@@ -233,9 +233,9 @@ discard block |
||
233 | 233 | * @param string|array $default |
234 | 234 | * @return string|array |
235 | 235 | */ |
236 | - function extra_datum( $key, $default = '' ) { |
|
237 | - if( isset( $this->_extra_data[ $key ] ) ) { |
|
238 | - return $this->_extra_data[ $key ]; |
|
236 | + function extra_datum($key, $default = '') { |
|
237 | + if (isset($this->_extra_data[$key])) { |
|
238 | + return $this->_extra_data[$key]; |
|
239 | 239 | } else { |
240 | 240 | return $default; |
241 | 241 | } |
@@ -248,8 +248,8 @@ discard block |
||
248 | 248 | * @param string $key |
249 | 249 | * @param string|int|array|null $value almost any extra data you want to store |
250 | 250 | */ |
251 | - function add_extra_data( $key, $value ) { |
|
252 | - $this->_extra_data[ $key ] = $value; |
|
251 | + function add_extra_data($key, $value) { |
|
252 | + $this->_extra_data[$key] = $value; |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * Sets the job size. You decide what units to use |
279 | 279 | * @param int $size |
280 | 280 | */ |
281 | - function set_job_size( $size ) { |
|
281 | + function set_job_size($size) { |
|
282 | 282 | $this->_job_size = $size; |
283 | 283 | } |
284 | 284 | |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | * @param int $newly_processed |
300 | 300 | * @return int updated units processed |
301 | 301 | */ |
302 | - function mark_processed( $newly_processed ) { |
|
302 | + function mark_processed($newly_processed) { |
|
303 | 303 | $this->_units_processed += $newly_processed; |
304 | 304 | return $this->_units_processed; |
305 | 305 | } |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | * Sets the total count of units processed. You might prefer to use mark_processed |
311 | 311 | * @param int $total_units_processed |
312 | 312 | */ |
313 | - function set_units_processed( $total_units_processed ) { |
|
313 | + function set_units_processed($total_units_processed) { |
|
314 | 314 | $this->_units_processed = $total_units_processed; |
315 | 315 | } |
316 | 316 | |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | * Sets the job's ID |
321 | 321 | * @param string $job_id |
322 | 322 | */ |
323 | - function set_job_id( $job_id ) { |
|
323 | + function set_job_id($job_id) { |
|
324 | 324 | $this->_job_id = $job_id; |
325 | 325 | } |
326 | 326 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | * sets the classname |
331 | 331 | * @param string $classname |
332 | 332 | */ |
333 | - function set_classname( $classname ) { |
|
333 | + function set_classname($classname) { |
|
334 | 334 | $this->_classname = $classname; |
335 | 335 | } |
336 | 336 | |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | * Sets the request data |
341 | 341 | * @param array $request_data |
342 | 342 | */ |
343 | - function set_request_data( $request_data ) { |
|
343 | + function set_request_data($request_data) { |
|
344 | 344 | $this->_request_data = $request_data; |
345 | 345 | } |
346 | 346 | |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | * Sets the array of extra data we want to store on this request |
351 | 351 | * @param array $extra_data |
352 | 352 | */ |
353 | - function set_extra_data( $extra_data ) { |
|
353 | + function set_extra_data($extra_data) { |
|
354 | 354 | $this->_extra_data = $extra_data; |
355 | 355 | } |
356 | 356 | |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | * @return string |
362 | 362 | */ |
363 | 363 | function option_name() { |
364 | - return JobParameters::wp_option_prefix . $this->job_id(); |
|
364 | + return JobParameters::wp_option_prefix.$this->job_id(); |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | * |
381 | 381 | * @param string $status on eof JobParameters::valid_stati() |
382 | 382 | */ |
383 | - public function set_status( $status ) { |
|
383 | + public function set_status($status) { |
|
384 | 384 | $this->_status = $status; |
385 | 385 | } |
386 | 386 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('No direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -95,13 +95,13 @@ discard block |
||
95 | 95 | * @type $name string the name for this form section, if you want to explicitly define it |
96 | 96 | * } |
97 | 97 | */ |
98 | - function __construct( $options_array = array() ) { |
|
98 | + function __construct($options_array = array()) { |
|
99 | 99 | // used by display strategies |
100 | 100 | EE_Registry::instance()->load_helper('HTML'); |
101 | 101 | // assign incoming values to properties |
102 | - foreach( $options_array as $key => $value ) { |
|
103 | - $key = '_' . $key; |
|
104 | - if ( property_exists( $this, $key ) && empty( $this->{$key} )) { |
|
102 | + foreach ($options_array as $key => $value) { |
|
103 | + $key = '_'.$key; |
|
104 | + if (property_exists($this, $key) && empty($this->{$key} )) { |
|
105 | 105 | $this->{$key} = $value; |
106 | 106 | } |
107 | 107 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * @param $parent_form_section |
114 | 114 | * @param $name |
115 | 115 | */ |
116 | - protected function _construct_finalize( $parent_form_section, $name ){ |
|
116 | + protected function _construct_finalize($parent_form_section, $name) { |
|
117 | 117 | $this->_construction_finalized = TRUE; |
118 | 118 | $this->_parent_section = $parent_form_section; |
119 | 119 | $this->_name = $name; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | /** |
135 | 135 | * @param string $action |
136 | 136 | */ |
137 | - public function set_action( $action ) { |
|
137 | + public function set_action($action) { |
|
138 | 138 | $this->_action = $action; |
139 | 139 | } |
140 | 140 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * @return string |
145 | 145 | */ |
146 | 146 | public function method() { |
147 | - return ! empty( $this->_method ) ? $this->_method : 'POST'; |
|
147 | + return ! empty($this->_method) ? $this->_method : 'POST'; |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | /** |
153 | 153 | * @param string $method |
154 | 154 | */ |
155 | - public function set_method( $method ) { |
|
156 | - switch ( $method ) { |
|
155 | + public function set_method($method) { |
|
156 | + switch ($method) { |
|
157 | 157 | case 'get' : |
158 | 158 | case 'GET' : |
159 | 159 | $this->_method = 'GET'; |
@@ -171,12 +171,12 @@ discard block |
||
171 | 171 | * Calculation involves using the name and the parent's html id |
172 | 172 | * return void |
173 | 173 | */ |
174 | - protected function _set_default_html_id_if_empty(){ |
|
175 | - if( ! $this->_html_id ){ |
|
176 | - if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper ){ |
|
177 | - $this->_html_id = $this->_parent_section->html_id() . '-' . $this->_prep_name_for_html_id( $this->name() ); |
|
178 | - }else{ |
|
179 | - $this->_html_id = $this->_prep_name_for_html_id( $this->name() ); |
|
174 | + protected function _set_default_html_id_if_empty() { |
|
175 | + if ( ! $this->_html_id) { |
|
176 | + if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
|
177 | + $this->_html_id = $this->_parent_section->html_id().'-'.$this->_prep_name_for_html_id($this->name()); |
|
178 | + } else { |
|
179 | + $this->_html_id = $this->_prep_name_for_html_id($this->name()); |
|
180 | 180 | } |
181 | 181 | } |
182 | 182 | } |
@@ -188,8 +188,8 @@ discard block |
||
188 | 188 | * @param $name |
189 | 189 | * @return string |
190 | 190 | */ |
191 | - private function _prep_name_for_html_id( $name ) { |
|
192 | - return sanitize_key( str_replace( array( ' ', ' ', '_' ), '-', $name )); |
|
191 | + private function _prep_name_for_html_id($name) { |
|
192 | + return sanitize_key(str_replace(array(' ', ' ', '_'), '-', $name)); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | |
@@ -206,8 +206,8 @@ discard block |
||
206 | 206 | * @param bool $add_pound_sign |
207 | 207 | * @return string |
208 | 208 | */ |
209 | - public function html_id( $add_pound_sign = FALSE ){ |
|
210 | - return $add_pound_sign ? '#' . $this->_html_id : $this->_html_id; |
|
209 | + public function html_id($add_pound_sign = FALSE) { |
|
210 | + return $add_pound_sign ? '#'.$this->_html_id : $this->_html_id; |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | /** |
216 | 216 | * @return string |
217 | 217 | */ |
218 | - public function html_class(){ |
|
218 | + public function html_class() { |
|
219 | 219 | return $this->_html_class; |
220 | 220 | } |
221 | 221 | |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | /** |
225 | 225 | * @return string |
226 | 226 | */ |
227 | - public function html_style(){ |
|
227 | + public function html_style() { |
|
228 | 228 | return $this->_html_style; |
229 | 229 | } |
230 | 230 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | /** |
234 | 234 | * @param mixed $html_class |
235 | 235 | */ |
236 | - public function set_html_class( $html_class ) { |
|
236 | + public function set_html_class($html_class) { |
|
237 | 237 | $this->_html_class = $html_class; |
238 | 238 | } |
239 | 239 | |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | /** |
243 | 243 | * @param mixed $html_id |
244 | 244 | */ |
245 | - public function set_html_id( $html_id ) { |
|
245 | + public function set_html_id($html_id) { |
|
246 | 246 | $this->_html_id = $html_id; |
247 | 247 | } |
248 | 248 | |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | /** |
252 | 252 | * @param mixed $html_style |
253 | 253 | */ |
254 | - public function set_html_style( $html_style ) { |
|
254 | + public function set_html_style($html_style) { |
|
255 | 255 | $this->_html_style = $html_style; |
256 | 256 | } |
257 | 257 | |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | /** |
261 | 261 | * @param string $other_html_attributes |
262 | 262 | */ |
263 | - public function set_other_html_attributes( $other_html_attributes ) { |
|
263 | + public function set_other_html_attributes($other_html_attributes) { |
|
264 | 264 | $this->_other_html_attributes = $other_html_attributes; |
265 | 265 | } |
266 | 266 | |
@@ -280,9 +280,9 @@ discard block |
||
280 | 280 | * @throws EE_Error |
281 | 281 | * @return string |
282 | 282 | */ |
283 | - function name(){ |
|
284 | - if( ! $this->_construction_finalized ){ |
|
285 | - 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\'', 'event_espresso' ), get_class($this) ) ); |
|
283 | + function name() { |
|
284 | + if ( ! $this->_construction_finalized) { |
|
285 | + 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\'', 'event_espresso'), get_class($this))); |
|
286 | 286 | } |
287 | 287 | return $this->_name; |
288 | 288 | } |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | * Gets the parent section |
294 | 294 | * @return EE_Form_Section_Proper |
295 | 295 | */ |
296 | - function parent_section(){ |
|
296 | + function parent_section() { |
|
297 | 297 | return $this->_parent_section; |
298 | 298 | } |
299 | 299 | |
@@ -306,18 +306,18 @@ discard block |
||
306 | 306 | * @param string $other_attributes anything else added to the form open tag, MUST BE VALID HTML |
307 | 307 | * @return string |
308 | 308 | */ |
309 | - public function form_open( $action = '', $method = '', $other_attributes = '' ) { |
|
310 | - if ( ! empty( $action )) { |
|
311 | - $this->set_action( $action ); |
|
309 | + public function form_open($action = '', $method = '', $other_attributes = '') { |
|
310 | + if ( ! empty($action)) { |
|
311 | + $this->set_action($action); |
|
312 | 312 | } |
313 | - if ( ! empty( $method )) { |
|
314 | - $this->set_method( $method ); |
|
313 | + if ( ! empty($method)) { |
|
314 | + $this->set_method($method); |
|
315 | 315 | } |
316 | - $html = EEH_HTML::nl( 1, 'form' ) . '<form'; |
|
317 | - $html .= $this->html_id() !== '' ? ' id="' . $this->html_id() . '"' : ''; |
|
318 | - $html .= ' action="' . $this->action() . '"'; |
|
319 | - $html .= ' method="' . $this->method() . '"'; |
|
320 | - $html .= $other_attributes . '>'; |
|
316 | + $html = EEH_HTML::nl(1, 'form').'<form'; |
|
317 | + $html .= $this->html_id() !== '' ? ' id="'.$this->html_id().'"' : ''; |
|
318 | + $html .= ' action="'.$this->action().'"'; |
|
319 | + $html .= ' method="'.$this->method().'"'; |
|
320 | + $html .= $other_attributes.'>'; |
|
321 | 321 | return $html; |
322 | 322 | } |
323 | 323 | |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | * @return string |
329 | 329 | */ |
330 | 330 | public function form_close() { |
331 | - return EEH_HTML::nl( -1, 'form' ) . '</form>' . EEH_HTML::nl() . '<!-- end of ee-' . $this->html_id() . '-form -->' . EEH_HTML::nl(); |
|
331 | + return EEH_HTML::nl( -1, 'form' ).'</form>'.EEH_HTML::nl().'<!-- end of ee-'.$this->html_id().'-form -->'.EEH_HTML::nl(); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * before the hook wp_enqueue_scripts is called (so that the form section can enqueue its needed scripts). |
8 | 8 | * However, you may output the form (usually by calling get_html_and_js) anywhere you like. |
9 | 9 | */ |
10 | -class EE_Form_Section_Proper extends EE_Form_Section_Validatable{ |
|
10 | +class EE_Form_Section_Proper extends EE_Form_Section_Validatable { |
|
11 | 11 | |
12 | 12 | /** |
13 | 13 | * Subsections |
@@ -68,38 +68,38 @@ discard block |
||
68 | 68 | * } @see EE_Form_Section_Validatable::__construct() |
69 | 69 | * |
70 | 70 | */ |
71 | - public function __construct( $options_array = array() ){ |
|
71 | + public function __construct($options_array = array()) { |
|
72 | 72 | EE_Registry::instance()->load_helper('Formatter'); |
73 | - $options_array = apply_filters( 'FHEE__EE_Form_Section_Proper___construct__options_array', $options_array, $this ); |
|
73 | + $options_array = apply_filters('FHEE__EE_Form_Section_Proper___construct__options_array', $options_array, $this); |
|
74 | 74 | //call parent first, as it may be setting the name |
75 | 75 | parent::__construct($options_array); |
76 | 76 | //if they've included subsections in the constructor, add them now |
77 | - if( isset( $options_array['include'] )){ |
|
77 | + if (isset($options_array['include'])) { |
|
78 | 78 | //we are going to make sure we ONLY have those subsections to include |
79 | 79 | //AND we are going to make sure they're in that specified order |
80 | 80 | $reordered_subsections = array(); |
81 | - foreach($options_array['include'] as $input_name){ |
|
82 | - if(isset($this->_subsections[$input_name])){ |
|
81 | + foreach ($options_array['include'] as $input_name) { |
|
82 | + if (isset($this->_subsections[$input_name])) { |
|
83 | 83 | $reordered_subsections[$input_name] = $this->_subsections[$input_name]; |
84 | 84 | } |
85 | 85 | } |
86 | 86 | $this->_subsections = $reordered_subsections; |
87 | 87 | } |
88 | - if(isset($options_array['exclude'])){ |
|
88 | + if (isset($options_array['exclude'])) { |
|
89 | 89 | $exclude = $options_array['exclude']; |
90 | 90 | $this->_subsections = array_diff_key($this->_subsections, array_flip($exclude)); |
91 | 91 | } |
92 | - if(isset($options_array['layout_strategy'])){ |
|
92 | + if (isset($options_array['layout_strategy'])) { |
|
93 | 93 | $this->_layout_strategy = $options_array['layout_strategy']; |
94 | 94 | } |
95 | - if( ! $this->_layout_strategy){ |
|
95 | + if ( ! $this->_layout_strategy) { |
|
96 | 96 | $this->_layout_strategy = new EE_Two_Column_Layout(); |
97 | 97 | } |
98 | 98 | $this->_layout_strategy->_construct_finalize($this); |
99 | 99 | |
100 | - add_action( 'wp_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' )); |
|
101 | - add_action( 'admin_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' )); |
|
102 | - add_action( 'wp_footer', array( $this, 'ensure_scripts_localized' ), 1 ); |
|
100 | + add_action('wp_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts')); |
|
101 | + add_action('admin_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts')); |
|
102 | + add_action('wp_footer', array($this, 'ensure_scripts_localized'), 1); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -111,25 +111,25 @@ discard block |
||
111 | 111 | * @param string $name |
112 | 112 | * @throws \EE_Error |
113 | 113 | */ |
114 | - public function _construct_finalize( $parent_form_section, $name ) { |
|
114 | + public function _construct_finalize($parent_form_section, $name) { |
|
115 | 115 | parent::_construct_finalize($parent_form_section, $name); |
116 | 116 | $this->_set_default_name_if_empty(); |
117 | 117 | $this->_set_default_html_id_if_empty(); |
118 | - foreach( $this->_subsections as $subsection_name => $subsection ){ |
|
119 | - if ( $subsection instanceof EE_Form_Section_Base ) { |
|
120 | - $subsection->_construct_finalize( $this, $subsection_name ); |
|
118 | + foreach ($this->_subsections as $subsection_name => $subsection) { |
|
119 | + if ($subsection instanceof EE_Form_Section_Base) { |
|
120 | + $subsection->_construct_finalize($this, $subsection_name); |
|
121 | 121 | } else { |
122 | 122 | throw new EE_Error( |
123 | 123 | sprintf( |
124 | - __( 'Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso' ), |
|
124 | + __('Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso'), |
|
125 | 125 | $subsection_name, |
126 | 126 | get_class($this), |
127 | - $subsection ? get_class($subsection) : __( 'NULL', 'event_espresso' ) |
|
127 | + $subsection ? get_class($subsection) : __('NULL', 'event_espresso') |
|
128 | 128 | ) |
129 | 129 | ); |
130 | 130 | } |
131 | 131 | } |
132 | - do_action( 'AHEE__EE_Form_Section_Proper___construct_finalize__end', $this, $parent_form_section, $name ); |
|
132 | + do_action('AHEE__EE_Form_Section_Proper___construct_finalize__end', $this, $parent_form_section, $name); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * Gets the layout strategy for this form section |
139 | 139 | * @return EE_Form_Section_Layout_Base |
140 | 140 | */ |
141 | - public function get_layout_strategy(){ |
|
141 | + public function get_layout_strategy() { |
|
142 | 142 | return $this->_layout_strategy; |
143 | 143 | } |
144 | 144 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * @param EE_Form_Input_Base $input |
151 | 151 | * @return string |
152 | 152 | */ |
153 | - public function get_html_for_input($input){ |
|
153 | + public function get_html_for_input($input) { |
|
154 | 154 | return $this->_layout_strategy->layout_input($input); |
155 | 155 | } |
156 | 156 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * @param null $form_data |
164 | 164 | * @return boolean |
165 | 165 | */ |
166 | - public function was_submitted($form_data = NULL){ |
|
166 | + public function was_submitted($form_data = NULL) { |
|
167 | 167 | return $this->form_data_present_in($form_data); |
168 | 168 | } |
169 | 169 | |
@@ -184,16 +184,16 @@ discard block |
||
184 | 184 | * to skip this step. |
185 | 185 | * @return void |
186 | 186 | */ |
187 | - public function receive_form_submission($req_data = NULL, $validate = TRUE){ |
|
188 | - $req_data = apply_filters( 'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', $req_data, $this, $validate ); |
|
189 | - if( $req_data === NULL){ |
|
187 | + public function receive_form_submission($req_data = NULL, $validate = TRUE) { |
|
188 | + $req_data = apply_filters('FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', $req_data, $this, $validate); |
|
189 | + if ($req_data === NULL) { |
|
190 | 190 | $req_data = $_REQUEST; |
191 | 191 | } |
192 | 192 | $this->_normalize($req_data); |
193 | - if( $validate ){ |
|
193 | + if ($validate) { |
|
194 | 194 | $this->_validate(); |
195 | 195 | } |
196 | - do_action( 'AHEE__EE_Form_Section_Proper__receive_form_submission__end', $req_data, $this, $validate ); |
|
196 | + do_action('AHEE__EE_Form_Section_Proper__receive_form_submission__end', $req_data, $this, $validate); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | |
@@ -206,12 +206,12 @@ discard block |
||
206 | 206 | * the value being an array formatted in teh same way |
207 | 207 | * @param array $default_data |
208 | 208 | */ |
209 | - public function populate_defaults($default_data){ |
|
210 | - foreach($this->subsections() as $subsection_name => $subsection){ |
|
211 | - if(isset($default_data[$subsection_name])){ |
|
212 | - if($subsection instanceof EE_Form_Input_Base){ |
|
209 | + public function populate_defaults($default_data) { |
|
210 | + foreach ($this->subsections() as $subsection_name => $subsection) { |
|
211 | + if (isset($default_data[$subsection_name])) { |
|
212 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
213 | 213 | $subsection->set_default($default_data[$subsection_name]); |
214 | - }elseif($subsection instanceof EE_Form_Section_Proper){ |
|
214 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
215 | 215 | $subsection->populate_defaults($default_data[$subsection_name]); |
216 | 216 | } |
217 | 217 | } |
@@ -229,8 +229,8 @@ discard block |
||
229 | 229 | * (realizing that the subsections' html names might not be set yet, etc.) |
230 | 230 | * @return EE_Form_Section_Base |
231 | 231 | */ |
232 | - public function get_subsection($name, $require_construction_to_be_finalized = TRUE ){ |
|
233 | - if( $require_construction_to_be_finalized ){ |
|
232 | + public function get_subsection($name, $require_construction_to_be_finalized = TRUE) { |
|
233 | + if ($require_construction_to_be_finalized) { |
|
234 | 234 | $this->ensure_construct_finalized_called(); |
235 | 235 | } |
236 | 236 | return isset($this->_subsections[$name]) ? $this->_subsections[$name] : NULL; |
@@ -242,10 +242,10 @@ discard block |
||
242 | 242 | * Gets all the validatable subsections of this form section |
243 | 243 | * @return EE_Form_Section_Validatable[] |
244 | 244 | */ |
245 | - public function get_validatable_subsections(){ |
|
245 | + public function get_validatable_subsections() { |
|
246 | 246 | $validatable_subsections = array(); |
247 | - foreach($this->subsections() as $name=>$obj){ |
|
248 | - if($obj instanceof EE_Form_Section_Validatable){ |
|
247 | + foreach ($this->subsections() as $name=>$obj) { |
|
248 | + if ($obj instanceof EE_Form_Section_Validatable) { |
|
249 | 249 | $validatable_subsections[$name] = $obj; |
250 | 250 | } |
251 | 251 | } |
@@ -265,10 +265,10 @@ discard block |
||
265 | 265 | * @return EE_Form_Input_Base |
266 | 266 | * @throws EE_Error |
267 | 267 | */ |
268 | - public function get_input($name, $require_construction_to_be_finalized = TRUE ){ |
|
268 | + public function get_input($name, $require_construction_to_be_finalized = TRUE) { |
|
269 | 269 | $subsection = $this->get_subsection($name, $require_construction_to_be_finalized); |
270 | - if( ! $subsection instanceof EE_Form_Input_Base){ |
|
271 | - throw new EE_Error(sprintf(__("Subsection '%s' is not an instanceof EE_Form_Input_Base on form '%s'. It is a '%s'", 'event_espresso'),$name, get_class($this),$subsection ? get_class($subsection) : __("NULL", 'event_espresso'))); |
|
270 | + if ( ! $subsection instanceof EE_Form_Input_Base) { |
|
271 | + throw new EE_Error(sprintf(__("Subsection '%s' is not an instanceof EE_Form_Input_Base on form '%s'. It is a '%s'", 'event_espresso'), $name, get_class($this), $subsection ? get_class($subsection) : __("NULL", 'event_espresso'))); |
|
272 | 272 | } |
273 | 273 | return $subsection; |
274 | 274 | } |
@@ -286,10 +286,10 @@ discard block |
||
286 | 286 | * @return EE_Form_Section_Proper |
287 | 287 | * @throws EE_Error |
288 | 288 | */ |
289 | - public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE ){ |
|
290 | - $subsection = $this->get_subsection( $name, $require_construction_to_be_finalized ); |
|
291 | - if( ! $subsection instanceof EE_Form_Section_Proper){ |
|
292 | - throw new EE_Error(sprintf(__("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'),$name, get_class($this))); |
|
289 | + public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE) { |
|
290 | + $subsection = $this->get_subsection($name, $require_construction_to_be_finalized); |
|
291 | + if ( ! $subsection instanceof EE_Form_Section_Proper) { |
|
292 | + throw new EE_Error(sprintf(__("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'), $name, get_class($this))); |
|
293 | 293 | } |
294 | 294 | return $subsection; |
295 | 295 | } |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | * @param string $name |
303 | 303 | * @return mixed depending on the input's type and its normalization strategy |
304 | 304 | */ |
305 | - public function get_input_value($name){ |
|
305 | + public function get_input_value($name) { |
|
306 | 306 | $input = $this->get_input($name); |
307 | 307 | return $input->normalized_value(); |
308 | 308 | } |
@@ -315,16 +315,16 @@ discard block |
||
315 | 315 | * @return boolean |
316 | 316 | */ |
317 | 317 | public function is_valid() { |
318 | - if( ! $this->has_received_submission()){ |
|
318 | + if ( ! $this->has_received_submission()) { |
|
319 | 319 | throw new EE_Error(sprintf(__("You cannot check if a form is valid before receiving the form submission using receive_form_submission", "event_espresso"))); |
320 | 320 | } |
321 | - if( ! parent::is_valid()){ |
|
321 | + if ( ! parent::is_valid()) { |
|
322 | 322 | return false; |
323 | 323 | } |
324 | 324 | //ok so no errors general to this entire form section. so let's check the subsections |
325 | - foreach( $this->get_validatable_subsections() as $subsection ){ |
|
326 | - if( ! $subsection->is_valid() || $subsection->get_validation_error_string() != '' ){ |
|
327 | - $this->set_submission_error_message( $subsection->get_validation_error_string() ); |
|
325 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
326 | + if ( ! $subsection->is_valid() || $subsection->get_validation_error_string() != '') { |
|
327 | + $this->set_submission_error_message($subsection->get_validation_error_string()); |
|
328 | 328 | return false; |
329 | 329 | } |
330 | 330 | } |
@@ -337,11 +337,11 @@ discard block |
||
337 | 337 | * gets teh default name of this form section if none is specified |
338 | 338 | * @return string |
339 | 339 | */ |
340 | - protected function _set_default_name_if_empty(){ |
|
341 | - if( ! $this->_name ){ |
|
340 | + protected function _set_default_name_if_empty() { |
|
341 | + if ( ! $this->_name) { |
|
342 | 342 | $classname = get_class($this); |
343 | 343 | $default_name = str_replace("EE_", "", $classname); |
344 | - $this->_name = $default_name; |
|
344 | + $this->_name = $default_name; |
|
345 | 345 | } |
346 | 346 | } |
347 | 347 | |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | * Also returns the HTML for the form, except for the form opening and closing tags |
353 | 353 | * (as the form section doesn't know where you necessarily want to send the information to), and except for a submit button. |
354 | 354 | */ |
355 | - public function get_html_and_js(){ |
|
355 | + public function get_html_and_js() { |
|
356 | 356 | $this->enqueue_js(); |
357 | 357 | return $this->get_html(); |
358 | 358 | } |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | * returns HTML for displaying this form section. recursively calls display_section() on all subsections |
364 | 364 | * @return string |
365 | 365 | */ |
366 | - public function get_html(){ |
|
366 | + public function get_html() { |
|
367 | 367 | $this->ensure_construct_finalized_called(); |
368 | 368 | return $this->_layout_strategy->layout_form(); |
369 | 369 | } |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | * enqueues JS for the form |
375 | 375 | * @return string |
376 | 376 | */ |
377 | - public function enqueue_js(){ |
|
377 | + public function enqueue_js() { |
|
378 | 378 | $this->_enqueue_and_localize_form_js(); |
379 | 379 | } |
380 | 380 | |
@@ -390,11 +390,11 @@ discard block |
||
390 | 390 | * @param boolean $init_form_validation_automatically whether or not we want the form validation to be triggered automatically or not |
391 | 391 | * @return void |
392 | 392 | */ |
393 | - public static function wp_enqueue_scripts( $init_form_validation_automatically = false ){ |
|
394 | - add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
|
395 | - wp_register_script( 'ee_form_section_validation', EE_GLOBAL_ASSETS_URL . 'scripts' . DS . 'form_section_validation.js', array( 'jquery-validate', 'jquery-ui-datepicker' ), EVENT_ESPRESSO_VERSION, TRUE ); |
|
393 | + public static function wp_enqueue_scripts($init_form_validation_automatically = false) { |
|
394 | + add_filter('FHEE_load_jquery_validate', '__return_true'); |
|
395 | + wp_register_script('ee_form_section_validation', EE_GLOBAL_ASSETS_URL.'scripts'.DS.'form_section_validation.js', array('jquery-validate', 'jquery-ui-datepicker'), EVENT_ESPRESSO_VERSION, TRUE); |
|
396 | 396 | |
397 | - wp_localize_script( 'ee_form_section_validation', 'ee_form_section_validation_init', array( 'init' => $init_form_validation_automatically ) ); |
|
397 | + wp_localize_script('ee_form_section_validation', 'ee_form_section_validation_init', array('init' => $init_form_validation_automatically)); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | |
@@ -404,14 +404,14 @@ discard block |
||
404 | 404 | * This needs to be called AFTER we've called $this->_enqueue_jquery_validate_script, |
405 | 405 | * but before the wordpress hook wp_loaded |
406 | 406 | */ |
407 | - public function _enqueue_and_localize_form_js(){ |
|
407 | + public function _enqueue_and_localize_form_js() { |
|
408 | 408 | $this->ensure_construct_finalized_called(); |
409 | 409 | //actually, we don't want to localize just yet. There may be other forms on the page. |
410 | 410 | //so we need to add our form section data to a static variable accessible by all form sections |
411 | 411 | //and localize it just before the footer |
412 | 412 | $this->localize_validation_rules(); |
413 | - add_action( 'wp_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ), 2 ); |
|
414 | - add_action( 'admin_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ) ); |
|
413 | + add_action('wp_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'), 2); |
|
414 | + add_action('admin_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms')); |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | |
@@ -421,11 +421,11 @@ discard block |
||
421 | 421 | * @param bool $return_for_subsection |
422 | 422 | * @return void |
423 | 423 | */ |
424 | - public function localize_validation_rules( $return_for_subsection = FALSE ){ |
|
424 | + public function localize_validation_rules($return_for_subsection = FALSE) { |
|
425 | 425 | // we only want to localize vars ONCE for the entire form, so if the form section doesn't have a parent, then it must be the top dog |
426 | - if ( ! $this->parent_section() || $return_for_subsection ) { |
|
427 | - EE_Form_Section_Proper::$_js_localization['form_data'][ $this->html_id() ] = array( |
|
428 | - 'form_section_id'=> $this->html_id( TRUE ), |
|
426 | + if ( ! $this->parent_section() || $return_for_subsection) { |
|
427 | + EE_Form_Section_Proper::$_js_localization['form_data'][$this->html_id()] = array( |
|
428 | + 'form_section_id'=> $this->html_id(TRUE), |
|
429 | 429 | 'validation_rules'=> $this->get_jquery_validation_rules(), |
430 | 430 | 'errors'=> $this->subsection_validation_errors_by_html_name() |
431 | 431 | ); |
@@ -440,12 +440,12 @@ discard block |
||
440 | 440 | * Keys are their form names, and values are the inputs themselves |
441 | 441 | * @return EE_Form_Input_Base |
442 | 442 | */ |
443 | - public function inputs_in_subsections(){ |
|
443 | + public function inputs_in_subsections() { |
|
444 | 444 | $inputs = array(); |
445 | - foreach($this->subsections() as $subsection){ |
|
446 | - if( $subsection instanceof EE_Form_Input_Base ){ |
|
447 | - $inputs[ $subsection->html_name() ] = $subsection; |
|
448 | - }elseif($subsection instanceof EE_Form_Section_Proper ){ |
|
445 | + foreach ($this->subsections() as $subsection) { |
|
446 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
447 | + $inputs[$subsection->html_name()] = $subsection; |
|
448 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
449 | 449 | $inputs += $subsection->inputs_in_subsections(); |
450 | 450 | } |
451 | 451 | } |
@@ -458,12 +458,12 @@ discard block |
||
458 | 458 | * and values are a string of all their validation errors |
459 | 459 | * @return string[] |
460 | 460 | */ |
461 | - public function subsection_validation_errors_by_html_name(){ |
|
461 | + public function subsection_validation_errors_by_html_name() { |
|
462 | 462 | $inputs = $this->inputs(); |
463 | 463 | $errors = array(); |
464 | - foreach( $inputs as $form_input ){ |
|
465 | - if ( $form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors() ){ |
|
466 | - $errors[ $form_input->html_name() ] = $form_input->get_validation_error_string(); |
|
464 | + foreach ($inputs as $form_input) { |
|
465 | + if ($form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors()) { |
|
466 | + $errors[$form_input->html_name()] = $form_input->get_validation_error_string(); |
|
467 | 467 | } |
468 | 468 | } |
469 | 469 | return $errors; |
@@ -475,12 +475,12 @@ discard block |
||
475 | 475 | * passes all the form data required by the JS to the JS, and enqueues the few required JS files. |
476 | 476 | * Should be setup by each form during the _enqueues_and_localize_form_js |
477 | 477 | */ |
478 | - public static function localize_script_for_all_forms(){ |
|
478 | + public static function localize_script_for_all_forms() { |
|
479 | 479 | //allow inputs and stuff to hook in their JS and stuff here |
480 | 480 | do_action('AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin'); |
481 | 481 | EE_Form_Section_Proper::$_js_localization['localized_error_messages'] = EE_Form_Section_Proper::_get_localized_error_messages(); |
482 | - wp_enqueue_script( 'ee_form_section_validation' ); |
|
483 | - wp_localize_script( 'ee_form_section_validation', 'ee_form_section_vars', EE_Form_Section_Proper::$_js_localization ); |
|
482 | + wp_enqueue_script('ee_form_section_validation'); |
|
483 | + wp_localize_script('ee_form_section_validation', 'ee_form_section_vars', EE_Form_Section_Proper::$_js_localization); |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | |
@@ -488,8 +488,8 @@ discard block |
||
488 | 488 | /** |
489 | 489 | * ensure_scripts_localized |
490 | 490 | */ |
491 | - public function ensure_scripts_localized(){ |
|
492 | - if ( ! EE_Form_Section_Proper::$_scripts_localized ) { |
|
491 | + public function ensure_scripts_localized() { |
|
492 | + if ( ! EE_Form_Section_Proper::$_scripts_localized) { |
|
493 | 493 | $this->_enqueue_and_localize_form_js(); |
494 | 494 | } |
495 | 495 | } |
@@ -501,10 +501,10 @@ discard block |
||
501 | 501 | * is that the key here should be the same as the custom validation rule put in the JS file |
502 | 502 | * @return array keys are custom validation rules, and values are internationalized strings |
503 | 503 | */ |
504 | - private static function _get_localized_error_messages(){ |
|
504 | + private static function _get_localized_error_messages() { |
|
505 | 505 | return array( |
506 | 506 | 'validUrl'=> __("This is not a valid absolute URL. Eg, http://domain.com/monkey.jpg", "event_espresso"), |
507 | - 'regex' => __( 'Please check your input', 'event_espresso' ), |
|
507 | + 'regex' => __('Please check your input', 'event_espresso'), |
|
508 | 508 | ); |
509 | 509 | } |
510 | 510 | |
@@ -532,10 +532,10 @@ discard block |
||
532 | 532 | * Gets the JS to put inside the jquery validation rules for subsection of this form section. See parent function for more... |
533 | 533 | * @return array |
534 | 534 | */ |
535 | - function get_jquery_validation_rules(){ |
|
535 | + function get_jquery_validation_rules() { |
|
536 | 536 | $jquery_validation_rules = array(); |
537 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
538 | - $jquery_validation_rules = array_merge( $jquery_validation_rules, $subsection->get_jquery_validation_rules() ); |
|
537 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
538 | + $jquery_validation_rules = array_merge($jquery_validation_rules, $subsection->get_jquery_validation_rules()); |
|
539 | 539 | } |
540 | 540 | return $jquery_validation_rules; |
541 | 541 | } |
@@ -550,11 +550,11 @@ discard block |
||
550 | 550 | protected function _normalize($req_data) { |
551 | 551 | $this->_received_submission = TRUE; |
552 | 552 | $this->_validation_errors = array(); |
553 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
554 | - try{ |
|
553 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
554 | + try { |
|
555 | 555 | $subsection->_normalize($req_data); |
556 | - }catch( EE_Validation_Error $e ){ |
|
557 | - $subsection->add_validation_error( $e ); |
|
556 | + } catch (EE_Validation_Error $e) { |
|
557 | + $subsection->add_validation_error($e); |
|
558 | 558 | } |
559 | 559 | } |
560 | 560 | } |
@@ -568,9 +568,9 @@ discard block |
||
568 | 568 | * calling parent::_validate() first. |
569 | 569 | */ |
570 | 570 | protected function _validate() { |
571 | - foreach($this->get_validatable_subsections() as $subsection_name => $subsection){ |
|
572 | - if(method_exists($this,'_validate_'.$subsection_name)){ |
|
573 | - call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection)); |
|
571 | + foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) { |
|
572 | + if (method_exists($this, '_validate_'.$subsection_name)) { |
|
573 | + call_user_func_array(array($this, '_validate_'.$subsection_name), array($subsection)); |
|
574 | 574 | } |
575 | 575 | $subsection->_validate(); |
576 | 576 | } |
@@ -582,13 +582,13 @@ discard block |
||
582 | 582 | * Gets all the validated inputs for the form section |
583 | 583 | * @return array |
584 | 584 | */ |
585 | - public function valid_data(){ |
|
585 | + public function valid_data() { |
|
586 | 586 | $inputs = array(); |
587 | - foreach( $this->subsections() as $subsection_name =>$subsection ){ |
|
588 | - if ( $subsection instanceof EE_Form_Section_Proper ) { |
|
589 | - $inputs[ $subsection_name ] = $subsection->valid_data(); |
|
590 | - } else if ( $subsection instanceof EE_Form_Input_Base ){ |
|
591 | - $inputs[ $subsection_name ] = $subsection->normalized_value(); |
|
587 | + foreach ($this->subsections() as $subsection_name =>$subsection) { |
|
588 | + if ($subsection instanceof EE_Form_Section_Proper) { |
|
589 | + $inputs[$subsection_name] = $subsection->valid_data(); |
|
590 | + } else if ($subsection instanceof EE_Form_Input_Base) { |
|
591 | + $inputs[$subsection_name] = $subsection->normalized_value(); |
|
592 | 592 | } |
593 | 593 | } |
594 | 594 | return $inputs; |
@@ -600,11 +600,11 @@ discard block |
||
600 | 600 | * Gets all the inputs on this form section |
601 | 601 | * @return EE_Form_Input_Base[] |
602 | 602 | */ |
603 | - public function inputs(){ |
|
603 | + public function inputs() { |
|
604 | 604 | $inputs = array(); |
605 | - foreach( $this->subsections() as $subsection_name =>$subsection ){ |
|
606 | - if ( $subsection instanceof EE_Form_Input_Base ){ |
|
607 | - $inputs[ $subsection_name ] = $subsection; |
|
605 | + foreach ($this->subsections() as $subsection_name =>$subsection) { |
|
606 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
607 | + $inputs[$subsection_name] = $subsection; |
|
608 | 608 | } |
609 | 609 | } |
610 | 610 | return $inputs; |
@@ -616,10 +616,10 @@ discard block |
||
616 | 616 | * Gets all the subsections which are a proper form |
617 | 617 | * @return EE_Form_Section_Proper[] |
618 | 618 | */ |
619 | - public function subforms(){ |
|
619 | + public function subforms() { |
|
620 | 620 | $form_sections = array(); |
621 | - foreach($this->subsections() as $name=>$obj){ |
|
622 | - if($obj instanceof EE_Form_Section_Proper){ |
|
621 | + foreach ($this->subsections() as $name=>$obj) { |
|
622 | + if ($obj instanceof EE_Form_Section_Proper) { |
|
623 | 623 | $form_sections[$name] = $obj; |
624 | 624 | } |
625 | 625 | } |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | * if you only want form inputs or proper form sections. |
635 | 635 | * @return EE_Form_Section_Proper[] |
636 | 636 | */ |
637 | - public function subsections(){ |
|
637 | + public function subsections() { |
|
638 | 638 | $this->ensure_construct_finalized_called(); |
639 | 639 | return $this->_subsections; |
640 | 640 | } |
@@ -652,8 +652,8 @@ discard block |
||
652 | 652 | * it can be a multidimensional array where keys are always subsection names and values are either the |
653 | 653 | * input's normalized value, or an array like the top-level array |
654 | 654 | */ |
655 | - public function input_values( $include_subform_inputs = false, $flatten = false ){ |
|
656 | - return $this->_input_values( false, $include_subform_inputs, $flatten ); |
|
655 | + public function input_values($include_subform_inputs = false, $flatten = false) { |
|
656 | + return $this->_input_values(false, $include_subform_inputs, $flatten); |
|
657 | 657 | } |
658 | 658 | |
659 | 659 | /** |
@@ -669,8 +669,8 @@ discard block |
||
669 | 669 | * it can be a multidimensional array where keys are always subsection names and values are either the |
670 | 670 | * input's normalized value, or an array like the top-level array |
671 | 671 | */ |
672 | - public function input_pretty_values( $include_subform_inputs = false, $flatten = false ){ |
|
673 | - return $this->_input_values( true, $include_subform_inputs, $flatten ); |
|
672 | + public function input_pretty_values($include_subform_inputs = false, $flatten = false) { |
|
673 | + return $this->_input_values(true, $include_subform_inputs, $flatten); |
|
674 | 674 | } |
675 | 675 | |
676 | 676 | /** |
@@ -683,17 +683,17 @@ discard block |
||
683 | 683 | * it can be a multidimensional array where keys are always subsection names and values are either the |
684 | 684 | * input's normalized value, or an array like the top-level array |
685 | 685 | */ |
686 | - public function _input_values( $pretty = false, $include_subform_inputs = false, $flatten = false ) { |
|
686 | + public function _input_values($pretty = false, $include_subform_inputs = false, $flatten = false) { |
|
687 | 687 | $input_values = array(); |
688 | - foreach( $this->subsections() as $subsection_name => $subsection ) { |
|
689 | - if( $subsection instanceof EE_Form_Input_Base ) { |
|
690 | - $input_values[ $subsection_name ] = $pretty ? $subsection->pretty_value() : $subsection->normalized_value(); |
|
691 | - } else if( $subsection instanceof EE_Form_Section_Proper && $include_subform_inputs ) { |
|
692 | - $subform_input_values = $subsection->_input_values( $pretty, $include_subform_inputs, $flatten ); |
|
693 | - if( $flatten ) { |
|
694 | - $input_values = array_merge( $input_values, $subform_input_values ); |
|
688 | + foreach ($this->subsections() as $subsection_name => $subsection) { |
|
689 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
690 | + $input_values[$subsection_name] = $pretty ? $subsection->pretty_value() : $subsection->normalized_value(); |
|
691 | + } else if ($subsection instanceof EE_Form_Section_Proper && $include_subform_inputs) { |
|
692 | + $subform_input_values = $subsection->_input_values($pretty, $include_subform_inputs, $flatten); |
|
693 | + if ($flatten) { |
|
694 | + $input_values = array_merge($input_values, $subform_input_values); |
|
695 | 695 | } else { |
696 | - $input_values[ $subsection_name ] = $subform_input_values; |
|
696 | + $input_values[$subsection_name] = $subform_input_values; |
|
697 | 697 | } |
698 | 698 | } |
699 | 699 | } |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | * (ie, had receive_form_submission called on it yet) |
708 | 708 | * @return boolean |
709 | 709 | */ |
710 | - public function has_received_submission(){ |
|
710 | + public function has_received_submission() { |
|
711 | 711 | $this->ensure_construct_finalized_called(); |
712 | 712 | return $this->_received_submission; |
713 | 713 | } |
@@ -720,8 +720,8 @@ discard block |
||
720 | 720 | * @param array $inputs_to_exclude values are the input names |
721 | 721 | * @return void |
722 | 722 | */ |
723 | - public function exclude($inputs_to_exclude = array()){ |
|
724 | - foreach($inputs_to_exclude as $input_to_exclude_name){ |
|
723 | + public function exclude($inputs_to_exclude = array()) { |
|
724 | + foreach ($inputs_to_exclude as $input_to_exclude_name) { |
|
725 | 725 | unset($this->_subsections[$input_to_exclude_name]); |
726 | 726 | } |
727 | 727 | } |
@@ -731,8 +731,8 @@ discard block |
||
731 | 731 | /** |
732 | 732 | * @param array $inputs_to_hide |
733 | 733 | */ |
734 | - public function hide($inputs_to_hide= array()){ |
|
735 | - foreach($inputs_to_hide as $input_to_hide){ |
|
734 | + public function hide($inputs_to_hide = array()) { |
|
735 | + foreach ($inputs_to_hide as $input_to_hide) { |
|
736 | 736 | $input = $this->get_input($input_to_hide); |
737 | 737 | |
738 | 738 | $input->set_display_strategy(new EE_Hidden_Display_Strategy()); |
@@ -757,13 +757,13 @@ discard block |
||
757 | 757 | * or if $subsection_name_to_target is null, before or after entire subsections array |
758 | 758 | * @return void |
759 | 759 | */ |
760 | - public function add_subsections( $new_subsections, $subsection_name_to_target = NULL, $add_before = true ){ |
|
761 | - foreach($new_subsections as $subsection_name => $subsection){ |
|
762 | - if( ! $subsection instanceof EE_Form_Section_Base){ |
|
760 | + public function add_subsections($new_subsections, $subsection_name_to_target = NULL, $add_before = true) { |
|
761 | + foreach ($new_subsections as $subsection_name => $subsection) { |
|
762 | + if ( ! $subsection instanceof EE_Form_Section_Base) { |
|
763 | 763 | EE_Error::add_error( |
764 | 764 | sprintf( |
765 | 765 | __("Trying to add a %s as a subsection (it was named '%s') to the form section '%s'. It was removed.", "event_espresso"), |
766 | - get_class( $subsection ), |
|
766 | + get_class($subsection), |
|
767 | 767 | $subsection_name, |
768 | 768 | $this->name() |
769 | 769 | ) |
@@ -772,8 +772,8 @@ discard block |
||
772 | 772 | } |
773 | 773 | } |
774 | 774 | |
775 | - EE_Registry::instance()->load_helper( 'Array' ); |
|
776 | - $this->_subsections = EEH_Array::insert_into_array( $this->_subsections, $new_subsections, $subsection_name_to_target, $add_before ); |
|
775 | + EE_Registry::instance()->load_helper('Array'); |
|
776 | + $this->_subsections = EEH_Array::insert_into_array($this->_subsections, $new_subsections, $subsection_name_to_target, $add_before); |
|
777 | 777 | |
778 | 778 | /*$subsections_before = array(); |
779 | 779 | if( $subsection_name_to_target ){ |
@@ -804,8 +804,8 @@ discard block |
||
804 | 804 | $this->_subsections = $new_subsections; |
805 | 805 | } |
806 | 806 | }*/ |
807 | - if( $this->_construction_finalized ){ |
|
808 | - foreach($this->_subsections as $name => $subsection){ |
|
807 | + if ($this->_construction_finalized) { |
|
808 | + foreach ($this->_subsections as $name => $subsection) { |
|
809 | 809 | $subsection->_construct_finalize($this, $name); |
810 | 810 | } |
811 | 811 | } |
@@ -816,8 +816,8 @@ discard block |
||
816 | 816 | /** |
817 | 817 | * Just gets all validatable subsections to clean their sensitive data |
818 | 818 | */ |
819 | - public function clean_sensitive_data(){ |
|
820 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
819 | + public function clean_sensitive_data() { |
|
820 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
821 | 821 | $subsection->clean_sensitive_data(); |
822 | 822 | } |
823 | 823 | } |
@@ -827,8 +827,8 @@ discard block |
||
827 | 827 | /** |
828 | 828 | * @param string $form_submission_error_message |
829 | 829 | */ |
830 | - public function set_submission_error_message( $form_submission_error_message = '' ) { |
|
831 | - $this->_form_submission_error_message .= ! empty( $form_submission_error_message ) ? $form_submission_error_message : __( 'Form submission failed due to errors', 'event_espresso' ); |
|
830 | + public function set_submission_error_message($form_submission_error_message = '') { |
|
831 | + $this->_form_submission_error_message .= ! empty($form_submission_error_message) ? $form_submission_error_message : __('Form submission failed due to errors', 'event_espresso'); |
|
832 | 832 | } |
833 | 833 | |
834 | 834 | |
@@ -845,8 +845,8 @@ discard block |
||
845 | 845 | /** |
846 | 846 | * @param string $form_submission_success_message |
847 | 847 | */ |
848 | - public function set_submission_success_message( $form_submission_success_message ) { |
|
849 | - $this->_form_submission_success_message .= ! empty( $form_submission_success_message ) ? $form_submission_success_message : __( 'Form submitted successfully', 'event_espresso' ); |
|
848 | + public function set_submission_success_message($form_submission_success_message) { |
|
849 | + $this->_form_submission_success_message .= ! empty($form_submission_success_message) ? $form_submission_success_message : __('Form submitted successfully', 'event_espresso'); |
|
850 | 850 | } |
851 | 851 | |
852 | 852 | |
@@ -868,10 +868,10 @@ discard block |
||
868 | 868 | * EE_Form_Input_Base::_set_default_html_name_if_empty |
869 | 869 | * @return string |
870 | 870 | */ |
871 | - public function html_name_prefix(){ |
|
872 | - if( $this->parent_section() instanceof EE_Form_Section_Proper ){ |
|
873 | - return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']'; |
|
874 | - }else{ |
|
871 | + public function html_name_prefix() { |
|
872 | + if ($this->parent_section() instanceof EE_Form_Section_Proper) { |
|
873 | + return $this->parent_section()->html_name_prefix().'['.$this->name().']'; |
|
874 | + } else { |
|
875 | 875 | return $this->name(); |
876 | 876 | } |
877 | 877 | } |
@@ -882,7 +882,7 @@ discard block |
||
882 | 882 | * was set, which is probably nothing, or the classname) |
883 | 883 | * @return string |
884 | 884 | */ |
885 | - public function name(){ |
|
885 | + public function name() { |
|
886 | 886 | $this->ensure_construct_finalized_called(); |
887 | 887 | return parent::name(); |
888 | 888 | } |
@@ -891,7 +891,7 @@ discard block |
||
891 | 891 | * |
892 | 892 | * @return EE_Form_Section_Proper |
893 | 893 | */ |
894 | - public function parent_section(){ |
|
894 | + public function parent_section() { |
|
895 | 895 | $this->ensure_construct_finalized_called(); |
896 | 896 | return parent::parent_section(); |
897 | 897 | } |
@@ -900,9 +900,9 @@ discard block |
||
900 | 900 | * make sure construction finalized was called, otherwise children might not be ready |
901 | 901 | * @return void |
902 | 902 | */ |
903 | - public function ensure_construct_finalized_called(){ |
|
904 | - if( ! $this->_construction_finalized ){ |
|
905 | - $this->_construct_finalize($this->_parent_section, $this->_name ); |
|
903 | + public function ensure_construct_finalized_called() { |
|
904 | + if ( ! $this->_construction_finalized) { |
|
905 | + $this->_construct_finalize($this->_parent_section, $this->_name); |
|
906 | 906 | } |
907 | 907 | } |
908 | 908 | |
@@ -914,17 +914,17 @@ discard block |
||
914 | 914 | * @param array $req_data |
915 | 915 | * @return boolean |
916 | 916 | */ |
917 | - public function form_data_present_in( $req_data = NULL ) { |
|
918 | - if( $req_data === NULL){ |
|
917 | + public function form_data_present_in($req_data = NULL) { |
|
918 | + if ($req_data === NULL) { |
|
919 | 919 | $req_data = $_POST; |
920 | 920 | } |
921 | - foreach( $this->subsections() as $subsection ) { |
|
922 | - if($subsection instanceof EE_Form_Input_Base ) { |
|
923 | - if( $subsection->form_data_present_in( $req_data ) ) { |
|
921 | + foreach ($this->subsections() as $subsection) { |
|
922 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
923 | + if ($subsection->form_data_present_in($req_data)) { |
|
924 | 924 | return TRUE; |
925 | 925 | } |
926 | - }elseif( $subsection instanceof EE_Form_Section_Proper ) { |
|
927 | - if( $subsection->form_data_present_in( $req_data ) ) { |
|
926 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
927 | + if ($subsection->form_data_present_in($req_data)) { |
|
928 | 928 | return TRUE; |
929 | 929 | } |
930 | 930 | } |
@@ -941,14 +941,14 @@ discard block |
||
941 | 941 | */ |
942 | 942 | public function get_validation_errors_accumulated() { |
943 | 943 | $validation_errors = $this->get_validation_errors(); |
944 | - foreach($this->get_validatable_subsections() as $subsection ) { |
|
945 | - if( $subsection instanceof EE_Form_Section_Proper ) { |
|
944 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
945 | + if ($subsection instanceof EE_Form_Section_Proper) { |
|
946 | 946 | $validation_errors_on_this_subsection = $subsection->get_validation_errors_accumulated(); |
947 | 947 | } else { |
948 | - $validation_errors_on_this_subsection = $subsection->get_validation_errors(); |
|
948 | + $validation_errors_on_this_subsection = $subsection->get_validation_errors(); |
|
949 | 949 | } |
950 | - if( $validation_errors_on_this_subsection ){ |
|
951 | - $validation_errors = array_merge( $validation_errors, $validation_errors_on_this_subsection ); |
|
950 | + if ($validation_errors_on_this_subsection) { |
|
951 | + $validation_errors = array_merge($validation_errors, $validation_errors_on_this_subsection); |
|
952 | 952 | } |
953 | 953 | } |
954 | 954 | return $validation_errors; |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @subpackage |
9 | 9 | * @author Mike Nelson |
10 | 10 | */ |
11 | -abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable{ |
|
11 | +abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * the input's name attribute |
@@ -141,67 +141,67 @@ discard block |
||
141 | 141 | * @type EE_Validation_Strategy_Base[] $validation_strategies |
142 | 142 | * } |
143 | 143 | */ |
144 | - public function __construct( $input_args = array() ){ |
|
145 | - $input_args = apply_filters( 'FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this ); |
|
144 | + public function __construct($input_args = array()) { |
|
145 | + $input_args = apply_filters('FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this); |
|
146 | 146 | // the following properties must be cast as arrays |
147 | 147 | $set_as_array = array( |
148 | 148 | 'validation_strategies' |
149 | 149 | ); |
150 | 150 | // loop thru incoming options |
151 | - foreach( $input_args as $key => $value ) { |
|
151 | + foreach ($input_args as $key => $value) { |
|
152 | 152 | // add underscore to $key to match property names |
153 | - $_key = '_' . $key; |
|
154 | - if ( property_exists( $this, $_key )) { |
|
153 | + $_key = '_'.$key; |
|
154 | + if (property_exists($this, $_key)) { |
|
155 | 155 | // first check if this property needs to be set as an array |
156 | - if ( isset( $set_as_array[ $key ] )) { |
|
156 | + if (isset($set_as_array[$key])) { |
|
157 | 157 | // ensure value is an array |
158 | - $value = is_array( $value ) ? $value : array( $value ); |
|
158 | + $value = is_array($value) ? $value : array($value); |
|
159 | 159 | // and merge with existing values |
160 | - $this->{$_key} = array_merge( $this->{$_key}, $value ); |
|
160 | + $this->{$_key} = array_merge($this->{$_key}, $value); |
|
161 | 161 | } else { |
162 | 162 | $this->{$_key} = $value; |
163 | 163 | } |
164 | 164 | } |
165 | 165 | } |
166 | 166 | // ensure that "required" is set correctly |
167 | - $this->set_required( $this->_required, isset( $input_args[ 'required_validation_error_message' ] ) ? $input_args[ 'required_validation_error_message' ] : NULL ); |
|
167 | + $this->set_required($this->_required, isset($input_args['required_validation_error_message']) ? $input_args['required_validation_error_message'] : NULL); |
|
168 | 168 | |
169 | - $this->_html_name_specified = isset( $input_args['html_name'] ) ? TRUE : FALSE; |
|
169 | + $this->_html_name_specified = isset($input_args['html_name']) ? TRUE : FALSE; |
|
170 | 170 | |
171 | 171 | $this->_display_strategy->_construct_finalize($this); |
172 | 172 | |
173 | - if ( $this->_validation_strategies ){ |
|
174 | - foreach( $this->_validation_strategies as $validation_strategy ){ |
|
173 | + if ($this->_validation_strategies) { |
|
174 | + foreach ($this->_validation_strategies as $validation_strategy) { |
|
175 | 175 | $validation_strategy->_construct_finalize($this); |
176 | 176 | } |
177 | 177 | } |
178 | 178 | |
179 | - if( ! $this->_normalization_strategy){ |
|
179 | + if ( ! $this->_normalization_strategy) { |
|
180 | 180 | $this->_normalization_strategy = new EE_Text_Normalization(); |
181 | 181 | } |
182 | 182 | $this->_normalization_strategy->_construct_finalize($this); |
183 | 183 | |
184 | 184 | //at least we can use the normalization strategy to populate the default |
185 | - if( isset( $input_args[ 'default' ] ) ) { |
|
186 | - $this->set_default( $input_args[ 'default' ] ); |
|
185 | + if (isset($input_args['default'])) { |
|
186 | + $this->set_default($input_args['default']); |
|
187 | 187 | } |
188 | 188 | |
189 | - if( ! $this->_sensitive_data_removal_strategy){ |
|
189 | + if ( ! $this->_sensitive_data_removal_strategy) { |
|
190 | 190 | $this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal(); |
191 | 191 | } |
192 | 192 | $this->_sensitive_data_removal_strategy->_construct_finalize($this); |
193 | - parent::__construct( $input_args ); |
|
193 | + parent::__construct($input_args); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
197 | 197 | * Sets the html_name to its default value, if none was specified in teh constructor. |
198 | 198 | * Calculation involves using the name and the parent's html_name |
199 | 199 | */ |
200 | - protected function _set_default_html_name_if_empty(){ |
|
201 | - if( ! $this->_html_name){ |
|
202 | - if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper){ |
|
203 | - $this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]"; |
|
204 | - }else{ |
|
200 | + protected function _set_default_html_name_if_empty() { |
|
201 | + if ( ! $this->_html_name) { |
|
202 | + if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
|
203 | + $this->_html_name = $this->_parent_section->html_name_prefix()."[{$this->name()}]"; |
|
204 | + } else { |
|
205 | 205 | $this->_html_name = $this->name(); |
206 | 206 | } |
207 | 207 | } |
@@ -216,12 +216,12 @@ discard block |
||
216 | 216 | function _construct_finalize($parent_form_section, $name) { |
217 | 217 | parent::_construct_finalize($parent_form_section, $name); |
218 | 218 | $this->_set_default_html_name_if_empty(); |
219 | - if( ! $this->_html_label ){ |
|
220 | - if( ! $this->_html_label_text){ |
|
221 | - $this->_html_label_text = ucwords( str_replace("_"," ",$name)); |
|
219 | + if ( ! $this->_html_label) { |
|
220 | + if ( ! $this->_html_label_text) { |
|
221 | + $this->_html_label_text = ucwords(str_replace("_", " ", $name)); |
|
222 | 222 | } |
223 | 223 | } |
224 | - do_action( 'AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name ); |
|
224 | + do_action('AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /** |
@@ -229,10 +229,10 @@ discard block |
||
229 | 229 | * @return EE_Display_Strategy_Base |
230 | 230 | * @throws EE_Error |
231 | 231 | */ |
232 | - protected function _get_display_strategy(){ |
|
233 | - if( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base){ |
|
234 | - throw new EE_Error(sprintf(__("Cannot get display strategy for form input with name %s and id %s, because it has not been set in the constructor", "event_espresso"),$this->html_name(),$this->html_id())); |
|
235 | - }else{ |
|
232 | + protected function _get_display_strategy() { |
|
233 | + if ( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) { |
|
234 | + throw new EE_Error(sprintf(__("Cannot get display strategy for form input with name %s and id %s, because it has not been set in the constructor", "event_espresso"), $this->html_name(), $this->html_id())); |
|
235 | + } else { |
|
236 | 236 | return $this->_display_strategy; |
237 | 237 | } |
238 | 238 | } |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * Sets the display strategy. |
241 | 241 | * @param EE_Display_Strategy_Base $strategy |
242 | 242 | */ |
243 | - protected function _set_display_strategy(EE_Display_Strategy_Base $strategy){ |
|
243 | + protected function _set_display_strategy(EE_Display_Strategy_Base $strategy) { |
|
244 | 244 | $this->_display_strategy = $strategy; |
245 | 245 | } |
246 | 246 | |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | * Sets the sanitization strategy |
249 | 249 | * @param EE_Normalization_Strategy_Base $strategy |
250 | 250 | */ |
251 | - protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy){ |
|
251 | + protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy) { |
|
252 | 252 | $this->_normalization_strategy = $strategy; |
253 | 253 | } |
254 | 254 | |
@@ -274,14 +274,14 @@ discard block |
||
274 | 274 | * Gets the display strategy for this input |
275 | 275 | * @return EE_Display_Strategy_Base |
276 | 276 | */ |
277 | - public function get_display_strategy(){ |
|
277 | + public function get_display_strategy() { |
|
278 | 278 | return $this->_display_strategy; |
279 | 279 | } |
280 | 280 | /** |
281 | 281 | * Overwrites the display strategy |
282 | 282 | * @param EE_Display_Strategy_Base $display_strategy |
283 | 283 | */ |
284 | - public function set_display_strategy($display_strategy){ |
|
284 | + public function set_display_strategy($display_strategy) { |
|
285 | 285 | $this->_display_strategy = $display_strategy; |
286 | 286 | $this->_display_strategy->_construct_finalize($this); |
287 | 287 | } |
@@ -289,14 +289,14 @@ discard block |
||
289 | 289 | * Gets the normalization strategy set on this input |
290 | 290 | * @return EE_Normalization_Strategy_Base |
291 | 291 | */ |
292 | - public function get_normalization_strategy(){ |
|
292 | + public function get_normalization_strategy() { |
|
293 | 293 | return $this->_normalization_strategy; |
294 | 294 | } |
295 | 295 | /** |
296 | 296 | * Overwrites the normalization strategy |
297 | 297 | * @param EE_Normalization_Strategy_Base $normalization_strategy |
298 | 298 | */ |
299 | - public function set_normalization_strategy($normalization_strategy){ |
|
299 | + public function set_normalization_strategy($normalization_strategy) { |
|
300 | 300 | $this->_normalization_strategy = $normalization_strategy; |
301 | 301 | $this->_normalization_strategy->_construct_finalize($this); |
302 | 302 | } |
@@ -305,10 +305,10 @@ discard block |
||
305 | 305 | * Returns all teh validation strategies which apply to this field, numerically indexed |
306 | 306 | * @return EE_Validation_Strategy_Base[] |
307 | 307 | */ |
308 | - public function get_validation_strategies(){ |
|
309 | - if(is_array($this->_validation_strategies)){ |
|
308 | + public function get_validation_strategies() { |
|
309 | + if (is_array($this->_validation_strategies)) { |
|
310 | 310 | return $this->_validation_strategies; |
311 | - }else{ |
|
311 | + } else { |
|
312 | 312 | return array(); |
313 | 313 | } |
314 | 314 | |
@@ -318,9 +318,9 @@ discard block |
||
318 | 318 | * @param EE_Validation_Strategy_Base $validation_strategy |
319 | 319 | * @return void |
320 | 320 | */ |
321 | - protected function _add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ){ |
|
322 | - $validation_strategy->_construct_finalize( $this ); |
|
323 | - $this->_validation_strategies[ get_class($validation_strategy) ] = $validation_strategy; |
|
321 | + protected function _add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) { |
|
322 | + $validation_strategy->_construct_finalize($this); |
|
323 | + $this->_validation_strategies[get_class($validation_strategy)] = $validation_strategy; |
|
324 | 324 | |
325 | 325 | } |
326 | 326 | |
@@ -329,18 +329,18 @@ discard block |
||
329 | 329 | * @param EE_Validation_Strategy_Base $validation_strategy |
330 | 330 | * @return void |
331 | 331 | */ |
332 | - public function add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ) { |
|
333 | - $this->_add_validation_strategy( $validation_strategy ); |
|
332 | + public function add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) { |
|
333 | + $this->_add_validation_strategy($validation_strategy); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | /** |
337 | 337 | * The classname of the validation strategy to remove |
338 | 338 | * @param string $validation_strategy_classname |
339 | 339 | */ |
340 | - public function remove_validation_strategy( $validation_strategy_classname ) { |
|
341 | - foreach( $this->_validation_strategies as $key => $validation_strategy ){ |
|
342 | - if( is_subclass_of( $validation_strategy, $validation_strategy_classname ) ){ |
|
343 | - unset( $this->_validation_strategies[ $key ] ); |
|
340 | + public function remove_validation_strategy($validation_strategy_classname) { |
|
341 | + foreach ($this->_validation_strategies as $key => $validation_strategy) { |
|
342 | + if (is_subclass_of($validation_strategy, $validation_strategy_classname)) { |
|
343 | + unset($this->_validation_strategies[$key]); |
|
344 | 344 | } |
345 | 345 | } |
346 | 346 | } |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | * to the parent form's layout strategy |
350 | 350 | * @return string |
351 | 351 | */ |
352 | - public function get_html_and_js(){ |
|
352 | + public function get_html_and_js() { |
|
353 | 353 | return $this->_parent_section->get_html_for_input($this); |
354 | 354 | } |
355 | 355 | /** |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | * Makes sure the JS and CSS are enqueued for it |
359 | 359 | * @return string |
360 | 360 | */ |
361 | - public function get_html_for_input(){ |
|
361 | + public function get_html_for_input() { |
|
362 | 362 | return $this->_get_display_strategy()->display(); |
363 | 363 | } |
364 | 364 | |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | * @return string |
369 | 369 | */ |
370 | 370 | public function html_other_attributes() { |
371 | - return ! empty( $this->_html_other_attributes ) ? ' ' . $this->_html_other_attributes : ''; |
|
371 | + return ! empty($this->_html_other_attributes) ? ' '.$this->_html_other_attributes : ''; |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | /** |
377 | 377 | * @param string $html_other_attributes |
378 | 378 | */ |
379 | - public function set_html_other_attributes( $html_other_attributes ) { |
|
379 | + public function set_html_other_attributes($html_other_attributes) { |
|
380 | 380 | $this->_html_other_attributes = $html_other_attributes; |
381 | 381 | } |
382 | 382 | |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | * according to the form section's layout strategy |
386 | 386 | * @return string |
387 | 387 | */ |
388 | - public function get_html_for_label(){ |
|
388 | + public function get_html_for_label() { |
|
389 | 389 | return $this->_parent_section->get_layout_strategy()->display_label($this); |
390 | 390 | } |
391 | 391 | /** |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | * according to the form section's layout strategy |
394 | 394 | * @return string |
395 | 395 | */ |
396 | - public function get_html_for_errors(){ |
|
396 | + public function get_html_for_errors() { |
|
397 | 397 | return $this->_parent_section->get_layout_strategy()->display_errors($this); |
398 | 398 | } |
399 | 399 | /** |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | * according to the form section's layout strategy |
402 | 402 | * @return string |
403 | 403 | */ |
404 | - public function get_html_for_help(){ |
|
404 | + public function get_html_for_help() { |
|
405 | 405 | return $this->_parent_section->get_layout_strategy()->display_help_text($this); |
406 | 406 | } |
407 | 407 | /** |
@@ -410,20 +410,20 @@ discard block |
||
410 | 410 | * @return boolean |
411 | 411 | */ |
412 | 412 | protected function _validate() { |
413 | - if(is_array($this->_validation_strategies)){ |
|
414 | - foreach($this->_validation_strategies as $validation_strategy){ |
|
415 | - if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) { |
|
416 | - try{ |
|
413 | + if (is_array($this->_validation_strategies)) { |
|
414 | + foreach ($this->_validation_strategies as $validation_strategy) { |
|
415 | + if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
416 | + try { |
|
417 | 417 | $validation_strategy->validate($this->normalized_value()); |
418 | - }catch(EE_Validation_Error $e){ |
|
418 | + } catch (EE_Validation_Error $e) { |
|
419 | 419 | $this->add_validation_error($e); |
420 | 420 | } |
421 | 421 | } |
422 | 422 | } |
423 | 423 | } |
424 | - if( $this->get_validation_errors()){ |
|
424 | + if ($this->get_validation_errors()) { |
|
425 | 425 | return false; |
426 | - }else{ |
|
426 | + } else { |
|
427 | 427 | return true; |
428 | 428 | } |
429 | 429 | } |
@@ -436,8 +436,8 @@ discard block |
||
436 | 436 | * @param string $value |
437 | 437 | * @return null|string |
438 | 438 | */ |
439 | - private function _sanitize($value){ |
|
440 | - return $value !== NULL ?stripslashes(html_entity_decode($value)) : NULL;//don't sanitize_text_field |
|
439 | + private function _sanitize($value) { |
|
440 | + return $value !== NULL ? stripslashes(html_entity_decode($value)) : NULL; //don't sanitize_text_field |
|
441 | 441 | } |
442 | 442 | |
443 | 443 | |
@@ -449,24 +449,24 @@ discard block |
||
449 | 449 | * @param array $req_data like $_POST |
450 | 450 | * @return boolean whether or not there was an error |
451 | 451 | */ |
452 | - protected function _normalize( $req_data ) { |
|
452 | + protected function _normalize($req_data) { |
|
453 | 453 | //any existing validation errors don't apply so clear them |
454 | 454 | $this->_validation_errors = array(); |
455 | 455 | try { |
456 | - $raw_input = $this->find_form_data_for_this_section( $req_data ); |
|
456 | + $raw_input = $this->find_form_data_for_this_section($req_data); |
|
457 | 457 | //super simple sanitization for now |
458 | - if ( is_array( $raw_input )) { |
|
458 | + if (is_array($raw_input)) { |
|
459 | 459 | $this->_raw_value = array(); |
460 | - foreach( $raw_input as $key => $value ) { |
|
461 | - $this->_raw_value[ $key ] = $this->_sanitize( $value ); |
|
460 | + foreach ($raw_input as $key => $value) { |
|
461 | + $this->_raw_value[$key] = $this->_sanitize($value); |
|
462 | 462 | } |
463 | 463 | } else { |
464 | - $this->_raw_value = $this->_sanitize( $raw_input ); |
|
464 | + $this->_raw_value = $this->_sanitize($raw_input); |
|
465 | 465 | } |
466 | 466 | //we want ot mostly leave the input alone in case we need to re-display it to the user |
467 | - $this->_normalized_value = $this->_normalization_strategy->normalize( $this->raw_value() ); |
|
468 | - } catch ( EE_Validation_Error $e ) { |
|
469 | - $this->add_validation_error( $e ); |
|
467 | + $this->_normalized_value = $this->_normalization_strategy->normalize($this->raw_value()); |
|
468 | + } catch (EE_Validation_Error $e) { |
|
469 | + $this->add_validation_error($e); |
|
470 | 470 | } |
471 | 471 | } |
472 | 472 | |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | /** |
476 | 476 | * @return string |
477 | 477 | */ |
478 | - public function html_name(){ |
|
478 | + public function html_name() { |
|
479 | 479 | return $this->_html_name; |
480 | 480 | } |
481 | 481 | |
@@ -484,8 +484,8 @@ discard block |
||
484 | 484 | /** |
485 | 485 | * @return string |
486 | 486 | */ |
487 | - function html_label_id(){ |
|
488 | - return ! empty( $this->_html_label_id ) ? $this->_html_label_id : $this->_html_id . '-lbl'; |
|
487 | + function html_label_id() { |
|
488 | + return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->_html_id.'-lbl'; |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | /** |
494 | 494 | * @return string |
495 | 495 | */ |
496 | - function html_label_class(){ |
|
496 | + function html_label_class() { |
|
497 | 497 | return $this->_html_label_class; |
498 | 498 | } |
499 | 499 | |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | /** |
503 | 503 | * @return string |
504 | 504 | */ |
505 | - function html_label_style(){ |
|
505 | + function html_label_style() { |
|
506 | 506 | return $this->_html_label_style; |
507 | 507 | } |
508 | 508 | |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | /** |
512 | 512 | * @return string |
513 | 513 | */ |
514 | - function html_label_text(){ |
|
514 | + function html_label_text() { |
|
515 | 515 | return $this->_html_label_text; |
516 | 516 | } |
517 | 517 | |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | /** |
521 | 521 | * @return string |
522 | 522 | */ |
523 | - function html_help_text(){ |
|
523 | + function html_help_text() { |
|
524 | 524 | return $this->_html_help_text; |
525 | 525 | } |
526 | 526 | |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | /** |
530 | 530 | * @return string |
531 | 531 | */ |
532 | - function html_help_class(){ |
|
532 | + function html_help_class() { |
|
533 | 533 | return $this->_html_help_class; |
534 | 534 | } |
535 | 535 | |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | /** |
539 | 539 | * @return string |
540 | 540 | */ |
541 | - function html_help_style(){ |
|
541 | + function html_help_style() { |
|
542 | 542 | return $this->_html_style; |
543 | 543 | } |
544 | 544 | /** |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | * in which case, we would have stored the malicious content to our database. |
552 | 552 | * @return string |
553 | 553 | */ |
554 | - function raw_value(){ |
|
554 | + function raw_value() { |
|
555 | 555 | return $this->_raw_value; |
556 | 556 | } |
557 | 557 | /** |
@@ -559,15 +559,15 @@ discard block |
||
559 | 559 | * it escapes all html entities |
560 | 560 | * @return string |
561 | 561 | */ |
562 | - function raw_value_in_form(){ |
|
563 | - return htmlentities($this->raw_value(),ENT_QUOTES, 'UTF-8'); |
|
562 | + function raw_value_in_form() { |
|
563 | + return htmlentities($this->raw_value(), ENT_QUOTES, 'UTF-8'); |
|
564 | 564 | } |
565 | 565 | /** |
566 | 566 | * returns the value after it's been sanitized, and then converted into it's proper type |
567 | 567 | * in PHP. Eg, a string, an int, an array, |
568 | 568 | * @return mixed |
569 | 569 | */ |
570 | - function normalized_value(){ |
|
570 | + function normalized_value() { |
|
571 | 571 | return $this->_normalized_value; |
572 | 572 | } |
573 | 573 | |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | * the best thing to display |
578 | 578 | * @return string |
579 | 579 | */ |
580 | - function pretty_value(){ |
|
580 | + function pretty_value() { |
|
581 | 581 | return $this->_normalized_value; |
582 | 582 | } |
583 | 583 | /** |
@@ -596,15 +596,15 @@ discard block |
||
596 | 596 | }</code> |
597 | 597 | * @return array |
598 | 598 | */ |
599 | - function get_jquery_validation_rules(){ |
|
599 | + function get_jquery_validation_rules() { |
|
600 | 600 | $jquery_validation_rules = array(); |
601 | - foreach($this->get_validation_strategies() as $validation_strategy){ |
|
602 | - $jquery_validation_rules = array_replace_recursive( $jquery_validation_rules, $validation_strategy->get_jquery_validation_rule_array()); |
|
601 | + foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
602 | + $jquery_validation_rules = array_replace_recursive($jquery_validation_rules, $validation_strategy->get_jquery_validation_rule_array()); |
|
603 | 603 | } |
604 | 604 | |
605 | - if(! empty($jquery_validation_rules)){ |
|
606 | - $jquery_validation_js[ $this->html_id( TRUE ) ] = $jquery_validation_rules; |
|
607 | - }else{ |
|
605 | + if ( ! empty($jquery_validation_rules)) { |
|
606 | + $jquery_validation_js[$this->html_id(TRUE)] = $jquery_validation_rules; |
|
607 | + } else { |
|
608 | 608 | return array(); |
609 | 609 | } |
610 | 610 | return $jquery_validation_js; |
@@ -616,9 +616,9 @@ discard block |
||
616 | 616 | * @param mixed $value |
617 | 617 | * @return void |
618 | 618 | */ |
619 | - function set_default($value){ |
|
619 | + function set_default($value) { |
|
620 | 620 | $this->_normalized_value = $value; |
621 | - $this->_raw_value = $this->_normalization_strategy->unnormalize( $value ); |
|
621 | + $this->_raw_value = $this->_normalization_strategy->unnormalize($value); |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | /** |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | * @param string $label |
627 | 627 | * @return void |
628 | 628 | */ |
629 | - function set_html_label_text($label){ |
|
629 | + function set_html_label_text($label) { |
|
630 | 630 | $this->_html_label_text = $label; |
631 | 631 | } |
632 | 632 | |
@@ -638,12 +638,12 @@ discard block |
||
638 | 638 | * @param boolean $required |
639 | 639 | * @param null $required_text |
640 | 640 | */ |
641 | - function set_required($required = true, $required_text = NULL ){ |
|
642 | - $required = filter_var( $required, FILTER_VALIDATE_BOOLEAN ); |
|
643 | - if ( $required ) { |
|
644 | - $this->_add_validation_strategy( new EE_Required_Validation_Strategy( $required_text ) ); |
|
641 | + function set_required($required = true, $required_text = NULL) { |
|
642 | + $required = filter_var($required, FILTER_VALIDATE_BOOLEAN); |
|
643 | + if ($required) { |
|
644 | + $this->_add_validation_strategy(new EE_Required_Validation_Strategy($required_text)); |
|
645 | 645 | } else { |
646 | - unset( $this->_validation_strategies[ get_class( new EE_Required_Validation_Strategy() ) ] ); |
|
646 | + unset($this->_validation_strategies[get_class(new EE_Required_Validation_Strategy())]); |
|
647 | 647 | } |
648 | 648 | $this->_required = $required; |
649 | 649 | } |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | * Returns whether or not this field is required |
652 | 652 | * @return boolean |
653 | 653 | */ |
654 | - public function required(){ |
|
654 | + public function required() { |
|
655 | 655 | return $this->_required; |
656 | 656 | } |
657 | 657 | |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | /** |
661 | 661 | * @param string $required_css_class |
662 | 662 | */ |
663 | - public function set_required_css_class( $required_css_class ) { |
|
663 | + public function set_required_css_class($required_css_class) { |
|
664 | 664 | $this->_required_css_class = $required_css_class; |
665 | 665 | } |
666 | 666 | |
@@ -679,7 +679,7 @@ discard block |
||
679 | 679 | * Sets the help text, in case |
680 | 680 | * @param string $text |
681 | 681 | */ |
682 | - public function set_html_help_text($text){ |
|
682 | + public function set_html_help_text($text) { |
|
683 | 683 | $this->_html_help_text = $text; |
684 | 684 | } |
685 | 685 | /** |
@@ -691,8 +691,8 @@ discard block |
||
691 | 691 | public function clean_sensitive_data() { |
692 | 692 | //if we do ANY kind of sensitive data removal on this, then just clear out the raw value |
693 | 693 | //if we need more logic than this we'll make a strategy for it |
694 | - if( $this->_sensitive_data_removal_strategy && |
|
695 | - ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal ){ |
|
694 | + if ($this->_sensitive_data_removal_strategy && |
|
695 | + ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal) { |
|
696 | 696 | $this->_raw_value = NULL; |
697 | 697 | } |
698 | 698 | //and clean the normalized value according to the appropriate strategy |
@@ -706,10 +706,10 @@ discard block |
||
706 | 706 | * @param string $button_size |
707 | 707 | * @param string $other_attributes |
708 | 708 | */ |
709 | - public function set_button_css_attributes( $primary = TRUE, $button_size = '', $other_attributes = '' ) { |
|
709 | + public function set_button_css_attributes($primary = TRUE, $button_size = '', $other_attributes = '') { |
|
710 | 710 | $button_css_attributes = 'button'; |
711 | 711 | $button_css_attributes .= $primary === TRUE ? ' button-primary' : ' button-secondary'; |
712 | - switch ( $button_size ) { |
|
712 | + switch ($button_size) { |
|
713 | 713 | case 'xs' : |
714 | 714 | case 'extra-small' : |
715 | 715 | $button_css_attributes .= ' button-xs'; |
@@ -730,7 +730,7 @@ discard block |
||
730 | 730 | default : |
731 | 731 | $button_css_attributes .= ''; |
732 | 732 | } |
733 | - $this->_button_css_attributes .= ! empty( $other_attributes ) ? $button_css_attributes . ' ' . $other_attributes : $button_css_attributes; |
|
733 | + $this->_button_css_attributes .= ! empty($other_attributes) ? $button_css_attributes.' '.$other_attributes : $button_css_attributes; |
|
734 | 734 | } |
735 | 735 | |
736 | 736 | |
@@ -739,7 +739,7 @@ discard block |
||
739 | 739 | * @return string |
740 | 740 | */ |
741 | 741 | public function button_css_attributes() { |
742 | - if ( empty( $this->_button_css_attributes )) { |
|
742 | + if (empty($this->_button_css_attributes)) { |
|
743 | 743 | $this->set_button_css_attributes(); |
744 | 744 | } |
745 | 745 | return $this->_button_css_attributes; |
@@ -759,27 +759,27 @@ discard block |
||
759 | 759 | * @param array $req_data |
760 | 760 | * @return mixed whatever the raw value of this form section is in the request data |
761 | 761 | */ |
762 | - public function find_form_data_for_this_section( $req_data ){ |
|
762 | + public function find_form_data_for_this_section($req_data) { |
|
763 | 763 | // break up the html name by "[]" |
764 | - if ( strpos( $this->html_name(), '[' ) !== FALSE ) { |
|
765 | - $before_any_brackets = substr( $this->html_name(), 0, strpos($this->html_name(), '[') ); |
|
764 | + if (strpos($this->html_name(), '[') !== FALSE) { |
|
765 | + $before_any_brackets = substr($this->html_name(), 0, strpos($this->html_name(), '[')); |
|
766 | 766 | } else { |
767 | 767 | $before_any_brackets = $this->html_name(); |
768 | 768 | } |
769 | 769 | // grab all of the segments |
770 | - preg_match_all('~\[([^]]*)\]~',$this->html_name(), $matches); |
|
771 | - if( isset( $matches[ 1 ] ) && is_array( $matches[ 1 ] ) ){ |
|
772 | - $name_parts = $matches[ 1 ]; |
|
770 | + preg_match_all('~\[([^]]*)\]~', $this->html_name(), $matches); |
|
771 | + if (isset($matches[1]) && is_array($matches[1])) { |
|
772 | + $name_parts = $matches[1]; |
|
773 | 773 | array_unshift($name_parts, $before_any_brackets); |
774 | - }else{ |
|
775 | - $name_parts = array( $before_any_brackets ); |
|
774 | + } else { |
|
775 | + $name_parts = array($before_any_brackets); |
|
776 | 776 | } |
777 | 777 | // now get the value for the input |
778 | 778 | $value = $this->_find_form_data_for_this_section_using_name_parts($name_parts, $req_data); |
779 | - if( $value === NULL ){ |
|
779 | + if ($value === NULL) { |
|
780 | 780 | //check if this thing's name is at the TOP level of the request data |
781 | - if( isset( $req_data[ $this->name() ] ) ){ |
|
782 | - $value = $req_data[ $this->name() ]; |
|
781 | + if (isset($req_data[$this->name()])) { |
|
782 | + $value = $req_data[$this->name()]; |
|
783 | 783 | } |
784 | 784 | } |
785 | 785 | return $value; |
@@ -793,15 +793,15 @@ discard block |
||
793 | 793 | * @param array $req_data |
794 | 794 | * @return array | NULL |
795 | 795 | */ |
796 | - public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data){ |
|
797 | - $first_part_to_consider = array_shift( $html_name_parts ); |
|
798 | - if( isset( $req_data[ $first_part_to_consider ] ) ){ |
|
799 | - if( empty($html_name_parts ) ){ |
|
800 | - return $req_data[ $first_part_to_consider ]; |
|
801 | - }else{ |
|
802 | - return $this->_find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data[ $first_part_to_consider ] ); |
|
796 | + public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data) { |
|
797 | + $first_part_to_consider = array_shift($html_name_parts); |
|
798 | + if (isset($req_data[$first_part_to_consider])) { |
|
799 | + if (empty($html_name_parts)) { |
|
800 | + return $req_data[$first_part_to_consider]; |
|
801 | + } else { |
|
802 | + return $this->_find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data[$first_part_to_consider]); |
|
803 | 803 | } |
804 | - }else{ |
|
804 | + } else { |
|
805 | 805 | return NULL; |
806 | 806 | } |
807 | 807 | } |
@@ -813,14 +813,14 @@ discard block |
||
813 | 813 | * @param array $req_data like $_POST |
814 | 814 | * @return boolean |
815 | 815 | */ |
816 | - public function form_data_present_in($req_data = NULL){ |
|
817 | - if( $req_data === NULL ){ |
|
816 | + public function form_data_present_in($req_data = NULL) { |
|
817 | + if ($req_data === NULL) { |
|
818 | 818 | $req_data = $_POST; |
819 | 819 | } |
820 | - $checked_value = $this->find_form_data_for_this_section( $req_data ); |
|
821 | - if( $checked_value !== null ){ |
|
820 | + $checked_value = $this->find_form_data_for_this_section($req_data); |
|
821 | + if ($checked_value !== null) { |
|
822 | 822 | return TRUE; |
823 | - }else{ |
|
823 | + } else { |
|
824 | 824 | return FALSE; |
825 | 825 | } |
826 | 826 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | * @return void |
290 | 290 | */ |
291 | 291 | public function enqueue_scripts_styles() { |
292 | - do_action( 'AHEE__EE_messenger__enqueue_scripts_styles'); |
|
292 | + do_action('AHEE__EE_messenger__enqueue_scripts_styles'); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | |
326 | 326 | $this->_supports_labels->template_variation_description = __('These are different styles to choose from for the selected template structure. Usually these affect things like font style, color, borders etc. In some cases the styles will also make minor layout changes.'); |
327 | 327 | |
328 | - $this->_supports_labels = apply_filters( 'FHEE__EE_messenger___set_supports_labels_defaults___supports_labels', $this->_supports_labels, $this ); |
|
328 | + $this->_supports_labels = apply_filters('FHEE__EE_messenger___set_supports_labels_defaults___supports_labels', $this->_supports_labels, $this); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | |
@@ -340,10 +340,10 @@ discard block |
||
340 | 340 | * @return stdClass |
341 | 341 | */ |
342 | 342 | public function get_supports_labels() { |
343 | - if ( empty( $this->_supports_labels->template_pack ) || empty( $this->_supports_labels->template_variation) ) { |
|
343 | + if (empty($this->_supports_labels->template_pack) || empty($this->_supports_labels->template_variation)) { |
|
344 | 344 | $this->_set_supports_labels_defaults(); |
345 | 345 | } |
346 | - return apply_filters( 'FHEE__EE_messenger__get_supports_labels', $this->_supports_labels, $this ); |
|
346 | + return apply_filters('FHEE__EE_messenger__get_supports_labels', $this->_supports_labels, $this); |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | |
@@ -363,10 +363,10 @@ discard block |
||
363 | 363 | * |
364 | 364 | * @return string path or url for the requested variation. |
365 | 365 | */ |
366 | - public function get_variation( EE_Messages_Template_Pack $pack, $message_type_name, $url = FALSE, $type = 'main', $variation = 'default', $skip_filters = FALSE ) { |
|
366 | + public function get_variation(EE_Messages_Template_Pack $pack, $message_type_name, $url = FALSE, $type = 'main', $variation = 'default', $skip_filters = FALSE) { |
|
367 | 367 | $this->_tmp_pack = $pack; |
368 | - $variation_path = apply_filters( 'EE_messenger__get_variation__variation', false, $pack, $this->name, $message_type_name, $url, $type, $variation, $skip_filters ); |
|
369 | - $variation_path = empty( $variation_path ) ? $this->_tmp_pack->get_variation( $this->name, $message_type_name, $type, $variation, $url, '.css', $skip_filters ) : $variation_path; |
|
368 | + $variation_path = apply_filters('EE_messenger__get_variation__variation', false, $pack, $this->name, $message_type_name, $url, $type, $variation, $skip_filters); |
|
369 | + $variation_path = empty($variation_path) ? $this->_tmp_pack->get_variation($this->name, $message_type_name, $type, $variation, $url, '.css', $skip_filters) : $variation_path; |
|
370 | 370 | return $variation_path; |
371 | 371 | |
372 | 372 | } |
@@ -384,13 +384,13 @@ discard block |
||
384 | 384 | * @return array |
385 | 385 | */ |
386 | 386 | public function get_default_message_types() { |
387 | - $class = get_class( $this ); |
|
387 | + $class = get_class($this); |
|
388 | 388 | |
389 | 389 | //messenger specific filter |
390 | - $default_types = apply_filters( 'FHEE__' . $class . '__get_default_message_types__default_types', $this->_default_message_types, $this ); |
|
390 | + $default_types = apply_filters('FHEE__'.$class.'__get_default_message_types__default_types', $this->_default_message_types, $this); |
|
391 | 391 | |
392 | 392 | //all messengers filter |
393 | - $default_types = apply_filters( 'FHEE__EE_messenger__get_default_message_types__default_types', $default_types, $this ); |
|
393 | + $default_types = apply_filters('FHEE__EE_messenger__get_default_message_types__default_types', $default_types, $this); |
|
394 | 394 | return $default_types; |
395 | 395 | } |
396 | 396 | |
@@ -405,14 +405,14 @@ discard block |
||
405 | 405 | * @return array |
406 | 406 | */ |
407 | 407 | public function get_valid_message_types() { |
408 | - $class = get_class( $this ); |
|
408 | + $class = get_class($this); |
|
409 | 409 | |
410 | 410 | //messenger specific filter |
411 | 411 | //messenger specific filter |
412 | - $valid_types = apply_filters( 'FHEE__' . $class . '__get_valid_message_types__valid_types', $this->_valid_message_types, $this ); |
|
412 | + $valid_types = apply_filters('FHEE__'.$class.'__get_valid_message_types__valid_types', $this->_valid_message_types, $this); |
|
413 | 413 | |
414 | 414 | //all messengers filter |
415 | - $valid_types = apply_filters( 'FHEE__EE_messenger__get_valid_message_types__valid_types', $valid_types, $this ); |
|
415 | + $valid_types = apply_filters('FHEE__EE_messenger__get_valid_message_types__valid_types', $valid_types, $this); |
|
416 | 416 | return $valid_types; |
417 | 417 | } |
418 | 418 | |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | * @access public |
427 | 427 | * @param array $new_config Whatever is put in here will reset the _validator_config property |
428 | 428 | */ |
429 | - public function set_validator_config( $new_config ) { |
|
429 | + public function set_validator_config($new_config) { |
|
430 | 430 | $this->_validator_config = $new_config; |
431 | 431 | } |
432 | 432 | |
@@ -442,8 +442,8 @@ discard block |
||
442 | 442 | public function get_validator_config() { |
443 | 443 | $class = get_class($this); |
444 | 444 | |
445 | - $config = apply_filters( 'FHEE__' . $class . '__get_validator_config', $this->_validator_config, $this ); |
|
446 | - $config = apply_filters( 'FHEE__EE_messenger__get_validator_config', $config, $this ); |
|
445 | + $config = apply_filters('FHEE__'.$class.'__get_validator_config', $this->_validator_config, $this); |
|
446 | + $config = apply_filters('FHEE__EE_messenger__get_validator_config', $config, $this); |
|
447 | 447 | return $config; |
448 | 448 | } |
449 | 449 | |
@@ -460,8 +460,8 @@ discard block |
||
460 | 460 | * @access public |
461 | 461 | * @return string content for page |
462 | 462 | */ |
463 | - public function get_messenger_admin_page_content( $page, $action = null, $extra = array(), $message_types = array() ) { |
|
464 | - return $this->_get_admin_page_content( $page, $action, $extra, $message_types ); |
|
463 | + public function get_messenger_admin_page_content($page, $action = null, $extra = array(), $message_types = array()) { |
|
464 | + return $this->_get_admin_page_content($page, $action, $extra, $message_types); |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | |
@@ -470,76 +470,76 @@ discard block |
||
470 | 470 | |
471 | 471 | |
472 | 472 | |
473 | - protected function _get_admin_content_events_edit( $message_types, $extra ) { |
|
473 | + protected function _get_admin_content_events_edit($message_types, $extra) { |
|
474 | 474 | //defaults |
475 | 475 | $template_args = array(); |
476 | 476 | $custom_templates = array(); |
477 | 477 | $selector_rows = ''; |
478 | 478 | |
479 | 479 | //we don't need message types here so we're just going to ignore. we do, however, expect the event id here. The event id is needed to provide a link to setup a custom template for this event. |
480 | - $event_id = isset( $extra['event'] ) ? $extra['event'] : NULL; |
|
480 | + $event_id = isset($extra['event']) ? $extra['event'] : NULL; |
|
481 | 481 | |
482 | - $template_wrapper_path = EE_LIBRARIES . 'messages/messenger/admin_templates/event_switcher_wrapper.template.php'; |
|
483 | - $template_row_path = EE_LIBRARIES . 'messages/messenger/admin_templates/event_switcher_row.template.php'; |
|
482 | + $template_wrapper_path = EE_LIBRARIES.'messages/messenger/admin_templates/event_switcher_wrapper.template.php'; |
|
483 | + $template_row_path = EE_LIBRARIES.'messages/messenger/admin_templates/event_switcher_row.template.php'; |
|
484 | 484 | |
485 | 485 | //array of template objects for global and custom (non-trashed) (but remember just for this messenger!) |
486 | - $global_templates = EEM_Message_Template_Group::instance()->get_all( array( array('MTP_messenger' => $this->name, 'MTP_is_global' => TRUE, 'MTP_is_active' => TRUE ) ) ); |
|
487 | - $templates_for_event = EEM_Message_Template_Group::instance()->get_all_custom_templates_by_event( $event_id, array( 'MTP_messenger' => $this->name, 'MTP_is_active' => TRUE ) ); |
|
488 | - $templates_for_event = !empty( $templates_for_event ) ? $templates_for_event : array(); |
|
486 | + $global_templates = EEM_Message_Template_Group::instance()->get_all(array(array('MTP_messenger' => $this->name, 'MTP_is_global' => TRUE, 'MTP_is_active' => TRUE))); |
|
487 | + $templates_for_event = EEM_Message_Template_Group::instance()->get_all_custom_templates_by_event($event_id, array('MTP_messenger' => $this->name, 'MTP_is_active' => TRUE)); |
|
488 | + $templates_for_event = ! empty($templates_for_event) ? $templates_for_event : array(); |
|
489 | 489 | |
490 | 490 | //so we need to setup the rows for the selectors and we use the global mtpgs (cause those will the active message template groups) |
491 | - foreach ( $global_templates as $mtpgID => $mtpg ) { |
|
491 | + foreach ($global_templates as $mtpgID => $mtpg) { |
|
492 | 492 | //verify this message type is supposed to show on this page |
493 | 493 | $mtp_obj = $mtpg->message_type_obj(); |
494 | - if ( ! $mtp_obj instanceof EE_message_type ) { |
|
494 | + if ( ! $mtp_obj instanceof EE_message_type) { |
|
495 | 495 | continue; |
496 | 496 | } |
497 | 497 | $mtp_obj->admin_registered_pages = (array) $mtp_obj->admin_registered_pages; |
498 | - if ( ! in_array( 'events_edit', $mtp_obj->admin_registered_pages ) ) |
|
498 | + if ( ! in_array('events_edit', $mtp_obj->admin_registered_pages)) |
|
499 | 499 | continue; |
500 | 500 | $stargs = array(); |
501 | 501 | $default_value = ''; |
502 | 502 | $select_values = array(); |
503 | 503 | $select_values[$mtpgID] = __('Global', 'event_espresso'); |
504 | - $default_value = array_key_exists( $mtpgID, $templates_for_event ) && ! $mtpg->get('MTP_is_override' ) ? $mtpgID : NULL; |
|
504 | + $default_value = array_key_exists($mtpgID, $templates_for_event) && ! $mtpg->get('MTP_is_override') ? $mtpgID : NULL; |
|
505 | 505 | |
506 | 506 | //if the override has been set for the global template, then that means even if there are custom templates already created we ignore them because of the set override. |
507 | 507 | |
508 | - if ( ! $mtpg->get('MTP_is_override' ) ) { |
|
508 | + if ( ! $mtpg->get('MTP_is_override')) { |
|
509 | 509 | //any custom templates for this message type? |
510 | - $custom_templates = EEM_Message_Template_Group::instance()->get_custom_message_template_by_m_and_mt( $this->name, $mtpg->message_type() ); |
|
510 | + $custom_templates = EEM_Message_Template_Group::instance()->get_custom_message_template_by_m_and_mt($this->name, $mtpg->message_type()); |
|
511 | 511 | |
512 | - foreach( $custom_templates as $cmtpgID => $cmtpg ) { |
|
512 | + foreach ($custom_templates as $cmtpgID => $cmtpg) { |
|
513 | 513 | $select_values[$cmtpgID] = $cmtpg->name(); |
514 | - $default_value = array_key_exists( $cmtpgID, $templates_for_event ) ? $cmtpgID : $default_value; |
|
514 | + $default_value = array_key_exists($cmtpgID, $templates_for_event) ? $cmtpgID : $default_value; |
|
515 | 515 | } |
516 | 516 | } |
517 | 517 | |
518 | 518 | //if there is no $default_value then we set it as the global |
519 | - $default_value = empty( $default_value ) ? $mtpgID : $default_value; |
|
519 | + $default_value = empty($default_value) ? $mtpgID : $default_value; |
|
520 | 520 | |
521 | - $edit_url = EEH_URL::add_query_args_and_nonce( array('page' => 'espresso_messages', 'action' => 'edit_message_template', 'id' => $default_value), admin_url('admin.php') ); |
|
522 | - $create_url = EEH_URL::add_query_args_and_nonce( array('page' => 'espresso_messages', 'action' => 'add_new_message_template', 'GRP_ID' => $default_value ), admin_url( 'admin.php' ) ); |
|
521 | + $edit_url = EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_messages', 'action' => 'edit_message_template', 'id' => $default_value), admin_url('admin.php')); |
|
522 | + $create_url = EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_messages', 'action' => 'add_new_message_template', 'GRP_ID' => $default_value), admin_url('admin.php')); |
|
523 | 523 | |
524 | - $st_args['mt_name'] = ucwords( $mtp_obj->label['singular'] ); |
|
524 | + $st_args['mt_name'] = ucwords($mtp_obj->label['singular']); |
|
525 | 525 | $st_args['mt_slug'] = $mtpg->message_type(); |
526 | 526 | $st_args['messenger_slug'] = $this->name; |
527 | - $st_args['selector'] = EEH_Form_Fields::select_input( 'event_message_templates_relation[' . $mtpgID . ']', $select_values, $default_value, 'data-messenger="' . $this->name . '" data-messagetype="' . $mtpg->message_type() . '"', 'message-template-selector' ); |
|
527 | + $st_args['selector'] = EEH_Form_Fields::select_input('event_message_templates_relation['.$mtpgID.']', $select_values, $default_value, 'data-messenger="'.$this->name.'" data-messagetype="'.$mtpg->message_type().'"', 'message-template-selector'); |
|
528 | 528 | |
529 | 529 | //note that message template group that has override_all_custom set will remove the ability to set a custom message template based off of the global (and that also in turn overrides any other custom templates). |
530 | - $st_args['create_button'] = $mtpg->get('MTP_is_override') ? '' : '<a data-messenger="' . $this->name . '" data-messagetype="' . $mtpg->message_type() . '" data-grpid="' . $default_value . '" target="_blank" href="' . $create_url . '" class="button button-small create-mtpg-button">' . __('Create New Custom', 'event_espresso') . '</a>'; |
|
531 | - $st_args['create_button'] = EE_Registry::instance()->CAP->current_user_can( 'ee_edit_messages', 'espresso_messsages_add_new_message_template' ) ? $st_args['create_button'] : ''; |
|
532 | - $st_args['edit_button'] = EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $mtpgID ) ? '<a data-messagetype="' . $mtpg->message_type() . '" data-grpid="' . $default_value . '" target="_blank" href="' . $edit_url . '" class="button button-small edit-mtpg-button">' . __('Edit', 'event_espresso') . '</a>' : ''; |
|
533 | - $selector_rows .= EEH_Template::display_template( $template_row_path, $st_args, TRUE ); |
|
530 | + $st_args['create_button'] = $mtpg->get('MTP_is_override') ? '' : '<a data-messenger="'.$this->name.'" data-messagetype="'.$mtpg->message_type().'" data-grpid="'.$default_value.'" target="_blank" href="'.$create_url.'" class="button button-small create-mtpg-button">'.__('Create New Custom', 'event_espresso').'</a>'; |
|
531 | + $st_args['create_button'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'espresso_messsages_add_new_message_template') ? $st_args['create_button'] : ''; |
|
532 | + $st_args['edit_button'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $mtpgID) ? '<a data-messagetype="'.$mtpg->message_type().'" data-grpid="'.$default_value.'" target="_blank" href="'.$edit_url.'" class="button button-small edit-mtpg-button">'.__('Edit', 'event_espresso').'</a>' : ''; |
|
533 | + $selector_rows .= EEH_Template::display_template($template_row_path, $st_args, TRUE); |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | //if no selectors present then get out. |
537 | - if ( empty( $selector_rows ) ) { |
|
537 | + if (empty($selector_rows)) { |
|
538 | 538 | return ''; |
539 | 539 | } |
540 | 540 | |
541 | 541 | $template_args['selector_rows'] = $selector_rows; |
542 | - return EEH_Template::display_template( $template_wrapper_path, $template_args, TRUE ); |
|
542 | + return EEH_Template::display_template($template_wrapper_path, $template_args, TRUE); |
|
543 | 543 | } |
544 | 544 | |
545 | 545 | |
@@ -554,8 +554,8 @@ discard block |
||
554 | 554 | * @return array $this->_template_fields |
555 | 555 | */ |
556 | 556 | public function get_template_fields() { |
557 | - $template_fields = apply_filters( 'FHEE__' . get_class($this) . '__get_template_fields', $this->_template_fields, $this ); |
|
558 | - $template_fields = apply_filters( 'FHEE__EE_messenger__get_template_fields', $template_fields, $this ); |
|
557 | + $template_fields = apply_filters('FHEE__'.get_class($this).'__get_template_fields', $this->_template_fields, $this); |
|
558 | + $template_fields = apply_filters('FHEE__EE_messenger__get_template_fields', $template_fields, $this); |
|
559 | 559 | return $template_fields; |
560 | 560 | } |
561 | 561 | |
@@ -568,9 +568,9 @@ discard block |
||
568 | 568 | * The following method doesn't NEED to be used by child classes but might be modified by the specific messenger |
569 | 569 | */ |
570 | 570 | protected function _set_template_value($item, $value) { |
571 | - if ( array_key_exists($item, $this->_template_fields) ) { |
|
572 | - $prop = '_' . $item; |
|
573 | - $this->{$prop}= $value; |
|
571 | + if (array_key_exists($item, $this->_template_fields)) { |
|
572 | + $prop = '_'.$item; |
|
573 | + $this->{$prop} = $value; |
|
574 | 574 | } |
575 | 575 | } |
576 | 576 | |
@@ -580,8 +580,8 @@ discard block |
||
580 | 580 | * @param EE_message_type $message_type The message type object used in combination with this messenger to generate the provided message. |
581 | 581 | * @return bool | WP_Error |
582 | 582 | */ |
583 | - public function send_message( $message, EE_message_type $message_type ) { |
|
584 | - $this->_validate_and_setup( $message ); |
|
583 | + public function send_message($message, EE_message_type $message_type) { |
|
584 | + $this->_validate_and_setup($message); |
|
585 | 585 | $this->_incoming_message_type = $message_type; |
586 | 586 | return $this->_send_message(); |
587 | 587 | } |
@@ -595,28 +595,28 @@ discard block |
||
595 | 595 | * @param bool $send true we will actually use the _send method (for test sends). FALSE we just return preview |
596 | 596 | * @return string return the message html content |
597 | 597 | */ |
598 | - public function get_preview( $message, EE_message_type $message_type, $send = FALSE ) { |
|
599 | - $this->_validate_and_setup( $message ); |
|
598 | + public function get_preview($message, EE_message_type $message_type, $send = FALSE) { |
|
599 | + $this->_validate_and_setup($message); |
|
600 | 600 | |
601 | 601 | $this->_incoming_message_type = $message_type; |
602 | 602 | |
603 | - if ( $send ) { |
|
603 | + if ($send) { |
|
604 | 604 | //are we overriding any existing template fields? |
605 | 605 | $settings = $this->get_existing_test_settings(); |
606 | - if ( !empty( $settings ) ) { |
|
607 | - foreach( $settings as $field => $value ) { |
|
608 | - $this->_set_template_value( $field, $value ); |
|
606 | + if ( ! empty($settings)) { |
|
607 | + foreach ($settings as $field => $value) { |
|
608 | + $this->_set_template_value($field, $value); |
|
609 | 609 | } |
610 | 610 | } |
611 | 611 | } |
612 | 612 | |
613 | 613 | //enqueue preview js so that any links/buttons on the page are disabled. |
614 | - if ( ! $send ) { |
|
614 | + if ( ! $send) { |
|
615 | 615 | // the below may seem like duplication. However, typically if a messenger enqueues scripts/styles, |
616 | 616 | // it deregisters all existing wp scripts and styles first. So the second hook ensures our previewer still gets setup. |
617 | - add_action( 'admin_enqueue_scripts', array( $this, 'add_preview_script' ), 10 ); |
|
618 | - add_action( 'wp_enqueue_scripts', array( $this, 'add_preview_script' ), 10 ); |
|
619 | - add_action( 'AHEE__EE_messenger__enqueue_scripts_styles', array( $this, 'add_preview_script' ), 10 ); |
|
617 | + add_action('admin_enqueue_scripts', array($this, 'add_preview_script'), 10); |
|
618 | + add_action('wp_enqueue_scripts', array($this, 'add_preview_script'), 10); |
|
619 | + add_action('AHEE__EE_messenger__enqueue_scripts_styles', array($this, 'add_preview_script'), 10); |
|
620 | 620 | } |
621 | 621 | |
622 | 622 | return $send ? $this->_send_message() : $this->_preview(); |
@@ -634,10 +634,10 @@ discard block |
||
634 | 634 | */ |
635 | 635 | public function add_preview_script() { |
636 | 636 | //error message |
637 | - EE_Registry::$i18n_js_strings[ 'links_disabled' ] = __( 'All the links on this page have been disabled because this is a generated preview message for the purpose of ensuring layout, style, and content setup. To test generated links, you must trigger an actual message notification.', 'event_espresso' ); |
|
638 | - wp_register_script( 'ee-messages-preview-js', EE_LIBRARIES_URL . 'messages/messenger/assets/js/ee-messages-preview.js', array( 'jquery' ), EVENT_ESPRESSO_VERSION, true ); |
|
639 | - wp_localize_script( 'ee-messages-preview-js', 'eei18n', EE_Registry::$i18n_js_strings ); |
|
640 | - wp_enqueue_script( 'ee-messages-preview-js' ); |
|
637 | + EE_Registry::$i18n_js_strings['links_disabled'] = __('All the links on this page have been disabled because this is a generated preview message for the purpose of ensuring layout, style, and content setup. To test generated links, you must trigger an actual message notification.', 'event_espresso'); |
|
638 | + wp_register_script('ee-messages-preview-js', EE_LIBRARIES_URL.'messages/messenger/assets/js/ee-messages-preview.js', array('jquery'), EVENT_ESPRESSO_VERSION, true); |
|
639 | + wp_localize_script('ee-messages-preview-js', 'eei18n', EE_Registry::$i18n_js_strings); |
|
640 | + wp_enqueue_script('ee-messages-preview-js'); |
|
641 | 641 | } |
642 | 642 | |
643 | 643 | |
@@ -647,23 +647,23 @@ discard block |
||
647 | 647 | * @param object $message message object |
648 | 648 | * @throws \EE_Error |
649 | 649 | */ |
650 | - protected function _validate_and_setup( $message ) { |
|
651 | - if ( !is_object( $message ) ) |
|
652 | - throw new EE_Error( __('Incoming "$message" must be an object', 'event_espresso' ) ); |
|
650 | + protected function _validate_and_setup($message) { |
|
651 | + if ( ! is_object($message)) |
|
652 | + throw new EE_Error(__('Incoming "$message" must be an object', 'event_espresso')); |
|
653 | 653 | |
654 | 654 | //verify we have the required template pack value on the $message object. |
655 | - if ( empty( $message->template_pack ) || ! $message->template_pack instanceof EE_Messages_Template_Pack ) { |
|
656 | - throw new EE_Error( __('Incoming $message object must have a EE_Messages_Template_Pack object assigned to the template_pack property', 'event_espresso' ) ); |
|
655 | + if (empty($message->template_pack) || ! $message->template_pack instanceof EE_Messages_Template_Pack) { |
|
656 | + throw new EE_Error(__('Incoming $message object must have a EE_Messages_Template_Pack object assigned to the template_pack property', 'event_espresso')); |
|
657 | 657 | } |
658 | 658 | |
659 | 659 | $this->_tmp_pack = $message->template_pack; |
660 | 660 | |
661 | - $this->_variation = !empty ( $message->variation ) ? $message->variation : 'default'; |
|
661 | + $this->_variation = ! empty ($message->variation) ? $message->variation : 'default'; |
|
662 | 662 | |
663 | 663 | $template_fields = $this->get_template_fields(); |
664 | 664 | |
665 | - foreach ( $template_fields as $template => $value ) { |
|
666 | - if ( $template !== 'extra' ) |
|
665 | + foreach ($template_fields as $template => $value) { |
|
666 | + if ($template !== 'extra') |
|
667 | 667 | $this->_set_template_value($template, $message->{$template}); |
668 | 668 | } |
669 | 669 | } |
@@ -678,21 +678,21 @@ discard block |
||
678 | 678 | * @return string |
679 | 679 | * @throws \EE_Error |
680 | 680 | */ |
681 | - protected function _get_main_template( $preview = FALSE ) { |
|
681 | + protected function _get_main_template($preview = FALSE) { |
|
682 | 682 | $type = $preview ? 'preview' : 'main'; |
683 | 683 | |
684 | - $wrapper_template = $this->_tmp_pack->get_wrapper( $this->name, $type ); |
|
684 | + $wrapper_template = $this->_tmp_pack->get_wrapper($this->name, $type); |
|
685 | 685 | |
686 | 686 | //check file exists and is readable |
687 | - if ( !is_readable( $wrapper_template ) ) |
|
688 | - throw new EE_Error( sprintf( __('Unable to access the template file for the %s messenger main content wrapper. The location being attempted is %s.', 'event_espresso' ), ucwords($this->label['singular']) , $wrapper_template ) ); |
|
687 | + if ( ! is_readable($wrapper_template)) |
|
688 | + throw new EE_Error(sprintf(__('Unable to access the template file for the %s messenger main content wrapper. The location being attempted is %s.', 'event_espresso'), ucwords($this->label['singular']), $wrapper_template)); |
|
689 | 689 | |
690 | 690 | //add message type to template args |
691 | 691 | $this->_template_args['message_type'] = $this->_incoming_message_type; |
692 | 692 | |
693 | 693 | //require template helper |
694 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
695 | - return EEH_Template::display_template( $wrapper_template, $this->_template_args, TRUE ); |
|
694 | + EE_Registry::instance()->load_helper('Template'); |
|
695 | + return EEH_Template::display_template($wrapper_template, $this->_template_args, TRUE); |
|
696 | 696 | } |
697 | 697 | |
698 | 698 | |
@@ -728,7 +728,7 @@ discard block |
||
728 | 728 | */ |
729 | 729 | public function get_existing_test_settings() { |
730 | 730 | $settings = EEH_MSG_Template::get_active_messengers_in_db(); |
731 | - return isset( $settings[$this->name]['test_settings'] ) ? $settings[$this->name]['test_settings'] : array(); |
|
731 | + return isset($settings[$this->name]['test_settings']) ? $settings[$this->name]['test_settings'] : array(); |
|
732 | 732 | } |
733 | 733 | |
734 | 734 | |
@@ -739,10 +739,10 @@ discard block |
||
739 | 739 | * @access public |
740 | 740 | * @return bool success/fail |
741 | 741 | */ |
742 | - public function set_existing_test_settings( $settings ) { |
|
742 | + public function set_existing_test_settings($settings) { |
|
743 | 743 | $existing = EEH_MSG_Template::get_active_messengers_in_db(); |
744 | 744 | $existing[$this->name]['test_settings'] = $settings; |
745 | - return EEH_MSG_Template::update_active_messengers_in_db( $existing ); |
|
745 | + return EEH_MSG_Template::update_active_messengers_in_db($existing); |
|
746 | 746 | } |
747 | 747 | |
748 | 748 | |
@@ -755,21 +755,21 @@ discard block |
||
755 | 755 | * @param string $field The field to retrieve the label for |
756 | 756 | * @return string The label |
757 | 757 | */ |
758 | - public function get_field_label( $field ) { |
|
758 | + public function get_field_label($field) { |
|
759 | 759 | //first let's see if the field requests is in the top level array. |
760 | - if ( isset( $this->_template_fields[$field] ) && !empty( $this->_template_fields[$field]['label'] ) ) |
|
760 | + if (isset($this->_template_fields[$field]) && ! empty($this->_template_fields[$field]['label'])) |
|
761 | 761 | return $this->_template[$field]['label']; |
762 | 762 | |
763 | 763 | //nope so let's look in the extra array to see if it's there HOWEVER if the field exists as a top level index in the extra array then we know the label is in the 'main' index. |
764 | - if ( isset( $this->_template_fields['extra'] ) && !empty( $this->_template_fields['extra'][$field] ) && !empty( $this->_template_fields['extra'][$field]['main']['label'] ) ) |
|
764 | + if (isset($this->_template_fields['extra']) && ! empty($this->_template_fields['extra'][$field]) && ! empty($this->_template_fields['extra'][$field]['main']['label'])) |
|
765 | 765 | return $this->_template_fields['extra'][$field]['main']['label']; |
766 | 766 | |
767 | 767 | //now it's possible this field may just be existing in any of the extra array items. |
768 | - if ( !empty( $this->_template_fields['extra'] ) && is_array( $this->_template_fields['extra'] ) ) { |
|
769 | - foreach ( $this->_template_fields['extra'] as $main_field => $subfields ) { |
|
770 | - if ( !is_array( $subfields ) ) |
|
768 | + if ( ! empty($this->_template_fields['extra']) && is_array($this->_template_fields['extra'])) { |
|
769 | + foreach ($this->_template_fields['extra'] as $main_field => $subfields) { |
|
770 | + if ( ! is_array($subfields)) |
|
771 | 771 | continue; |
772 | - if ( isset( $subfields[$field] ) && !empty( $subfields[$field]['label'] ) ) |
|
772 | + if (isset($subfields[$field]) && ! empty($subfields[$field]['label'])) |
|
773 | 773 | return $subfields[$field]['label']; |
774 | 774 | } |
775 | 775 | } |
@@ -790,7 +790,7 @@ discard block |
||
790 | 790 | * |
791 | 791 | * @return void |
792 | 792 | */ |
793 | - public function do_secondary_messenger_hooks( $sending_messenger_name ) { |
|
793 | + public function do_secondary_messenger_hooks($sending_messenger_name) { |
|
794 | 794 | return; |
795 | 795 | } |
796 | 796 |
@@ -1,6 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | +} |
|
4 | 5 | |
5 | 6 | /** |
6 | 7 | * Event Espresso |
@@ -495,8 +496,9 @@ discard block |
||
495 | 496 | continue; |
496 | 497 | } |
497 | 498 | $mtp_obj->admin_registered_pages = (array) $mtp_obj->admin_registered_pages; |
498 | - if ( ! in_array( 'events_edit', $mtp_obj->admin_registered_pages ) ) |
|
499 | - continue; |
|
499 | + if ( ! in_array( 'events_edit', $mtp_obj->admin_registered_pages ) ) { |
|
500 | + continue; |
|
501 | + } |
|
500 | 502 | $stargs = array(); |
501 | 503 | $default_value = ''; |
502 | 504 | $select_values = array(); |
@@ -648,8 +650,9 @@ discard block |
||
648 | 650 | * @throws \EE_Error |
649 | 651 | */ |
650 | 652 | protected function _validate_and_setup( $message ) { |
651 | - if ( !is_object( $message ) ) |
|
652 | - throw new EE_Error( __('Incoming "$message" must be an object', 'event_espresso' ) ); |
|
653 | + if ( !is_object( $message ) ) { |
|
654 | + throw new EE_Error( __('Incoming "$message" must be an object', 'event_espresso' ) ); |
|
655 | + } |
|
653 | 656 | |
654 | 657 | //verify we have the required template pack value on the $message object. |
655 | 658 | if ( empty( $message->template_pack ) || ! $message->template_pack instanceof EE_Messages_Template_Pack ) { |
@@ -663,8 +666,9 @@ discard block |
||
663 | 666 | $template_fields = $this->get_template_fields(); |
664 | 667 | |
665 | 668 | foreach ( $template_fields as $template => $value ) { |
666 | - if ( $template !== 'extra' ) |
|
667 | - $this->_set_template_value($template, $message->{$template}); |
|
669 | + if ( $template !== 'extra' ) { |
|
670 | + $this->_set_template_value($template, $message->{$template}); |
|
671 | + } |
|
668 | 672 | } |
669 | 673 | } |
670 | 674 | |
@@ -684,8 +688,9 @@ discard block |
||
684 | 688 | $wrapper_template = $this->_tmp_pack->get_wrapper( $this->name, $type ); |
685 | 689 | |
686 | 690 | //check file exists and is readable |
687 | - if ( !is_readable( $wrapper_template ) ) |
|
688 | - throw new EE_Error( sprintf( __('Unable to access the template file for the %s messenger main content wrapper. The location being attempted is %s.', 'event_espresso' ), ucwords($this->label['singular']) , $wrapper_template ) ); |
|
691 | + if ( !is_readable( $wrapper_template ) ) { |
|
692 | + throw new EE_Error( sprintf( __('Unable to access the template file for the %s messenger main content wrapper. The location being attempted is %s.', 'event_espresso' ), ucwords($this->label['singular']) , $wrapper_template ) ); |
|
693 | + } |
|
689 | 694 | |
690 | 695 | //add message type to template args |
691 | 696 | $this->_template_args['message_type'] = $this->_incoming_message_type; |
@@ -757,20 +762,24 @@ discard block |
||
757 | 762 | */ |
758 | 763 | public function get_field_label( $field ) { |
759 | 764 | //first let's see if the field requests is in the top level array. |
760 | - if ( isset( $this->_template_fields[$field] ) && !empty( $this->_template_fields[$field]['label'] ) ) |
|
761 | - return $this->_template[$field]['label']; |
|
765 | + if ( isset( $this->_template_fields[$field] ) && !empty( $this->_template_fields[$field]['label'] ) ) { |
|
766 | + return $this->_template[$field]['label']; |
|
767 | + } |
|
762 | 768 | |
763 | 769 | //nope so let's look in the extra array to see if it's there HOWEVER if the field exists as a top level index in the extra array then we know the label is in the 'main' index. |
764 | - if ( isset( $this->_template_fields['extra'] ) && !empty( $this->_template_fields['extra'][$field] ) && !empty( $this->_template_fields['extra'][$field]['main']['label'] ) ) |
|
765 | - return $this->_template_fields['extra'][$field]['main']['label']; |
|
770 | + if ( isset( $this->_template_fields['extra'] ) && !empty( $this->_template_fields['extra'][$field] ) && !empty( $this->_template_fields['extra'][$field]['main']['label'] ) ) { |
|
771 | + return $this->_template_fields['extra'][$field]['main']['label']; |
|
772 | + } |
|
766 | 773 | |
767 | 774 | //now it's possible this field may just be existing in any of the extra array items. |
768 | 775 | if ( !empty( $this->_template_fields['extra'] ) && is_array( $this->_template_fields['extra'] ) ) { |
769 | 776 | foreach ( $this->_template_fields['extra'] as $main_field => $subfields ) { |
770 | - if ( !is_array( $subfields ) ) |
|
771 | - continue; |
|
772 | - if ( isset( $subfields[$field] ) && !empty( $subfields[$field]['label'] ) ) |
|
773 | - return $subfields[$field]['label']; |
|
777 | + if ( !is_array( $subfields ) ) { |
|
778 | + continue; |
|
779 | + } |
|
780 | + if ( isset( $subfields[$field] ) && !empty( $subfields[$field]['label'] ) ) { |
|
781 | + return $subfields[$field]['label']; |
|
782 | + } |
|
774 | 783 | } |
775 | 784 | } |
776 | 785 |