forked from alpacaaa/shorten
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextension.driver.php
executable file
·46 lines (40 loc) · 1.03 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
<?php
class extension_shorten extends Extension
{
public function getSubscribedDelegates()
{
return array(
array (
'page' =>'/frontend/',
'delegate' => 'EventFinalSaveFilter',
'callback' => 'cleanup'
)
);
}
public function uninstall()
{
Symphony::Database()->query("DROP TABLE `tbl_fields_shorten`");
}
public function install()
{
return Symphony::Database()->query(
"CREATE TABLE `tbl_fields_shorten` (
`id` int(11) unsigned NOT NULL auto_increment,
`field_id` int(11) unsigned NOT NULL,
`redirect` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`hide` ENUM('yes', 'no') DEFAULT 'no',
PRIMARY KEY (`id`),
KEY `field_id` (`field_id`)
) ENGINE=MyISAM;"
);
}
public function cleanup($context)
{
$section = SectionManager::fetch($context['entry']->get('section_id'));
$field = $section->fetchFields('shorten');
if (!$field) return;
$field = current($field);
$entry_id = $context['entry']->get('id');
$field->update($entry_id);
}
}