1
|
|
|
<?php |
2
|
|
|
namespace EventEspresso\modules\ticket_selector; |
3
|
|
|
|
4
|
|
|
defined('ABSPATH') || exit; |
5
|
|
|
|
6
|
|
|
|
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Class TicketSelector |
10
|
|
|
* Description |
11
|
|
|
* |
12
|
|
|
* @package Event Espresso |
13
|
|
|
* @author Brent Christensen |
14
|
|
|
* @since $VID:$ |
15
|
|
|
*/ |
16
|
|
|
abstract class TicketSelector |
17
|
|
|
{ |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @var \EE_Event $event |
21
|
|
|
*/ |
22
|
|
|
protected $event; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var \EE_Ticket[] $tickets |
26
|
|
|
*/ |
27
|
|
|
protected $tickets; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var int max_attendees |
31
|
|
|
*/ |
32
|
|
|
protected $max_attendees; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var array $template_args |
36
|
|
|
*/ |
37
|
|
|
protected $template_args; |
38
|
|
|
|
39
|
|
|
|
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* TicketSelectorSimple constructor. |
43
|
|
|
* |
44
|
|
|
* @param \EE_Event $event |
45
|
|
|
* @param \EE_Ticket[] $tickets |
46
|
|
|
* @param int $max_attendees |
47
|
|
|
* @param array $template_args |
48
|
|
|
* @throws \EE_Error |
49
|
|
|
*/ |
50
|
|
|
public function __construct(\EE_Event $event, array $tickets, $max_attendees, array $template_args) |
51
|
|
|
{ |
52
|
|
|
$this->event = $event; |
53
|
|
|
$this->tickets = $tickets; |
54
|
|
|
$this->max_attendees = $max_attendees; |
55
|
|
|
$this->template_args = $template_args; |
56
|
|
|
$this->template_args['hidden_inputs'] = $this->getHiddenInputs(); |
57
|
|
|
$this->addTemplateArgs(); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
|
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* sets any and all template args that are required for this Ticket Selector |
64
|
|
|
* |
65
|
|
|
* @return void |
66
|
|
|
*/ |
67
|
|
|
abstract protected function addTemplateArgs(); |
68
|
|
|
|
69
|
|
|
|
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* loadTicketSelectorTemplate |
73
|
|
|
* |
74
|
|
|
* @return string |
75
|
|
|
*/ |
76
|
|
|
protected function loadTicketSelectorTemplate() |
77
|
|
|
{ |
78
|
|
|
try { |
79
|
|
|
return \EEH_Template::locate_template( |
80
|
|
|
apply_filters( |
81
|
|
|
'FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', |
82
|
|
|
$this->template_args['template_path'], |
83
|
|
|
$this->event |
84
|
|
|
), |
85
|
|
|
$this->template_args |
86
|
|
|
); |
87
|
|
|
} catch (\Exception $e) { |
88
|
|
|
\EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
89
|
|
|
} |
90
|
|
|
return ''; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
|
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* The __toString method allows a class to decide how it will react when it is converted to a string. |
97
|
|
|
* |
98
|
|
|
* @return string |
99
|
|
|
* @link http://php.net/manual/en/language.oop5.magic.php#language.oop5.magic.tostring |
100
|
|
|
*/ |
101
|
|
|
public function __toString() |
102
|
|
|
{ |
103
|
|
|
return $this->loadTicketSelectorTemplate(); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
|
107
|
|
|
|
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* getHiddenInputs |
111
|
|
|
* |
112
|
|
|
* @return string |
113
|
|
|
* @throws \EE_Error |
114
|
|
|
*/ |
115
|
|
|
public function getHiddenInputs() |
116
|
|
|
{ |
117
|
|
|
// $rows = count($this->tickets); |
118
|
|
|
$html = '<input type="hidden" name="noheader" value="true"/>'; |
119
|
|
|
$html .= '<input type="hidden" name="tkt-slctr-return-url-' . $this->event->ID() . '"'; |
120
|
|
|
$html .= ' value="' . \EEH_URL::current_url() . $this->template_args['anchor_id'] . '"/>'; |
121
|
|
|
$html .= '<input type="hidden" name="tkt-slctr-rows-' . $this->event->ID(); |
122
|
|
|
$html .= '" value="' . count($this->tickets) . '"/>'; |
123
|
|
|
$html .= '<input type="hidden" name="tkt-slctr-max-atndz-' . $this->event->ID(); |
124
|
|
|
$html .= '" value="' . $this->template_args['max_atndz'] . '"/>'; |
125
|
|
|
$html .= '<input type="hidden" name="tkt-slctr-event-id" value="' . $this->event->ID() . '"/>'; |
126
|
|
|
return $html; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
} |
130
|
|
|
// End of file TicketSelector.php |
131
|
|
|
// Location: EventEspresso\modules\ticket_selector/TicketSelector.php |