1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Contains install and update functions for ctools.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Use requirements to ensure that the CTools CSS cache directory can be
|
10 |
|
|
* created and that the PHP version requirement is met.
|
11 |
|
|
*/
|
12 |
|
|
function ctools_requirements($phase) {
|
13 |
|
|
$requirements = array();
|
14 |
|
|
if ($phase == 'runtime') {
|
15 |
c304a780
|
Assos Assos
|
$t = get_t();
|
16 |
85ad3d82
|
Assos Assos
|
$requirements['ctools_css_cache'] = array(
|
17 |
c304a780
|
Assos Assos
|
'title' => $t('CTools CSS Cache'),
|
18 |
85ad3d82
|
Assos Assos
|
'severity' => REQUIREMENT_OK,
|
19 |
c304a780
|
Assos Assos
|
'value' => $t('Exists'),
|
20 |
85ad3d82
|
Assos Assos
|
);
|
21 |
|
|
|
22 |
|
|
$path = 'public://ctools/css';
|
23 |
|
|
if (!file_prepare_directory($path, FILE_CREATE_DIRECTORY)) {
|
24 |
c304a780
|
Assos Assos
|
$requirements['ctools_css_cache']['description'] = $t('The CTools CSS cache directory, %path could not be created due to a misconfigured files directory. Please ensure that the files directory is correctly configured and that the webserver has permission to create directories.', array('%path' => file_uri_target($path)));
|
25 |
85ad3d82
|
Assos Assos
|
$requirements['ctools_css_cache']['severity'] = REQUIREMENT_ERROR;
|
26 |
c304a780
|
Assos Assos
|
$requirements['ctools_css_cache']['value'] = $t('Unable to create');
|
27 |
85ad3d82
|
Assos Assos
|
}
|
28 |
|
|
|
29 |
|
|
if (!function_exists('error_get_last')) {
|
30 |
c304a780
|
Assos Assos
|
$requirements['ctools_php_52']['title'] = $t('CTools PHP requirements');
|
31 |
|
|
$requirements['ctools_php_52']['description'] = $t('CTools requires certain features only available in PHP 5.2.0 or higher.');
|
32 |
85ad3d82
|
Assos Assos
|
$requirements['ctools_php_52']['severity'] = REQUIREMENT_WARNING;
|
33 |
c304a780
|
Assos Assos
|
$requirements['ctools_php_52']['value'] = $t('PHP !version', array('!version' => phpversion()));
|
34 |
85ad3d82
|
Assos Assos
|
}
|
35 |
|
|
}
|
36 |
|
|
|
37 |
|
|
return $requirements;
|
38 |
|
|
}
|
39 |
|
|
|
40 |
|
|
/**
|
41 |
3753f249
|
Assos Assos
|
* Implements hook_schema().
|
42 |
85ad3d82
|
Assos Assos
|
*/
|
43 |
|
|
function ctools_schema() {
|
44 |
7e72b748
|
Assos Assos
|
return ctools_schema_4();
|
45 |
|
|
}
|
46 |
|
|
|
47 |
|
|
/**
|
48 |
|
|
* Version 4 of the CTools schema.
|
49 |
|
|
*/
|
50 |
|
|
function ctools_schema_4() {
|
51 |
|
|
$schema = ctools_schema_3();
|
52 |
|
|
|
53 |
c304a780
|
Assos Assos
|
// Removed due to alternative database configuration issues.
|
54 |
|
|
// @see https://www.drupal.org/project/ctools/issues/2941920
|
55 |
7e72b748
|
Assos Assos
|
|
56 |
|
|
return $schema;
|
57 |
e4c061ad
|
Assos Assos
|
}
|
58 |
|
|
|
59 |
|
|
/**
|
60 |
|
|
* Version 3 of the CTools schema.
|
61 |
|
|
*/
|
62 |
|
|
function ctools_schema_3() {
|
63 |
|
|
$schema = ctools_schema_2();
|
64 |
|
|
|
65 |
7e72b748
|
Assos Assos
|
// Update the 'obj' field to be 128 bytes long:
|
66 |
e4c061ad
|
Assos Assos
|
$schema['ctools_object_cache']['fields']['obj']['length'] = 128;
|
67 |
|
|
|
68 |
|
|
return $schema;
|
69 |
85ad3d82
|
Assos Assos
|
}
|
70 |
|
|
|
71 |
|
|
/**
|
72 |
|
|
* Version 2 of the CTools schema.
|
73 |
|
|
*/
|
74 |
|
|
function ctools_schema_2() {
|
75 |
|
|
$schema = ctools_schema_1();
|
76 |
|
|
|
77 |
7e72b748
|
Assos Assos
|
// Update the 'name' field to be 128 bytes long:
|
78 |
85ad3d82
|
Assos Assos
|
$schema['ctools_object_cache']['fields']['name']['length'] = 128;
|
79 |
|
|
|
80 |
|
|
// Update the 'data' field to be type 'blob'.
|
81 |
|
|
$schema['ctools_object_cache']['fields']['data'] = array(
|
82 |
|
|
'type' => 'blob',
|
83 |
|
|
'size' => 'big',
|
84 |
|
|
'description' => 'Serialized data being stored.',
|
85 |
|
|
'serialize' => TRUE,
|
86 |
|
|
);
|
87 |
|
|
|
88 |
|
|
// DO NOT MODIFY THIS TABLE -- this definition is used to create the table.
|
89 |
|
|
// Changes to this table must be made in schema_3 or higher.
|
90 |
|
|
$schema['ctools_css_cache'] = array(
|
91 |
|
|
'description' => 'A special cache used to store CSS that must be non-volatile.',
|
92 |
|
|
'fields' => array(
|
93 |
|
|
'cid' => array(
|
94 |
|
|
'type' => 'varchar',
|
95 |
|
|
'length' => '128',
|
96 |
|
|
'description' => 'The CSS ID this cache object belongs to.',
|
97 |
|
|
'not null' => TRUE,
|
98 |
|
|
),
|
99 |
|
|
'filename' => array(
|
100 |
|
|
'type' => 'varchar',
|
101 |
|
|
'length' => '255',
|
102 |
|
|
'description' => 'The filename this CSS is stored in.',
|
103 |
|
|
),
|
104 |
|
|
'css' => array(
|
105 |
|
|
'type' => 'text',
|
106 |
|
|
'size' => 'big',
|
107 |
|
|
'description' => 'CSS being stored.',
|
108 |
|
|
'serialize' => TRUE,
|
109 |
|
|
),
|
110 |
|
|
'filter' => array(
|
111 |
7e72b748
|
Assos Assos
|
'type' => 'int',
|
112 |
|
|
'size' => 'tiny',
|
113 |
|
|
'description' => 'Whether or not this CSS needs to be filtered.',
|
114 |
|
|
),
|
115 |
85ad3d82
|
Assos Assos
|
),
|
116 |
|
|
'primary key' => array('cid'),
|
117 |
|
|
);
|
118 |
|
|
|
119 |
|
|
return $schema;
|
120 |
|
|
}
|
121 |
|
|
|
122 |
|
|
/**
|
123 |
|
|
* CTools' initial schema; separated for the purposes of updates.
|
124 |
|
|
*
|
125 |
|
|
* DO NOT MAKE CHANGES HERE. This schema version is locked.
|
126 |
|
|
*/
|
127 |
|
|
function ctools_schema_1() {
|
128 |
|
|
$schema['ctools_object_cache'] = array(
|
129 |
|
|
'description' => t('A special cache used to store objects that are being edited; it serves to save state in an ordinarily stateless environment.'),
|
130 |
|
|
'fields' => array(
|
131 |
|
|
'sid' => array(
|
132 |
|
|
'type' => 'varchar',
|
133 |
|
|
'length' => '64',
|
134 |
|
|
'not null' => TRUE,
|
135 |
|
|
'description' => 'The session ID this cache object belongs to.',
|
136 |
|
|
),
|
137 |
|
|
'name' => array(
|
138 |
|
|
'type' => 'varchar',
|
139 |
|
|
'length' => '32',
|
140 |
|
|
'not null' => TRUE,
|
141 |
|
|
'description' => 'The name of the object this cache is attached to.',
|
142 |
|
|
),
|
143 |
|
|
'obj' => array(
|
144 |
|
|
'type' => 'varchar',
|
145 |
|
|
'length' => '32',
|
146 |
|
|
'not null' => TRUE,
|
147 |
|
|
'description' => 'The type of the object this cache is attached to; this essentially represents the owner so that several sub-systems can use this cache.',
|
148 |
|
|
),
|
149 |
|
|
'updated' => array(
|
150 |
|
|
'type' => 'int',
|
151 |
|
|
'unsigned' => TRUE,
|
152 |
|
|
'not null' => TRUE,
|
153 |
|
|
'default' => 0,
|
154 |
|
|
'description' => 'The time this cache was created or updated.',
|
155 |
|
|
),
|
156 |
|
|
'data' => array(
|
157 |
|
|
'type' => 'text',
|
158 |
|
|
'size' => 'big',
|
159 |
|
|
'description' => 'Serialized data being stored.',
|
160 |
|
|
'serialize' => TRUE,
|
161 |
|
|
),
|
162 |
|
|
),
|
163 |
|
|
'primary key' => array('sid', 'obj', 'name'),
|
164 |
|
|
'indexes' => array('updated' => array('updated')),
|
165 |
|
|
);
|
166 |
|
|
return $schema;
|
167 |
|
|
}
|
168 |
|
|
|
169 |
e4c061ad
|
Assos Assos
|
/**
|
170 |
|
|
* Implements hook_install().
|
171 |
|
|
*/
|
172 |
|
|
function ctools_install() {
|
173 |
|
|
// Activate our custom cache handler for the CSS cache.
|
174 |
|
|
variable_set('cache_class_cache_ctools_css', 'CToolsCssCache');
|
175 |
|
|
}
|
176 |
|
|
|
177 |
|
|
/**
|
178 |
|
|
* Implements hook_uninstall().
|
179 |
|
|
*/
|
180 |
|
|
function ctools_uninstall() {
|
181 |
|
|
variable_del('cache_class_cache_ctools_css');
|
182 |
|
|
}
|
183 |
|
|
|
184 |
85ad3d82
|
Assos Assos
|
/**
|
185 |
|
|
* Enlarge the ctools_object_cache.name column to prevent truncation and weird
|
186 |
|
|
* errors.
|
187 |
|
|
*/
|
188 |
|
|
function ctools_update_6001() {
|
189 |
|
|
// Perform updates like this to reduce code duplication.
|
190 |
|
|
$schema = ctools_schema_2();
|
191 |
|
|
|
192 |
|
|
db_change_field('ctools_object_cache', 'name', 'name', $schema['ctools_object_cache']['fields']['name']);
|
193 |
|
|
}
|
194 |
|
|
|
195 |
|
|
/**
|
196 |
|
|
* Add the new css cache table.
|
197 |
|
|
*/
|
198 |
|
|
function ctools_update_6002() {
|
199 |
|
|
// Schema 2 is locked and should not be changed.
|
200 |
|
|
$schema = ctools_schema_2();
|
201 |
|
|
|
202 |
|
|
db_create_table('ctools_css_cache', $schema['ctools_css_cache']);
|
203 |
|
|
}
|
204 |
|
|
|
205 |
|
|
/**
|
206 |
|
|
* Take over for the panels_views module if it was on.
|
207 |
|
|
*/
|
208 |
|
|
function ctools_update_6003() {
|
209 |
|
|
$result = db_query('SELECT status FROM {system} WHERE name = :name', array(':name' => 'panels_views'))->fetchField();
|
210 |
|
|
if ($result) {
|
211 |
|
|
db_delete('system')->condition('name', 'panels_views')->execute();
|
212 |
|
|
module_enable(array('views_content'), TRUE);
|
213 |
7e72b748
|
Assos Assos
|
}
|
214 |
85ad3d82
|
Assos Assos
|
}
|
215 |
|
|
|
216 |
|
|
/**
|
217 |
|
|
* Add primary key to the ctools_object_cache table.
|
218 |
|
|
*/
|
219 |
|
|
function ctools_update_6004() {
|
220 |
|
|
db_add_primary_key('ctools_object_cache', array('sid', 'obj', 'name'));
|
221 |
|
|
db_drop_index('ctools_object_cache', 'sid_obj_name');
|
222 |
|
|
}
|
223 |
|
|
|
224 |
|
|
/**
|
225 |
|
|
* Removed update.
|
226 |
|
|
*/
|
227 |
|
|
function ctools_update_6005() {
|
228 |
|
|
return array();
|
229 |
|
|
}
|
230 |
|
|
|
231 |
|
|
/**
|
232 |
7e72b748
|
Assos Assos
|
* The ctools_custom_content table was originally here, but is now moved to
|
233 |
85ad3d82
|
Assos Assos
|
* its own module.
|
234 |
|
|
*/
|
235 |
|
|
function ctools_update_6007() {
|
236 |
|
|
$ret = array();
|
237 |
|
|
if (db_table_exists('ctools_custom_content')) {
|
238 |
|
|
// Enable the module to make everything as seamless as possible.
|
239 |
|
|
module_enable(array('ctools_custom_content'), TRUE);
|
240 |
|
|
}
|
241 |
|
|
|
242 |
|
|
return $ret;
|
243 |
|
|
}
|
244 |
|
|
|
245 |
|
|
/**
|
246 |
7e72b748
|
Assos Assos
|
* The ctools_object_cache needs to be defined as a blob.
|
247 |
85ad3d82
|
Assos Assos
|
*/
|
248 |
|
|
function ctools_update_6008() {
|
249 |
|
|
db_delete('ctools_object_cache')
|
250 |
|
|
->execute();
|
251 |
|
|
|
252 |
|
|
db_change_field('ctools_object_cache', 'data', 'data', array(
|
253 |
7e72b748
|
Assos Assos
|
'type' => 'blob',
|
254 |
|
|
'size' => 'big',
|
255 |
|
|
'description' => 'Serialized data being stored.',
|
256 |
|
|
'serialize' => TRUE,
|
257 |
|
|
)
|
258 |
85ad3d82
|
Assos Assos
|
);
|
259 |
|
|
}
|
260 |
e4c061ad
|
Assos Assos
|
|
261 |
|
|
/**
|
262 |
|
|
* Enable the custom CSS cache handler.
|
263 |
|
|
*/
|
264 |
|
|
function ctools_update_7000() {
|
265 |
|
|
variable_set('cache_class_cache_ctools_css', 'CToolsCssCache');
|
266 |
|
|
}
|
267 |
|
|
|
268 |
|
|
/**
|
269 |
|
|
* Increase the length of the ctools_object_cache.obj column.
|
270 |
|
|
*/
|
271 |
|
|
function ctools_update_7001() {
|
272 |
|
|
db_change_field('ctools_object_cache', 'obj', 'obj', array(
|
273 |
|
|
'type' => 'varchar',
|
274 |
|
|
'length' => '128',
|
275 |
|
|
'not null' => TRUE,
|
276 |
|
|
'description' => 'The type of the object this cache is attached to; this essentially represents the owner so that several sub-systems can use this cache.',
|
277 |
|
|
));
|
278 |
|
|
}
|
279 |
7e72b748
|
Assos Assos
|
|
280 |
|
|
/**
|
281 |
|
|
* Increase the length of the ctools_object_cache.name column to 255.
|
282 |
|
|
*/
|
283 |
|
|
function ctools_update_7002() {
|
284 |
c304a780
|
Assos Assos
|
// Removed due to alternative database configuration issues.
|
285 |
|
|
// @see https://www.drupal.org/project/ctools/issues/2941920
|
286 |
|
|
}
|
287 |
|
|
|
288 |
|
|
/**
|
289 |
|
|
* Revert the length of the ctools_object_cache.name column back to 128.
|
290 |
|
|
*/
|
291 |
|
|
function ctools_update_7003() {
|
292 |
|
|
db_delete('ctools_object_cache')->execute();
|
293 |
7e72b748
|
Assos Assos
|
db_change_field('ctools_object_cache', 'name', 'name', array(
|
294 |
|
|
'type' => 'varchar',
|
295 |
c304a780
|
Assos Assos
|
'length' => '128',
|
296 |
7e72b748
|
Assos Assos
|
'not null' => TRUE,
|
297 |
c304a780
|
Assos Assos
|
'description' => 'The name of the object this cache is attached to.',
|
298 |
7e72b748
|
Assos Assos
|
));
|
299 |
|
|
} |