-
Notifications
You must be signed in to change notification settings - Fork 1
/
extension.driver.php
71 lines (51 loc) · 1.92 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
if( !defined('__IN_SYMPHONY__') ) die('<h2>Symphony Error</h2><p>You cannot directly access this file</p>');
define_safe(UF_NAME, 'Field: URL');
define_safe(UF_GROUP, 'url_field');
class Extension_URL_Field extends Extension
{
public $field_table = 'tbl_fields_url';
protected static $assets_loaded = false;
/*------------------------------------------------------------------------------------------------*/
/* Installation */
/*------------------------------------------------------------------------------------------------*/
public function install(){
return Symphony::Database()->query(sprintf(
"CREATE TABLE `%s` (
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`field_id` INT(11) UNSIGNED NOT NULL,
`related_field_id` VARCHAR(255) NULL,
PRIMARY KEY (`id`),
KEY `field_id` (`field_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;",
$this->field_table
));
}
public function uninstall(){
try{
Symphony::Database()->query(sprintf(
"DROP TABLE `%s`",
$this->field_table
));
}
catch( DatabaseException $dbe ){
// table deosn't exist
}
}
/*------------------------------------------------------------------------------------------------*/
/* Utilities */
/*------------------------------------------------------------------------------------------------*/
public static function appendAssets(){
if(
!self::$assets_loaded
&& class_exists('Administration')
&& Administration::instance() instanceof Administration
&& Administration::instance()->Page instanceof HTMLPage
){
$page = Administration::instance()->Page;
$page->addStylesheetToHead(URL.'/extensions/'.UF_GROUP.'/assets/'.UF_GROUP.'.publish.css', 'screen', null, false);
$page->addScriptToHead(URL.'/extensions/'.UF_GROUP.'/assets/'.UF_GROUP.'.publish.js', null, false);
self::$assets_loaded = true;
}
}
}