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