1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace CMSFactory; |
4
|
|
|
|
5
|
|
|
use Closure; |
6
|
|
|
use Exception; |
|
|
|
|
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* @abstract |
10
|
|
|
* @version CMS Event system v.1 Beta |
11
|
|
|
*/ |
12
|
|
|
abstract class BaseEvents |
13
|
|
|
{ |
|
|
|
|
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @var array |
17
|
|
|
*/ |
18
|
|
|
public $holder = []; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var string |
22
|
|
|
*/ |
23
|
|
|
public $key; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var array |
27
|
|
|
*/ |
28
|
|
|
protected $storage = []; |
29
|
|
|
|
30
|
|
|
final public function ShopAdminPropertiesCreate() { |
31
|
|
|
|
32
|
|
|
$this->key = 'ShopAdminProperties:create'; |
33
|
|
|
return $this; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
final public function ShopAdminPropertiesFastCreate() { |
37
|
|
|
|
38
|
|
|
$this->key = 'ShopAdminProperties:fastCreate'; |
39
|
|
|
return $this; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
final public function ShopAdminPropertiesPreCreate() { |
43
|
|
|
|
44
|
|
|
$this->key = 'ShopAdminProperties:preCreate'; |
45
|
|
|
return $this; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
final public function ShopAdminPropertiesPreFastCreate() { |
49
|
|
|
|
50
|
|
|
$this->key = 'ShopAdminProperties:preFastCreate'; |
51
|
|
|
return $this; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
final public function onShopPropertiesDelete() { |
55
|
|
|
|
56
|
|
|
$this->key = 'ShopAdminProperties::delete'; |
57
|
|
|
return $this; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
final public function onShopPropertiesEdit() { |
61
|
|
|
|
62
|
|
|
$this->key = 'ShopAdminProperties:edit'; |
63
|
|
|
return $this; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function get() { |
67
|
|
|
|
68
|
|
|
//var_dumps($this->storage); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @param string $key |
73
|
|
|
* @return $this |
74
|
|
|
*/ |
75
|
|
|
final public function on($key) { |
76
|
|
|
|
77
|
|
|
$this->key = $key; |
78
|
|
|
return $this; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* <p>The possible returned elements from <b>setListener</b> are as follows:</p> |
83
|
|
|
* <table> |
84
|
|
|
* <tr valign="top"><td>['commentId']</td><td>Comment ID</td></tr> |
85
|
|
|
* </table> |
86
|
|
|
* @return BaseEvents |
87
|
|
|
* @author Kaero |
88
|
|
|
* @copyright ImageCMS (c) 2013, Kaero <[email protected]> |
89
|
|
|
*/ |
90
|
|
|
final public function onAddComment() { |
91
|
|
|
|
92
|
|
|
$this->key = 'Commentsapi:newPost'; |
93
|
|
|
return $this; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
public function onAddItemToCart() { |
97
|
|
|
|
98
|
|
|
$this->key = 'Cart:addItem'; |
99
|
|
|
return $this; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** */ |
|
|
|
|
103
|
|
|
public function onAddToCart() { |
104
|
|
|
|
105
|
|
|
$this->key = 'Cart:add'; |
106
|
|
|
return $this; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* <p>The possible returned elements from <b>setListener</b> are as follows:</p> |
111
|
|
|
* <table> |
112
|
|
|
* <tr valign="top"><td>['userId']</td><td>User ID</td></tr> |
113
|
|
|
* <tr valign="top"><td>['name']</td><td>Category name</td></tr> |
114
|
|
|
* <tr valign="top"><td>['url']</td><td>Category url</td></tr> |
115
|
|
|
* <tr valign="top"><td>['short_desc']</td><td>Category short description</td></tr> |
116
|
|
|
* </table> |
117
|
|
|
* @return BaseEvents |
118
|
|
|
* @author Kaero |
119
|
|
|
* @copyright ImageCMS (c) 2013, Kaero <[email protected]> |
120
|
|
|
*/ |
121
|
|
|
final public function onAdminCategoryCreate() { |
122
|
|
|
|
123
|
|
|
$this->key = 'Categories:create'; |
124
|
|
|
return $this; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* @return $this |
129
|
|
|
*/ |
130
|
|
|
final public function onAdminCategoryPreCreate() { |
131
|
|
|
|
132
|
|
|
$this->key = 'BaseAdminCategory:preCreate'; |
133
|
|
|
return $this; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
final public function onAdminCategoryPreUpdate() { |
137
|
|
|
|
138
|
|
|
$this->key = 'Categories:preUpdate'; |
139
|
|
|
return $this; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* <p>The possible returned elements from <b>setListener</b> are as follows:</p> |
144
|
|
|
* <table> |
145
|
|
|
* <tr valign="top"><td>['userId']</td><td>User ID</td></tr> |
146
|
|
|
* <tr valign="top"><td>['name']</td><td>Category name</td></tr> |
147
|
|
|
* <tr valign="top"><td>['url']</td><td>Category url</td></tr> |
148
|
|
|
* <tr valign="top"><td>['short_desc']</td><td>Category short description</td></tr> |
149
|
|
|
* </table> |
150
|
|
|
* @return BaseEvents |
151
|
|
|
* @author Kaero |
152
|
|
|
* @copyright ImageCMS (c) 2013, Kaero <[email protected]> |
153
|
|
|
*/ |
154
|
|
|
final public function onAdminCategoryUpdate() { |
155
|
|
|
|
156
|
|
|
$this->key = 'Categories:update'; |
157
|
|
|
return $this; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
final public function onAdminDashboardShow() { |
161
|
|
|
|
162
|
|
|
$this->key = 'Dashboard:show'; |
163
|
|
|
return $this; |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* <p>The possible returned elements from <b>setListener</b> are as follows:</p> |
168
|
|
|
* @return BaseEvents |
169
|
|
|
* @author a.gula |
170
|
|
|
* @copyright ImageCMS (c) 2014, a.gula <[email protected]> |
171
|
|
|
*/ |
172
|
|
|
public function onAdminModulesTable() { |
173
|
|
|
|
174
|
|
|
$this->key = 'Components:modules_table'; |
175
|
|
|
return $this; |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
final public function onAdminOrderUserCreate() { |
179
|
|
|
|
180
|
|
|
$this->key = 'AdminOrder:userCreate'; |
181
|
|
|
return $this; |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* <p>The possible returned elements from <b>setListener</b> are as follows:</p> |
186
|
|
|
* <table> |
187
|
|
|
* <tr valign="top"><td>['id']</td><td>Page ID</td></tr> |
188
|
|
|
* <tr valign="top"><td>['title']</td><td>Page title</td></tr> |
189
|
|
|
* <tr valign="top"><td>['full_text']</td><td>Page full text</td></tr> |
190
|
|
|
* <tr valign="top"><td>['prev_text']</td><td>Page short text</td></tr> |
191
|
|
|
* </table> |
192
|
|
|
* @return BaseEvents |
193
|
|
|
* @author Kaero |
194
|
|
|
* @copyright ImageCMS (c) 2013, Kaero <[email protected]> |
195
|
|
|
*/ |
196
|
|
|
final public function onAdminPageCreate() { |
197
|
|
|
|
198
|
|
|
$this->key = 'Page:create'; |
199
|
|
|
return $this; |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
/** |
203
|
|
|
* <p>The possible returned elements from <b>setListener</b> are as follows:</p> |
204
|
|
|
* <table> |
205
|
|
|
* <tr valign="top"><td>['id']</td><td>Page ID</td></tr> |
206
|
|
|
* <tr valign="top"><td>['title']</td><td>Page title</td></tr> |
207
|
|
|
* <tr valign="top"><td>['full_text']</td><td>Page full text</td></tr> |
208
|
|
|
* <tr valign="top"><td>['prev_text']</td><td>Page short text</td></tr> |
209
|
|
|
* </table> |
210
|
|
|
* @return BaseEvents |
211
|
|
|
* @author Kaero |
212
|
|
|
* @copyright ImageCMS (c) 2013, Kaero <[email protected]> |
213
|
|
|
*/ |
214
|
|
|
final public function onAdminPageDelete() { |
215
|
|
|
|
216
|
|
|
$this->key = 'Page:delete'; |
217
|
|
|
return $this; |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
final public function onAdminPagePreCreate() { |
221
|
|
|
|
222
|
|
|
$this->key = 'BaseAdminPage:preCreate'; |
223
|
|
|
return $this; |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
final public function onAdminPagePreEdit() { |
227
|
|
|
|
228
|
|
|
$this->key = 'BaseAdminPage:preUpdate'; |
229
|
|
|
return $this; |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
/** |
233
|
|
|
* <p>The possible returned elements from <b>setListener</b> are as follows:</p> |
234
|
|
|
* <table> |
235
|
|
|
* <tr valign="top"><td>['id']</td><td>Page ID</td></tr> |
236
|
|
|
* <tr valign="top"><td>['title']</td><td>Page title</td></tr> |
237
|
|
|
* <tr valign="top"><td>['full_text']</td><td>Page full text</td></tr> |
238
|
|
|
* <tr valign="top"><td>['prev_text']</td><td>Page short text</td></tr> |
239
|
|
|
* </table> |
240
|
|
|
* @return BaseEvents |
241
|
|
|
* @author Kaero |
242
|
|
|
* @copyright ImageCMS (c) 2013, Kaero <[email protected]> |
243
|
|
|
*/ |
244
|
|
|
final public function onAdminPageUpdate() { |
245
|
|
|
|
246
|
|
|
$this->key = 'Page:update'; |
247
|
|
|
return $this; |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
final public function onAuthUserRegister() { |
251
|
|
|
|
252
|
|
|
$this->key = 'AuthUser:register'; |
253
|
|
|
return $this; |
254
|
|
|
} |
255
|
|
|
|
256
|
|
|
public function onBrandPageLoad() { |
257
|
|
|
|
258
|
|
|
$this->key = 'brand:load'; |
259
|
|
|
return $this; |
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
public function onBrandsPageLoad() { |
263
|
|
|
|
264
|
|
|
$this->key = 'brands:load'; |
265
|
|
|
return $this; |
266
|
|
|
} |
267
|
|
|
|
268
|
|
|
final public function onCartInit() { |
269
|
|
|
|
270
|
|
|
$this->key = 'Cart:Init'; |
271
|
|
|
return $this; |
272
|
|
|
} |
273
|
|
|
|
274
|
|
|
public function onCartShowed() { |
275
|
|
|
|
276
|
|
|
$this->key = 'Cart:index'; |
277
|
|
|
return $this; |
278
|
|
|
} |
279
|
|
|
|
280
|
|
|
public function onActionTypeSearch() { |
281
|
|
|
$this->key = 'Action_Type:preSearch'; |
282
|
|
|
return $this; |
283
|
|
|
} |
284
|
|
|
|
285
|
|
|
public function onCategoryPageLoad() { |
286
|
|
|
|
287
|
|
|
$this->key = 'category:load'; |
288
|
|
|
return $this; |
289
|
|
|
} |
290
|
|
|
|
291
|
|
|
public function onGalleryLoad() { |
292
|
|
|
$this->key = 'gallery:load'; |
293
|
|
|
return $this; |
294
|
|
|
} |
295
|
|
|
|
296
|
|
|
public function onGalleryAlbumLoad() { |
297
|
|
|
$this->key = 'gallery:album'; |
298
|
|
|
return $this; |
299
|
|
|
} |
300
|
|
|
|
301
|
|
|
public function onGalleryCategoryLoad() { |
302
|
|
|
$this->key = 'gallery:category'; |
303
|
|
|
return $this; |
304
|
|
|
} |
305
|
|
|
|
306
|
|
|
final public function onCorePageLoaded() { |
307
|
|
|
|
308
|
|
|
$this->key = 'Core:pageLoaded'; |
309
|
|
|
return $this; |
310
|
|
|
} |
311
|
|
|
|
312
|
|
|
final public function onFrontOrderUserCreate() { |
313
|
|
|
|
314
|
|
|
$this->key = 'FrontOrder:userCreate'; |
315
|
|
|
return $this; |
316
|
|
|
} |
317
|
|
|
|
318
|
|
|
final public function onNotifyingRequest() { |
319
|
|
|
|
320
|
|
|
$this->key = 'Shop:notifyingRequest'; |
321
|
|
|
return $this; |
322
|
|
|
} |
323
|
|
|
|
324
|
|
|
/** |
325
|
|
|
* @return $this |
326
|
|
|
*/ |
327
|
|
|
final public function onPageCategoryLoad() { |
328
|
|
|
|
329
|
|
|
$this->key = 'pageCategory:load'; |
330
|
|
|
return $this; |
331
|
|
|
} |
332
|
|
|
|
333
|
|
|
/** |
334
|
|
|
* @return $this |
335
|
|
|
*/ |
336
|
|
|
final public function onPageLoad() { |
337
|
|
|
|
338
|
|
|
$this->key = 'page:load'; |
339
|
|
|
return $this; |
340
|
|
|
} |
341
|
|
|
|
342
|
|
|
final public function onPaimentSystemSuccessPaid() { |
343
|
|
|
|
344
|
|
|
$this->key = 'PaimentSystem:successPaid'; |
345
|
|
|
return $this; |
346
|
|
|
} |
347
|
|
|
|
348
|
|
|
public function onProductPageLoad() { |
349
|
|
|
|
350
|
|
|
$this->key = 'product:load'; |
351
|
|
|
return $this; |
352
|
|
|
} |
353
|
|
|
|
354
|
|
|
final public function onProfileApiChangeInfo() { |
355
|
|
|
|
356
|
|
|
$this->key = 'ProfileApi:changeInfo'; |
357
|
|
|
return $this; |
358
|
|
|
} |
359
|
|
|
|
360
|
|
|
public function onRemoveFromCart() { |
361
|
|
|
|
362
|
|
|
$this->key = 'SCart:removeOne'; |
363
|
|
|
return $this; |
364
|
|
|
} |
365
|
|
|
|
366
|
|
|
final public function onSearchPageLoad() { |
367
|
|
|
|
368
|
|
|
$this->key = 'search:load'; |
369
|
|
|
return $this; |
370
|
|
|
} |
371
|
|
|
|
372
|
|
|
/** |
373
|
|
|
* <p>The possible returned elements from <b>setListener</b> are as follows:</p> |
374
|
|
|
* @return BaseEvents |
375
|
|
|
* @author a.gula |
376
|
|
|
* @copyright ImageCMS (c) 2014, a.gula <[email protected]> |
377
|
|
|
*/ |
378
|
|
|
public function onSeoExpertSave() { |
379
|
|
|
|
380
|
|
|
$this->key = 'SeoExpert:save'; |
381
|
|
|
return $this; |
382
|
|
|
} |
383
|
|
|
|
384
|
|
|
final public function onShopAdminAjaxChangeOrderPaid() { |
385
|
|
|
|
386
|
|
|
$this->key = 'ShopAdminOrders:ajaxChangeOrdersPaid'; |
387
|
|
|
return $this; |
388
|
|
|
} |
389
|
|
|
|
390
|
|
|
final public function onShopAdminAjaxChangeOrderStatus() { |
391
|
|
|
|
392
|
|
|
$this->key = 'ShopAdminOrders:ajaxChangeOrdersStatus'; |
393
|
|
|
return $this; |
394
|
|
|
} |
395
|
|
|
|
396
|
|
|
final public function onShopAdminOrderCreate() { |
397
|
|
|
|
398
|
|
|
$this->key = 'ShopAdminOrder:create'; |
399
|
|
|
return $this; |
400
|
|
|
} |
401
|
|
|
|
402
|
|
|
final public function onShopAdminOrderDelete() { |
403
|
|
|
|
404
|
|
|
$this->key = 'ShopAdminOrder:ajaxDeleteOrders'; |
405
|
|
|
return $this; |
406
|
|
|
} |
407
|
|
|
|
408
|
|
|
final public function onShopAdminOrderEdit() { |
409
|
|
|
|
410
|
|
|
$this->key = 'ShopAdminOrders:edit'; |
411
|
|
|
return $this; |
412
|
|
|
} |
413
|
|
|
|
414
|
|
|
/** */ |
|
|
|
|
415
|
|
|
|
416
|
|
|
final public function onShopAdminOrderUserCreate() { |
417
|
|
|
|
418
|
|
|
$this->key = 'ShopAdminOrder:createUser'; |
419
|
|
|
return $this; |
420
|
|
|
} |
421
|
|
|
|
422
|
|
|
/** */ |
|
|
|
|
423
|
|
|
/** */ |
|
|
|
|
424
|
|
|
|
425
|
|
|
/** |
426
|
|
|
* <p>The possible returned elements from <b>setListener</b> are as follows:</p> |
427
|
|
|
* <table> |
428
|
|
|
* <tr valign="top"><td>['model']</td><td>Brand model</td></tr> |
429
|
|
|
* <tr valign="top"><td>['userId']</td><td>User Id</td></tr> |
430
|
|
|
* </table> |
431
|
|
|
* @return BaseEvents |
432
|
|
|
* @author Hellmark |
433
|
|
|
* @copyright ImageCMS (c) 2014, Hellmark <[email protected]> |
434
|
|
|
*/ |
435
|
|
|
public function onShopBrandCreate() { |
436
|
|
|
|
437
|
|
|
$this->key = 'ShopAdminBrands:create'; |
438
|
|
|
return $this; |
439
|
|
|
} |
440
|
|
|
|
441
|
|
|
/** |
442
|
|
|
* <p>The possible returned elements from <b>setListener</b> are as follows:</p> |
443
|
|
|
* <table> |
444
|
|
|
* <tr valign="top"><td>['brandId']</td><td>Brand Id</td></tr> |
445
|
|
|
* <tr valign="top"><td>['url']</td><td>Brand Url</td></tr> |
446
|
|
|
* </table> |
447
|
|
|
* @return BaseEvents |
448
|
|
|
* @author Hellmark |
449
|
|
|
* @copyright ImageCMS (c) 2014, Hellmark <[email protected]> |
450
|
|
|
*/ |
451
|
|
|
public function onShopBrandDelete() { |
452
|
|
|
|
453
|
|
|
$this->key = 'ShopAdminBrands:delete'; |
454
|
|
|
return $this; |
455
|
|
|
} |
456
|
|
|
|
457
|
|
|
/** |
458
|
|
|
* <p>The possible returned elements from <b>setListener</b> are as follows:</p> |
459
|
|
|
* <table> |
460
|
|
|
* <tr valign="top"><td>['model']</td><td>Brand model</td></tr> |
461
|
|
|
* <tr valign="top"><td>['url']</td><td>Brand Url</td></tr> |
462
|
|
|
* <tr valign="top"><td>['userId']</td><td>User Id</td></tr> |
463
|
|
|
* </table> |
464
|
|
|
* @return BaseEvents |
465
|
|
|
* @author Hellmark |
466
|
|
|
* @copyright ImageCMS (c) 2014, Hellmark <[email protected]> |
467
|
|
|
*/ |
468
|
|
|
public function onShopBrandEdit() { |
469
|
|
|
|
470
|
|
|
$this->key = 'ShopAdminBrands:edit'; |
471
|
|
|
return $this; |
472
|
|
|
} |
473
|
|
|
|
474
|
|
|
/** |
475
|
|
|
* <p>The possible returned elements from <b>setListener</b> are as follows:</p> |
476
|
|
|
* @return BaseEvents |
477
|
|
|
* @author a.gula |
478
|
|
|
* @copyright ImageCMS (c) 2014, a.gula <[email protected]> |
479
|
|
|
*/ |
480
|
|
|
public function onShopBrandPreCreate() { |
481
|
|
|
|
482
|
|
|
$this->key = 'ShopAdminBrands:preCreate'; |
483
|
|
|
return $this; |
484
|
|
|
} |
485
|
|
|
|
486
|
|
|
/** |
487
|
|
|
* <p>The possible returned elements from <b>setListener</b> are as follows:</p> |
488
|
|
|
* <table> |
489
|
|
|
* <tr valign="top"><td>['model']</td><td>Brand model</td></tr> |
490
|
|
|
* <tr valign="top"><td>['url']</td><td>Brand Url</td></tr> |
491
|
|
|
* <tr valign="top"><td>['userId']</td><td>User Id</td></tr> |
492
|
|
|
* </table> |
493
|
|
|
* @return BaseEvents |
494
|
|
|
* @author Hellmark |
495
|
|
|
* @copyright ImageCMS (c) 2014, Hellmark <[email protected]> |
496
|
|
|
*/ |
497
|
|
|
public function onShopBrandPreEdit() { |
498
|
|
|
|
499
|
|
|
$this->key = 'ShopAdminBrands:preEdit'; |
500
|
|
|
return $this; |
501
|
|
|
} |
502
|
|
|
|
503
|
|
|
final public function onShopCallback() { |
504
|
|
|
|
505
|
|
|
$this->key = 'Shop:callback'; |
506
|
|
|
return $this; |
507
|
|
|
} |
508
|
|
|
|
509
|
|
|
/** |
510
|
|
|
* <p>The possible returned elements from <b>setListener</b> are as follows:</p> |
511
|
|
|
* <table> |
512
|
|
|
* <tr valign="top"><td>['ShopCategoryId']</td><td>Category ID</td></tr> |
513
|
|
|
* </table> |
514
|
|
|
* @return BaseEvents |
515
|
|
|
* @author Kaero |
516
|
|
|
* @copyright ImageCMS (c) 2013, Kaero <[email protected]> |
517
|
|
|
*/ |
518
|
|
|
public function onShopCategoryCreate() { |
519
|
|
|
|
520
|
|
|
$this->key = 'ShopAdminCategories:create'; |
521
|
|
|
return $this; |
522
|
|
|
} |
523
|
|
|
|
524
|
|
|
/** |
525
|
|
|
* <p>The possible returned elements from <b>setListener</b> are as follows:</p> |
526
|
|
|
* <table> |
527
|
|
|
* <tr valign="top"><td>['ShopCategoryId']</td><td>Category ID</td></tr> |
528
|
|
|
* </table> |
529
|
|
|
* @return BaseEvents |
530
|
|
|
* @author Kaero |
531
|
|
|
* @copyright ImageCMS (c) 2013, Kaero <[email protected]> |
532
|
|
|
*/ |
533
|
|
|
public function onShopCategoryDelete() { |
534
|
|
|
|
535
|
|
|
$this->key = 'ShopAdminCategories:delete'; |
536
|
|
|
return $this; |
537
|
|
|
} |
538
|
|
|
|
539
|
|
|
/** |
540
|
|
|
* <p>The possible returned elements from <b>setListener</b> are as follows:</p> |
541
|
|
|
* <table> |
542
|
|
|
* <tr valign="top"><td>['ShopCategoryId']</td><td>Category ID</td></tr> |
543
|
|
|
* </table> |
544
|
|
|
* @return BaseEvents |
545
|
|
|
* @author Kaero |
546
|
|
|
* @copyright ImageCMS (c) 2013, Kaero <[email protected]> |
547
|
|
|
*/ |
548
|
|
|
public function onShopCategoryEdit() { |
549
|
|
|
|
550
|
|
|
$this->key = 'ShopAdminCategories:edit'; |
551
|
|
|
return $this; |
552
|
|
|
} |
553
|
|
|
|
554
|
|
|
public function onShopCategoryFastCreate() { |
555
|
|
|
|
556
|
|
|
$this->key = 'ShopAdminCategories:fastCreate'; |
557
|
|
|
return $this; |
558
|
|
|
} |
559
|
|
|
|
560
|
|
|
public function onShopCategoryPreCreate() { |
561
|
|
|
|
562
|
|
|
$this->key = 'ShopAdminCategories:preCreate'; |
563
|
|
|
return $this; |
564
|
|
|
} |
565
|
|
|
|
566
|
|
|
public function onShopCategoryPreEdit() { |
567
|
|
|
|
568
|
|
|
$this->key = 'ShopAdminCategories:preEdit'; |
569
|
|
|
return $this; |
570
|
|
|
} |
571
|
|
|
|
572
|
|
|
public function onShopCategoryPreFastCreate() { |
573
|
|
|
|
574
|
|
|
$this->key = 'ShopAdminCategories:preFastCreate'; |
575
|
|
|
return $this; |
576
|
|
|
} |
577
|
|
|
|
578
|
|
|
final public function onShopDashboardShow() { |
579
|
|
|
|
580
|
|
|
$this->key = 'ShopDashboard:show'; |
581
|
|
|
return $this; |
582
|
|
|
} |
583
|
|
|
|
584
|
|
|
final public function onShopMakeOrder() { |
585
|
|
|
|
586
|
|
|
$this->key = 'Cart:MakeOrder'; |
587
|
|
|
return $this; |
588
|
|
|
} |
589
|
|
|
|
590
|
|
|
final public function onShopOrderView() { |
591
|
|
|
|
592
|
|
|
$this->key = 'Order:view'; |
593
|
|
|
return $this; |
594
|
|
|
} |
595
|
|
|
|
596
|
|
|
final public function onShopProductAjaxChangeActive() { |
597
|
|
|
|
598
|
|
|
$this->key = 'ShopAdminProducts:ajaxChangeActive'; |
599
|
|
|
return $this; |
600
|
|
|
} |
601
|
|
|
|
602
|
|
|
/** |
603
|
|
|
* <p>The possible returned elements from <b>setListener</b> are as follows:</p> |
604
|
|
|
* <table> |
605
|
|
|
* <tr valign="top"><td>['userId']</td><td>User ID</td></tr> |
606
|
|
|
* <tr valign="top"><td>['productId']</td><td>Product ID</td></tr> |
607
|
|
|
* </table> |
608
|
|
|
* @return BaseEvents |
609
|
|
|
* @author Kaero |
610
|
|
|
* @copyright ImageCMS (c) 2013, Kaero <[email protected]> |
611
|
|
|
*/ |
612
|
|
|
final public function onShopProductCreate() { |
613
|
|
|
|
614
|
|
|
$this->key = 'ShopAdminProducts:create'; |
615
|
|
|
return $this; |
616
|
|
|
} |
617
|
|
|
|
618
|
|
|
/** |
619
|
|
|
* <p>The possible returned elements from <b>setListener</b> are as follows:</p> |
620
|
|
|
* <table> |
621
|
|
|
* <tr valign="top"><td>['userId']</td><td>User ID</td></tr> |
622
|
|
|
* <tr valign="top"><td>['model']</td><td></td>Instanceof SProducts</tr> |
623
|
|
|
* </table> |
624
|
|
|
* @return BaseEvents |
625
|
|
|
* @author Kaero |
626
|
|
|
* @copyright ImageCMS (c) 2013, Kaero <[email protected]> |
627
|
|
|
*/ |
628
|
|
|
final public function onShopProductDelete() { |
629
|
|
|
|
630
|
|
|
$this->key = 'ShopAdminProducts:delete'; |
631
|
|
|
return $this; |
632
|
|
|
} |
633
|
|
|
|
634
|
|
|
final public function onShopProductFastProdCreate() { |
635
|
|
|
|
636
|
|
|
$this->key = 'ShopAdminProducts:fastProdCreate'; |
637
|
|
|
return $this; |
638
|
|
|
} |
639
|
|
|
|
640
|
|
|
final public function onShopProductPreCreate() { |
641
|
|
|
|
642
|
|
|
$this->key = 'ShopAdminProducts:preCreate'; |
643
|
|
|
return $this; |
644
|
|
|
} |
645
|
|
|
|
646
|
|
|
final public function onShopProductPreFastProdCreate() { |
647
|
|
|
|
648
|
|
|
$this->key = 'ShopAdminProducts:prefastProdCreate'; |
649
|
|
|
return $this; |
650
|
|
|
} |
651
|
|
|
|
652
|
|
|
final public function onShopProductPreUpdate() { |
653
|
|
|
|
654
|
|
|
$this->key = 'ShopAdminProducts:preEdit'; |
655
|
|
|
return $this; |
656
|
|
|
} |
657
|
|
|
|
658
|
|
|
/** |
659
|
|
|
* <p>The possible returned elements from <b>setListener</b> are as follows:</p> |
660
|
|
|
* <table> |
661
|
|
|
* <tr valign="top"><td>['userId']</td><td>User ID</td></tr> |
662
|
|
|
* <tr valign="top"><td>['productId']</td><td>Product ID</td></tr> |
663
|
|
|
* </table> |
664
|
|
|
* @return BaseEvents |
665
|
|
|
* @author Kaero |
666
|
|
|
* @copyright ImageCMS (c) 2013, Kaero <[email protected]> |
667
|
|
|
*/ |
668
|
|
|
final public function onShopProductUpdate() { |
669
|
|
|
|
670
|
|
|
$this->key = 'ShopAdminProducts:edit'; |
671
|
|
|
return $this; |
672
|
|
|
} |
673
|
|
|
|
674
|
|
|
final public function onShopSearchAC() { |
675
|
|
|
|
676
|
|
|
$this->key = 'search:AC'; |
677
|
|
|
return $this; |
678
|
|
|
} |
679
|
|
|
|
680
|
|
|
final public function onShopUserAfterEdit() { |
681
|
|
|
|
682
|
|
|
$this->key = 'ShopAdminUsers:afterEdit'; |
683
|
|
|
return $this; |
684
|
|
|
} |
685
|
|
|
|
686
|
|
|
final public function onShopUserBeforeEdit() { |
687
|
|
|
|
688
|
|
|
$this->key = 'ShopAdminUsers:beforeEdit'; |
689
|
|
|
return $this; |
690
|
|
|
} |
691
|
|
|
|
692
|
|
|
final public function onShopUserCreate() { |
693
|
|
|
|
694
|
|
|
$this->key = 'ShopAdminUser:create'; |
695
|
|
|
return $this; |
696
|
|
|
} |
697
|
|
|
|
698
|
|
|
final public function onWidgetHTMLPreUpdate() { |
699
|
|
|
|
700
|
|
|
$this->key = 'WidgetHTML:preUpdate'; |
701
|
|
|
return $this; |
702
|
|
|
} |
703
|
|
|
|
704
|
|
|
final public function onWidgetModulePreUpdate() { |
705
|
|
|
|
706
|
|
|
$this->key = 'WidgetModule:preUpdate'; |
707
|
|
|
return $this; |
708
|
|
|
} |
709
|
|
|
|
710
|
|
|
/** |
711
|
|
|
* Run listeners for one event. After running removes listeners. |
712
|
|
|
* @param array|object $data |
713
|
|
|
* @param string $eventAlias |
714
|
|
|
* @return $this |
715
|
|
|
*/ |
716
|
|
|
public function raiseEvent($data, $eventAlias) { |
717
|
|
|
|
718
|
|
|
$this->registerEvent($data, $eventAlias); |
719
|
|
|
$this->runFactory($eventAlias, false); |
720
|
|
|
return $this; |
721
|
|
|
} |
722
|
|
|
|
723
|
|
|
/** |
724
|
|
|
* Declares a new event. The method adds the general pool of information about the event and sets it as held. |
725
|
|
|
* The user can call the place where, in his opinion, there is a need. |
726
|
|
|
* Will be generated key that consists of a pair of "Class: method." |
727
|
|
|
* @param mixed $data <b>[optional]</b>Fetch some Data and peredaje to user method's |
728
|
|
|
* @param string $key |
729
|
|
|
* @access public |
730
|
|
|
* @copyright ImageCMS (c) 2013, Kaero <[email protected]> |
731
|
|
|
* @return $this |
732
|
|
|
*/ |
733
|
|
|
public function registerEvent($data = null, $key = null) { |
734
|
|
|
|
735
|
|
|
if (NULL == $key) { |
736
|
|
|
$trace = debug_backtrace(); |
737
|
|
|
$key = $trace[1]['class'] . ':' . $trace[1]['function']; |
738
|
|
|
} |
739
|
|
|
$this->storage[$key]['run'] = TRUE; |
740
|
|
|
$this->storage[$key]['params'] = $data; |
741
|
|
|
return $this; |
742
|
|
|
} |
743
|
|
|
|
744
|
|
|
/** |
745
|
|
|
* Run Behavior factory when controller is completely loaded |
746
|
|
|
* @param string $eventAlias |
747
|
|
|
* @param bool $cleanQueue |
748
|
|
|
* @access public |
749
|
|
|
* @author Kaero |
750
|
|
|
* @copyright ImageCMS (c) 2012, Kaero <[email protected]> |
751
|
|
|
*/ |
752
|
|
|
public static function runFactory($eventAlias = null, $cleanQueue = false) { |
753
|
|
|
|
754
|
|
|
(defined('BASEPATH')) OR exit('No direct script access allowed'); |
755
|
|
|
foreach (Events::create()->storage as $storageKey => $value) { |
756
|
|
|
if ($eventAlias != null && $eventAlias != $storageKey) { |
757
|
|
|
continue; |
758
|
|
|
} |
759
|
|
|
if (isset($value['run'])) { |
760
|
|
|
if ($value['run'] === TRUE && isset($value['collable'])) { |
761
|
|
|
foreach ($value['collable'] as $collableKey => $run) { |
762
|
|
|
if ($run['isClosure'] === false) { |
763
|
|
|
call_user_func([$run['collClass'], $run['collMethod']], $value['params']); |
764
|
|
|
} else { |
765
|
|
|
call_user_func($run['collMethod'], $value['params']); |
766
|
|
|
} |
767
|
|
|
if ($cleanQueue === true) { |
768
|
|
|
unset(Events::create()->storage[$storageKey]['collable'][$collableKey]); |
769
|
|
|
} |
770
|
|
|
} |
771
|
|
|
} |
772
|
|
|
} |
773
|
|
|
} |
774
|
|
|
} |
775
|
|
|
|
776
|
|
|
/** |
777
|
|
|
* Removes specified event with all listeners |
778
|
|
|
* @param string $eventAlias |
779
|
|
|
*/ |
780
|
|
|
public function removeEvent($eventAlias) { |
781
|
|
|
|
782
|
|
|
if (isset($this->storage[$eventAlias])) { |
783
|
|
|
unset($this->storage[$eventAlias]); |
784
|
|
|
} |
785
|
|
|
} |
786
|
|
|
|
787
|
|
|
/** |
788
|
|
|
* Binds a custom method to the event. |
789
|
|
|
* <br/><br/><code> |
790
|
|
|
* public function autoload() {<br/> |
791
|
|
|
*   \CMSFactory\Events::create()->setListener('myMethod', 'Comments::add');<br/> |
792
|
|
|
* } |
793
|
|
|
* </code> |
794
|
|
|
* @param string|array|Closure $callback Indicates the name of the method that will be called in response to a trigger-event. The method will be matched in the class from which the requested binding. |
795
|
|
|
* @param string $alias <b>[optional]</b> The second parameter is optional if you make a call type was given an expected event. |
796
|
|
|
* @throws Exception |
|
|
|
|
797
|
|
|
* @copyright ImageCMS (c) 2013, Kaero <[email protected]> |
798
|
|
|
*/ |
799
|
|
|
public function setListener($callback, $alias = null) { |
800
|
|
|
|
801
|
|
|
if ($alias !== null && $this->key !== null) { |
802
|
|
|
throw new Exception("Can't declarete both."); |
803
|
|
|
} |
804
|
|
|
$alias = ($this->key) ?: $alias; |
805
|
|
|
if ($alias == null) { |
806
|
|
|
throw new Exception("Bind value can't not be null."); |
807
|
|
|
} |
808
|
|
|
|
809
|
|
|
$trace = debug_backtrace(); |
810
|
|
|
$isClosure = false; |
811
|
|
|
if (is_string($callback)) { |
812
|
|
|
$method = $callback; |
813
|
|
|
$class = $trace[1]['class']; |
814
|
|
|
} elseif (is_array($callback)) { |
815
|
|
|
$method = $callback[1]; |
816
|
|
|
$class = $callback[0]; |
817
|
|
|
} elseif ($callback instanceof Closure) { |
818
|
|
|
$method = $callback; |
819
|
|
|
$class = $trace[1]['class']; |
820
|
|
|
$isClosure = true; |
821
|
|
|
} else { |
822
|
|
|
throw new Exception('Wrong argument type'); |
823
|
|
|
} |
824
|
|
|
|
825
|
|
|
if ($isClosure == false && isset($this->holder[$alias]) && $this->holder[$alias][$method] == $class) { |
826
|
|
|
return; |
827
|
|
|
} |
828
|
|
|
if ($isClosure == false) { |
829
|
|
|
$this->holder[$alias][$method] = $class; |
830
|
|
|
} |
831
|
|
|
$storageData = [ |
832
|
|
|
'collMethod' => $method, |
833
|
|
|
'collClass' => $class, |
834
|
|
|
'isClosure' => $isClosure, |
835
|
|
|
]; |
836
|
|
|
$this->storage[$alias]['collable'][] = $storageData; |
837
|
|
|
} |
838
|
|
|
|
839
|
|
|
} |
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: