/
Events.php
310 lines (283 loc) · 10.1 KB
/
Events.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
<?php
/**
* Copyright 2006 - 2015 TubePress LLC (http://tubepress.com)
*
* This file is part of TubePress (http://tubepress.com)
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/**
* @api
* @since 4.0.0
*/
interface tubepress_app_api_event_Events
{
/**
* This event is fired after TubePress builds the gallery initialization JSON, which is inserted immediately
* after each gallery as it appears in the HTML.
*
* @subject `array` An associative `array` that will be converted into JSON and applied as
* init code for the gallery in JavaScript.
*
* @argument <var>mediaPage</var> (`{@link tubepress_app_api_media_MediaPage}`): The backing {@link tubepress_app_api_media_MediaPage}.
* @argument <var>pageNumber</var> (`integer`): The page number.
*
* @api
* @since 4.0.0
*/
const GALLERY_INIT_JS = 'tubepress.app.gallery.initJs';
/**
* This event is fired when TubePress encounters an error during processing and is
* about to return an error message to the screen.
*
* @subject `Exception` A PHP exception containing the caught error message.
*
* @api
* @since 4.0.0
*/
const HTML_EXCEPTION_CAUGHT = 'tubepress.app.html.exception.caught';
/**
* This event is fired when TubePress builds the global `TubePressJsConfig` JavaScript object.
*
* @subject `array` An associative `array` that will be converted into JSON and applied as global JS configuration
* for TubePress.
*
* @api
* @since 4.0.0
*/
const HTML_GLOBAL_JS_CONFIG = 'tubepress.app.html.globalJsConfig';
/**
* This event is fired when TubePress generates its "primary" HTML (e.g. a media gallery,
* search input widget, embedded media player, etc).
*
* @subject `string` Initially null, listeners are expected to populate the subject with HTML.
*
* @api
* @since 4.0.0
*/
const HTML_GENERATION = 'tubepress.app.html.generation';
/**
* This event is fired after TubePress generates its "primary" HTML (e.g. a media gallery,
* search input widget, embedded media player, etc).
*
* @subject `string` The HTML that will be returned to the user.
*
* @api
* @since 4.1.10
*/
const HTML_GENERATION_POST = 'tubepress.app.html.generation.post';
/**
* This event is fired immediately after TubePress assembles its list of scripts to print.
*
* @subject `tubepress_platform_api_url_UrlInterface[]` An array of URLs for the scripts that TubePress will print in the HTML <head>
* or near the closing </body> tag.
*
* @api
* @since 4.0.0
*/
const HTML_SCRIPTS = 'tubepress.app.html.scripts';
/**
* This event is fired immediately after TubePress assembles its list of stylesheets to print.
*
* @subject `tubepress_platform_api_url_UrlInterface[]` An array of URLs for the stylesheets that TubePress will print in the HTML <head>
*
* @api
* @since 4.0.0
*/
const HTML_STYLESHEETS = 'tubepress.app.html.stylesheets';
/**
* This event is fired immediately after TubePress assembles its list of scripts to print in the options GUI.
*
* @subject `tubepress_platform_api_url_UrlInterface[]` An array of URLs for the scripts that TubePress will print in the HTML <head>
* or near the closing </body> tag.
*
* @api
* @since 4.0.0
*/
const HTML_SCRIPTS_ADMIN = 'tubepress.app.html.scripts.admin';
/**
* This event is fired immediately after TubePress assembles its list of stylesheets to print in the options GUI.
*
* @subject `tubepress_platform_api_url_UrlInterface[]` An array of URLs for the stylesheets that TubePress will print in the HTML <head>
*
* @api
* @since 4.0.0
*/
const HTML_STYLESHEETS_ADMIN = 'tubepress.app.html.stylesheets.admin';
/**
* @api
* @since 4.0.0
*/
const HTTP_AJAX = 'tubepress.app.http.ajax';
/**
* Fired when an HTTP-based media provider constructs a new item.
*
* @subject `tubepress_app_api_media_MediaItem` The media item being constructed.
*
* @arguments Varies based on the provider.
*
* @api
* @since 4.0.0
*/
const MEDIA_ITEM_HTTP_NEW = 'tubepress.app.media.item.http.new';
/**
* This event is fired when TubePress constructs the URL for a single media item.
*
* @subject {@tubepress_platform_api_url_UrlInterface} The URL for the media item.
*
* @argument <var>itemId</var> (`string`) The item ID.
*/
const MEDIA_ITEM_HTTP_URL = 'tubepress.app.media.item.http.url';
/**
* This event is fired when a TubePress collects a new media item.
*
* @subject {@link tubepress_app_api_media_MediaItem} The media item.
*
* @api
* @since 4.0.0
*/
const MEDIA_ITEM_NEW = 'tubepress.app.media.item.new';
/**
* This event is fired when TubePress receives a request to fetch a media item
* from a provider.
*
* @subject `string` The media item ID.
*
* @api
* @since 4.0.0
*/
const MEDIA_ITEM_REQUEST = 'tubepress.app.media.item.request';
/**
* This event is fired when TubePress constructs the URL for a media page.
*
* @subject {@tubepress_platform_api_url_UrlInterface} The URL for the media page.
*
* @argument <var>pageNumber</var> (`int`) The page number.
*/
const MEDIA_PAGE_HTTP_NEW = 'tubepress.app.media.page.http.new';
/**
* This event is fired when TubePress constructs the URL for a media page.
*
* @subject {@tubepress_platform_api_url_UrlInterface} The URL for the media page.
*
* @argument <var>pageNumber</var> (`int`) The page number.
*/
const MEDIA_PAGE_HTTP_URL = 'tubepress.app.media.page.http.url';
/**
* This event is fired when a TubePress collects a new tubepress_app_api_media_MediaPage.
*
* @subject {@tubepress_app_api_media_MediaPage} The page being built.
*
* @argument <var>pageNumber</var> (`int`) The page number of this page.
*
* @api
* @since 4.0.0
*/
const MEDIA_PAGE_NEW = 'tubepress.app.media.page.new';
/**
* This event is fired when TubePress receives a request to fetch a new page of media
* items from a provider.
*
* @subject `string` The current value of the "mode" option.
*
* @argument <var>pageNumber</var> (`int`) The page number.
*
* @api
* @since 4.0.0
*/
const MEDIA_PAGE_REQUEST = 'tubepress.app.media.page.request';
/**
* This event is fired when a name-value pair is being read from external input.
*
* @subject `mixed` The incoming value.
*
* @argument <var>optionName</var> (`string`): The incoming name.
*
* @api
* @since 4.0.0
*/
const NVP_FROM_EXTERNAL_INPUT = 'tubepress.app.nvp.fromExternalInput';
/**
* This event is fired when TubePress looks the acceptable values for an option. This
* only applies to options that take on discrete values.
*
* @subject `array`|`null` Initially null, the acceptable values for this option. This *may* be an associative array
* where the keys are values and the values are untranslated labels. You can use
* {@link tubepress_platform_impl_util_LangUtils::isAssociativeArray()} to check the type of array.
*
* @argument <var>optionName</var> (`string`): The name of the option.
*
* @api
* @since 4.0.0
*/
const OPTION_ACCEPTABLE_VALUES = 'tubepress.app.option.acceptableValues';
/**
* This event is fired when TubePress looks up the default value for a specific option. Typically
* this only happens the first time TubePress is used on a system, but may also fire
* after an upgrade.
*
* @subject `mixed` The default value of an option. May be null.
*
* @argument <var>optionName</var> (`string`): The name of the option.
*
* @api
* @since 4.0.0
*/
const OPTION_DEFAULT_VALUE = 'tubepress.app.option.defaultValue';
/**
* This event is fired when TubePress looks up the description for a specific option.
*
* @subject `string` The untranslated (i.e. in English) option description.
*
* @argument <var>optionName</var> (`string`): The name of the option.
*
* @api
* @since 4.0.0
*/
const OPTION_DESCRIPTION = 'tubepress.app.option.description';
/**
* This event is fired when TubePress looks up the label for a specific option.
*
* @subject `string` The untranslated (i.e. in English) option label.
*
* @argument <var>optionName</var> (`string`): The name of the option.
*
* @api
* @since 4.0.0
*/
const OPTION_LABEL = 'tubepress.app.option.label';
/**
* This event is fired when any TubePress option (a name-value pair) is being set.
*
* @subject `string[]` The errors found for this option's value. Initially empty, listeners may add
* to the array.
*
* @argument <var>optionName</var> (`string`): The name of the option being set.
* @argument <var>optionValue</var> (`mixed`): The value of the option being set.
*
* @api
* @since 4.0.0
*/
const OPTION_SET = 'tubepress.app.option.set';
/**
* @api
* @since 4.0.0
*/
const TEMPLATE_SELECT = 'tubepress.app.template.select';
/**
* @api
* @since 4.0.0
*/
const TEMPLATE_PRE_RENDER = 'tubepress.app.template.pre';
/**
* This event is fired after TubePress renders a template.
*
* @subject `string` The result of the template render.
*
* @api
* @since 4.0.0
*/
const TEMPLATE_POST_RENDER = 'tubepress.app.template.post';
}