forked from symphonycms/selectbox_link_field
-
Notifications
You must be signed in to change notification settings - Fork 5
/
extension.driver.php
63 lines (54 loc) · 1.8 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
<?php
Class extension_association_field extends Extension
{
/**
* {@inheritDoc}
*/
public function getSubscribedDelegates() {
return array(
array(
'page' => '/backend/',
'delegate' => 'InitaliseAdminPageHead',
'callback' => 'appendAssets'
)
);
}
/**
* Append assets
*/
public function appendAssets()
{
$callback = Symphony::Engine()->getPageCallback();
if ($callback['driver'] == 'publish' && $callback['context']['page'] === 'index') {
Administration::instance()->Page->addStylesheetToHead(URL . '/extensions/association_field/assets/association_field.publish.css');
}
}
public function install()
{
try {
Symphony::Database()->query(
"CREATE TABLE IF NOT EXISTS `tbl_fields_association` (
`id` int(11) unsigned NOT NULL auto_increment,
`field_id` int(11) unsigned NOT NULL,
`allow_multiple_selection` enum('yes','no') NOT NULL default 'no',
`hide_when_prepopulated` enum('yes','no') NOT NULL default 'no',
`related_field_id` VARCHAR(255) NOT NULL,
`limit` int(4) unsigned NOT NULL default '20',
PRIMARY KEY (`id`),
KEY `field_id` (`field_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"
);
} catch (Exception $e) {
return false;
}
return true;
}
public function uninstall()
{
if (parent::uninstall() == true) {
Symphony::Database()->query("DROP TABLE `tbl_fields_association`");
return true;
}
return false;
}
}