forked from pointybeard-archives/system_date_field
-
Notifications
You must be signed in to change notification settings - Fork 8
/
extension.driver.php
99 lines (87 loc) · 2.72 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
Class extension_System_Date_Fields extends Extension
{
public function getSubscribedDelegates()
{
return array(
array(
'page' => '/backend/',
'delegate' => 'InitialiseAdminPageHead',
'callback' => 'appendAssets'
),
);
}
/**
*
* Appends js/css files references into the head, if needed
* @param array $context
*/
public function appendAssets(array $context)
{
// store de callback array localy
$c = Administration::instance()->getPageCallback();
// publish page
if(isset($c['context']['section_handle'])) {
Administration::instance()->Page->addStylesheetToHead(
URL . '/extensions/system_date_fields/assets/system_date_fields.publish.css',
'screen',
104,
false
);
Administration::instance()->Page->addScriptToHead(
URL . '/extensions/system_date_fields/assets/system_date_fields.publish.js',
105,
false
);
return;
}
}
public function update($previousVersion = false)
{
$ret = true;
if ($ret && version_compare($previousVersion,'1.1.0') == -1) {
$ret1 = Symphony::Database()->query("
ALTER TABLE `tbl_fields_systemcreateddate`
ADD COLUMN `show_time` enum('yes','no') NOT NULL DEFAULT 'no',
ADD COLUMN `use_timeago` enum('yes','no') NOT NULL DEFAULT 'no'
");
$ret2 = Symphony::Database()->query("
ALTER TABLE `tbl_fields_systemmodifieddate`
ADD COLUMN `show_time` enum('yes','no') NOT NULL DEFAULT 'no',
ADD COLUMN `use_timeago` enum('yes','no') NOT NULL DEFAULT 'no'
");
$ret = $ret1 && $ret2;
}
return $ret;
}
public function uninstall()
{
$ret1 = Symphony::Database()->query("DROP TABLE `tbl_fields_systemcreateddate`");
$ret2 = Symphony::Database()->query("DROP TABLE `tbl_fields_systemmodifieddate`");
return $ret1 && $ret2;
}
public function install()
{
$ret1 = Symphony::Database()->query("
CREATE TABLE `tbl_fields_systemcreateddate` (
`id` int(11) unsigned NOT NULL auto_increment,
`field_id` int(11) unsigned NOT NULL,
`show_time` enum('yes','no') NOT NULL DEFAULT 'no',
`use_timeago` enum('yes','no') NOT NULL DEFAULT 'no',
PRIMARY KEY (`id`),
KEY `field_id` (`field_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
");
$ret2 = Symphony::Database()->query("
CREATE TABLE `tbl_fields_systemmodifieddate` (
`id` int(11) unsigned NOT NULL auto_increment,
`field_id` int(11) unsigned NOT NULL,
`show_time` enum('yes','no') NOT NULL DEFAULT 'no',
`use_timeago` enum('yes','no') NOT NULL DEFAULT 'no',
PRIMARY KEY (`id`),
KEY `field_id` (`field_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
");
return $ret1 && $ret2;
}
}