-
Notifications
You must be signed in to change notification settings - Fork 6
/
extension.driver.php
83 lines (70 loc) · 2.54 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
<?php
Class extension_scaffolds extends Extension{
public function about() {
return array(
'name' => 'Scaffolds',
'version' => '0.5',
'release-date' => '2012-02-03',
'author' => array(
'name' => 'Brendan Abbott',
'email' => 'brendan@bloodbone.ws'
),
'description' => 'A Symphony extension that allows a developer to quickly create Sections using JSON'
);
}
public function getSubscribedDelegates(){
return array(
array(
'page' => '/backend/',
'delegate' => 'InitaliseAdminPageHead',
'callback' => 'appendAssets'
),
array(
'page' => '/blueprints/sections/',
'delegate' => 'AddSectionElements',
'callback' => 'addSectionElements'
),
);
}
/*-------------------------------------------------------------------------
Delegates:
-------------------------------------------------------------------------*/
public function appendAssets() {
if(class_exists('Administration')
&& Administration::instance() instanceof Administration
&& Administration::instance()->Page instanceof contentBlueprintsSections
) {
Administration::instance()->Page->addStylesheetToHead(URL . '/extensions/scaffolds/assets/scaffolds.sections.css', 'screen', 10000, false);
Administration::instance()->Page->addScriptToHead(URL . '/extensions/scaffolds/assets/scaffolds.sections.js', 10001, false);
}
}
public function addSectionElements(array $context = array()) {
$callback = Administration::instance()->getPageCallback();
$ul = new XMLElement('ul');
$ul->setAttribute('id', 'scaffolds');
// Add 'Import'
$a = Widget::Anchor(__('Import'), '#', __('Import a Section definition'), 'create button', NULL, array('accesskey' => 'c'));
$a->setAttribute('data-action', 'import');
$ul->appendChild(
new XMLElement('li', $a->generate())
);
// If we are editing a Section, add 'Export'
if($callback['context'][0] == 'edit') {
$a = Widget::Anchor(__('Export'), '#', __('Export this Section definition'), 'create button', NULL, array('accesskey' => 'c'));
$a->setAttribute('data-action', 'export');
$ul->appendChild(
new XMLElement('li', $a->generate())
);
}
// Scaffolds Area
$div = new XMLElement('div');
$div->setAttribute('id', 'scaffolds-area');
$div->appendChild($ul);
if($ul->getNumberOfChildren() == 2) {
$div->appendChild(
Widget::Anchor('⬇', '#scaffolds', __('Select'), 'button', NULL, array('accesskey' => 'c'))
);
}
$context['form']->prependChild($div);
}
}