-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathextension.driver.php
198 lines (155 loc) · 4.84 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<?php
/*
Copyight: Deux Huit Huit 2012
Copyight: Solutions Nitriques 2011
License: MIT, see the LICENCE file
*/
if(!defined("__IN_SYMPHONY__")) die("<h2>Error</h2><p>You cannot directly access this file</p>");
require_once(EXTENSIONS . '/oembed_field/fields/field.oembed.php');
/**
*
* Embed Videos/Image Decorator/Extension
* Leverage oEmbed standard in Symphony CMS (http://oembed.com/)
* @author nicolas
*
*/
class extension_oembed_field extends Extension {
/**
* Name of the extension
* @var string
*/
const EXT_NAME = 'Field: oEmbed';
/**
*
* 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' => 'appendJS'
),
array(
'page' => '*',
'delegate' => 'AppendContentType',
'callback' => 'appendContentType'
)
);
}
/**
*
* Append the content type for the Content Field.
* @param array $context
*/
public function appendContentType(&$context) {
require_once __DIR__ . '/lib/oembed-content.php';
$context['items']->{'oembed'} = new OembedContentType();
}
/**
*
* Appends javascript file referneces into the head, if needed
* @param array $context
*/
public function appendJS(Array $context) {
// store de callback array localy
$c = Administration::instance()->getPageCallback();
// publish page, new or edit
if(isset($c['context']['section_handle']) && in_array($c['context']['page'], array('new', 'edit'))){
Administration::instance()->Page->addScriptToHead(
URL . '/extensions/oembed_field/assets/publish.oembed.js',
time(),
false
);
return;
}
// section page, new or edit
if($c['driver'] == 'blueprintssections') {
Administration::instance()->Page->addStylesheetToHead(
URL . '/extensions/oembed_field/assets/section.oembed.css',
'screen',
time() + 1,
false
);
return;
}
}
/* ********* INSTALL/UPDATE/UNISTALL ******* */
/**
* Creates the table needed for the settings of the field
*/
public function install() {
// pre v1.3.1
$create = FieldOembed::createFieldTable();
// v1.3.1
$unique = FieldOembed::updateFieldTable_Unique();
// v1.3.2
$thumbs = FieldOembed::updateFieldTable_Thumbs();
// v1.4
$params = FieldOembed::updateFieldTable_QueryParams();
// v1.6
$ssl = FieldOembed::updateFieldTable_ForceSSL();
// v1.7.3
$uniqueMedia = FieldOembed::updateFieldTable_UniqueMedia();
return $create && $unique && $thumbs && $params && $ssl && $uniqueMedia;
}
/**
* Creates the table needed for the settings of the field
*/
public function update($previousVersion = false) {
$ret = true;
// are we updating from lower than 1.3.1 ?
if ($ret && version_compare($previousVersion,'1.3.1') == -1) {
// update for unique setting
$ret_unique = FieldOembed::updateFieldTable_Unique();
// set the return value
$ret = $ret_unique;
}
// are we updating from lower than 1.3.2 ?
if ($ret && version_compare($previousVersion, '1.3.2') == -1) {
// update for the thumbs settings
$ret_thumbs = FieldOembed::updateFieldTable_Thumbs();
// v1.4
// update for the params settings
$ret_params = FieldOembed::updateFieldTable_QueryParams();
// update for the driver column && set all drivers as allowed by default
$ret_driver = FieldOembed::updateFieldTable_Driver() &&
FieldOembed::updateFieldData_Driver();
// set the return value
$ret = $ret_thumbs && $ret_params && $ret_driver;
}
// are we updating from lower or equal to 1.4 ?
if ($ret && version_compare($previousVersion, '1.4') < 1) {
// Fixes issue #22
$ret = FieldOembed::updateDataTable_Driver();
}
// are we updating from lower then 1.6 ?
if ($ret && version_compare($previousVersion, '1.6') < 0) {
$ret = FieldOembed::updateFieldTable_ForceSSL();
}
// are we updating from lower then 1.7.3 ?
if ($ret && version_compare($previousVersion, '1.7.3') < 0) {
$ret = FieldOembed::updateFieldTable_UniqueMedia();
}
// are we updating from lower then 1.8 ?
if ($ret && version_compare($previousVersion, '1.8') < 0) {
$ret = FieldOembed::updateFieldTable_UniqueKey();
}
// are we updating from lower then 1.8 ?
if ($ret && version_compare($previousVersion, '1.8') < 0) {
$ret = FieldOembed::updateDataTable_UniqueKey();
}
return $ret;
}
/**
*
* Drops the table needed for the settings of the field
*/
public function uninstall() {
// pre v1.3.2
$field = FieldOembed::deleteFieldTable();
return $field;
}
}