forked from DeuxHuitHuit/color_chooser_field
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextension.driver.php
71 lines (55 loc) · 1.84 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
<?php
Class Extension_Color_Chooser_Field extends Extension {
/*
* Subscribe to delegates
*/
public function getSubscribedDelegates() {
return array(
array(
'page' => '/backend/',
'delegate' => 'InitaliseAdminPageHead',
'callback' => 'appendResources'
),
);
}
/*********** DELEGATES ***********************/
/*
* Appends resource (js/css) files references into the head, if needed
* @param array $context
*/
public function appendResources() {
// store callback array locally
$c = Administration::instance()->getPageCallback();
// publish page, new or edit
if(in_array($c['context']['page'], array('index', 'new', 'edit'))){
$page = Administration::instance()->Page;
$page->addScriptToHead(URL.'/extensions/color_chooser_field/assets/jquery.farbtastic.js', 3001);
$page->addScriptToHead(URL.'/extensions/color_chooser_field/assets/jquery.tools.min.js', 3002);
$page->addScriptToHead(URL.'/extensions/color_chooser_field/assets/jquery.color-chooser.js', 3003);
$page->addStylesheetToHead(URL.'/extensions/color_chooser_field/assets/farbtastic.css', 'screen', 3004);
return;
}
}
/*
* Delegate fired when the extension is installed
*/
public function install(){
return Symphony::Database()->query("CREATE TABLE `tbl_fields_colorchooser` (
`id` int(11) unsigned NOT NULL auto_increment,
`field_id` int(11) unsigned NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `field_id` (`field_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
}
/*
* Delegate fired when the extension is uninstalled
* Cleans settings and Database
*/
public function uninstall() {
try {
Symphony::Database()->query("DROP TABLE `tbl_fields_colorchooser`");
} catch( Exception $e ){}
return true;
}
}
?>