-
Notifications
You must be signed in to change notification settings - Fork 14
/
extension.driver.php
executable file
·51 lines (42 loc) · 1.32 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
<?php
class Extension_DebugDevKit extends Extension {
/*-------------------------------------------------------------------------
Definition:
-------------------------------------------------------------------------*/
public static $active = false;
public function getSubscribedDelegates() {
return array(
array(
'page' => '/frontend/',
'delegate' => 'FrontendDevKitResolve',
'callback' => 'frontendDevKitResolve'
),
array(
'page' => '/frontend/',
'delegate' => 'ManipulateDevKitNavigation',
'callback' => 'manipulateDevKitNavigation'
)
);
}
public function frontendDevKitResolve($context) {
if (false or isset($_GET['debug'])) {
require_once(EXTENSIONS . '/debugdevkit/content/content.debug.php');
$context['devkit'] = new Content_DebugDevKit_Debug();
self::$active = true;
}
}
public function manipulateDevKitNavigation($context) {
$xml = $context['xml'];
$item = $xml->createElement('item');
$item->setAttribute('name', __('Debug'));
$item->setAttribute('handle', 'debug');
$item->setAttribute('active', (self::$active ? 'yes' : 'no'));
$parent = $xml->documentElement;
if ($parent->hasChildNodes()) {
$parent->insertBefore($item, $parent->firstChild);
}
else {
$xml->documentElement->appendChild($item);
}
}
}