1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
Copyight: Deux Huit Huit 2014 |
4
|
|
|
LICENCE: MIT https://deuxhuithuit.mit-license.org |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
if(!defined("__IN_SYMPHONY__")) die("<h2>Error</h2><p>You cannot directly access this file</p>"); |
8
|
|
|
|
9
|
|
|
require_once(EXTENSIONS . '/entry_relationship_field/fields/field.entry_relationship.php'); |
10
|
|
|
require_once(EXTENSIONS . '/entry_relationship_field/fields/field.reverse_relationship.php'); |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* |
14
|
|
|
* @author Deux Huit Huit |
15
|
|
|
* https://deuxhuithuit.com/ |
16
|
|
|
* |
17
|
|
|
*/ |
18
|
|
|
class extension_entry_relationship_field extends Extension { |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Name of the extension |
22
|
|
|
* @var string |
23
|
|
|
*/ |
24
|
|
|
const EXT_NAME = 'Entry Relationship Field'; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Symphony utility function that permits to |
28
|
|
|
* implement the Observer/Observable pattern. |
29
|
|
|
* We register here delegate that will be fired by Symphony |
30
|
|
|
*/ |
31
|
|
|
|
32
|
|
|
public function getSubscribedDelegates(){ |
33
|
|
|
return array( |
34
|
|
|
array( |
35
|
|
|
'page' => '/backend/', |
36
|
|
|
'delegate' => 'InitaliseAdminPageHead', |
37
|
|
|
'callback' => 'appendAssets' |
38
|
|
|
) |
39
|
|
|
); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Delegate fired to add a link to Cache Management |
44
|
|
|
*/ |
45
|
|
|
public function fetchNavigation() { |
46
|
|
|
if (is_callable(array('Symphony', 'Author'))) { |
47
|
|
|
$author = Symphony::Author(); |
48
|
|
|
} else { |
49
|
|
|
$author = Administration::instance()->Author; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
// Work around single group limit in nav |
53
|
|
|
$group = $author->isDeveloper() ? 'developer' : 'manager'; |
54
|
|
|
|
55
|
|
|
return array( |
56
|
|
|
array ( |
57
|
|
|
'location' => __('System'), |
58
|
|
|
'name' => __('ERF Clean up'), |
59
|
|
|
'link' => 'cleanup', |
60
|
|
|
'limit' => $group, |
61
|
|
|
) // nav group |
62
|
|
|
); // nav |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* |
67
|
|
|
* Appends javascript file references into the head, if needed |
68
|
|
|
* @param array $context |
69
|
|
|
*/ |
70
|
|
|
public function appendAssets(array $context) { |
71
|
|
|
// store the callback array locally |
72
|
|
|
$c = Administration::instance()->getPageCallback(); |
73
|
|
|
|
74
|
|
|
// publish page |
75
|
|
|
if($c['driver'] == 'publish') { |
76
|
|
|
Administration::instance()->Page->addStylesheetToHead( |
77
|
|
|
URL . '/extensions/entry_relationship_field/assets/publish.entry_relationship_field.css', |
78
|
|
|
'screen', |
79
|
|
|
time() + 1, |
80
|
|
|
false |
81
|
|
|
); |
82
|
|
|
Administration::instance()->Page->addScriptToHead( |
83
|
|
|
URL . '/extensions/entry_relationship_field/assets/publish.entry_relationship_field.js', |
84
|
|
|
10, |
85
|
|
|
false |
86
|
|
|
); |
87
|
|
|
|
88
|
|
|
} else if ($c['driver'] == 'blueprintssections') { |
89
|
|
|
Administration::instance()->Page->addStylesheetToHead( |
90
|
|
|
URL . '/extensions/entry_relationship_field/assets/section.entry_relationship_field.css', |
91
|
|
|
'screen', |
92
|
|
|
time() + 1, |
93
|
|
|
false |
94
|
|
|
); |
95
|
|
|
Administration::instance()->Page->addScriptToHead( |
96
|
|
|
URL . '/extensions/entry_relationship_field/assets/section.entry_relationship_field.js', |
97
|
|
|
time(), |
98
|
|
|
false |
99
|
|
|
); |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/* ********* INSTALL/UPDATE/UNINSTALL ******* */ |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Creates the table needed for the settings of the field |
107
|
|
|
*/ |
108
|
|
|
public function install() { |
109
|
|
|
General::realiseDirectory(WORKSPACE . '/er-templates'); |
110
|
|
|
return FieldEntry_Relationship::createFieldTable() && FieldReverse_Relationship::createFieldTable(); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* This method will update the extension according to the |
115
|
|
|
* previous and current version parameters. |
116
|
|
|
* @param string $previousVersion |
117
|
|
|
*/ |
118
|
|
|
public function update($previousVersion = false) { |
119
|
|
|
$ret = true; |
120
|
|
|
|
121
|
|
|
if (!$previousVersion) { |
|
|
|
|
122
|
|
|
$previousVersion = '0.0.1'; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
// less than 1.0.2 |
126
|
|
|
if ($ret && version_compare($previousVersion, '1.0.2', '<')) { |
127
|
|
|
$ret = FieldEntry_Relationship::update_102(); |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
// less than 1.0.3 |
131
|
|
|
if ($ret && version_compare($previousVersion, '1.0.3', '<')) { |
132
|
|
|
$ret = FieldEntry_Relationship::update_103(); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
// less than 2.0.0.beta5 |
136
|
|
|
if ($ret && version_compare($previousVersion, '2.0.0.beta5', '<')) { |
137
|
|
|
$ret = FieldEntry_Relationship::update_200(); |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
// less than 2.0.0.beta6 |
141
|
|
|
if ($ret && version_compare($previousVersion, '2.0.0.beta6', '<')) { |
142
|
|
|
$ret = FieldReverse_Relationship::update_200(); |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
// less than 2.0.0.beta8 |
146
|
|
|
if ($ret && version_compare($previousVersion, '2.0.0.beta8', '<')) { |
147
|
|
|
$ret = FieldEntry_Relationship::update_2008(); |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
// less than 2.1.0 |
151
|
|
|
if ($ret && version_compare($previousVersion, '2.1.0', '<')) { |
152
|
|
|
$ret = FieldReverse_Relationship::update_210(); |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
return $ret; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* Drops the table needed for the settings of the field |
160
|
|
|
*/ |
161
|
|
|
public function uninstall() { |
162
|
|
|
return FieldEntry_Relationship::deleteFieldTable() && FieldReverse_Relationship::deleteFieldTable(); |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
} |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: