Completed
Branch BUG-10738-inconsistency-in-ses... (8f6fbc)
by
unknown
74:03 queued 63:31
created

eventEditorTicketQuantityFieldSelector()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Page;
4
5
6
/**
7
 * EventsAdmin
8
 * Selectors/references for elements in the Events Admin pages
9
 *
10
 * @package Page
11
 * @author  Darren Ethier
12
 * @since   1.0.0
13
 */
14
class EventsAdmin extends CoreAdmin
15
{
16
17
    /**
18
     * Selector for the Add new Event button in the admin.
19
     * @var string
20
     */
21
    const ADD_NEW_EVENT_BUTTON_SELECTOR = '#add-new-event';
22
23
24
    /**
25
     * Selector for the Event Title field in the event editor
26
     * @var string
27
     */
28
    const EVENT_EDITOR_TITLE_FIELD_SELECTOR = "//input[@id='title']";
29
30
    /**
31
     * Selector for the publish submit button in the event editor.
32
     * @var string
33
     */
34
    const EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR = "#publish";
35
36
37
    /**
38
     * Selector for the save button in the event editor
39
     */
40
    const EVENT_EDITOR_SAVE_BUTTON_SELECTOR = "#save-post";
41
42
43
    /**
44
     * @var string
45
     */
46
    const EVENT_EDITOR_DEFAULT_REGISTRATION_STATUS_FIELD_SELECTOR = '#EVT_default_registration_status';
47
48
    /**
49
     * Selector for the view link after publishing an event.
50
     * @var string
51
     */
52
    const EVENT_EDITOR_VIEW_LINK_AFTER_PUBLISH_SELECTOR = "//span[@id='sample-permalink']/a";
53
54
55
    /**
56
     * Selector for the ID of the event in the event editor
57
     * @var string
58
     */
59
    const EVENT_EDITOR_EVT_ID_SELECTOR = "//input[@id='post_ID']";
60
61
62
    /**
63
     * Selector for the search input on the event list table page.
64
     * @var string
65
     */
66
    const EVENT_LIST_TABLE_SEARCH_INPUT_SELECTOR = '#toplevel_page_espresso_events-search-input';
67
68
69
70
71
    /**
72
     * @param string $additional_params
73
     * @return string
74
     */
75
    public static function defaultEventsListTableUrl($additional_params = '')
76
    {
77
        return self::adminUrl('espresso_events', 'default', $additional_params);
78
    }
79
80
81
    /**
82
     * The selector for the DTTname field for the given row in the event editor.
83
     * @param int $row_number
84
     * @return string
85
     */
86
    public static function eventEditorDatetimeNameFieldSelector($row_number = 1)
87
    {
88
        return self::eventEditorDatetimeFieldSelectorForField('DTT_name', $row_number);
89
    }
90
91
92
    /**
93
     * The selector for the DTT_EVT_start field for the given row in the event editor.d
94
     * @param int $row_number
95
     * @return string
96
     */
97
    public static function eventEditorDatetimeStartDateFieldSelector($row_number = 1)
98
    {
99
        return self::eventEditorDatetimeFieldSelectorForField('DTT_EVT_start', $row_number);
100
    }
101
102
103
    /**
104
     * Wrapper for getting the selector for a given field and given row of a datetime in the event editor.
105
     *
106
     * @param string $field_name
107
     * @param int    $row_number
108
     * @return string
109
     */
110
    public static function eventEditorDatetimeFieldSelectorForField($field_name, $row_number = 1)
111
    {
112
        return "//input[@id='event-datetime-$field_name-$row_number']";
113
    }
114
115
116
    /**
117
     * The selector for the TKT_name field for the given display row in the event editor.
118
     * @param int $row_number
119
     * @return string
120
     */
121
    public static function eventEditorTicketNameFieldSelector($row_number = 1)
122
    {
123
        return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_name', $row_number);
124
    }
125
126
127
    /**
128
     * Selector for the TKT_base_price field for the given display row in the event editor.
129
     * @param int $row_number
130
     * @return string
131
     */
132
    public static function eventEditorTicketPriceFieldSelector($row_number = 1)
133
    {
134
        return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_base_price', $row_number);
135
    }
136
137
138
    /**
139
     * Selector for the TKT_qty field for the given display row in the event editor.
140
     * @param int $row_number
141
     * @return string
142
     */
143
    public static function eventEditorTicketQuantityFieldSelector($row_number = 1)
144
    {
145
        return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_qty', $row_number);
146
    }
147
148
149
    /**
150
     * Selector for the advanced details toggle for the ticket for the given display row in the event editor.
151
     * @param int $row_number
152
     * @return string
153
     */
154
    public static function eventEditorTicketAdvancedDetailsSelector($row_number = 1)
155
    {
156
        return "//tr[@id='display-ticketrow-$row_number']//span[contains(@class, 'gear-icon')]";
157
    }
158
159
160
    /**
161
     * Selector for the subtotal amount for the given display row of the ticket in the event editor.
162
     * @param int $row_number
163
     * @return string
164
     */
165
    public static function eventEditorTicketAdvancedDetailsSubtotalSelector($row_number = 1)
166
    {
167
        return "//span[@id='price-total-amount-$row_number']";
168
    }
169
170
171
    /**
172
     * Selector for the Total element for the given display row of the ticket in the event editor.
173
     * @param int $row_number
174
     * @return string
175
     */
176
    public static function eventEditorTicketAdvancedDetailsTotalSelector($row_number = 1)
177
    {
178
        return "//span[@id='price-total-amount-$row_number']";
179
    }
180
181
182
    /**
183
     * Selector for the taxable selector for the ticket for the given display row in the event editor.
184
     * @param int $row_number
185
     * @return string
186
     */
187
    public static function eventEditorTicketTaxableCheckboxSelector($row_number = 1)
188
    {
189
        return "//input[@id='edit-ticket-TKT_taxable-$row_number']";
190
    }
191
192
193
    /**
194
     * This returns the xpath locater for the Tax amount display container within the advanced settings view for the
195
     * given ticket (row) and the given tax id (PRC_ID).
196
     *
197
     * @param int $tax_id     The PRC_ID for the tax you want the locater for.  Note, this defaults to the default tax
198
     *                        setup on a fresh install.
199
     * @param int $row_number What row representing the ticket you want the locator for.
200
     * @return string
201
     */
202
    public static function eventEditorTicketTaxAmountDisplayForTaxIdAndTicketRowSelector($tax_id = 2, $row_number = 1)
203
    {
204
        return "//span[@id='TKT-tax-amount-display-$tax_id-$row_number']";
205
    }
206
207
208
    /**
209
     * Wrapper for getting the selector for a given field and given display row of a ticket in the event editor.
210
     * @param     $field_name
211
     * @param int $row_number
212
     * @return string
213
     */
214
    public static function eventEditorTicketFieldSelectorForFieldInDisplayRow($field_name, $row_number = 1)
215
    {
216
        return "//tr[@id='display-ticketrow-$row_number']//input[contains(@class, 'edit-ticket-$field_name')]";
217
    }
218
219
220
    /**
221
     * Returns the selector for the event title edit link in the events list table for the given Event Title.
222
     * @param string $event_title
223
     * @return string
224
     */
225
    public static function eventListTableEventTitleEditLinkSelectorForTitle($event_title)
226
    {
227
        return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']";
228
    }
229
230
231
    /**
232
     * Locator for for the ID column in the event list table for a given event title.
233
     * @param string $event_title
234
     * @return string
235
     */
236
    public static function eventListTableEventIdSelectorForTitle($event_title)
237
    {
238
        return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']"
239
               . "//ancestor::tr/th[contains(@class, 'check-column')]/input";
240
    }
241
242
243
    /**
244
     * Locator for the view link in the row of an event list table for the given event title.
245
     * @param string $event_title
246
     * @return string
247
     */
248
    public static function eventListTableEventTitleViewLinkSelectorForTitle($event_title)
249
    {
250
        return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']"
251
               . "//ancestor::td//span[@class='view']/a";
252
    }
253
254
255
    /**
256
     * Locator for the messenger tab in the Notifications metabox in the event editor.
257
     * @param string $messenger_slug  The slug for the messenger (it's reference slug).
258
     * @return string
259
     */
260
    public static function eventEditorNotificationsMetaBoxMessengerTabSelector($messenger_slug)
261
    {
262
        return "//div[@id='espresso_events_Messages_Hooks_Extend_messages_metabox_metabox']"
263
               . "//a[@rel='ee-tab-$messenger_slug']";
264
    }
265
266
267
    /**
268
     * Locator for the select input within the notifications metabox.
269
     * Note, this assumes the tab content for the related messenger is already visible.
270
     * @param string $message_type_label The message type label (visible string in the table) you want the selector for.
271
     * @return string
272
     */
273
    public static function eventEditorNotificationsMetaBoxSelectSelectorForMessageType($message_type_label)
274
    {
275
        return "//div[@id='espresso_events_Messages_Hooks_Extend_messages_metabox_metabox']"
276
               . "//table[@class='messages-custom-template-switcher']"
277
               . "//tr/td[contains(.,'Registration Approved')]"
278
               . "//ancestor::tr//select[contains(@class,'message-template-selector')]";
279
    }
280
}
281