forked from simoneeconomo/edui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextension.driver.php
More file actions
executable file
·125 lines (101 loc) · 3.13 KB
/
extension.driver.php
File metadata and controls
executable file
·125 lines (101 loc) · 3.13 KB
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
<?php
Class extension_edui extends Extension {
public function about() {
return array(
'name' => 'Events, Datasources & Utilities Indexes',
'version' => '0.6.1',
'release-date' => '2011-07-31',
'author' => array('name' => 'Simone Economo',
'website' => 'http://www.lineheight.net',
'email' => 'my.ekoes@gmail.com'),
'description' => 'Dinstinct index pages for events, datasources and utilities.'
);
}
public function fetchNavigation() {
return array(
array(
'location' => __('Blueprints'),
'name' => __('Events'),
'link' => '/events/'
),
array(
'location' => __('Blueprints'),
'name' => __('Data Sources'),
'link' => '/datasources/'
),
array(
'location' => __('Blueprints'),
'name' => __('Utilities'),
'link' => '/utilities/'
),
);
}
public function getSubscribedDelegates(){
return array(
array(
'page' => '/backend/',
'delegate' => 'NavigationPreRender',
'callback' => 'deleteComponentsItem'
),
array(
'page' => '/backend/',
'delegate' => 'AdminPagePreGenerate',
'callback' => 'setRedirects'
),
);
}
public function deleteComponentsItem($context) {
foreach ($context['navigation'] as &$menu) {
if ($menu['name'] == __('Blueprints')) {
for ($i = 0; $i < count($menu['children']); ++$i) {
if ($menu['children'][$i]['name'] == __('Components')) {
array_splice($menu['children'], $i, 1);
}
}
}
}
}
public function setRedirects($context) {
$links = array(
'blueprintsdatasources' => 'extension/edui/datasources/',
'blueprintsevents' => 'extension/edui/events/',
'blueprintsutilities' => 'extension/edui/utilities/',
);
$callback = $this->_Parent->getPageCallback();
if ($callback['driver'] == 'blueprintscomponents') {
foreach ($links as $key => $value) {
if (file_exists(TMP . '/' . $key . '.tmp')) {
unlink(TMP . '/' . $key . '.tmp');
redirect(URL . '/symphony/' . $value);
}
}
}
else if (in_array($callback['driver'], array_keys($links))) {
$c = $this->_Parent->Page->Header->getChildren();
if ($callback['context'][2] && (in_array($callback['context'][2], array('saved', 'created')))) {
$c[0]->setValue(str_replace('blueprints/components/', $links[$callback['driver']], $c[0]->getValue()));
}
if ($_POST['action'] && array_key_exists('delete_custom', $_POST['action'])) {
touch(TMP . '/' . $callback['driver'] . '.tmp');
$_POST['action']['delete'] = $_POST['action']['delete_custom'];
if (method_exists($this->_Parent->Page, '__actionEdit'))
$this->_Parent->Page->__actionEdit();
else
$this->_Parent->Page->action();
}
for($i = count($c) - 1; $i > 0 ; --$i) {
$child = &$c[$i];
$attr = $child->getAttributes();
if ($child->getName() == 'div' && $attr['class'] && $attr['class'] == 'actions') {
$actions = $child->getChildren();
foreach($actions as &$a) {
if ($a->getValue() == __('Delete')) {
$a->setAttribute('name', 'action[delete_custom]');
}
}
}
}
}
}
}
?>