1
|
|
|
<?php |
2
|
|
|
namespace EventEspresso\modules\ticket_selector; |
3
|
|
|
|
4
|
|
|
defined('ABSPATH') || exit; |
5
|
|
|
|
6
|
|
|
|
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Class TicketDetails |
10
|
|
|
* class for loading template and resolving template args for the ticket details template |
11
|
|
|
* |
12
|
|
|
* @package Event Espresso |
13
|
|
|
* @author Brent Christensen |
14
|
|
|
* @since $VID:$ |
15
|
|
|
*/ |
16
|
|
|
class TicketDetails |
17
|
|
|
{ |
18
|
|
|
|
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var \EE_Ticket $ticket |
22
|
|
|
*/ |
23
|
|
|
protected $ticket; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var \EE_Ticket_Selector_Config $template_settings |
27
|
|
|
*/ |
28
|
|
|
protected $template_settings; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var string $date_format |
32
|
|
|
*/ |
33
|
|
|
protected $date_format; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var string $time_format |
37
|
|
|
*/ |
38
|
|
|
protected $time_format; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var boolean $event_is_expired |
42
|
|
|
*/ |
43
|
|
|
protected $event_is_expired; |
44
|
|
|
|
45
|
|
|
|
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* TicketDetails constructor. |
49
|
|
|
* |
50
|
|
|
* @param \EE_Ticket $ticket |
51
|
|
|
* @param \EE_Ticket_Selector_Config $template_settings |
52
|
|
|
* @param array $template_args |
53
|
|
|
*/ |
54
|
|
|
public function __construct( |
55
|
|
|
\EE_Ticket $ticket, |
56
|
|
|
\EE_Ticket_Selector_Config $template_settings, |
57
|
|
|
array $template_args |
58
|
|
|
) |
59
|
|
|
{ |
60
|
|
|
$this->ticket = $ticket; |
61
|
|
|
$this->template_settings = $template_settings; |
62
|
|
|
$this->date_format = $template_args['date_format']; |
63
|
|
|
$this->time_format = $template_args['time_format']; |
64
|
|
|
$this->event_is_expired = $template_args['event_is_expired']; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
|
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @return \EE_Ticket |
71
|
|
|
*/ |
72
|
|
|
public function getTicket() |
73
|
|
|
{ |
74
|
|
|
return $this->ticket; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
|
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @return bool |
81
|
|
|
*/ |
82
|
|
|
public function showTicketDetails() |
83
|
|
|
{ |
84
|
|
|
return $this->template_settings->show_ticket_details; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
|
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @return \EE_Ticket_Selector_Config |
91
|
|
|
*/ |
92
|
|
|
public function getTemplateSettings() |
93
|
|
|
{ |
94
|
|
|
return $this->template_settings; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
|
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @return string |
101
|
|
|
*/ |
102
|
|
|
public function getDateFormat() |
103
|
|
|
{ |
104
|
|
|
return $this->date_format; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
|
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @return string |
111
|
|
|
*/ |
112
|
|
|
public function getTimeFormat() |
113
|
|
|
{ |
114
|
|
|
return $this->time_format; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
|
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @return string |
121
|
|
|
*/ |
122
|
|
|
public function getShowHideLinks() |
123
|
|
|
{ |
124
|
|
|
if ( ! $this->showTicketDetails()) { |
125
|
|
|
return ''; |
126
|
|
|
} |
127
|
|
|
return \EEH_HTML::link( |
128
|
|
|
'', |
129
|
|
|
sprintf(__('show%1$sdetails%1$s+', 'event_espresso'), ' '), |
130
|
|
|
esc_attr( |
131
|
|
|
apply_filters( |
132
|
|
|
'FHEE__ticket_selector_chart_template__show_ticket_details_link_title', |
133
|
|
|
__('click to show additional ticket details', 'event_espresso') |
134
|
|
|
) |
135
|
|
|
), |
136
|
|
|
"display-{$this->cssId()}", |
137
|
|
|
'display-tckt-slctr-tkt-details display-the-hidden lt-grey-text smaller-text hide-if-no-js', |
138
|
|
|
'', |
139
|
|
|
'rel="' . $this->cssId() . '"' |
140
|
|
|
) . \EEH_HTML::link( |
141
|
|
|
'', |
142
|
|
|
sprintf(__('hide%1$sdetails%1$s-', 'event_espresso'), ' '), |
143
|
|
|
esc_attr( |
144
|
|
|
apply_filters( |
145
|
|
|
'FHEE__ticket_selector_chart_template__hide_ticket_details_link_title', |
146
|
|
|
__('click to hide additional ticket details', 'event_espresso') |
147
|
|
|
) |
148
|
|
|
), |
149
|
|
|
"hide-{$this->cssId()}", |
150
|
|
|
'hide-tckt-slctr-tkt-details hide-the-displayed lt-grey-text smaller-text hide-if-no-js', |
151
|
|
|
'display:none;', |
152
|
|
|
'rel="' . $this->cssId() . '"' |
153
|
|
|
); |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
|
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* @return string |
160
|
|
|
*/ |
161
|
|
|
public function cssId() |
162
|
|
|
{ |
163
|
|
|
return apply_filters( |
164
|
|
|
'FHEE__ticket_selector_chart_template__ticket_details_css_id', |
165
|
|
|
"tckt-slctr-tkt-details-{$this->ticket->get_event_ID()}-{$this->ticket->ID()}" |
166
|
|
|
); |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
|
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* @param float $ticket_price |
173
|
|
|
* @param int $remaining |
174
|
|
|
* @param int $cols |
175
|
|
|
* @return string |
176
|
|
|
*/ |
177
|
|
|
public function display( |
178
|
|
|
$ticket_price = 0.00, |
179
|
|
|
$remaining, |
180
|
|
|
$cols = 2 |
181
|
|
|
) { |
182
|
|
|
$template_args = array(); |
183
|
|
|
$template_args['ticket'] = $this->ticket; |
184
|
|
|
$template_args['ticket_price'] = $ticket_price; |
185
|
|
|
$template_args['remaining'] = $remaining; |
186
|
|
|
$template_args['cols'] = $cols; |
187
|
|
|
$template_args['show_ticket_details'] = $this->template_settings->show_ticket_details; |
188
|
|
|
$template_args['show_ticket_sale_columns'] = $this->template_settings->show_ticket_sale_columns; |
189
|
|
|
$template_args['ticket_details_row_class'] = espresso_get_object_css_class($this->ticket, '', 'details'); |
190
|
|
|
$template_args['ticket_details_css_id'] = $this->cssId(); |
191
|
|
|
$template_args['display_ticket_price'] = $ticket_price !== 0 && apply_filters( |
192
|
|
|
'FHEE__ticket_selector_chart_template__display_ticket_price_details', |
193
|
|
|
true |
194
|
|
|
); |
195
|
|
|
$template_args['price_breakdown_heading'] = apply_filters( |
196
|
|
|
'FHEE__ticket_selector_chart_template__ticket_details_price_breakdown_heading', |
197
|
|
|
esc_html__('Price', 'event_espresso') |
198
|
|
|
); |
199
|
|
|
$template_args['date_format'] = $this->date_format; |
200
|
|
|
$template_args['time_format'] = $this->time_format; |
201
|
|
|
$template_args['event_is_expired'] = $this->event_is_expired; |
202
|
|
|
|
203
|
|
|
return \EEH_Template::locate_template( |
204
|
|
|
apply_filters( |
205
|
|
|
'FHEE__EventEspresso_modules_ticket_selector_TicketDetails__display__template_path', |
206
|
|
|
TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_details.template.php', |
207
|
|
|
$this->ticket |
208
|
|
|
), |
209
|
|
|
$template_args |
210
|
|
|
); |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
} |
214
|
|
|
// End of file TicketDetails.php |
215
|
|
|
// Location: EventEspresso\modules\ticket_selector/TicketDetails.php |