-
Notifications
You must be signed in to change notification settings - Fork 6
/
extension.driver.php
97 lines (84 loc) · 2.38 KB
/
extension.driver.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
<?php
require_once EXTENSIONS . '/storage/data-sources/datasource.storage.php';
require_once EXTENSIONS . '/storage/lib/class.storage.php';
class extension_Storage extends Extension
{
protected static $provides = array();
public static function registerProviders()
{
self::$provides = array(
'data-sources' => array(
'StorageDatasource' => StorageDatasource::getName()
)
);
return true;
}
public static function providerOf($type = null)
{
self::registerProviders();
if (is_null($type)) {
return self::$provides;
}
if (!isset(self::$provides[$type])) {
return array();
}
return self::$provides[$type];
}
/**
* Delegates and callbacks
*
* @return array
*/
public function getSubscribedDelegates()
{
return array(
array(
'page' => '/blueprints/events/new/',
'delegate' => 'AppendEventFilter',
'callback' => 'appendEventFilter'
),
array(
'page' => '/blueprints/events/edit/',
'delegate' => 'AppendEventFilter',
'callback' => 'appendEventFilter'
),
array(
'page' => '/frontend/',
'delegate' => 'EventFinalSaveFilter',
'callback' => 'eventFinalSaveFilter'
),
);
}
/**
* Append event filters to event pages
*
* @param string $context
* @return void
*/
public function appendEventFilter($context)
{
$selected = !is_array($context['selected']) ? array() : $context['selected'];
$context['options'][] = array(
'storage-drop',
in_array('storage-drop', $selected),
__('Storage: Drop')
);
}
/**
* Drop storage item if request data is found
*
* @uses EventFinalSaveFilter
* @param string $context
* @return void
*/
public function eventFinalSaveFilter($context)
{
if (in_array('storage-drop', $context['event']->eParamFILTERS)) {
$drop_request = $_REQUEST['storage-action']['drop'];
if (is_array($drop_request)) {
$s = new Storage();
$s->drop($drop_request);
}
}
}
}