@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | |
60 | 60 | $ticket_archive_class .= WP_DEBUG ? ' ee-wp-debug' : ''; |
61 | 61 | ?> |
62 | -<tr class="ee-ticket-sortable ticket-row <?php echo sanitize_html_class($ticket_archive_class);?>" |
|
62 | +<tr class="ee-ticket-sortable ticket-row <?php echo sanitize_html_class($ticket_archive_class); ?>" |
|
63 | 63 | id="display-ticketrow-<?php echo esc_attr($tkt_row); ?>"> |
64 | 64 | <!-- TKT_order --> |
65 | 65 | <td class="ee-tkt-order-field"> |
@@ -344,23 +344,23 @@ discard block |
||
344 | 344 | name="<?php echo esc_attr($edit_tickets_name); ?>[<?php echo esc_attr($tkt_row); ?>][TKT_min]" |
345 | 345 | value="<?php echo esc_attr($TKT_min); ?>" |
346 | 346 | /> |
347 | - <label class='screen-reader-text' for='disabled-ticket-TKT_min-<?php echo esc_attr($tkt_row);?>'> |
|
347 | + <label class='screen-reader-text' for='disabled-ticket-TKT_min-<?php echo esc_attr($tkt_row); ?>'> |
|
348 | 348 | <?php |
349 | 349 | esc_html_e('Minimum Quantity', 'event_espresso') ?> |
350 | 350 | </label> |
351 | 351 | <input type="text" disabled |
352 | 352 | class="edit-ticket-TKT_min ee-small-text-inp ee-numeric" |
353 | - id='disabled-ticket-TKT_min-<?php echo esc_attr($tkt_row);?>' |
|
353 | + id='disabled-ticket-TKT_min-<?php echo esc_attr($tkt_row); ?>' |
|
354 | 354 | name="archived_ticket[<?php echo esc_attr($tkt_row); ?>][TKT_min]" |
355 | 355 | value="<?php echo esc_attr($TKT_min); ?>" |
356 | 356 | /> |
357 | 357 | <?php else : ?> |
358 | - <label class='screen-reader-text' for='edit-ticket-TKT_min-<?php echo esc_attr($tkt_row);?>'> |
|
358 | + <label class='screen-reader-text' for='edit-ticket-TKT_min-<?php echo esc_attr($tkt_row); ?>'> |
|
359 | 359 | <?php esc_html_e('Minimum Quantity', 'event_espresso') ?> |
360 | 360 | </label> |
361 | 361 | <input type="text" |
362 | 362 | class="edit-ticket-TKT_min ee-small-text-inp ee-numeric" |
363 | - id='edit-ticket-TKT_min-<?php echo esc_attr($tkt_row);?>' |
|
363 | + id='edit-ticket-TKT_min-<?php echo esc_attr($tkt_row); ?>' |
|
364 | 364 | name="<?php echo esc_attr($edit_tickets_name); ?>[<?php echo esc_attr($tkt_row); ?>][TKT_min]" |
365 | 365 | value="<?php echo esc_attr($TKT_min); ?>" |
366 | 366 | /> |
@@ -372,22 +372,22 @@ discard block |
||
372 | 372 | name="<?php echo esc_attr($edit_tickets_name); ?>[<?php echo esc_attr($tkt_row); ?>][TKT_max]" |
373 | 373 | value="<?php echo esc_attr($TKT_max); ?>" |
374 | 374 | /> |
375 | - <label class='screen-reader-text' for='disabled-ticket-TKT_max-<?php echo esc_attr($tkt_row);?>'> |
|
375 | + <label class='screen-reader-text' for='disabled-ticket-TKT_max-<?php echo esc_attr($tkt_row); ?>'> |
|
376 | 376 | <?php esc_html_e('Maximum Quantity', 'event_espresso') ?> |
377 | 377 | </label> |
378 | 378 | <input type="text" disabled |
379 | 379 | class="edit-ticket-TKT_max ee-small-text-inp ee-numeric" |
380 | - id='disabled-ticket-TKT_max-<?php echo esc_attr($tkt_row);?>' |
|
380 | + id='disabled-ticket-TKT_max-<?php echo esc_attr($tkt_row); ?>' |
|
381 | 381 | name="<?php echo esc_attr($edit_tickets_name); ?>[<?php echo esc_attr($tkt_row); ?>][TKT_max]" |
382 | 382 | value="<?php echo esc_attr($TKT_max); ?>" |
383 | 383 | /> |
384 | 384 | <?php else : ?> |
385 | - <label class='screen-reader-text' for='edit-ticket-TKT_max-<?php echo esc_attr($tkt_row);?>'> |
|
385 | + <label class='screen-reader-text' for='edit-ticket-TKT_max-<?php echo esc_attr($tkt_row); ?>'> |
|
386 | 386 | <?php esc_html_e('Maximum Quantity', 'event_espresso') ?> |
387 | 387 | </label> |
388 | 388 | <input type="text" |
389 | 389 | class="edit-ticket-TKT_max ee-small-text-inp ee-numeric" |
390 | - id='edit-ticket-TKT_max-<?php echo esc_attr($tkt_row);?>' |
|
390 | + id='edit-ticket-TKT_max-<?php echo esc_attr($tkt_row); ?>' |
|
391 | 391 | name="<?php echo esc_attr($edit_tickets_name); ?>[<?php echo esc_attr($tkt_row); ?>][TKT_max]" |
392 | 392 | value="<?php echo esc_attr($TKT_max); ?>" |
393 | 393 | /> |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | </label> |
420 | 420 | </div> |
421 | 421 | <div class="ticket-is-taxable-container"> |
422 | - <?php if (! empty($tax_rows)) { ?> |
|
422 | + <?php if ( ! empty($tax_rows)) { ?> |
|
423 | 423 | <label for="edit-ticket-TKT_taxable-<?php echo esc_attr($tkt_row); ?>"> |
424 | 424 | <?php if ($disabled) : ?> |
425 | 425 | <?php $tax_value = ! empty($TKT_taxable) ? 1 : 0; ?> |
@@ -102,8 +102,11 @@ discard block |
||
102 | 102 | name="archived_ticket[TKT_start_date]" |
103 | 103 | value="<?php echo esc_attr($TKT_start_date); ?>" |
104 | 104 | /> |
105 | - <?php else : ?> |
|
106 | - <label class='screen-reader-text' for="edit-ticket-TKT_start_date-<?php echo esc_attr($tkt_row); ?>"> |
|
105 | + <?php else { |
|
106 | + : ?> |
|
107 | + <label class='screen-reader-text' for="edit-ticket-TKT_start_date-<?php echo esc_attr($tkt_row); |
|
108 | +} |
|
109 | +?>"> |
|
107 | 110 | <?php esc_html_e('Sale Starts', 'event_espresso') ?> |
108 | 111 | </label> |
109 | 112 | <input type='text' |
@@ -136,8 +139,11 @@ discard block |
||
136 | 139 | name="archived_ticket[<?php echo esc_attr($tkt_row); ?>][TKT_end_date]" |
137 | 140 | value="<?php echo esc_attr($TKT_end_date); ?>" |
138 | 141 | /> |
139 | - <?php else : ?> |
|
140 | - <label class='screen-reader-text' for='edit-ticket-TKT_end_date-<?php echo esc_attr($tkt_row); ?>'> |
|
142 | + <?php else { |
|
143 | + : ?> |
|
144 | + <label class='screen-reader-text' for='edit-ticket-TKT_end_date-<?php echo esc_attr($tkt_row); |
|
145 | +} |
|
146 | +?>'> |
|
141 | 147 | <?php esc_html_e('Sell Until', 'event_espresso') ?> |
142 | 148 | </label> |
143 | 149 | <input type='text' |
@@ -169,8 +175,11 @@ discard block |
||
169 | 175 | name="archived_ticket[<?php echo esc_attr($tkt_row); ?>][TKT_base_price]" |
170 | 176 | value="<?php echo esc_attr($TKT_base_price); ?>" |
171 | 177 | /> |
172 | - <?php else : ?> |
|
173 | - <label class='screen-reader-text' for='edit-ticket-TKT_base_price-<?php echo esc_attr($tkt_row); ?>'> |
|
178 | + <?php else { |
|
179 | + : ?> |
|
180 | + <label class='screen-reader-text' for='edit-ticket-TKT_base_price-<?php echo esc_attr($tkt_row); |
|
181 | +} |
|
182 | +?>'> |
|
174 | 183 | <?php esc_html_e('Price', 'event_espresso') ?> |
175 | 184 | </label> |
176 | 185 | <input id="edit-ticket-TKT_base_price-<?php echo esc_attr($tkt_row); ?>" type="text" |
@@ -200,8 +209,11 @@ discard block |
||
200 | 209 | name="archived_ticket[<?php echo esc_attr($tkt_row); ?>][TKT_qty]" |
201 | 210 | value="<?php echo esc_attr($TKT_qty_for_input); ?>" |
202 | 211 | /> |
203 | - <?php else : ?> |
|
204 | - <label class='screen-reader-text' for='edit-ticket-TKT_qty-<?php echo esc_attr($tkt_row); ?>'> |
|
212 | + <?php else { |
|
213 | + : ?> |
|
214 | + <label class='screen-reader-text' for='edit-ticket-TKT_qty-<?php echo esc_attr($tkt_row); |
|
215 | +} |
|
216 | +?>'> |
|
205 | 217 | <?php esc_html_e('Qty', 'event_espresso') ?> |
206 | 218 | </label> |
207 | 219 | <input type="text" |
@@ -321,9 +333,12 @@ discard block |
||
321 | 333 | name="archived_ticket[<?php echo esc_attr($tkt_row); ?>][TKT_uses]" |
322 | 334 | value="<?php echo esc_attr($TKT_uses); ?>" |
323 | 335 | /> |
324 | - <?php else : ?> |
|
336 | + <?php else { |
|
337 | + : ?> |
|
325 | 338 | <label class='screen-reader-text' |
326 | - for='edit-ticket-TKT_uses-<?php echo esc_attr($tkt_row); ?>' |
|
339 | + for='edit-ticket-TKT_uses-<?php echo esc_attr($tkt_row); |
|
340 | +} |
|
341 | +?>' |
|
327 | 342 | > |
328 | 343 | <?php |
329 | 344 | esc_html_e('Ticket Uses', 'event_espresso') ?> |
@@ -353,8 +368,11 @@ discard block |
||
353 | 368 | name="archived_ticket[<?php echo esc_attr($tkt_row); ?>][TKT_min]" |
354 | 369 | value="<?php echo esc_attr($TKT_min); ?>" |
355 | 370 | /> |
356 | - <?php else : ?> |
|
357 | - <label class='screen-reader-text' for='edit-ticket-TKT_min-<?php echo esc_attr($tkt_row);?>'> |
|
371 | + <?php else { |
|
372 | + : ?> |
|
373 | + <label class='screen-reader-text' for='edit-ticket-TKT_min-<?php echo esc_attr($tkt_row); |
|
374 | +} |
|
375 | +?>'> |
|
358 | 376 | <?php esc_html_e('Minimum Quantity', 'event_espresso') ?> |
359 | 377 | </label> |
360 | 378 | <input type="text" |
@@ -380,8 +398,11 @@ discard block |
||
380 | 398 | name="<?php echo esc_attr($edit_tickets_name); ?>[<?php echo esc_attr($tkt_row); ?>][TKT_max]" |
381 | 399 | value="<?php echo esc_attr($TKT_max); ?>" |
382 | 400 | /> |
383 | - <?php else : ?> |
|
384 | - <label class='screen-reader-text' for='edit-ticket-TKT_max-<?php echo esc_attr($tkt_row);?>'> |
|
401 | + <?php else { |
|
402 | + : ?> |
|
403 | + <label class='screen-reader-text' for='edit-ticket-TKT_max-<?php echo esc_attr($tkt_row); |
|
404 | +} |
|
405 | +?>'> |
|
385 | 406 | <?php esc_html_e('Maximum Quantity', 'event_espresso') ?> |
386 | 407 | </label> |
387 | 408 | <input type="text" |
@@ -434,10 +455,13 @@ discard block |
||
434 | 455 | value="1" |
435 | 456 | <?php echo esc_attr($TKT_taxable); ?> |
436 | 457 | /> |
437 | - <?php else : ?> |
|
458 | + <?php else { |
|
459 | + : ?> |
|
438 | 460 | <input type='checkbox' |
439 | 461 | class="TKT-taxable-checkbox" |
440 | - id="edit-ticket-TKT_taxable-<?php echo esc_attr($tkt_row); ?>" |
|
462 | + id="edit-ticket-TKT_taxable-<?php echo esc_attr($tkt_row); |
|
463 | +} |
|
464 | +?>" |
|
441 | 465 | name="<?php echo esc_attr($edit_tickets_name); ?>[<?php echo esc_attr($tkt_row); ?>][TKT_taxable]" |
442 | 466 | value="1" |
443 | 467 | <?php echo esc_attr($TKT_taxable); ?> |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | maxlength='245' |
82 | 82 | name="<?php echo esc_attr($edit_tickets_name); ?>[<?php echo esc_attr($tkt_row); ?>][TKT_name]" |
83 | 83 | placeholder="<?php |
84 | - esc_html_e('Ticket Title', 'event_espresso') ?>" |
|
84 | + esc_html_e('Ticket Title', 'event_espresso') ?>" |
|
85 | 85 | value="<?php echo esc_attr($TKT_name); ?>" |
86 | 86 | /> |
87 | 87 | </td> |
@@ -279,11 +279,11 @@ discard block |
||
279 | 279 | <div class="ee-editor-id-container"> |
280 | 280 | <h3 class="ee-item-id"> |
281 | 281 | <?php |
282 | - echo esc_html( |
|
283 | - $TKT_ID |
|
284 | - ? sprintf(__('Ticket ID: %d', 'event_espresso'), $TKT_ID) |
|
285 | - : '' |
|
286 | - ); ?> |
|
282 | + echo esc_html( |
|
283 | + $TKT_ID |
|
284 | + ? sprintf(__('Ticket ID: %d', 'event_espresso'), $TKT_ID) |
|
285 | + : '' |
|
286 | + ); ?> |
|
287 | 287 | </h3> |
288 | 288 | </div> |
289 | 289 | <div class="basic-ticket-container"> |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | for='edit-ticket-TKT_uses-<?php echo esc_attr($tkt_row); ?>' |
344 | 344 | > |
345 | 345 | <?php |
346 | - esc_html_e('Ticket Uses', 'event_espresso') ?> |
|
346 | + esc_html_e('Ticket Uses', 'event_espresso') ?> |
|
347 | 347 | </label> |
348 | 348 | <input type="text" |
349 | 349 | class="edit-ticket-TKT_uses ee-small-text-inp ee-numeric" |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | /> |
363 | 363 | <label class='screen-reader-text' for='disabled-ticket-TKT_min-<?php echo esc_attr($tkt_row);?>'> |
364 | 364 | <?php |
365 | - esc_html_e('Minimum Quantity', 'event_espresso') ?> |
|
365 | + esc_html_e('Minimum Quantity', 'event_espresso') ?> |
|
366 | 366 | </label> |
367 | 367 | <input type="text" disabled |
368 | 368 | class="edit-ticket-TKT_min ee-small-text-inp ee-numeric" |
@@ -427,14 +427,14 @@ discard block |
||
427 | 427 | id="edit-ticket-TKT_required-<?php echo esc_attr($tkt_row); ?>" |
428 | 428 | value="1" |
429 | 429 | <?php |
430 | - echo esc_attr($TKT_required ? ' checked' : ''); |
|
431 | - echo esc_attr($disabled ? ' disabled' : ''); |
|
432 | - ?> |
|
430 | + echo esc_attr($TKT_required ? ' checked' : ''); |
|
431 | + echo esc_attr($disabled ? ' disabled' : ''); |
|
432 | + ?> |
|
433 | 433 | /> |
434 | 434 | <?php esc_html_e( |
435 | - 'This ticket is required (will appear first in frontend ticket lists).', |
|
436 | - 'event_espresso' |
|
437 | - ); ?> |
|
435 | + 'This ticket is required (will appear first in frontend ticket lists).', |
|
436 | + 'event_espresso' |
|
437 | + ); ?> |
|
438 | 438 | </label> |
439 | 439 | </div> |
440 | 440 | <div class="ticket-is-taxable-container"> |
@@ -537,19 +537,19 @@ discard block |
||
537 | 537 | <h4 class="tickets-heading"><?php esc_html_e('Event Datetimes', 'event_espresso'); ?></h4> |
538 | 538 | <p> |
539 | 539 | <?php esc_html_e( |
540 | - 'This ticket will be usable (allow entrance) for the following selected event datetimes (click to select). The "# Datetimes" amount (above) indicates how many of the assigned datetimes the ticket holder can gain access to:', |
|
541 | - 'event_espresso' |
|
542 | - ); ?> |
|
540 | + 'This ticket will be usable (allow entrance) for the following selected event datetimes (click to select). The "# Datetimes" amount (above) indicates how many of the assigned datetimes the ticket holder can gain access to:', |
|
541 | + 'event_espresso' |
|
542 | + ); ?> |
|
543 | 543 | </p> |
544 | 544 | <ul class="datetime-tickets-list"> |
545 | 545 | <?php echo wp_kses($ticket_datetimes_list, AllowedTags::getWithFormTags()); ?> |
546 | 546 | </ul> |
547 | 547 | |
548 | 548 | <?php do_action( |
549 | - 'AHEE__event_tickets_datetime_ticket_row_template__advanced_details_end', |
|
550 | - $tkt_row, |
|
551 | - $TKT_ID |
|
552 | - ); ?> |
|
549 | + 'AHEE__event_tickets_datetime_ticket_row_template__advanced_details_end', |
|
550 | + $tkt_row, |
|
551 | + $TKT_ID |
|
552 | + ); ?> |
|
553 | 553 | <div class="ee-editor-footer-container"> |
554 | 554 | <div class="ee-layout-row ee-layout-row--spaced"> |
555 | 555 | <label for="edit-ticket-TKT_is_default_selector-<?php echo esc_attr($tkt_row); ?>"> |
@@ -561,9 +561,9 @@ discard block |
||
561 | 561 | <?php echo esc_attr($disabled ? ' disabled' : ''); ?> |
562 | 562 | /> |
563 | 563 | <?php esc_html_e( |
564 | - 'use this new ticket as a default ticket for any new events', |
|
565 | - 'event_espresso' |
|
566 | - ); ?> |
|
564 | + 'use this new ticket as a default ticket for any new events', |
|
565 | + 'event_espresso' |
|
566 | + ); ?> |
|
567 | 567 | </label> |
568 | 568 | <input type="hidden" |
569 | 569 | name="<?php echo esc_attr($edit_tickets_name); ?>[<?php echo esc_attr($tkt_row); ?>][TKT_is_default]" |
@@ -15,9 +15,9 @@ |
||
15 | 15 | </ul> |
16 | 16 | <div id="espresso_event_type-all" class="tabs-panel"> |
17 | 17 | <?php |
18 | - $name = 'tax_input[espresso_event_type]'; |
|
19 | - echo "<input type='hidden' name='{$name}[]' value='0' />"; // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks. |
|
20 | - ?> |
|
18 | + $name = 'tax_input[espresso_event_type]'; |
|
19 | + echo "<input type='hidden' name='{$name}[]' value='0' />"; // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks. |
|
20 | + ?> |
|
21 | 21 | <ul id="espresso_event_typechecklist" data-wp-lists="list:espresso_event_type" |
22 | 22 | class="categorychecklist form-no-clear"> |
23 | 23 | <?php echo wp_kses($radio_list, AllowedTags::getWithFormTags()); ?> |
@@ -9,18 +9,18 @@ |
||
9 | 9 | */ |
10 | 10 | class EE_Yes_No_Input extends EE_Select_Input |
11 | 11 | { |
12 | - /** |
|
13 | - * @param array $options |
|
14 | - */ |
|
15 | - public function __construct($options = []) |
|
16 | - { |
|
17 | - parent::__construct( |
|
18 | - [ |
|
19 | - true => esc_html__('Yes', 'event_espresso'), |
|
20 | - false => esc_html__('No', 'event_espresso') |
|
21 | - ], |
|
22 | - $options |
|
23 | - ); |
|
24 | - $this->set_html_class($this->html_class() . ' ee-input-width--tiny'); |
|
25 | - } |
|
12 | + /** |
|
13 | + * @param array $options |
|
14 | + */ |
|
15 | + public function __construct($options = []) |
|
16 | + { |
|
17 | + parent::__construct( |
|
18 | + [ |
|
19 | + true => esc_html__('Yes', 'event_espresso'), |
|
20 | + false => esc_html__('No', 'event_espresso') |
|
21 | + ], |
|
22 | + $options |
|
23 | + ); |
|
24 | + $this->set_html_class($this->html_class() . ' ee-input-width--tiny'); |
|
25 | + } |
|
26 | 26 | } |
@@ -21,6 +21,6 @@ |
||
21 | 21 | ], |
22 | 22 | $options |
23 | 23 | ); |
24 | - $this->set_html_class($this->html_class() . ' ee-input-width--tiny'); |
|
24 | + $this->set_html_class($this->html_class().' ee-input-width--tiny'); |
|
25 | 25 | } |
26 | 26 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | ); ?> |
85 | 85 | </span> |
86 | 86 | <span class="dashicons dashicons-calendar"></span> |
87 | - <?php echo esc_html($ticket->get_i18n_datetime('TKT_start_date', $date_format)) . ' '; ?> |
|
87 | + <?php echo esc_html($ticket->get_i18n_datetime('TKT_start_date', $date_format)).' '; ?> |
|
88 | 88 | <span class="dashicons dashicons-clock"></span> |
89 | 89 | <?php echo esc_html($ticket->get_i18n_datetime('TKT_start_date', $time_format)); ?> |
90 | 90 | <br /> |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | ); ?> |
96 | 96 | </span> |
97 | 97 | <span class="dashicons dashicons-calendar"></span> |
98 | - <?php echo esc_html($ticket->get_i18n_datetime('TKT_end_date', $date_format)) . ' '; ?> |
|
98 | + <?php echo esc_html($ticket->get_i18n_datetime('TKT_end_date', $date_format)).' '; ?> |
|
99 | 99 | <span class="dashicons dashicons-clock"></span> |
100 | 100 | <?php echo esc_html($ticket->get_i18n_datetime('TKT_end_date', $time_format)); ?> |
101 | 101 | <br /> |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | <br /> |
161 | 161 | <?php } ?> |
162 | 162 | |
163 | - <?php if ((! defined('EE_DECAF') || EE_DECAF !== true) && $ticket->uses() !== EE_INF) { ?> |
|
163 | + <?php if (( ! defined('EE_DECAF') || EE_DECAF !== true) && $ticket->uses() !== EE_INF) { ?> |
|
164 | 164 | <section class="tckt-slctr-tkt-uses-sctn"> |
165 | 165 | <h5> |
166 | 166 | <?php echo apply_filters( |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | <?php |
199 | 199 | $datetimes = $ticket->datetimes_ordered($event_is_expired, false); |
200 | 200 | $chart_column_width = $show_ticket_sale_columns ? ' ee-fourth-width' : ' ee-half-width'; |
201 | - if (! empty($datetimes)) { ?> |
|
201 | + if ( ! empty($datetimes)) { ?> |
|
202 | 202 | <section class="tckt-slctr-tkt-datetimes-sctn"> |
203 | 203 | <h5> |
204 | 204 | <?php echo apply_filters( |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | <td data-th="<?php echo esc_attr($event_date_label); ?>" class="small-text"> |
278 | 278 | <?php $datetime_name = $datetime->name(); ?> |
279 | 279 | <?php echo ! empty($datetime_name) |
280 | - ? '<b>' . esc_html($datetime_name) . '</b><br/>' |
|
280 | + ? '<b>'.esc_html($datetime_name).'</b><br/>' |
|
281 | 281 | : ''; ?> |
282 | 282 | <?php echo esc_html($datetime->date_range( |
283 | 283 | $date_format, |
@@ -334,4 +334,4 @@ discard block |
||
334 | 334 | </div> |
335 | 335 | </td> |
336 | 336 | </tr> |
337 | -<?php endif; // end template_settings->show_ticket_details check |
|
337 | +<?php endif; // end template_settings->show_ticket_details check |
@@ -21,28 +21,28 @@ discard block |
||
21 | 21 | use EventEspresso\modules\ticket_selector\TicketDetails; |
22 | 22 | |
23 | 23 | $event_date_label = apply_filters( |
24 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', |
|
25 | - esc_html__('Event Date ', 'event_espresso') |
|
24 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', |
|
25 | + esc_html__('Event Date ', 'event_espresso') |
|
26 | 26 | ); |
27 | 27 | |
28 | 28 | $sold_label = apply_filters( |
29 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', |
|
30 | - esc_html__('Sold', 'event_espresso') |
|
29 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', |
|
30 | + esc_html__('Sold', 'event_espresso') |
|
31 | 31 | ); |
32 | 32 | |
33 | 33 | $remaining_label = apply_filters( |
34 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', |
|
35 | - esc_html__('Remaining', 'event_espresso') |
|
34 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', |
|
35 | + esc_html__('Remaining', 'event_espresso') |
|
36 | 36 | ); |
37 | 37 | |
38 | 38 | $total_sold_label = apply_filters( |
39 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', |
|
40 | - esc_html__('Total Sold', 'event_espresso') |
|
39 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', |
|
40 | + esc_html__('Total Sold', 'event_espresso') |
|
41 | 41 | ); |
42 | 42 | |
43 | 43 | $spaces_left_label = apply_filters( |
44 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', |
|
45 | - esc_html__('Total Spaces Left', 'event_espresso') |
|
44 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', |
|
45 | + esc_html__('Total Spaces Left', 'event_espresso') |
|
46 | 46 | ); |
47 | 47 | |
48 | 48 | ?> |
@@ -56,32 +56,32 @@ discard block |
||
56 | 56 | <p><?php echo wp_kses($ticket->description(), AllowedTags::getAllowedTags()); ?></p> |
57 | 57 | |
58 | 58 | <?php |
59 | - do_action( |
|
60 | - 'AHEE__ticket_selector_chart_template__ticket_details__after_description', |
|
61 | - $ticket, |
|
62 | - $ticket_price, |
|
63 | - $display_ticket_price |
|
64 | - ); |
|
65 | - ?> |
|
59 | + do_action( |
|
60 | + 'AHEE__ticket_selector_chart_template__ticket_details__after_description', |
|
61 | + $ticket, |
|
62 | + $ticket_price, |
|
63 | + $display_ticket_price |
|
64 | + ); |
|
65 | + ?> |
|
66 | 66 | <section class="tckt-slctr-tkt-sale-dates-sctn"> |
67 | 67 | <h5> |
68 | 68 | <?php echo apply_filters( |
69 | - 'FHEE__ticket_selector_chart_template__ticket_details_sales_date_heading', |
|
70 | - esc_html__('Sale Dates', 'event_espresso') |
|
71 | - ); ?> |
|
69 | + 'FHEE__ticket_selector_chart_template__ticket_details_sales_date_heading', |
|
70 | + esc_html__('Sale Dates', 'event_espresso') |
|
71 | + ); ?> |
|
72 | 72 | </h5> |
73 | 73 | <span class="drk-grey-text small-text no-bold"> - |
74 | 74 | <?php echo apply_filters( |
75 | - 'FHEE__ticket_selector_chart_template__ticket_details_dates_available_message', |
|
76 | - esc_html__('The dates when this option is available for purchase.', 'event_espresso') |
|
77 | - ); ?> |
|
75 | + 'FHEE__ticket_selector_chart_template__ticket_details_dates_available_message', |
|
76 | + esc_html__('The dates when this option is available for purchase.', 'event_espresso') |
|
77 | + ); ?> |
|
78 | 78 | </span> |
79 | 79 | <br /> |
80 | 80 | <span class="ticket-details-label-spn drk-grey-text"> |
81 | 81 | <?php echo apply_filters( |
82 | - 'FHEE__ticket_selector_chart_template__ticket_details_goes_on_sale', |
|
83 | - esc_html__('Goes On Sale:', 'event_espresso') |
|
84 | - ); ?> |
|
82 | + 'FHEE__ticket_selector_chart_template__ticket_details_goes_on_sale', |
|
83 | + esc_html__('Goes On Sale:', 'event_espresso') |
|
84 | + ); ?> |
|
85 | 85 | </span> |
86 | 86 | <span class="dashicons dashicons-calendar"></span> |
87 | 87 | <?php echo esc_html($ticket->get_i18n_datetime('TKT_start_date', $date_format)) . ' '; ?> |
@@ -90,9 +90,9 @@ discard block |
||
90 | 90 | <br /> |
91 | 91 | <span class="ticket-details-label-spn drk-grey-text"> |
92 | 92 | <?php echo apply_filters( |
93 | - 'FHEE__ticket_selector_chart_template__ticket_details_sales_end', |
|
94 | - esc_html__('Sales End:', 'event_espresso') |
|
95 | - ); ?> |
|
93 | + 'FHEE__ticket_selector_chart_template__ticket_details_sales_end', |
|
94 | + esc_html__('Sales End:', 'event_espresso') |
|
95 | + ); ?> |
|
96 | 96 | </span> |
97 | 97 | <span class="dashicons dashicons-calendar"></span> |
98 | 98 | <?php echo esc_html($ticket->get_i18n_datetime('TKT_end_date', $date_format)) . ' '; ?> |
@@ -108,55 +108,55 @@ discard block |
||
108 | 108 | <section class="tckt-slctr-tkt-quantities-sctn"> |
109 | 109 | <h5> |
110 | 110 | <?php echo apply_filters( |
111 | - 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_heading', |
|
112 | - esc_html__('Purchasable Quantities', 'event_espresso') |
|
113 | - ); ?> |
|
111 | + 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_heading', |
|
112 | + esc_html__('Purchasable Quantities', 'event_espresso') |
|
113 | + ); ?> |
|
114 | 114 | </h5> |
115 | 115 | <span class="drk-grey-text small-text no-bold"> - |
116 | 116 | <?php echo apply_filters( |
117 | - 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_message', |
|
118 | - esc_html__( |
|
119 | - 'The number of tickets that can be purchased per transaction (if available).', |
|
120 | - 'event_espresso' |
|
121 | - ) |
|
122 | - ); ?> |
|
117 | + 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_message', |
|
118 | + esc_html__( |
|
119 | + 'The number of tickets that can be purchased per transaction (if available).', |
|
120 | + 'event_espresso' |
|
121 | + ) |
|
122 | + ); ?> |
|
123 | 123 | </span> |
124 | 124 | <br /> |
125 | 125 | <span class="ticket-details-label-spn drk-grey-text"> |
126 | 126 | <?php echo apply_filters( |
127 | - 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty', |
|
128 | - esc_html__('Minimum Qty:', 'event_espresso') |
|
129 | - ); ?> |
|
127 | + 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty', |
|
128 | + esc_html__('Minimum Qty:', 'event_espresso') |
|
129 | + ); ?> |
|
130 | 130 | </span> |
131 | 131 | <?php |
132 | - echo esc_html($ticket->min() > 0 ? $ticket->min() : 0); |
|
132 | + echo esc_html($ticket->min() > 0 ? $ticket->min() : 0); |
|
133 | 133 | |
134 | - if ($ticket->min() > $remaining) { |
|
135 | - ?> |
|
134 | + if ($ticket->min() > $remaining) { |
|
135 | + ?> |
|
136 | 136 | <span class="important-notice small-text"> |
137 | 137 | <?php echo apply_filters( |
138 | - 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty_message', |
|
139 | - esc_html__( |
|
140 | - 'The Minimum Quantity purchasable for this ticket exceeds the number of spaces remaining', |
|
141 | - 'event_espresso' |
|
142 | - ) |
|
143 | - ); ?> |
|
138 | + 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty_message', |
|
139 | + esc_html__( |
|
140 | + 'The Minimum Quantity purchasable for this ticket exceeds the number of spaces remaining', |
|
141 | + 'event_espresso' |
|
142 | + ) |
|
143 | + ); ?> |
|
144 | 144 | </span> |
145 | 145 | <?php } ?> |
146 | 146 | <br /> |
147 | 147 | <?php // $max = min( $max, $max_atndz );?> |
148 | 148 | <span class="ticket-details-label-spn drk-grey-text"> |
149 | 149 | <?php echo apply_filters( |
150 | - 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_max_qty', |
|
151 | - esc_html__('Maximum Qty:', 'event_espresso') |
|
152 | - ); ?> |
|
150 | + 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_max_qty', |
|
151 | + esc_html__('Maximum Qty:', 'event_espresso') |
|
152 | + ); ?> |
|
153 | 153 | </span> |
154 | 154 | <?php echo esc_html( |
155 | - $ticket->max() === EE_INF |
|
156 | - ? __('no limit', 'event_espresso') |
|
157 | - : max($ticket->max(), 1) |
|
158 | - ); |
|
159 | - ?> |
|
155 | + $ticket->max() === EE_INF |
|
156 | + ? __('no limit', 'event_espresso') |
|
157 | + : max($ticket->max(), 1) |
|
158 | + ); |
|
159 | + ?> |
|
160 | 160 | <br /> |
161 | 161 | </section> |
162 | 162 | <br /> |
@@ -166,31 +166,31 @@ discard block |
||
166 | 166 | <section class="tckt-slctr-tkt-uses-sctn"> |
167 | 167 | <h5> |
168 | 168 | <?php echo apply_filters( |
169 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_heading', |
|
170 | - esc_html__('Event Date Ticket Uses', 'event_espresso') |
|
171 | - ); ?> |
|
169 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_heading', |
|
170 | + esc_html__('Event Date Ticket Uses', 'event_espresso') |
|
171 | + ); ?> |
|
172 | 172 | </h5> |
173 | 173 | <span class="drk-grey-text small-text no-bold"> - |
174 | 174 | <?php echo apply_filters( |
175 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_message', |
|
176 | - sprintf( |
|
177 | - esc_html__( |
|
178 | - 'The number of separate event datetimes (see table below) that this ticket can be used to gain admittance to.%1$s%2$sAdmission is always one person per ticket.%3$s', |
|
179 | - 'event_espresso' |
|
180 | - ), |
|
181 | - '<br/>', |
|
182 | - '<strong>', |
|
183 | - '</strong>' |
|
184 | - ) |
|
185 | - ); |
|
186 | - ?> |
|
175 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_message', |
|
176 | + sprintf( |
|
177 | + esc_html__( |
|
178 | + 'The number of separate event datetimes (see table below) that this ticket can be used to gain admittance to.%1$s%2$sAdmission is always one person per ticket.%3$s', |
|
179 | + 'event_espresso' |
|
180 | + ), |
|
181 | + '<br/>', |
|
182 | + '<strong>', |
|
183 | + '</strong>' |
|
184 | + ) |
|
185 | + ); |
|
186 | + ?> |
|
187 | 187 | </span> |
188 | 188 | <br /> |
189 | 189 | <span class="ticket-details-label-spn drk-grey-text"> |
190 | 190 | <?php echo apply_filters( |
191 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_date_number_datetimes', |
|
192 | - esc_html__('# Datetimes:', 'event_espresso') |
|
193 | - ); ?> |
|
191 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_date_number_datetimes', |
|
192 | + esc_html__('# Datetimes:', 'event_espresso') |
|
193 | + ); ?> |
|
194 | 194 | </span> |
195 | 195 | <?php echo wp_kses($ticket->uses(), AllowedTags::getAllowedTags()); ?> |
196 | 196 | <br /> |
@@ -198,24 +198,24 @@ discard block |
||
198 | 198 | <?php } ?> |
199 | 199 | |
200 | 200 | <?php |
201 | - $datetimes = $ticket->datetimes_ordered($event_is_expired, false); |
|
202 | - $chart_column_width = $show_ticket_sale_columns ? ' ee-fourth-width' : ' ee-half-width'; |
|
203 | - if (! empty($datetimes)) { ?> |
|
201 | + $datetimes = $ticket->datetimes_ordered($event_is_expired, false); |
|
202 | + $chart_column_width = $show_ticket_sale_columns ? ' ee-fourth-width' : ' ee-half-width'; |
|
203 | + if (! empty($datetimes)) { ?> |
|
204 | 204 | <section class="tckt-slctr-tkt-datetimes-sctn"> |
205 | 205 | <h5> |
206 | 206 | <?php echo apply_filters( |
207 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_heading', |
|
208 | - esc_html__('Access', 'event_espresso') |
|
209 | - ); ?> |
|
207 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_heading', |
|
208 | + esc_html__('Access', 'event_espresso') |
|
209 | + ); ?> |
|
210 | 210 | </h5> |
211 | 211 | <span class="drk-grey-text small-text no-bold"> - |
212 | 212 | <?php echo apply_filters( |
213 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_message', |
|
214 | - esc_html__( |
|
215 | - 'This option allows access to the following dates and times.', |
|
216 | - 'event_espresso' |
|
217 | - ) |
|
218 | - ); ?> |
|
213 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_message', |
|
214 | + esc_html__( |
|
215 | + 'This option allows access to the following dates and times.', |
|
216 | + 'event_espresso' |
|
217 | + ) |
|
218 | + ); ?> |
|
219 | 219 | </span> |
220 | 220 | <div class="tckt-slctr-tkt-details-tbl-wrap-dv"> |
221 | 221 | <table class="tckt-slctr-tkt-details-tbl"> |
@@ -225,9 +225,9 @@ discard block |
||
225 | 225 | <span class="dashicons dashicons-calendar"></span> |
226 | 226 | <span class="small-text"> |
227 | 227 | <?php echo apply_filters( |
228 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', |
|
229 | - esc_html__('Date ', 'event_espresso') |
|
230 | - ); ?> |
|
228 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', |
|
229 | + esc_html__('Date ', 'event_espresso') |
|
230 | + ); ?> |
|
231 | 231 | </span> |
232 | 232 | </th> |
233 | 233 | <th class="tckt-slctr-tkt-details-time-th <?php echo esc_attr($chart_column_width); ?>"> |
@@ -240,33 +240,33 @@ discard block |
||
240 | 240 | <th class="tckt-slctr-tkt-details-this-ticket-sold-th ee-fourth-width cntr"> |
241 | 241 | <span class="smaller-text"> |
242 | 242 | <?php echo apply_filters( |
243 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', |
|
244 | - sprintf(esc_html__('Sold', 'event_espresso'), '<br/>') |
|
245 | - ); ?> |
|
243 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', |
|
244 | + sprintf(esc_html__('Sold', 'event_espresso'), '<br/>') |
|
245 | + ); ?> |
|
246 | 246 | </span> |
247 | 247 | </th> |
248 | 248 | <th class="tckt-slctr-tkt-details-this-ticket-left-th ee-fourth-width cntr"> |
249 | 249 | <span class="smaller-text"> |
250 | 250 | <?php echo apply_filters( |
251 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', |
|
252 | - sprintf(esc_html__('Remaining', 'event_espresso'), '<br/>') |
|
253 | - ); ?> |
|
251 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', |
|
252 | + sprintf(esc_html__('Remaining', 'event_espresso'), '<br/>') |
|
253 | + ); ?> |
|
254 | 254 | </span> |
255 | 255 | </th> |
256 | 256 | <th class="tckt-slctr-tkt-details-total-tickets-sold-th ee-fourth-width cntr"> |
257 | 257 | <span class="smaller-text"> |
258 | 258 | <?php echo apply_filters( |
259 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', |
|
260 | - sprintf(esc_html__('Total%sSold', 'event_espresso'), '<br/>') |
|
261 | - ); ?> |
|
259 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', |
|
260 | + sprintf(esc_html__('Total%sSold', 'event_espresso'), '<br/>') |
|
261 | + ); ?> |
|
262 | 262 | </span> |
263 | 263 | </th> |
264 | 264 | <th class="tckt-slctr-tkt-details-total-tickets-left-th ee-fourth-width cntr"> |
265 | 265 | <span class="smaller-text"> |
266 | 266 | <?php echo apply_filters( |
267 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', |
|
268 | - sprintf(esc_html__('Total Spaces%sLeft', 'event_espresso'), '<br/>') |
|
269 | - ); ?> |
|
267 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', |
|
268 | + sprintf(esc_html__('Total Spaces%sLeft', 'event_espresso'), '<br/>') |
|
269 | + ); ?> |
|
270 | 270 | </span> |
271 | 271 | </th> |
272 | 272 | <?php endif; // end $show_ticket_sale_columns conditional ?> |
@@ -274,25 +274,25 @@ discard block |
||
274 | 274 | </thead> |
275 | 275 | <tbody> |
276 | 276 | <?php foreach ($datetimes as $datetime) { |
277 | - if ($datetime instanceof EE_Datetime) { ?> |
|
277 | + if ($datetime instanceof EE_Datetime) { ?> |
|
278 | 278 | <tr> |
279 | 279 | <td data-th="<?php echo esc_attr($event_date_label); ?>" class="small-text"> |
280 | 280 | <?php $datetime_name = $datetime->name(); ?> |
281 | 281 | <?php echo ! empty($datetime_name) |
282 | - ? '<b>' . esc_html($datetime_name) . '</b><br/>' |
|
283 | - : ''; ?> |
|
282 | + ? '<b>' . esc_html($datetime_name) . '</b><br/>' |
|
283 | + : ''; ?> |
|
284 | 284 | <?php echo esc_html($datetime->date_range( |
285 | - $date_format, |
|
286 | - esc_html__(' to ', 'event_espresso') |
|
287 | - )); ?> |
|
285 | + $date_format, |
|
286 | + esc_html__(' to ', 'event_espresso') |
|
287 | + )); ?> |
|
288 | 288 | </td> |
289 | 289 | <td data-th="<?php esc_html_e('Time ', 'event_espresso'); ?>" |
290 | 290 | class="cntr small-text" |
291 | 291 | > |
292 | 292 | <?php echo esc_html($datetime->time_range( |
293 | - $time_format, |
|
294 | - esc_html__(' to ', 'event_espresso') |
|
295 | - )); ?> |
|
293 | + $time_format, |
|
294 | + esc_html__(' to ', 'event_espresso') |
|
295 | + )); ?> |
|
296 | 296 | </td> |
297 | 297 | <?php if ($show_ticket_sale_columns) : ?> |
298 | 298 | <td data-th="<?php echo esc_attr($sold_label); ?>" class="cntr small-text"> |
@@ -300,31 +300,31 @@ discard block |
||
300 | 300 | </td> |
301 | 301 | <td data-th="<?php echo esc_attr($remaining_label); ?>" class="cntr small-text"> |
302 | 302 | <?php echo wp_kses( |
303 | - $remaining === EE_INF |
|
304 | - ? '<span class="smaller-text">' |
|
305 | - . esc_html__('unlimited ', 'event_espresso') |
|
306 | - . '</span>' |
|
307 | - : $remaining, |
|
308 | - AllowedTags::getAllowedTags() |
|
309 | - ); ?> |
|
303 | + $remaining === EE_INF |
|
304 | + ? '<span class="smaller-text">' |
|
305 | + . esc_html__('unlimited ', 'event_espresso') |
|
306 | + . '</span>' |
|
307 | + : $remaining, |
|
308 | + AllowedTags::getAllowedTags() |
|
309 | + ); ?> |
|
310 | 310 | </td> |
311 | 311 | <td data-th="<?php echo esc_attr($total_sold_label); ?>" class="cntr small-text"> |
312 | 312 | <?php echo esc_html($datetime->sold()); ?> |
313 | 313 | </td> |
314 | 314 | <?php $tkts_left = $datetime->sold_out() |
315 | - ? '<span class="sold-out smaller-text">' |
|
316 | - . esc_html__('Sold Out', 'event_espresso') |
|
317 | - . '</span>' |
|
318 | - : $datetime->spaces_remaining(); ?> |
|
315 | + ? '<span class="sold-out smaller-text">' |
|
316 | + . esc_html__('Sold Out', 'event_espresso') |
|
317 | + . '</span>' |
|
318 | + : $datetime->spaces_remaining(); ?> |
|
319 | 319 | <td data-th="<?php echo esc_attr($spaces_left_label); ?>" class="cntr small-text"> |
320 | 320 | <?php echo wp_kses( |
321 | - $tkts_left === EE_INF |
|
322 | - ? '<span class="smaller-text">' |
|
323 | - . esc_html__('unlimited ', 'event_espresso') |
|
324 | - . '</span>' |
|
325 | - : $tkts_left, |
|
326 | - AllowedTags::getAllowedTags() |
|
327 | - ); ?> |
|
321 | + $tkts_left === EE_INF |
|
322 | + ? '<span class="smaller-text">' |
|
323 | + . esc_html__('unlimited ', 'event_espresso') |
|
324 | + . '</span>' |
|
325 | + : $tkts_left, |
|
326 | + AllowedTags::getAllowedTags() |
|
327 | + ); ?> |
|
328 | 328 | </td> |
329 | 329 | <?php endif; // end $show_ticket_sale_columns conditional ?> |
330 | 330 | </tr> |
@@ -12,9 +12,9 @@ discard block |
||
12 | 12 | <p class="spco-copy-all-attendee-pg"> |
13 | 13 | <label class="ee-checkbox-label-before ee-checkbox-label-wide"> |
14 | 14 | <?php esc_html_e( |
15 | - 'Use Attendee #1\'s information for ALL attendees', |
|
16 | - 'event_espresso' |
|
17 | - ); ?> |
|
15 | + 'Use Attendee #1\'s information for ALL attendees', |
|
16 | + 'event_espresso' |
|
17 | + ); ?> |
|
18 | 18 | <input class='spco-copy-all-attendee-chk ee-do-not-validate' |
19 | 19 | id="spco-copy-all-attendee-chk" |
20 | 20 | type="checkbox" |
@@ -25,16 +25,16 @@ discard block |
||
25 | 25 | |
26 | 26 | <p class="spco-copy-attendee-pg"> |
27 | 27 | <?php echo apply_filters( |
28 | - 'FHEE__registration_page_attendee_information__copy_attendee_pg', |
|
29 | - sprintf( |
|
30 | - esc_html__( |
|
31 | - 'This option allows you to use the above information for all additional attendee question fields. %sPlease note:%s some events may have additional questions that you may still be required to answer in order to complete your registration.', |
|
32 | - 'event_espresso' |
|
33 | - ), |
|
34 | - '<strong>', |
|
35 | - '</strong>' |
|
36 | - ) |
|
37 | - ); ?></p> |
|
28 | + 'FHEE__registration_page_attendee_information__copy_attendee_pg', |
|
29 | + sprintf( |
|
30 | + esc_html__( |
|
31 | + 'This option allows you to use the above information for all additional attendee question fields. %sPlease note:%s some events may have additional questions that you may still be required to answer in order to complete your registration.', |
|
32 | + 'event_espresso' |
|
33 | + ), |
|
34 | + '<strong>', |
|
35 | + '</strong>' |
|
36 | + ) |
|
37 | + ); ?></p> |
|
38 | 38 | |
39 | 39 | <a class='display-the-hidden smaller-text float-right' |
40 | 40 | id="display-more-attendee-copy-options" |
@@ -54,15 +54,15 @@ discard block |
||
54 | 54 | <div id="more-attendee-copy-options-dv" class="" style="display: none;"> |
55 | 55 | <p class="spco-copy-attendee-pg"> |
56 | 56 | <?php esc_html_e( |
57 | - 'Only copy the above information to the following selected additional attendees.', |
|
58 | - 'event_espresso' |
|
59 | - ); ?> |
|
57 | + 'Only copy the above information to the following selected additional attendees.', |
|
58 | + 'event_espresso' |
|
59 | + ); ?> |
|
60 | 60 | </p> |
61 | 61 | |
62 | 62 | <?php |
63 | - foreach ($spco_copy_attendee_chk as $spco_copy_chk) { |
|
64 | - echo wp_kses($spco_copy_chk, AllowedTags::getWithFormTags()); |
|
65 | - } ?> |
|
63 | + foreach ($spco_copy_attendee_chk as $spco_copy_chk) { |
|
64 | + echo wp_kses($spco_copy_chk, AllowedTags::getWithFormTags()); |
|
65 | + } ?> |
|
66 | 66 | |
67 | 67 | </div> |
68 | 68 | <div class="clear-float"></div> |
@@ -14,16 +14,16 @@ discard block |
||
14 | 14 | <?php if (! is_admin()) : ?> |
15 | 15 | <p id="spco-attendee_information-pg" class="spco-steps-pg small-text drk-grey-text"> |
16 | 16 | <?php echo apply_filters( |
17 | - 'FHEE__registration_page_attendee_information__attendee_information_pg', |
|
18 | - sprintf( |
|
19 | - esc_html__( |
|
20 | - 'In order to process your registration, we ask you to provide the following information.%1$sPlease note that all fields marked with an asterisk (%2$s) are required.', |
|
21 | - 'event_espresso' |
|
22 | - ), |
|
23 | - '<br />', |
|
24 | - '<span class="asterisk">*</span>' |
|
25 | - ) |
|
26 | - ); ?> |
|
17 | + 'FHEE__registration_page_attendee_information__attendee_information_pg', |
|
18 | + sprintf( |
|
19 | + esc_html__( |
|
20 | + 'In order to process your registration, we ask you to provide the following information.%1$sPlease note that all fields marked with an asterisk (%2$s) are required.', |
|
21 | + 'event_espresso' |
|
22 | + ), |
|
23 | + '<br />', |
|
24 | + '<span class="asterisk">*</span>' |
|
25 | + ) |
|
26 | + ); ?> |
|
27 | 27 | </p> |
28 | 28 | <?php endif; ?> |
29 | 29 | |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | $prev_ticket = 0; |
34 | 34 | |
35 | 35 | if (count($registrations) > 0) { |
36 | - $ticketID = esc_attr(key($template_args['ticket_count'])); |
|
37 | - ?> |
|
36 | + $ticketID = esc_attr(key($template_args['ticket_count'])); |
|
37 | + ?> |
|
38 | 38 | |
39 | 39 | <div id="spco-attendee-panel-dv-<?php echo esc_attr($ticketID); ?>" |
40 | 40 | class="spco-attendee-panel-dv spco-attendee-ticket-<?php echo sanitize_html_class($ticketID); ?>" |
@@ -62,37 +62,37 @@ discard block |
||
62 | 62 | </thead> |
63 | 63 | <tbody> |
64 | 64 | <?php |
65 | - // Store previous values to avoid duplicated rows. |
|
66 | - $prev_ticket = 0; |
|
67 | - // Display all tickets inside. |
|
68 | - foreach ($registrations as $registration) { |
|
69 | - if ($registration instanceof EE_Registration) { |
|
70 | - if ($registration->ticket()->ID() !== $prev_ticket) { |
|
71 | - echo wp_kses($ticket_line_item[ $registration->ticket()->ID() ], AllowedTags::getWithFormTags()); |
|
72 | - } |
|
65 | + // Store previous values to avoid duplicated rows. |
|
66 | + $prev_ticket = 0; |
|
67 | + // Display all tickets inside. |
|
68 | + foreach ($registrations as $registration) { |
|
69 | + if ($registration instanceof EE_Registration) { |
|
70 | + if ($registration->ticket()->ID() !== $prev_ticket) { |
|
71 | + echo wp_kses($ticket_line_item[ $registration->ticket()->ID() ], AllowedTags::getWithFormTags()); |
|
72 | + } |
|
73 | 73 | |
74 | - $prev_ticket = $registration->ticket()->ID(); |
|
75 | - } |
|
76 | - } |
|
77 | - ?> |
|
74 | + $prev_ticket = $registration->ticket()->ID(); |
|
75 | + } |
|
76 | + } |
|
77 | + ?> |
|
78 | 78 | </tbody> |
79 | 79 | </table> |
80 | 80 | </div><!-- close spco-ticket-info-dv --> |
81 | 81 | |
82 | 82 | <?php |
83 | - // Display the forms below the table. |
|
84 | - foreach ($registrations as $registration) { |
|
85 | - if ($registration instanceof EE_Registration) { |
|
86 | - // Attendee Questions. |
|
87 | - $reg_form = EE_Template_Layout::get_subform_name($registration->reg_url_link()); |
|
88 | - echo wp_kses(${$reg_form}, AllowedTags::getWithFormTags()); |
|
89 | - } // if ( $registration instanceof EE_Registration ) |
|
90 | - } // end foreach ( $registrations as $registration ) |
|
83 | + // Display the forms below the table. |
|
84 | + foreach ($registrations as $registration) { |
|
85 | + if ($registration instanceof EE_Registration) { |
|
86 | + // Attendee Questions. |
|
87 | + $reg_form = EE_Template_Layout::get_subform_name($registration->reg_url_link()); |
|
88 | + echo wp_kses(${$reg_form}, AllowedTags::getWithFormTags()); |
|
89 | + } // if ( $registration instanceof EE_Registration ) |
|
90 | + } // end foreach ( $registrations as $registration ) |
|
91 | 91 | |
92 | - ?> |
|
92 | + ?> |
|
93 | 93 | </div><!-- close spco-attendee-panel-dv --> |
94 | 94 | <?php |
95 | - echo wp_kses($default_hidden_inputs, AllowedTags::getWithFormTags()); |
|
95 | + echo wp_kses($default_hidden_inputs, AllowedTags::getWithFormTags()); |
|
96 | 96 | } // end if ( count( $registrations ) > 0 ) |
97 | 97 | |
98 | 98 | ?> |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | use EventEspresso\core\services\request\sanitizers\AllowedTags; |
12 | 12 | |
13 | 13 | ?> |
14 | -<?php if (! is_admin()) : ?> |
|
14 | +<?php if ( ! is_admin()) : ?> |
|
15 | 15 | <p id="spco-attendee_information-pg" class="spco-steps-pg small-text drk-grey-text"> |
16 | 16 | <?php echo apply_filters( |
17 | 17 | 'FHEE__registration_page_attendee_information__attendee_information_pg', |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | foreach ($registrations as $registration) { |
61 | 61 | if ($registration instanceof EE_Registration) { |
62 | 62 | if ($registration->ticket()->ID() !== $prev_ticket) { |
63 | - echo wp_kses($ticket_line_item[ $registration->ticket()->ID() ], AllowedTags::getWithFormTags()); |
|
63 | + echo wp_kses($ticket_line_item[$registration->ticket()->ID()], AllowedTags::getWithFormTags()); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | $prev_ticket = $registration->ticket()->ID(); |
@@ -13,16 +13,16 @@ discard block |
||
13 | 13 | <?php if (! is_admin()) : ?> |
14 | 14 | <p id="spco-attendee_information-pg" class="spco-steps-pg small-text drk-grey-text"> |
15 | 15 | <?php echo apply_filters( |
16 | - 'FHEE__registration_page_attendee_information__attendee_information_pg', |
|
17 | - sprintf( |
|
18 | - esc_html__( |
|
19 | - 'In order to process your registration, we ask you to provide the following information.%1$sPlease note that all fields marked with an asterisk (%2$s) are required.', |
|
20 | - 'event_espresso' |
|
21 | - ), |
|
22 | - '<br />', |
|
23 | - '<span class="asterisk">*</span>' |
|
24 | - ) |
|
25 | - ); ?> |
|
16 | + 'FHEE__registration_page_attendee_information__attendee_information_pg', |
|
17 | + sprintf( |
|
18 | + esc_html__( |
|
19 | + 'In order to process your registration, we ask you to provide the following information.%1$sPlease note that all fields marked with an asterisk (%2$s) are required.', |
|
20 | + 'event_espresso' |
|
21 | + ), |
|
22 | + '<br />', |
|
23 | + '<span class="asterisk">*</span>' |
|
24 | + ) |
|
25 | + ); ?> |
|
26 | 26 | </p> |
27 | 27 | <?php endif; ?> |
28 | 28 | |
@@ -32,14 +32,14 @@ discard block |
||
32 | 32 | $prev_ticket = 0; |
33 | 33 | |
34 | 34 | if (count($registrations) > 0) { |
35 | - foreach ($registrations as $registration) { |
|
36 | - if ($registration instanceof EE_Registration) { |
|
37 | - $att_nmbr++; |
|
38 | - ?> |
|
35 | + foreach ($registrations as $registration) { |
|
36 | + if ($registration instanceof EE_Registration) { |
|
37 | + $att_nmbr++; |
|
38 | + ?> |
|
39 | 39 | |
40 | 40 | <div id="spco-attendee-panel-dv-<?php echo esc_url_raw($registration->reg_url_link()); ?>" |
41 | 41 | class="spco-attendee-panel-dv spco-attendee-ticket-<?php echo esc_attr($registration->ticket()->ID()); |
42 | - ?>" |
|
42 | + ?>" |
|
43 | 43 | > |
44 | 44 | |
45 | 45 | <?php if (! is_admin() && $registration->event()->ID() !== $prev_event) { ?> |
@@ -81,19 +81,19 @@ discard block |
||
81 | 81 | <?php } ?> |
82 | 82 | |
83 | 83 | <?php |
84 | - // ATTENDEE QUESTIONS |
|
85 | - $reg_form = EE_Template_Layout::get_subform_name($registration->reg_url_link()); |
|
86 | - echo wp_kses(${$reg_form}, AllowedTags::getWithFormTags()); |
|
87 | - ?> |
|
84 | + // ATTENDEE QUESTIONS |
|
85 | + $reg_form = EE_Template_Layout::get_subform_name($registration->reg_url_link()); |
|
86 | + echo wp_kses(${$reg_form}, AllowedTags::getWithFormTags()); |
|
87 | + ?> |
|
88 | 88 | |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - $prev_event = $registration->event()->ID(); |
|
92 | - $prev_ticket = $registration->ticket()->ID(); |
|
93 | - } // if ( $registration instanceof EE_Registration ) |
|
94 | - } // end foreach ( $registrations as $registration ) |
|
91 | + $prev_event = $registration->event()->ID(); |
|
92 | + $prev_ticket = $registration->ticket()->ID(); |
|
93 | + } // if ( $registration instanceof EE_Registration ) |
|
94 | + } // end foreach ( $registrations as $registration ) |
|
95 | 95 | |
96 | - echo wp_kses($default_hidden_inputs, AllowedTags::getWithFormTags()); |
|
96 | + echo wp_kses($default_hidden_inputs, AllowedTags::getWithFormTags()); |
|
97 | 97 | } // end if ( count( $registrations ) > 0 ) |
98 | 98 | |
99 | 99 | ?> |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | use EventEspresso\core\services\request\sanitizers\AllowedTags; |
11 | 11 | |
12 | 12 | ?> |
13 | -<?php if (! is_admin()) : ?> |
|
13 | +<?php if ( ! is_admin()) : ?> |
|
14 | 14 | <p id="spco-attendee_information-pg" class="spco-steps-pg small-text drk-grey-text"> |
15 | 15 | <?php echo apply_filters( |
16 | 16 | 'FHEE__registration_page_attendee_information__attendee_information_pg', |
@@ -42,14 +42,14 @@ discard block |
||
42 | 42 | ?>" |
43 | 43 | > |
44 | 44 | |
45 | - <?php if (! is_admin() && $registration->event()->ID() !== $prev_event) { ?> |
|
45 | + <?php if ( ! is_admin() && $registration->event()->ID() !== $prev_event) { ?> |
|
46 | 46 | <h4 id="event_title-<?php echo esc_attr($registration->event()->ID()) ?>" |
47 | 47 | class="big-event-title-hdr" |
48 | 48 | > |
49 | 49 | <?php echo esc_html($registration->event()->name()); ?> |
50 | 50 | </h4> |
51 | 51 | <?php } ?> |
52 | - <?php if (! $revisit && $registration->ticket()->ID() !== $prev_ticket) { ?> |
|
52 | + <?php if ( ! $revisit && $registration->ticket()->ID() !== $prev_ticket) { ?> |
|
53 | 53 | <div class="spco-ticket-info-dv"> |
54 | 54 | <table class="spco-ticket-details"> |
55 | 55 | <thead> |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | </tr> |
68 | 68 | </thead> |
69 | 69 | <tbody> |
70 | - <?php echo wp_kses($ticket_line_item[ $registration->ticket()->ID() ], AllowedTags::getWithFormTags()); ?> |
|
70 | + <?php echo wp_kses($ticket_line_item[$registration->ticket()->ID()], AllowedTags::getWithFormTags()); ?> |
|
71 | 71 | </tbody> |
72 | 72 | </table> |
73 | 73 | </div> |
@@ -26,9 +26,9 @@ |
||
26 | 26 | <?php echo wp_kses($nav_tabs, AllowedTags::getWithFormTags()); ?> |
27 | 27 | |
28 | 28 | <?php |
29 | - do_action('AHEE__admin_wrapper__template__before_about_admin_page_content'); |
|
30 | - echo wp_kses($about_admin_page_content, AllowedTags::getWithFormTags()); |
|
31 | - do_action('AHEE__admin_wrapper__template__after_about_admin_page_content'); |
|
32 | - ?> |
|
29 | + do_action('AHEE__admin_wrapper__template__before_about_admin_page_content'); |
|
30 | + echo wp_kses($about_admin_page_content, AllowedTags::getWithFormTags()); |
|
31 | + do_action('AHEE__admin_wrapper__template__after_about_admin_page_content'); |
|
32 | + ?> |
|
33 | 33 | |
34 | 34 | </div> |
@@ -46,31 +46,31 @@ discard block |
||
46 | 46 | global $wpdb; |
47 | 47 | |
48 | 48 | $this->_primary_keys = array( |
49 | - $wpdb->prefix . 'esp_answer' => array('ANS_ID'), |
|
50 | - $wpdb->prefix . 'esp_attendee' => array('ATT_ID'), |
|
51 | - $wpdb->prefix . 'esp_datetime' => array('DTT_ID'), |
|
52 | - $wpdb->prefix . 'esp_event_question_group' => array('EQG_ID'), |
|
53 | - $wpdb->prefix . 'esp_message_template' => array('MTP_ID'), |
|
54 | - $wpdb->prefix . 'esp_payment' => array('PAY_ID'), |
|
55 | - $wpdb->prefix . 'esp_price' => array('PRC_ID'), |
|
56 | - $wpdb->prefix . 'esp_price_type' => array('PRT_ID'), |
|
57 | - $wpdb->prefix . 'esp_question' => array('QST_ID'), |
|
58 | - $wpdb->prefix . 'esp_question_group' => array('QSG_ID'), |
|
59 | - $wpdb->prefix . 'esp_question_group_question' => array('QGQ_ID'), |
|
60 | - $wpdb->prefix . 'esp_question_option' => array('QSO_ID'), |
|
61 | - $wpdb->prefix . 'esp_registration' => array('REG_ID'), |
|
62 | - $wpdb->prefix . 'esp_status' => array('STS_ID'), |
|
63 | - $wpdb->prefix . 'esp_transaction' => array('TXN_ID'), |
|
64 | - $wpdb->prefix . 'esp_transaction' => array('TXN_ID'), |
|
65 | - $wpdb->prefix . 'events_detail' => array('id'), |
|
66 | - $wpdb->prefix . 'events_category_detail' => array('id'), |
|
67 | - $wpdb->prefix . 'events_category_rel' => array('id'), |
|
68 | - $wpdb->prefix . 'events_venue' => array('id'), |
|
69 | - $wpdb->prefix . 'events_venue_rel' => array('emeta_id'), |
|
70 | - $wpdb->prefix . 'events_locale' => array('id'), |
|
71 | - $wpdb->prefix . 'events_locale_rel' => array('id'), |
|
72 | - $wpdb->prefix . 'events_personnel' => array('id'), |
|
73 | - $wpdb->prefix . 'events_personnel_rel' => array('id'), |
|
49 | + $wpdb->prefix.'esp_answer' => array('ANS_ID'), |
|
50 | + $wpdb->prefix.'esp_attendee' => array('ATT_ID'), |
|
51 | + $wpdb->prefix.'esp_datetime' => array('DTT_ID'), |
|
52 | + $wpdb->prefix.'esp_event_question_group' => array('EQG_ID'), |
|
53 | + $wpdb->prefix.'esp_message_template' => array('MTP_ID'), |
|
54 | + $wpdb->prefix.'esp_payment' => array('PAY_ID'), |
|
55 | + $wpdb->prefix.'esp_price' => array('PRC_ID'), |
|
56 | + $wpdb->prefix.'esp_price_type' => array('PRT_ID'), |
|
57 | + $wpdb->prefix.'esp_question' => array('QST_ID'), |
|
58 | + $wpdb->prefix.'esp_question_group' => array('QSG_ID'), |
|
59 | + $wpdb->prefix.'esp_question_group_question' => array('QGQ_ID'), |
|
60 | + $wpdb->prefix.'esp_question_option' => array('QSO_ID'), |
|
61 | + $wpdb->prefix.'esp_registration' => array('REG_ID'), |
|
62 | + $wpdb->prefix.'esp_status' => array('STS_ID'), |
|
63 | + $wpdb->prefix.'esp_transaction' => array('TXN_ID'), |
|
64 | + $wpdb->prefix.'esp_transaction' => array('TXN_ID'), |
|
65 | + $wpdb->prefix.'events_detail' => array('id'), |
|
66 | + $wpdb->prefix.'events_category_detail' => array('id'), |
|
67 | + $wpdb->prefix.'events_category_rel' => array('id'), |
|
68 | + $wpdb->prefix.'events_venue' => array('id'), |
|
69 | + $wpdb->prefix.'events_venue_rel' => array('emeta_id'), |
|
70 | + $wpdb->prefix.'events_locale' => array('id'), |
|
71 | + $wpdb->prefix.'events_locale_rel' => array('id'), |
|
72 | + $wpdb->prefix.'events_personnel' => array('id'), |
|
73 | + $wpdb->prefix.'events_personnel_rel' => array('id'), |
|
74 | 74 | ); |
75 | 75 | } |
76 | 76 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | { |
103 | 103 | $fc = ""; |
104 | 104 | $fh = fopen($file_path, "rb"); |
105 | - if (! $fh) { |
|
105 | + if ( ! $fh) { |
|
106 | 106 | throw new EE_Error(sprintf(esc_html__("Cannot open file for read: %s<br>\n", 'event_espresso'), $file_path)); |
107 | 107 | } |
108 | 108 | $flen = filesize($file_path); |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | for ($i = 0; $i < $flen; $i++) { |
111 | 111 | $c = substr($bc, $i, 1); |
112 | 112 | if ((ord($c) != 0) && (ord($c) != 13)) { |
113 | - $fc = $fc . $c; |
|
113 | + $fc = $fc.$c; |
|
114 | 114 | } |
115 | 115 | } |
116 | 116 | if ((ord(substr($fc, 0, 1)) == 255) && (ord(substr($fc, 1, 1)) == 254)) { |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | public function import_csv_to_model_data_array($path_to_file, $model_name = false, $first_row_is_headers = true) |
206 | 206 | { |
207 | 207 | $multi_dimensional_array = $this->import_csv_to_multi_dimensional_array($path_to_file); |
208 | - if (! $multi_dimensional_array) { |
|
208 | + if ( ! $multi_dimensional_array) { |
|
209 | 209 | return false; |
210 | 210 | } |
211 | 211 | // gotta start somewhere |
@@ -241,23 +241,23 @@ discard block |
||
241 | 241 | // loop through each column |
242 | 242 | for ($i = 0; $i < $columns; $i++) { |
243 | 243 | // replace csv_enclosures with backslashed quotes |
244 | - $data[ $i ] = str_replace('"""', '\\"', $data[ $i ]); |
|
244 | + $data[$i] = str_replace('"""', '\\"', $data[$i]); |
|
245 | 245 | // do we need to grab the column names? |
246 | 246 | if ($row === 1) { |
247 | 247 | if ($first_row_is_headers) { |
248 | 248 | // store the column names to use for keys |
249 | - $column_name = $data[ $i ]; |
|
249 | + $column_name = $data[$i]; |
|
250 | 250 | // check it's not blank... sometimes CSV editign programs adda bunch of empty columns onto the end... |
251 | - if (! $column_name) { |
|
251 | + if ( ! $column_name) { |
|
252 | 252 | continue; |
253 | 253 | } |
254 | 254 | $matches = array(); |
255 | 255 | if ($model_name == EE_CSV::metadata_header) { |
256 | - $headers[ $i ] = $column_name; |
|
256 | + $headers[$i] = $column_name; |
|
257 | 257 | } else { |
258 | 258 | // now get the db table name from it (the part between square brackets) |
259 | 259 | $success = preg_match('~(.*)\[(.*)\]~', $column_name, $matches); |
260 | - if (! $success) { |
|
260 | + if ( ! $success) { |
|
261 | 261 | EE_Error::add_error( |
262 | 262 | sprintf( |
263 | 263 | esc_html__( |
@@ -273,24 +273,24 @@ discard block |
||
273 | 273 | ); |
274 | 274 | return false; |
275 | 275 | } |
276 | - $headers[ $i ] = $matches[2]; |
|
276 | + $headers[$i] = $matches[2]; |
|
277 | 277 | } |
278 | 278 | } else { |
279 | 279 | // no column names means our final array will just use counters for keys |
280 | - $model_entry[ $headers[ $i ] ] = $data[ $i ]; |
|
281 | - $headers[ $i ] = $i; |
|
280 | + $model_entry[$headers[$i]] = $data[$i]; |
|
281 | + $headers[$i] = $i; |
|
282 | 282 | } |
283 | 283 | // and we need to store csv data |
284 | 284 | } else { |
285 | 285 | // this column isn' ta header, store it if there is a header for it |
286 | - if (isset($headers[ $i ])) { |
|
287 | - $model_entry[ $headers[ $i ] ] = $data[ $i ]; |
|
286 | + if (isset($headers[$i])) { |
|
287 | + $model_entry[$headers[$i]] = $data[$i]; |
|
288 | 288 | } |
289 | 289 | } |
290 | 290 | } |
291 | 291 | // save the row's data IF it's a non-header-row |
292 | - if (! $first_row_is_headers || ($first_row_is_headers && $row > 1)) { |
|
293 | - $ee_formatted_data[ $model_name ][] = $model_entry; |
|
292 | + if ( ! $first_row_is_headers || ($first_row_is_headers && $row > 1)) { |
|
293 | + $ee_formatted_data[$model_name][] = $model_entry; |
|
294 | 294 | } |
295 | 295 | // advance to next row |
296 | 296 | $row++; |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | // header("Content-Type: application/force-download"); |
352 | 352 | // header("Content-Type: application/octet-stream"); |
353 | 353 | // header("Content-Type: application/download"); |
354 | - header('Content-disposition: attachment; filename=' . $filename); |
|
354 | + header('Content-disposition: attachment; filename='.$filename); |
|
355 | 355 | header("Content-Type: text/csv; charset=utf-8"); |
356 | 356 | do_action('AHEE__EE_CSV__begin_sending_csv__headers'); |
357 | 357 | echo apply_filters( |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | */ |
371 | 371 | public function write_metadata_to_csv($filehandle) |
372 | 372 | { |
373 | - $data_row = array(EE_CSV::metadata_header);// do NOT translate because this exact string is used when importing |
|
373 | + $data_row = array(EE_CSV::metadata_header); // do NOT translate because this exact string is used when importing |
|
374 | 374 | $this->fputcsv2($filehandle, $data_row); |
375 | 375 | $meta_data = array( |
376 | 376 | 0 => array( |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | $this->fputcsv2($filehandle, array('MODEL', $model_name)); |
500 | 500 | // if we have items to put in the CSV, do it normally |
501 | 501 | |
502 | - if (! empty($model_instance_arrays)) { |
|
502 | + if ( ! empty($model_instance_arrays)) { |
|
503 | 503 | $this->write_data_array_to_csv($filehandle, $model_instance_arrays); |
504 | 504 | } else { |
505 | 505 | // echo "no data to write... so just write the headers"; |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | $model = EE_Registry::instance()->load_model($model_name); |
509 | 509 | $column_names = array(); |
510 | 510 | foreach ($model->field_settings() as $field) { |
511 | - $column_names[ $field->get_nicename() . "[" . $field->get_name() . "]" ] = null; |
|
511 | + $column_names[$field->get_nicename()."[".$field->get_name()."]"] = null; |
|
512 | 512 | } |
513 | 513 | $this->write_data_array_to_csv($filehandle, array($column_names)); |
514 | 514 | } |
@@ -541,12 +541,12 @@ discard block |
||
541 | 541 | { |
542 | 542 | |
543 | 543 | // no data file?? get outta here |
544 | - if (! $data or ! is_array($data) or empty($data)) { |
|
544 | + if ( ! $data or ! is_array($data) or empty($data)) { |
|
545 | 545 | return false; |
546 | 546 | } |
547 | 547 | |
548 | 548 | // no filename?? get outta here |
549 | - if (! $filename) { |
|
549 | + if ( ! $filename) { |
|
550 | 550 | return false; |
551 | 551 | } |
552 | 552 | |
@@ -627,11 +627,11 @@ discard block |
||
627 | 627 | } |
628 | 628 | |
629 | 629 | $output[] = preg_match("/(?:${delimiter_esc}|${enclosure_esc}|\s)/", $field_value) ? |
630 | - ($enclosure . str_replace($enclosure, $enclosure . $enclosure, $field_value) . $enclosure) |
|
630 | + ($enclosure.str_replace($enclosure, $enclosure.$enclosure, $field_value).$enclosure) |
|
631 | 631 | : $field_value; |
632 | 632 | } |
633 | 633 | |
634 | - fwrite($fh, join($delimiter, $output) . PHP_EOL); |
|
634 | + fwrite($fh, join($delimiter, $output).PHP_EOL); |
|
635 | 635 | } |
636 | 636 | |
637 | 637 |
@@ -13,664 +13,664 @@ |
||
13 | 13 | */ |
14 | 14 | class EE_CSV |
15 | 15 | { |
16 | - // instance of the EE_CSV object |
|
17 | - private static $_instance = null; |
|
18 | - |
|
19 | - |
|
20 | - // multidimensional array to store update & error messages |
|
21 | - // var $_notices = array( 'updates' => array(), 'errors' => array() ); |
|
22 | - |
|
23 | - |
|
24 | - private $_primary_keys; |
|
25 | - |
|
26 | - /** |
|
27 | - * @var EE_Registry |
|
28 | - */ |
|
29 | - private $EE; |
|
30 | - /** |
|
31 | - * string used for 1st cell in exports, which indicates that the following 2 rows will be metadata keys and values |
|
32 | - */ |
|
33 | - const metadata_header = 'Event Espresso Export Meta Data'; |
|
34 | - |
|
35 | - /** |
|
36 | - * private constructor to prevent direct creation |
|
37 | - * |
|
38 | - * @return void |
|
39 | - */ |
|
40 | - private function __construct() |
|
41 | - { |
|
42 | - global $wpdb; |
|
43 | - |
|
44 | - $this->_primary_keys = array( |
|
45 | - $wpdb->prefix . 'esp_answer' => array('ANS_ID'), |
|
46 | - $wpdb->prefix . 'esp_attendee' => array('ATT_ID'), |
|
47 | - $wpdb->prefix . 'esp_datetime' => array('DTT_ID'), |
|
48 | - $wpdb->prefix . 'esp_event_question_group' => array('EQG_ID'), |
|
49 | - $wpdb->prefix . 'esp_message_template' => array('MTP_ID'), |
|
50 | - $wpdb->prefix . 'esp_payment' => array('PAY_ID'), |
|
51 | - $wpdb->prefix . 'esp_price' => array('PRC_ID'), |
|
52 | - $wpdb->prefix . 'esp_price_type' => array('PRT_ID'), |
|
53 | - $wpdb->prefix . 'esp_question' => array('QST_ID'), |
|
54 | - $wpdb->prefix . 'esp_question_group' => array('QSG_ID'), |
|
55 | - $wpdb->prefix . 'esp_question_group_question' => array('QGQ_ID'), |
|
56 | - $wpdb->prefix . 'esp_question_option' => array('QSO_ID'), |
|
57 | - $wpdb->prefix . 'esp_registration' => array('REG_ID'), |
|
58 | - $wpdb->prefix . 'esp_status' => array('STS_ID'), |
|
59 | - $wpdb->prefix . 'esp_transaction' => array('TXN_ID'), |
|
60 | - $wpdb->prefix . 'esp_transaction' => array('TXN_ID'), |
|
61 | - $wpdb->prefix . 'events_detail' => array('id'), |
|
62 | - $wpdb->prefix . 'events_category_detail' => array('id'), |
|
63 | - $wpdb->prefix . 'events_category_rel' => array('id'), |
|
64 | - $wpdb->prefix . 'events_venue' => array('id'), |
|
65 | - $wpdb->prefix . 'events_venue_rel' => array('emeta_id'), |
|
66 | - $wpdb->prefix . 'events_locale' => array('id'), |
|
67 | - $wpdb->prefix . 'events_locale_rel' => array('id'), |
|
68 | - $wpdb->prefix . 'events_personnel' => array('id'), |
|
69 | - $wpdb->prefix . 'events_personnel_rel' => array('id'), |
|
70 | - ); |
|
71 | - } |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * singleton method used to instantiate class object |
|
76 | - * |
|
77 | - * @return EE_CSV |
|
78 | - */ |
|
79 | - public static function instance() |
|
80 | - { |
|
81 | - // check if class object is instantiated |
|
82 | - if (self::$_instance === null or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_CSV)) { |
|
83 | - self::$_instance = new self(); |
|
84 | - } |
|
85 | - return self::$_instance; |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * Opens a unicode or utf file (normal file_get_contents has difficulty reading ga unicode file) |
|
90 | - * @see http://stackoverflow.com/questions/15092764/how-to-read-unicode-text-file-in-php |
|
91 | - * |
|
92 | - * @param string $file_path |
|
93 | - * @return string |
|
94 | - * @throws EE_Error |
|
95 | - */ |
|
96 | - private function read_unicode_file($file_path) |
|
97 | - { |
|
98 | - $fc = ""; |
|
99 | - $fh = fopen($file_path, "rb"); |
|
100 | - if (! $fh) { |
|
101 | - throw new EE_Error(sprintf(esc_html__("Cannot open file for read: %s<br>\n", 'event_espresso'), $file_path)); |
|
102 | - } |
|
103 | - $flen = filesize($file_path); |
|
104 | - $bc = fread($fh, $flen); |
|
105 | - for ($i = 0; $i < $flen; $i++) { |
|
106 | - $c = substr($bc, $i, 1); |
|
107 | - if ((ord($c) != 0) && (ord($c) != 13)) { |
|
108 | - $fc = $fc . $c; |
|
109 | - } |
|
110 | - } |
|
111 | - if ((ord(substr($fc, 0, 1)) == 255) && (ord(substr($fc, 1, 1)) == 254)) { |
|
112 | - $fc = substr($fc, 2); |
|
113 | - } |
|
114 | - return ($fc); |
|
115 | - } |
|
116 | - |
|
117 | - |
|
118 | - /** |
|
119 | - * Generic CSV-functionality to turn an entire CSV file into a single array that's |
|
120 | - * NOT in a specific format to EE. It's just a 2-level array, with top-level arrays |
|
121 | - * representing each row in the CSV file, and the second-level arrays being each column in that row |
|
122 | - * |
|
123 | - * @param string $path_to_file |
|
124 | - * @return array of arrays. Top-level array has rows, second-level array has each item |
|
125 | - */ |
|
126 | - public function import_csv_to_multi_dimensional_array($path_to_file) |
|
127 | - { |
|
128 | - // needed to deal with Mac line endings |
|
129 | - ini_set('auto_detect_line_endings', true); |
|
130 | - |
|
131 | - // because fgetcsv does not correctly deal with backslashed quotes such as \" |
|
132 | - // we'll read the file into a string |
|
133 | - $file_contents = $this->read_unicode_file($path_to_file); |
|
134 | - // replace backslashed quotes with CSV enclosures |
|
135 | - $file_contents = str_replace('\\"', '"""', $file_contents); |
|
136 | - // HEY YOU! PUT THAT FILE BACK!!! |
|
137 | - file_put_contents($path_to_file, $file_contents); |
|
138 | - |
|
139 | - if (($file_handle = fopen($path_to_file, "r")) !== false) { |
|
140 | - # Set the parent multidimensional array key to 0. |
|
141 | - $nn = 0; |
|
142 | - $csvarray = array(); |
|
143 | - |
|
144 | - // in PHP 5.3 fgetcsv accepts a 5th parameter, but the pre 5.3 versions of fgetcsv choke if passed more than 4 - is that crazy or what? |
|
145 | - if (version_compare(PHP_VERSION, '5.3.0') < 0) { |
|
146 | - // PHP 5.2- version |
|
147 | - // loop through each row of the file |
|
148 | - while (($data = fgetcsv($file_handle, 0, ',', '"')) !== false) { |
|
149 | - $csvarray[] = $data; |
|
150 | - } |
|
151 | - } else { |
|
152 | - // loop through each row of the file |
|
153 | - while (($data = fgetcsv($file_handle, 0, ',', '"', '\\')) !== false) { |
|
154 | - $csvarray[] = $data; |
|
155 | - } |
|
156 | - } |
|
157 | - # Close the File. |
|
158 | - fclose($file_handle); |
|
159 | - return $csvarray; |
|
160 | - } else { |
|
161 | - EE_Error::add_error( |
|
162 | - sprintf(esc_html__("An error occurred - the file: %s could not opened.", "event_espresso"), $path_to_file), |
|
163 | - __FILE__, |
|
164 | - __FUNCTION__, |
|
165 | - __LINE__ |
|
166 | - ); |
|
167 | - return false; |
|
168 | - } |
|
169 | - } |
|
170 | - |
|
171 | - |
|
172 | - /** |
|
173 | - * Import contents of csv file and store values in an array to be manipulated by other functions |
|
174 | - * @param string $path_to_file - the csv file to be imported including the path to it's location. |
|
175 | - * If $model_name is provided, assumes that each row in the CSV represents a |
|
176 | - * model object for that model If $model_name ISN'T provided, assumes that |
|
177 | - * before model object data, there is a row where the first entry is simply |
|
178 | - * 'MODEL', and next entry is the model's name, (untranslated) like Event, and |
|
179 | - * then maybe a row of headers, and then the model data. Eg. |
|
180 | - * '<br>MODEL,Event,<br>EVT_ID,EVT_name,...<br>1,Monkey |
|
181 | - * Party,...<br>2,Llamarama,...<br>MODEL,Venue,<br>VNU_ID,VNU_name<br>1,The |
|
182 | - * Forest |
|
183 | - * @param string $model_name model name if we know what model we're importing |
|
184 | - * @param boolean $first_row_is_headers - whether the first row of data is headers or not - TRUE = headers, FALSE = |
|
185 | - * data |
|
186 | - * @return mixed - array on success - multi dimensional with headers as keys (if headers exist) OR string on fail - |
|
187 | - * error message like the following array('Event'=>array( array('EVT_ID'=>1,'EVT_name'=>'bob |
|
188 | - * party',...), array('EVT_ID'=>2,'EVT_name'=>'llamarama',...), |
|
189 | - * ... |
|
190 | - * ) |
|
191 | - * 'Venue'=>array( |
|
192 | - * array('VNU_ID'=>1,'VNU_name'=>'the shack',...), |
|
193 | - * array('VNU_ID'=>2,'VNU_name'=>'tree house',...), |
|
194 | - * ... |
|
195 | - * ) |
|
196 | - * ... |
|
197 | - * ) |
|
198 | - */ |
|
199 | - public function import_csv_to_model_data_array($path_to_file, $model_name = false, $first_row_is_headers = true) |
|
200 | - { |
|
201 | - $multi_dimensional_array = $this->import_csv_to_multi_dimensional_array($path_to_file); |
|
202 | - if (! $multi_dimensional_array) { |
|
203 | - return false; |
|
204 | - } |
|
205 | - // gotta start somewhere |
|
206 | - $row = 1; |
|
207 | - // array to store csv data in |
|
208 | - $ee_formatted_data = array(); |
|
209 | - // array to store headers (column names) |
|
210 | - $headers = array(); |
|
211 | - foreach ($multi_dimensional_array as $data) { |
|
212 | - // if first cell is MODEL, then second cell is the MODEL name |
|
213 | - if ($data[0] == 'MODEL') { |
|
214 | - $model_name = $data[1]; |
|
215 | - // don't bother looking for model data in this row. The rest of this |
|
216 | - // row should be blank |
|
217 | - // AND pretend this is the first row again |
|
218 | - $row = 1; |
|
219 | - // reset headers |
|
220 | - $headers = array(); |
|
221 | - continue; |
|
222 | - } |
|
223 | - if (strpos($data[0], EE_CSV::metadata_header) !== false) { |
|
224 | - $model_name = EE_CSV::metadata_header; |
|
225 | - // store like model data, we just won't try importing it etc. |
|
226 | - $row = 1; |
|
227 | - continue; |
|
228 | - } |
|
229 | - |
|
230 | - |
|
231 | - // how many columns are there? |
|
232 | - $columns = count($data); |
|
233 | - |
|
234 | - $model_entry = array(); |
|
235 | - // loop through each column |
|
236 | - for ($i = 0; $i < $columns; $i++) { |
|
237 | - // replace csv_enclosures with backslashed quotes |
|
238 | - $data[ $i ] = str_replace('"""', '\\"', $data[ $i ]); |
|
239 | - // do we need to grab the column names? |
|
240 | - if ($row === 1) { |
|
241 | - if ($first_row_is_headers) { |
|
242 | - // store the column names to use for keys |
|
243 | - $column_name = $data[ $i ]; |
|
244 | - // check it's not blank... sometimes CSV editign programs adda bunch of empty columns onto the end... |
|
245 | - if (! $column_name) { |
|
246 | - continue; |
|
247 | - } |
|
248 | - $matches = array(); |
|
249 | - if ($model_name == EE_CSV::metadata_header) { |
|
250 | - $headers[ $i ] = $column_name; |
|
251 | - } else { |
|
252 | - // now get the db table name from it (the part between square brackets) |
|
253 | - $success = preg_match('~(.*)\[(.*)\]~', $column_name, $matches); |
|
254 | - if (! $success) { |
|
255 | - EE_Error::add_error( |
|
256 | - sprintf( |
|
257 | - esc_html__( |
|
258 | - "The column titled %s is invalid for importing. It must be be in the format of 'Nice Name[model_field_name]' in row %s", |
|
259 | - "event_espresso" |
|
260 | - ), |
|
261 | - $column_name, |
|
262 | - implode(",", $data) |
|
263 | - ), |
|
264 | - __FILE__, |
|
265 | - __FUNCTION__, |
|
266 | - __LINE__ |
|
267 | - ); |
|
268 | - return false; |
|
269 | - } |
|
270 | - $headers[ $i ] = $matches[2]; |
|
271 | - } |
|
272 | - } else { |
|
273 | - // no column names means our final array will just use counters for keys |
|
274 | - $model_entry[ $headers[ $i ] ] = $data[ $i ]; |
|
275 | - $headers[ $i ] = $i; |
|
276 | - } |
|
277 | - // and we need to store csv data |
|
278 | - } else { |
|
279 | - // this column isn' ta header, store it if there is a header for it |
|
280 | - if (isset($headers[ $i ])) { |
|
281 | - $model_entry[ $headers[ $i ] ] = $data[ $i ]; |
|
282 | - } |
|
283 | - } |
|
284 | - } |
|
285 | - // save the row's data IF it's a non-header-row |
|
286 | - if (! $first_row_is_headers || ($first_row_is_headers && $row > 1)) { |
|
287 | - $ee_formatted_data[ $model_name ][] = $model_entry; |
|
288 | - } |
|
289 | - // advance to next row |
|
290 | - $row++; |
|
291 | - } |
|
292 | - |
|
293 | - // delete the uploaded file |
|
294 | - unlink($path_to_file); |
|
295 | - // echo '<pre style="height:auto;border:2px solid lightblue;">' . print_r( $ee_formatted_data, TRUE ) . '</pre><br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>'; |
|
296 | - // die(); |
|
297 | - |
|
298 | - // it's good to give back |
|
299 | - return $ee_formatted_data; |
|
300 | - } |
|
301 | - |
|
302 | - |
|
303 | - public function save_csv_to_db($csv_data_array, $model_name = false) |
|
304 | - { |
|
305 | - EE_Error::doing_it_wrong( |
|
306 | - 'save_csv_to_db', |
|
307 | - esc_html__( |
|
308 | - 'Function moved to EE_Import and renamed to save_csv_data_array_to_db', |
|
309 | - 'event_espresso' |
|
310 | - ), |
|
311 | - '4.6.7' |
|
312 | - ); |
|
313 | - return EE_Import::instance()->save_csv_data_array_to_db($csv_data_array, $model_name); |
|
314 | - } |
|
315 | - |
|
316 | - /** |
|
317 | - * Sends HTTP headers to indicate that the browser should download a file, |
|
318 | - * and starts writing the file to PHP's output. Returns the file handle so other functions can |
|
319 | - * also write to it |
|
320 | - * |
|
321 | - * @param string $new_filename the name of the file that the user will download |
|
322 | - * @return resource, like the results of fopen(), which can be used for fwrite, fputcsv2, etc. |
|
323 | - */ |
|
324 | - public function begin_sending_csv($filename) |
|
325 | - { |
|
326 | - // grab file extension |
|
327 | - $ext = substr(strrchr($filename, '.'), 1); |
|
328 | - if ($ext == '.csv' or $ext == '.xls') { |
|
329 | - str_replace($ext, '', $filename); |
|
330 | - } |
|
331 | - $filename .= '.csv'; |
|
332 | - |
|
333 | - // if somebody's been naughty and already started outputting stuff, trash it |
|
334 | - // and start writing our stuff. |
|
335 | - if (ob_get_length()) { |
|
336 | - @ob_flush(); |
|
337 | - @flush(); |
|
338 | - @ob_end_flush(); |
|
339 | - } |
|
340 | - @ob_start(); |
|
341 | - header("Pragma: public"); |
|
342 | - header("Expires: 0"); |
|
343 | - header("Pragma: no-cache"); |
|
344 | - header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0"); |
|
345 | - // header("Content-Type: application/force-download"); |
|
346 | - // header("Content-Type: application/octet-stream"); |
|
347 | - // header("Content-Type: application/download"); |
|
348 | - header('Content-disposition: attachment; filename=' . $filename); |
|
349 | - header("Content-Type: text/csv; charset=utf-8"); |
|
350 | - do_action('AHEE__EE_CSV__begin_sending_csv__headers'); |
|
351 | - echo apply_filters( |
|
352 | - 'FHEE__EE_CSV__begin_sending_csv__start_writing', |
|
353 | - "\xEF\xBB\xBF" |
|
354 | - ); // makes excel open it as UTF-8. UTF-8 BOM, see http://stackoverflow.com/a/4440143/2773835 |
|
355 | - $fh = fopen('php://output', 'w'); |
|
356 | - return $fh; |
|
357 | - } |
|
358 | - |
|
359 | - /** |
|
360 | - * Writes some meta data to the CSV as a bunch of columns. Initially we're only |
|
361 | - * mentioning the version and timezone |
|
362 | - * |
|
363 | - * @param resource $filehandle |
|
364 | - */ |
|
365 | - public function write_metadata_to_csv($filehandle) |
|
366 | - { |
|
367 | - $data_row = array(EE_CSV::metadata_header);// do NOT translate because this exact string is used when importing |
|
368 | - $this->fputcsv2($filehandle, $data_row); |
|
369 | - $meta_data = array( |
|
370 | - 0 => array( |
|
371 | - 'version' => espresso_version(), |
|
372 | - 'timezone' => EEH_DTT_Helper::get_timezone(), |
|
373 | - 'time_of_export' => current_time('mysql'), |
|
374 | - 'site_url' => site_url(), |
|
375 | - ), |
|
376 | - ); |
|
377 | - $this->write_data_array_to_csv($filehandle, $meta_data); |
|
378 | - } |
|
379 | - |
|
380 | - |
|
381 | - /** |
|
382 | - * Writes $data to the csv file open in $filehandle. uses the array indices of $data for column headers |
|
383 | - * |
|
384 | - * @param array $data 2D array, first numerically-indexed, and next-level-down preferably indexed |
|
385 | - * by string |
|
386 | - * @param boolean $add_csv_column_names whether or not we should add the keys in the bottom-most array as a row for |
|
387 | - * headers in the CSV. Eg, if $data looked like |
|
388 | - * array(0=>array('EVT_ID'=>1,'EVT_name'=>'monkey'...), 1=>array(...),...)) |
|
389 | - * then the first row we'd write to the CSV would be "EVT_ID,EVT_name,..." |
|
390 | - * @return boolean if we successfully wrote to the CSV or not. If there's no $data, we consider that a success |
|
391 | - * (because we wrote everything there was...nothing) |
|
392 | - */ |
|
393 | - public function write_data_array_to_csv($filehandle, $data) |
|
394 | - { |
|
395 | - |
|
396 | - |
|
397 | - // determine if $data is actually a 2d array |
|
398 | - if ($data && is_array($data) && is_array(EEH_Array::get_one_item_from_array($data))) { |
|
399 | - // make sure top level is numerically indexed, |
|
400 | - |
|
401 | - if (EEH_Array::is_associative_array($data)) { |
|
402 | - throw new EE_Error( |
|
403 | - sprintf( |
|
404 | - esc_html__( |
|
405 | - "top-level array must be numerically indexed. Does these look like numbers to you? %s", |
|
406 | - "event_espresso" |
|
407 | - ), |
|
408 | - implode(",", array_keys($data)) |
|
409 | - ) |
|
410 | - ); |
|
411 | - } |
|
412 | - $item_in_top_level_array = EEH_Array::get_one_item_from_array($data); |
|
413 | - // now, is the last item in the top-level array of $data an associative or numeric array? |
|
414 | - if (EEH_Array::is_associative_array($item_in_top_level_array)) { |
|
415 | - // its associative, so we want to output its keys as column headers |
|
416 | - $keys = array_keys($item_in_top_level_array); |
|
417 | - $this->fputcsv2($filehandle, $keys); |
|
418 | - } |
|
419 | - // start writing data |
|
420 | - foreach ($data as $data_row) { |
|
421 | - $this->fputcsv2($filehandle, $data_row); |
|
422 | - } |
|
423 | - return true; |
|
424 | - } else { |
|
425 | - // no data TO write... so we can assume that's a success |
|
426 | - return true; |
|
427 | - } |
|
428 | - // //if 2nd level is indexed by strings, use those as csv column headers (ie, the first row) |
|
429 | - // |
|
430 | - // |
|
431 | - // $no_table = TRUE; |
|
432 | - // |
|
433 | - // // loop through data and add each row to the file/stream as csv |
|
434 | - // foreach ( $data as $model_name => $model_data ) { |
|
435 | - // // test first row to see if it is data or a model name |
|
436 | - // $model = EE_Registry::instance();->load_model($model_name); |
|
437 | - // //if the model really exists, |
|
438 | - // if ( $model ) { |
|
439 | - // |
|
440 | - // // we have a table name |
|
441 | - // $no_table = FALSE; |
|
442 | - // |
|
443 | - // // put the tablename into an array cuz that's how fputcsv rolls |
|
444 | - // $model_name_row = array( 'MODEL', $model_name ); |
|
445 | - // |
|
446 | - // // add table name to csv output |
|
447 | - // echo self::fputcsv2($filehandle, $model_name_row); |
|
448 | - // |
|
449 | - // // now get the rest of the data |
|
450 | - // foreach ( $model_data as $row ) { |
|
451 | - // // output the row |
|
452 | - // echo self::fputcsv2($filehandle, $row); |
|
453 | - // } |
|
454 | - // |
|
455 | - // } |
|
456 | - // |
|
457 | - // if ( $no_table ) { |
|
458 | - // // no table so just put the data |
|
459 | - // echo self::fputcsv2($filehandle, $model_data); |
|
460 | - // } |
|
461 | - // |
|
462 | - // } // END OF foreach ( $data ) |
|
463 | - } |
|
464 | - |
|
465 | - /** |
|
466 | - * Should be called after begin_sending_csv(), and one or more write_data_array_to_csv()s. |
|
467 | - * Calls exit to prevent polluting the CSV file with other junk |
|
468 | - * |
|
469 | - * @param resource $fh filehandle where we're writing the CSV to |
|
470 | - */ |
|
471 | - public function end_sending_csv($fh) |
|
472 | - { |
|
473 | - fclose($fh); |
|
474 | - exit(0); |
|
475 | - } |
|
476 | - |
|
477 | - /** |
|
478 | - * Given an open file, writes all the model data to it in the format the importer expects. |
|
479 | - * Usually preceded by begin_sending_csv($filename), and followed by end_sending_csv($filehandle). |
|
480 | - * |
|
481 | - * @param resource $filehandle |
|
482 | - * @param array $model_data_array is assumed to be a 3d array: 1st layer has keys of model names (eg 'Event'), |
|
483 | - * next layer is numerically indexed to represent each model object (eg, each |
|
484 | - * individual event), and the last layer has all the attributes o fthat model |
|
485 | - * object (eg, the event's id, name, etc) |
|
486 | - * @return boolean success |
|
487 | - */ |
|
488 | - public function write_model_data_to_csv($filehandle, $model_data_array) |
|
489 | - { |
|
490 | - $this->write_metadata_to_csv($filehandle); |
|
491 | - foreach ($model_data_array as $model_name => $model_instance_arrays) { |
|
492 | - // first: output a special row stating the model |
|
493 | - $this->fputcsv2($filehandle, array('MODEL', $model_name)); |
|
494 | - // if we have items to put in the CSV, do it normally |
|
495 | - |
|
496 | - if (! empty($model_instance_arrays)) { |
|
497 | - $this->write_data_array_to_csv($filehandle, $model_instance_arrays); |
|
498 | - } else { |
|
499 | - // echo "no data to write... so just write the headers"; |
|
500 | - // so there's actually NO model objects for that model. |
|
501 | - // probably still want to show the columns |
|
502 | - $model = EE_Registry::instance()->load_model($model_name); |
|
503 | - $column_names = array(); |
|
504 | - foreach ($model->field_settings() as $field) { |
|
505 | - $column_names[ $field->get_nicename() . "[" . $field->get_name() . "]" ] = null; |
|
506 | - } |
|
507 | - $this->write_data_array_to_csv($filehandle, array($column_names)); |
|
508 | - } |
|
509 | - } |
|
510 | - } |
|
511 | - |
|
512 | - /** |
|
513 | - * Writes the CSV file to the output buffer, with rows corresponding to $model_data_array, |
|
514 | - * and dies (in order to avoid other plugins from messing up the csv output) |
|
515 | - * |
|
516 | - * @param string $filename the filename you want to give the file |
|
517 | - * @param array $model_data_array 3d array, as described in EE_CSV::write_model_data_to_csv() |
|
518 | - * @return bool | void writes CSV file to output and dies |
|
519 | - */ |
|
520 | - public function export_multiple_model_data_to_csv($filename, $model_data_array) |
|
521 | - { |
|
522 | - $filehandle = $this->begin_sending_csv($filename); |
|
523 | - $this->write_model_data_to_csv($filehandle, $model_data_array); |
|
524 | - $this->end_sending_csv($filehandle); |
|
525 | - } |
|
526 | - |
|
527 | - /** |
|
528 | - * Export contents of an array to csv file |
|
529 | - * @param array $data - the array of data to be converted to csv and exported |
|
530 | - * @param string $filename - name for newly created csv file |
|
531 | - * @return TRUE on success, FALSE on fail |
|
532 | - */ |
|
533 | - public function export_array_to_csv($data = false, $filename = false) |
|
534 | - { |
|
535 | - |
|
536 | - // no data file?? get outta here |
|
537 | - if (! $data or ! is_array($data) or empty($data)) { |
|
538 | - return false; |
|
539 | - } |
|
540 | - |
|
541 | - // no filename?? get outta here |
|
542 | - if (! $filename) { |
|
543 | - return false; |
|
544 | - } |
|
545 | - |
|
546 | - |
|
547 | - // somebody told me i might need this ??? |
|
548 | - global $wpdb; |
|
549 | - $prefix = $wpdb->prefix; |
|
550 | - |
|
551 | - |
|
552 | - $fh = $this->begin_sending_csv($filename); |
|
553 | - |
|
554 | - |
|
555 | - $this->end_sending_csv($fh); |
|
556 | - } |
|
557 | - |
|
558 | - |
|
559 | - /** |
|
560 | - * Determine the maximum upload file size based on php.ini settings |
|
561 | - * @param int $percent_of_max - desired percentage of the max upload_mb |
|
562 | - * @return int KB |
|
563 | - */ |
|
564 | - public function get_max_upload_size($percent_of_max = false) |
|
565 | - { |
|
566 | - |
|
567 | - $max_upload = (int) (ini_get('upload_max_filesize')); |
|
568 | - $max_post = (int) (ini_get('post_max_size')); |
|
569 | - $memory_limit = (int) (ini_get('memory_limit')); |
|
570 | - |
|
571 | - // determine the smallest of the three values from above |
|
572 | - $upload_mb = min($max_upload, $max_post, $memory_limit); |
|
573 | - |
|
574 | - // convert MB to KB |
|
575 | - $upload_mb = $upload_mb * 1024; |
|
576 | - |
|
577 | - // don't want the full monty? then reduce the max uplaod size |
|
578 | - if ($percent_of_max) { |
|
579 | - // is percent_of_max like this -> 50 or like this -> 0.50 ? |
|
580 | - if ($percent_of_max > 1) { |
|
581 | - // chnages 50 to 0.50 |
|
582 | - $percent_of_max = $percent_of_max / 100; |
|
583 | - } |
|
584 | - // make upload_mb a percentage of the max upload_mb |
|
585 | - $upload_mb = $upload_mb * $percent_of_max; |
|
586 | - } |
|
587 | - |
|
588 | - return $upload_mb; |
|
589 | - } |
|
590 | - |
|
591 | - |
|
592 | - /** |
|
593 | - * Drop in replacement for PHP's fputcsv function - but this one works!!! |
|
594 | - * @param resource $fh - file handle - what we are writing to |
|
595 | - * @param array $row - individual row of csv data |
|
596 | - * @param string $delimiter - csv delimiter |
|
597 | - * @param string $enclosure - csv enclosure |
|
598 | - * @param string $mysql_null - allows php NULL to be overridden with MySQl's insertable NULL value |
|
599 | - * @return void |
|
600 | - */ |
|
601 | - private function fputcsv2($fh, array $row, $delimiter = ',', $enclosure = '"', $mysql_null = false) |
|
602 | - { |
|
603 | - // Allow user to filter the csv delimiter and enclosure for other countries csv standards |
|
604 | - $delimiter = apply_filters('FHEE__EE_CSV__fputcsv2__delimiter', $delimiter); |
|
605 | - $enclosure = apply_filters('FHEE__EE_CSV__fputcsv2__enclosure', $enclosure); |
|
606 | - |
|
607 | - $delimiter_esc = preg_quote($delimiter, '/'); |
|
608 | - $enclosure_esc = preg_quote($enclosure, '/'); |
|
609 | - |
|
610 | - $output = array(); |
|
611 | - foreach ($row as $field_value) { |
|
612 | - if (is_object($field_value) || is_array($field_value)) { |
|
613 | - $field_value = serialize($field_value); |
|
614 | - } |
|
615 | - if ($field_value === null && $mysql_null) { |
|
616 | - $output[] = 'NULL'; |
|
617 | - continue; |
|
618 | - } |
|
619 | - |
|
620 | - $output[] = preg_match("/(?:${delimiter_esc}|${enclosure_esc}|\s)/", $field_value) ? |
|
621 | - ($enclosure . str_replace($enclosure, $enclosure . $enclosure, $field_value) . $enclosure) |
|
622 | - : $field_value; |
|
623 | - } |
|
624 | - |
|
625 | - fwrite($fh, join($delimiter, $output) . PHP_EOL); |
|
626 | - } |
|
627 | - |
|
628 | - |
|
629 | - // /** |
|
630 | - // * CSV Import / Export messages |
|
631 | - // * @return void |
|
632 | - // */ |
|
633 | - // public function csv_admin_notices() |
|
634 | - // { |
|
635 | - // |
|
636 | - // // We play both kinds of music here! Country AND Western! - err... I mean, cycle through both types of notices |
|
637 | - // foreach (array('updates', 'errors') as $type) { |
|
638 | - // |
|
639 | - // // if particular notice type is not empty, then "You've got Mail" |
|
640 | - // if (! empty($this->_notices[ $type ])) { |
|
641 | - // |
|
642 | - // // is it an update or an error ? |
|
643 | - // $msg_class = $type == 'updates' ? 'updated' : 'error'; |
|
644 | - // echo '<div id="message" class="' . $msg_class . '">'; |
|
645 | - // // display each notice, however many that may be |
|
646 | - // foreach ($this->_notices[ $type ] as $message) { |
|
647 | - // echo '<p>' . $message . '</p>'; |
|
648 | - // } |
|
649 | - // // wrap it up |
|
650 | - // echo '</div>'; |
|
651 | - // } |
|
652 | - // } |
|
653 | - // } |
|
654 | - |
|
655 | - /** |
|
656 | - * Gets the date format to use in teh csv. filterable |
|
657 | - * |
|
658 | - * @param string $current_format |
|
659 | - * @return string |
|
660 | - */ |
|
661 | - public function get_date_format_for_csv($current_format = null) |
|
662 | - { |
|
663 | - return apply_filters('FHEE__EE_CSV__get_date_format_for_csv__format', 'Y-m-d', $current_format); |
|
664 | - } |
|
665 | - |
|
666 | - /** |
|
667 | - * Gets the time format we want to use in CSV reports. Filterable |
|
668 | - * |
|
669 | - * @param string $current_format |
|
670 | - * @return string |
|
671 | - */ |
|
672 | - public function get_time_format_for_csv($current_format = null) |
|
673 | - { |
|
674 | - return apply_filters('FHEE__EE_CSV__get_time_format_for_csv__format', 'H:i:s', $current_format); |
|
675 | - } |
|
16 | + // instance of the EE_CSV object |
|
17 | + private static $_instance = null; |
|
18 | + |
|
19 | + |
|
20 | + // multidimensional array to store update & error messages |
|
21 | + // var $_notices = array( 'updates' => array(), 'errors' => array() ); |
|
22 | + |
|
23 | + |
|
24 | + private $_primary_keys; |
|
25 | + |
|
26 | + /** |
|
27 | + * @var EE_Registry |
|
28 | + */ |
|
29 | + private $EE; |
|
30 | + /** |
|
31 | + * string used for 1st cell in exports, which indicates that the following 2 rows will be metadata keys and values |
|
32 | + */ |
|
33 | + const metadata_header = 'Event Espresso Export Meta Data'; |
|
34 | + |
|
35 | + /** |
|
36 | + * private constructor to prevent direct creation |
|
37 | + * |
|
38 | + * @return void |
|
39 | + */ |
|
40 | + private function __construct() |
|
41 | + { |
|
42 | + global $wpdb; |
|
43 | + |
|
44 | + $this->_primary_keys = array( |
|
45 | + $wpdb->prefix . 'esp_answer' => array('ANS_ID'), |
|
46 | + $wpdb->prefix . 'esp_attendee' => array('ATT_ID'), |
|
47 | + $wpdb->prefix . 'esp_datetime' => array('DTT_ID'), |
|
48 | + $wpdb->prefix . 'esp_event_question_group' => array('EQG_ID'), |
|
49 | + $wpdb->prefix . 'esp_message_template' => array('MTP_ID'), |
|
50 | + $wpdb->prefix . 'esp_payment' => array('PAY_ID'), |
|
51 | + $wpdb->prefix . 'esp_price' => array('PRC_ID'), |
|
52 | + $wpdb->prefix . 'esp_price_type' => array('PRT_ID'), |
|
53 | + $wpdb->prefix . 'esp_question' => array('QST_ID'), |
|
54 | + $wpdb->prefix . 'esp_question_group' => array('QSG_ID'), |
|
55 | + $wpdb->prefix . 'esp_question_group_question' => array('QGQ_ID'), |
|
56 | + $wpdb->prefix . 'esp_question_option' => array('QSO_ID'), |
|
57 | + $wpdb->prefix . 'esp_registration' => array('REG_ID'), |
|
58 | + $wpdb->prefix . 'esp_status' => array('STS_ID'), |
|
59 | + $wpdb->prefix . 'esp_transaction' => array('TXN_ID'), |
|
60 | + $wpdb->prefix . 'esp_transaction' => array('TXN_ID'), |
|
61 | + $wpdb->prefix . 'events_detail' => array('id'), |
|
62 | + $wpdb->prefix . 'events_category_detail' => array('id'), |
|
63 | + $wpdb->prefix . 'events_category_rel' => array('id'), |
|
64 | + $wpdb->prefix . 'events_venue' => array('id'), |
|
65 | + $wpdb->prefix . 'events_venue_rel' => array('emeta_id'), |
|
66 | + $wpdb->prefix . 'events_locale' => array('id'), |
|
67 | + $wpdb->prefix . 'events_locale_rel' => array('id'), |
|
68 | + $wpdb->prefix . 'events_personnel' => array('id'), |
|
69 | + $wpdb->prefix . 'events_personnel_rel' => array('id'), |
|
70 | + ); |
|
71 | + } |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * singleton method used to instantiate class object |
|
76 | + * |
|
77 | + * @return EE_CSV |
|
78 | + */ |
|
79 | + public static function instance() |
|
80 | + { |
|
81 | + // check if class object is instantiated |
|
82 | + if (self::$_instance === null or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_CSV)) { |
|
83 | + self::$_instance = new self(); |
|
84 | + } |
|
85 | + return self::$_instance; |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * Opens a unicode or utf file (normal file_get_contents has difficulty reading ga unicode file) |
|
90 | + * @see http://stackoverflow.com/questions/15092764/how-to-read-unicode-text-file-in-php |
|
91 | + * |
|
92 | + * @param string $file_path |
|
93 | + * @return string |
|
94 | + * @throws EE_Error |
|
95 | + */ |
|
96 | + private function read_unicode_file($file_path) |
|
97 | + { |
|
98 | + $fc = ""; |
|
99 | + $fh = fopen($file_path, "rb"); |
|
100 | + if (! $fh) { |
|
101 | + throw new EE_Error(sprintf(esc_html__("Cannot open file for read: %s<br>\n", 'event_espresso'), $file_path)); |
|
102 | + } |
|
103 | + $flen = filesize($file_path); |
|
104 | + $bc = fread($fh, $flen); |
|
105 | + for ($i = 0; $i < $flen; $i++) { |
|
106 | + $c = substr($bc, $i, 1); |
|
107 | + if ((ord($c) != 0) && (ord($c) != 13)) { |
|
108 | + $fc = $fc . $c; |
|
109 | + } |
|
110 | + } |
|
111 | + if ((ord(substr($fc, 0, 1)) == 255) && (ord(substr($fc, 1, 1)) == 254)) { |
|
112 | + $fc = substr($fc, 2); |
|
113 | + } |
|
114 | + return ($fc); |
|
115 | + } |
|
116 | + |
|
117 | + |
|
118 | + /** |
|
119 | + * Generic CSV-functionality to turn an entire CSV file into a single array that's |
|
120 | + * NOT in a specific format to EE. It's just a 2-level array, with top-level arrays |
|
121 | + * representing each row in the CSV file, and the second-level arrays being each column in that row |
|
122 | + * |
|
123 | + * @param string $path_to_file |
|
124 | + * @return array of arrays. Top-level array has rows, second-level array has each item |
|
125 | + */ |
|
126 | + public function import_csv_to_multi_dimensional_array($path_to_file) |
|
127 | + { |
|
128 | + // needed to deal with Mac line endings |
|
129 | + ini_set('auto_detect_line_endings', true); |
|
130 | + |
|
131 | + // because fgetcsv does not correctly deal with backslashed quotes such as \" |
|
132 | + // we'll read the file into a string |
|
133 | + $file_contents = $this->read_unicode_file($path_to_file); |
|
134 | + // replace backslashed quotes with CSV enclosures |
|
135 | + $file_contents = str_replace('\\"', '"""', $file_contents); |
|
136 | + // HEY YOU! PUT THAT FILE BACK!!! |
|
137 | + file_put_contents($path_to_file, $file_contents); |
|
138 | + |
|
139 | + if (($file_handle = fopen($path_to_file, "r")) !== false) { |
|
140 | + # Set the parent multidimensional array key to 0. |
|
141 | + $nn = 0; |
|
142 | + $csvarray = array(); |
|
143 | + |
|
144 | + // in PHP 5.3 fgetcsv accepts a 5th parameter, but the pre 5.3 versions of fgetcsv choke if passed more than 4 - is that crazy or what? |
|
145 | + if (version_compare(PHP_VERSION, '5.3.0') < 0) { |
|
146 | + // PHP 5.2- version |
|
147 | + // loop through each row of the file |
|
148 | + while (($data = fgetcsv($file_handle, 0, ',', '"')) !== false) { |
|
149 | + $csvarray[] = $data; |
|
150 | + } |
|
151 | + } else { |
|
152 | + // loop through each row of the file |
|
153 | + while (($data = fgetcsv($file_handle, 0, ',', '"', '\\')) !== false) { |
|
154 | + $csvarray[] = $data; |
|
155 | + } |
|
156 | + } |
|
157 | + # Close the File. |
|
158 | + fclose($file_handle); |
|
159 | + return $csvarray; |
|
160 | + } else { |
|
161 | + EE_Error::add_error( |
|
162 | + sprintf(esc_html__("An error occurred - the file: %s could not opened.", "event_espresso"), $path_to_file), |
|
163 | + __FILE__, |
|
164 | + __FUNCTION__, |
|
165 | + __LINE__ |
|
166 | + ); |
|
167 | + return false; |
|
168 | + } |
|
169 | + } |
|
170 | + |
|
171 | + |
|
172 | + /** |
|
173 | + * Import contents of csv file and store values in an array to be manipulated by other functions |
|
174 | + * @param string $path_to_file - the csv file to be imported including the path to it's location. |
|
175 | + * If $model_name is provided, assumes that each row in the CSV represents a |
|
176 | + * model object for that model If $model_name ISN'T provided, assumes that |
|
177 | + * before model object data, there is a row where the first entry is simply |
|
178 | + * 'MODEL', and next entry is the model's name, (untranslated) like Event, and |
|
179 | + * then maybe a row of headers, and then the model data. Eg. |
|
180 | + * '<br>MODEL,Event,<br>EVT_ID,EVT_name,...<br>1,Monkey |
|
181 | + * Party,...<br>2,Llamarama,...<br>MODEL,Venue,<br>VNU_ID,VNU_name<br>1,The |
|
182 | + * Forest |
|
183 | + * @param string $model_name model name if we know what model we're importing |
|
184 | + * @param boolean $first_row_is_headers - whether the first row of data is headers or not - TRUE = headers, FALSE = |
|
185 | + * data |
|
186 | + * @return mixed - array on success - multi dimensional with headers as keys (if headers exist) OR string on fail - |
|
187 | + * error message like the following array('Event'=>array( array('EVT_ID'=>1,'EVT_name'=>'bob |
|
188 | + * party',...), array('EVT_ID'=>2,'EVT_name'=>'llamarama',...), |
|
189 | + * ... |
|
190 | + * ) |
|
191 | + * 'Venue'=>array( |
|
192 | + * array('VNU_ID'=>1,'VNU_name'=>'the shack',...), |
|
193 | + * array('VNU_ID'=>2,'VNU_name'=>'tree house',...), |
|
194 | + * ... |
|
195 | + * ) |
|
196 | + * ... |
|
197 | + * ) |
|
198 | + */ |
|
199 | + public function import_csv_to_model_data_array($path_to_file, $model_name = false, $first_row_is_headers = true) |
|
200 | + { |
|
201 | + $multi_dimensional_array = $this->import_csv_to_multi_dimensional_array($path_to_file); |
|
202 | + if (! $multi_dimensional_array) { |
|
203 | + return false; |
|
204 | + } |
|
205 | + // gotta start somewhere |
|
206 | + $row = 1; |
|
207 | + // array to store csv data in |
|
208 | + $ee_formatted_data = array(); |
|
209 | + // array to store headers (column names) |
|
210 | + $headers = array(); |
|
211 | + foreach ($multi_dimensional_array as $data) { |
|
212 | + // if first cell is MODEL, then second cell is the MODEL name |
|
213 | + if ($data[0] == 'MODEL') { |
|
214 | + $model_name = $data[1]; |
|
215 | + // don't bother looking for model data in this row. The rest of this |
|
216 | + // row should be blank |
|
217 | + // AND pretend this is the first row again |
|
218 | + $row = 1; |
|
219 | + // reset headers |
|
220 | + $headers = array(); |
|
221 | + continue; |
|
222 | + } |
|
223 | + if (strpos($data[0], EE_CSV::metadata_header) !== false) { |
|
224 | + $model_name = EE_CSV::metadata_header; |
|
225 | + // store like model data, we just won't try importing it etc. |
|
226 | + $row = 1; |
|
227 | + continue; |
|
228 | + } |
|
229 | + |
|
230 | + |
|
231 | + // how many columns are there? |
|
232 | + $columns = count($data); |
|
233 | + |
|
234 | + $model_entry = array(); |
|
235 | + // loop through each column |
|
236 | + for ($i = 0; $i < $columns; $i++) { |
|
237 | + // replace csv_enclosures with backslashed quotes |
|
238 | + $data[ $i ] = str_replace('"""', '\\"', $data[ $i ]); |
|
239 | + // do we need to grab the column names? |
|
240 | + if ($row === 1) { |
|
241 | + if ($first_row_is_headers) { |
|
242 | + // store the column names to use for keys |
|
243 | + $column_name = $data[ $i ]; |
|
244 | + // check it's not blank... sometimes CSV editign programs adda bunch of empty columns onto the end... |
|
245 | + if (! $column_name) { |
|
246 | + continue; |
|
247 | + } |
|
248 | + $matches = array(); |
|
249 | + if ($model_name == EE_CSV::metadata_header) { |
|
250 | + $headers[ $i ] = $column_name; |
|
251 | + } else { |
|
252 | + // now get the db table name from it (the part between square brackets) |
|
253 | + $success = preg_match('~(.*)\[(.*)\]~', $column_name, $matches); |
|
254 | + if (! $success) { |
|
255 | + EE_Error::add_error( |
|
256 | + sprintf( |
|
257 | + esc_html__( |
|
258 | + "The column titled %s is invalid for importing. It must be be in the format of 'Nice Name[model_field_name]' in row %s", |
|
259 | + "event_espresso" |
|
260 | + ), |
|
261 | + $column_name, |
|
262 | + implode(",", $data) |
|
263 | + ), |
|
264 | + __FILE__, |
|
265 | + __FUNCTION__, |
|
266 | + __LINE__ |
|
267 | + ); |
|
268 | + return false; |
|
269 | + } |
|
270 | + $headers[ $i ] = $matches[2]; |
|
271 | + } |
|
272 | + } else { |
|
273 | + // no column names means our final array will just use counters for keys |
|
274 | + $model_entry[ $headers[ $i ] ] = $data[ $i ]; |
|
275 | + $headers[ $i ] = $i; |
|
276 | + } |
|
277 | + // and we need to store csv data |
|
278 | + } else { |
|
279 | + // this column isn' ta header, store it if there is a header for it |
|
280 | + if (isset($headers[ $i ])) { |
|
281 | + $model_entry[ $headers[ $i ] ] = $data[ $i ]; |
|
282 | + } |
|
283 | + } |
|
284 | + } |
|
285 | + // save the row's data IF it's a non-header-row |
|
286 | + if (! $first_row_is_headers || ($first_row_is_headers && $row > 1)) { |
|
287 | + $ee_formatted_data[ $model_name ][] = $model_entry; |
|
288 | + } |
|
289 | + // advance to next row |
|
290 | + $row++; |
|
291 | + } |
|
292 | + |
|
293 | + // delete the uploaded file |
|
294 | + unlink($path_to_file); |
|
295 | + // echo '<pre style="height:auto;border:2px solid lightblue;">' . print_r( $ee_formatted_data, TRUE ) . '</pre><br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>'; |
|
296 | + // die(); |
|
297 | + |
|
298 | + // it's good to give back |
|
299 | + return $ee_formatted_data; |
|
300 | + } |
|
301 | + |
|
302 | + |
|
303 | + public function save_csv_to_db($csv_data_array, $model_name = false) |
|
304 | + { |
|
305 | + EE_Error::doing_it_wrong( |
|
306 | + 'save_csv_to_db', |
|
307 | + esc_html__( |
|
308 | + 'Function moved to EE_Import and renamed to save_csv_data_array_to_db', |
|
309 | + 'event_espresso' |
|
310 | + ), |
|
311 | + '4.6.7' |
|
312 | + ); |
|
313 | + return EE_Import::instance()->save_csv_data_array_to_db($csv_data_array, $model_name); |
|
314 | + } |
|
315 | + |
|
316 | + /** |
|
317 | + * Sends HTTP headers to indicate that the browser should download a file, |
|
318 | + * and starts writing the file to PHP's output. Returns the file handle so other functions can |
|
319 | + * also write to it |
|
320 | + * |
|
321 | + * @param string $new_filename the name of the file that the user will download |
|
322 | + * @return resource, like the results of fopen(), which can be used for fwrite, fputcsv2, etc. |
|
323 | + */ |
|
324 | + public function begin_sending_csv($filename) |
|
325 | + { |
|
326 | + // grab file extension |
|
327 | + $ext = substr(strrchr($filename, '.'), 1); |
|
328 | + if ($ext == '.csv' or $ext == '.xls') { |
|
329 | + str_replace($ext, '', $filename); |
|
330 | + } |
|
331 | + $filename .= '.csv'; |
|
332 | + |
|
333 | + // if somebody's been naughty and already started outputting stuff, trash it |
|
334 | + // and start writing our stuff. |
|
335 | + if (ob_get_length()) { |
|
336 | + @ob_flush(); |
|
337 | + @flush(); |
|
338 | + @ob_end_flush(); |
|
339 | + } |
|
340 | + @ob_start(); |
|
341 | + header("Pragma: public"); |
|
342 | + header("Expires: 0"); |
|
343 | + header("Pragma: no-cache"); |
|
344 | + header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0"); |
|
345 | + // header("Content-Type: application/force-download"); |
|
346 | + // header("Content-Type: application/octet-stream"); |
|
347 | + // header("Content-Type: application/download"); |
|
348 | + header('Content-disposition: attachment; filename=' . $filename); |
|
349 | + header("Content-Type: text/csv; charset=utf-8"); |
|
350 | + do_action('AHEE__EE_CSV__begin_sending_csv__headers'); |
|
351 | + echo apply_filters( |
|
352 | + 'FHEE__EE_CSV__begin_sending_csv__start_writing', |
|
353 | + "\xEF\xBB\xBF" |
|
354 | + ); // makes excel open it as UTF-8. UTF-8 BOM, see http://stackoverflow.com/a/4440143/2773835 |
|
355 | + $fh = fopen('php://output', 'w'); |
|
356 | + return $fh; |
|
357 | + } |
|
358 | + |
|
359 | + /** |
|
360 | + * Writes some meta data to the CSV as a bunch of columns. Initially we're only |
|
361 | + * mentioning the version and timezone |
|
362 | + * |
|
363 | + * @param resource $filehandle |
|
364 | + */ |
|
365 | + public function write_metadata_to_csv($filehandle) |
|
366 | + { |
|
367 | + $data_row = array(EE_CSV::metadata_header);// do NOT translate because this exact string is used when importing |
|
368 | + $this->fputcsv2($filehandle, $data_row); |
|
369 | + $meta_data = array( |
|
370 | + 0 => array( |
|
371 | + 'version' => espresso_version(), |
|
372 | + 'timezone' => EEH_DTT_Helper::get_timezone(), |
|
373 | + 'time_of_export' => current_time('mysql'), |
|
374 | + 'site_url' => site_url(), |
|
375 | + ), |
|
376 | + ); |
|
377 | + $this->write_data_array_to_csv($filehandle, $meta_data); |
|
378 | + } |
|
379 | + |
|
380 | + |
|
381 | + /** |
|
382 | + * Writes $data to the csv file open in $filehandle. uses the array indices of $data for column headers |
|
383 | + * |
|
384 | + * @param array $data 2D array, first numerically-indexed, and next-level-down preferably indexed |
|
385 | + * by string |
|
386 | + * @param boolean $add_csv_column_names whether or not we should add the keys in the bottom-most array as a row for |
|
387 | + * headers in the CSV. Eg, if $data looked like |
|
388 | + * array(0=>array('EVT_ID'=>1,'EVT_name'=>'monkey'...), 1=>array(...),...)) |
|
389 | + * then the first row we'd write to the CSV would be "EVT_ID,EVT_name,..." |
|
390 | + * @return boolean if we successfully wrote to the CSV or not. If there's no $data, we consider that a success |
|
391 | + * (because we wrote everything there was...nothing) |
|
392 | + */ |
|
393 | + public function write_data_array_to_csv($filehandle, $data) |
|
394 | + { |
|
395 | + |
|
396 | + |
|
397 | + // determine if $data is actually a 2d array |
|
398 | + if ($data && is_array($data) && is_array(EEH_Array::get_one_item_from_array($data))) { |
|
399 | + // make sure top level is numerically indexed, |
|
400 | + |
|
401 | + if (EEH_Array::is_associative_array($data)) { |
|
402 | + throw new EE_Error( |
|
403 | + sprintf( |
|
404 | + esc_html__( |
|
405 | + "top-level array must be numerically indexed. Does these look like numbers to you? %s", |
|
406 | + "event_espresso" |
|
407 | + ), |
|
408 | + implode(",", array_keys($data)) |
|
409 | + ) |
|
410 | + ); |
|
411 | + } |
|
412 | + $item_in_top_level_array = EEH_Array::get_one_item_from_array($data); |
|
413 | + // now, is the last item in the top-level array of $data an associative or numeric array? |
|
414 | + if (EEH_Array::is_associative_array($item_in_top_level_array)) { |
|
415 | + // its associative, so we want to output its keys as column headers |
|
416 | + $keys = array_keys($item_in_top_level_array); |
|
417 | + $this->fputcsv2($filehandle, $keys); |
|
418 | + } |
|
419 | + // start writing data |
|
420 | + foreach ($data as $data_row) { |
|
421 | + $this->fputcsv2($filehandle, $data_row); |
|
422 | + } |
|
423 | + return true; |
|
424 | + } else { |
|
425 | + // no data TO write... so we can assume that's a success |
|
426 | + return true; |
|
427 | + } |
|
428 | + // //if 2nd level is indexed by strings, use those as csv column headers (ie, the first row) |
|
429 | + // |
|
430 | + // |
|
431 | + // $no_table = TRUE; |
|
432 | + // |
|
433 | + // // loop through data and add each row to the file/stream as csv |
|
434 | + // foreach ( $data as $model_name => $model_data ) { |
|
435 | + // // test first row to see if it is data or a model name |
|
436 | + // $model = EE_Registry::instance();->load_model($model_name); |
|
437 | + // //if the model really exists, |
|
438 | + // if ( $model ) { |
|
439 | + // |
|
440 | + // // we have a table name |
|
441 | + // $no_table = FALSE; |
|
442 | + // |
|
443 | + // // put the tablename into an array cuz that's how fputcsv rolls |
|
444 | + // $model_name_row = array( 'MODEL', $model_name ); |
|
445 | + // |
|
446 | + // // add table name to csv output |
|
447 | + // echo self::fputcsv2($filehandle, $model_name_row); |
|
448 | + // |
|
449 | + // // now get the rest of the data |
|
450 | + // foreach ( $model_data as $row ) { |
|
451 | + // // output the row |
|
452 | + // echo self::fputcsv2($filehandle, $row); |
|
453 | + // } |
|
454 | + // |
|
455 | + // } |
|
456 | + // |
|
457 | + // if ( $no_table ) { |
|
458 | + // // no table so just put the data |
|
459 | + // echo self::fputcsv2($filehandle, $model_data); |
|
460 | + // } |
|
461 | + // |
|
462 | + // } // END OF foreach ( $data ) |
|
463 | + } |
|
464 | + |
|
465 | + /** |
|
466 | + * Should be called after begin_sending_csv(), and one or more write_data_array_to_csv()s. |
|
467 | + * Calls exit to prevent polluting the CSV file with other junk |
|
468 | + * |
|
469 | + * @param resource $fh filehandle where we're writing the CSV to |
|
470 | + */ |
|
471 | + public function end_sending_csv($fh) |
|
472 | + { |
|
473 | + fclose($fh); |
|
474 | + exit(0); |
|
475 | + } |
|
476 | + |
|
477 | + /** |
|
478 | + * Given an open file, writes all the model data to it in the format the importer expects. |
|
479 | + * Usually preceded by begin_sending_csv($filename), and followed by end_sending_csv($filehandle). |
|
480 | + * |
|
481 | + * @param resource $filehandle |
|
482 | + * @param array $model_data_array is assumed to be a 3d array: 1st layer has keys of model names (eg 'Event'), |
|
483 | + * next layer is numerically indexed to represent each model object (eg, each |
|
484 | + * individual event), and the last layer has all the attributes o fthat model |
|
485 | + * object (eg, the event's id, name, etc) |
|
486 | + * @return boolean success |
|
487 | + */ |
|
488 | + public function write_model_data_to_csv($filehandle, $model_data_array) |
|
489 | + { |
|
490 | + $this->write_metadata_to_csv($filehandle); |
|
491 | + foreach ($model_data_array as $model_name => $model_instance_arrays) { |
|
492 | + // first: output a special row stating the model |
|
493 | + $this->fputcsv2($filehandle, array('MODEL', $model_name)); |
|
494 | + // if we have items to put in the CSV, do it normally |
|
495 | + |
|
496 | + if (! empty($model_instance_arrays)) { |
|
497 | + $this->write_data_array_to_csv($filehandle, $model_instance_arrays); |
|
498 | + } else { |
|
499 | + // echo "no data to write... so just write the headers"; |
|
500 | + // so there's actually NO model objects for that model. |
|
501 | + // probably still want to show the columns |
|
502 | + $model = EE_Registry::instance()->load_model($model_name); |
|
503 | + $column_names = array(); |
|
504 | + foreach ($model->field_settings() as $field) { |
|
505 | + $column_names[ $field->get_nicename() . "[" . $field->get_name() . "]" ] = null; |
|
506 | + } |
|
507 | + $this->write_data_array_to_csv($filehandle, array($column_names)); |
|
508 | + } |
|
509 | + } |
|
510 | + } |
|
511 | + |
|
512 | + /** |
|
513 | + * Writes the CSV file to the output buffer, with rows corresponding to $model_data_array, |
|
514 | + * and dies (in order to avoid other plugins from messing up the csv output) |
|
515 | + * |
|
516 | + * @param string $filename the filename you want to give the file |
|
517 | + * @param array $model_data_array 3d array, as described in EE_CSV::write_model_data_to_csv() |
|
518 | + * @return bool | void writes CSV file to output and dies |
|
519 | + */ |
|
520 | + public function export_multiple_model_data_to_csv($filename, $model_data_array) |
|
521 | + { |
|
522 | + $filehandle = $this->begin_sending_csv($filename); |
|
523 | + $this->write_model_data_to_csv($filehandle, $model_data_array); |
|
524 | + $this->end_sending_csv($filehandle); |
|
525 | + } |
|
526 | + |
|
527 | + /** |
|
528 | + * Export contents of an array to csv file |
|
529 | + * @param array $data - the array of data to be converted to csv and exported |
|
530 | + * @param string $filename - name for newly created csv file |
|
531 | + * @return TRUE on success, FALSE on fail |
|
532 | + */ |
|
533 | + public function export_array_to_csv($data = false, $filename = false) |
|
534 | + { |
|
535 | + |
|
536 | + // no data file?? get outta here |
|
537 | + if (! $data or ! is_array($data) or empty($data)) { |
|
538 | + return false; |
|
539 | + } |
|
540 | + |
|
541 | + // no filename?? get outta here |
|
542 | + if (! $filename) { |
|
543 | + return false; |
|
544 | + } |
|
545 | + |
|
546 | + |
|
547 | + // somebody told me i might need this ??? |
|
548 | + global $wpdb; |
|
549 | + $prefix = $wpdb->prefix; |
|
550 | + |
|
551 | + |
|
552 | + $fh = $this->begin_sending_csv($filename); |
|
553 | + |
|
554 | + |
|
555 | + $this->end_sending_csv($fh); |
|
556 | + } |
|
557 | + |
|
558 | + |
|
559 | + /** |
|
560 | + * Determine the maximum upload file size based on php.ini settings |
|
561 | + * @param int $percent_of_max - desired percentage of the max upload_mb |
|
562 | + * @return int KB |
|
563 | + */ |
|
564 | + public function get_max_upload_size($percent_of_max = false) |
|
565 | + { |
|
566 | + |
|
567 | + $max_upload = (int) (ini_get('upload_max_filesize')); |
|
568 | + $max_post = (int) (ini_get('post_max_size')); |
|
569 | + $memory_limit = (int) (ini_get('memory_limit')); |
|
570 | + |
|
571 | + // determine the smallest of the three values from above |
|
572 | + $upload_mb = min($max_upload, $max_post, $memory_limit); |
|
573 | + |
|
574 | + // convert MB to KB |
|
575 | + $upload_mb = $upload_mb * 1024; |
|
576 | + |
|
577 | + // don't want the full monty? then reduce the max uplaod size |
|
578 | + if ($percent_of_max) { |
|
579 | + // is percent_of_max like this -> 50 or like this -> 0.50 ? |
|
580 | + if ($percent_of_max > 1) { |
|
581 | + // chnages 50 to 0.50 |
|
582 | + $percent_of_max = $percent_of_max / 100; |
|
583 | + } |
|
584 | + // make upload_mb a percentage of the max upload_mb |
|
585 | + $upload_mb = $upload_mb * $percent_of_max; |
|
586 | + } |
|
587 | + |
|
588 | + return $upload_mb; |
|
589 | + } |
|
590 | + |
|
591 | + |
|
592 | + /** |
|
593 | + * Drop in replacement for PHP's fputcsv function - but this one works!!! |
|
594 | + * @param resource $fh - file handle - what we are writing to |
|
595 | + * @param array $row - individual row of csv data |
|
596 | + * @param string $delimiter - csv delimiter |
|
597 | + * @param string $enclosure - csv enclosure |
|
598 | + * @param string $mysql_null - allows php NULL to be overridden with MySQl's insertable NULL value |
|
599 | + * @return void |
|
600 | + */ |
|
601 | + private function fputcsv2($fh, array $row, $delimiter = ',', $enclosure = '"', $mysql_null = false) |
|
602 | + { |
|
603 | + // Allow user to filter the csv delimiter and enclosure for other countries csv standards |
|
604 | + $delimiter = apply_filters('FHEE__EE_CSV__fputcsv2__delimiter', $delimiter); |
|
605 | + $enclosure = apply_filters('FHEE__EE_CSV__fputcsv2__enclosure', $enclosure); |
|
606 | + |
|
607 | + $delimiter_esc = preg_quote($delimiter, '/'); |
|
608 | + $enclosure_esc = preg_quote($enclosure, '/'); |
|
609 | + |
|
610 | + $output = array(); |
|
611 | + foreach ($row as $field_value) { |
|
612 | + if (is_object($field_value) || is_array($field_value)) { |
|
613 | + $field_value = serialize($field_value); |
|
614 | + } |
|
615 | + if ($field_value === null && $mysql_null) { |
|
616 | + $output[] = 'NULL'; |
|
617 | + continue; |
|
618 | + } |
|
619 | + |
|
620 | + $output[] = preg_match("/(?:${delimiter_esc}|${enclosure_esc}|\s)/", $field_value) ? |
|
621 | + ($enclosure . str_replace($enclosure, $enclosure . $enclosure, $field_value) . $enclosure) |
|
622 | + : $field_value; |
|
623 | + } |
|
624 | + |
|
625 | + fwrite($fh, join($delimiter, $output) . PHP_EOL); |
|
626 | + } |
|
627 | + |
|
628 | + |
|
629 | + // /** |
|
630 | + // * CSV Import / Export messages |
|
631 | + // * @return void |
|
632 | + // */ |
|
633 | + // public function csv_admin_notices() |
|
634 | + // { |
|
635 | + // |
|
636 | + // // We play both kinds of music here! Country AND Western! - err... I mean, cycle through both types of notices |
|
637 | + // foreach (array('updates', 'errors') as $type) { |
|
638 | + // |
|
639 | + // // if particular notice type is not empty, then "You've got Mail" |
|
640 | + // if (! empty($this->_notices[ $type ])) { |
|
641 | + // |
|
642 | + // // is it an update or an error ? |
|
643 | + // $msg_class = $type == 'updates' ? 'updated' : 'error'; |
|
644 | + // echo '<div id="message" class="' . $msg_class . '">'; |
|
645 | + // // display each notice, however many that may be |
|
646 | + // foreach ($this->_notices[ $type ] as $message) { |
|
647 | + // echo '<p>' . $message . '</p>'; |
|
648 | + // } |
|
649 | + // // wrap it up |
|
650 | + // echo '</div>'; |
|
651 | + // } |
|
652 | + // } |
|
653 | + // } |
|
654 | + |
|
655 | + /** |
|
656 | + * Gets the date format to use in teh csv. filterable |
|
657 | + * |
|
658 | + * @param string $current_format |
|
659 | + * @return string |
|
660 | + */ |
|
661 | + public function get_date_format_for_csv($current_format = null) |
|
662 | + { |
|
663 | + return apply_filters('FHEE__EE_CSV__get_date_format_for_csv__format', 'Y-m-d', $current_format); |
|
664 | + } |
|
665 | + |
|
666 | + /** |
|
667 | + * Gets the time format we want to use in CSV reports. Filterable |
|
668 | + * |
|
669 | + * @param string $current_format |
|
670 | + * @return string |
|
671 | + */ |
|
672 | + public function get_time_format_for_csv($current_format = null) |
|
673 | + { |
|
674 | + return apply_filters('FHEE__EE_CSV__get_time_format_for_csv__format', 'H:i:s', $current_format); |
|
675 | + } |
|
676 | 676 | } |