forked from DeuxHuitHuit/entry_relationship_field
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextension.driver.php
115 lines (99 loc) · 2.88 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
/*
Copyight: Deux Huit Huit 2014
LICENCE: MIT http://deuxhuithuit.mit-license.org;
*/
if(!defined("__IN_SYMPHONY__")) die("<h2>Error</h2><p>You cannot directly access this file</p>");
require_once(EXTENSIONS . '/entry_relationship_field/fields/field.entry_relationship.php');
/**
*
* @author Deux Huit Huit
* https://deuxhuithuit.com/
*
*/
class extension_entry_relationship_field extends Extension {
/**
* Name of the extension
* @var string
*/
const EXT_NAME = 'Entry Relationship Field';
/**
* Symphony utility function that permits to
* implement the Observer/Observable pattern.
* We register here delegate that will be fired by Symphony
*/
public function getSubscribedDelegates(){
return array(
array(
'page' => '/backend/',
'delegate' => 'InitaliseAdminPageHead',
'callback' => 'appendAssets'
)
);
}
/**
*
* Appends javascript file references into the head, if needed
* @param array $context
*/
public function appendAssets(array $context) {
// store the callback array locally
$c = Administration::instance()->getPageCallback();
// publish page
if($c['driver'] == 'publish') {
Administration::instance()->Page->addStylesheetToHead(
URL . '/extensions/entry_relationship_field/assets/publish.entry_relationship_field.css',
'screen',
time() + 1,
false
);
Administration::instance()->Page->addScriptToHead(
URL . '/extensions/entry_relationship_field/assets/publish.entry_relationship_field.js',
time(),
false
);
} else if ($c['driver'] == 'blueprintssections') {
Administration::instance()->Page->addStylesheetToHead(
URL . '/extensions/entry_relationship_field/assets/section.entry_relationship_field.css',
'screen',
time() + 1,
false
);
Administration::instance()->Page->addScriptToHead(
URL . '/extensions/entry_relationship_field/assets/section.entry_relationship_field.js',
time(),
false
);
}
}
/* ********* INSTALL/UPDATE/UNINSTALL ******* */
/**
* Creates the table needed for the settings of the field
*/
public function install() {
General::realiseDirectory(WORKSPACE . '/er-templates');
return FieldEntry_relationship::createFieldTable();
}
/**
* This method will update the extension according to the
* previous and current version parameters.
* @param string $previousVersion
*/
public function update($previousVersion = false) {
$ret = true;
if (!$previousVersion) {
$previousVersion = '0.0.1';
}
// less than 1.0.2
if ($ret && version_compare($previousVersion, '1.0.2') == -1) {
$ret = FieldEntry_relationship::update_102();
}
return $ret;
}
/**
* Drops the table needed for the settings of the field
*/
public function uninstall() {
return FieldEntry_relationship::deleteFieldTable();
}
}