1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* Test requirements for installation and running.
|
5
|
*/
|
6
|
function panels_requirements($phase) {
|
7
|
$function = "panels_requirements_$phase";
|
8
|
return function_exists($function) ? $function() : array();
|
9
|
}
|
10
|
|
11
|
/**
|
12
|
* Check install-time requirements.
|
13
|
*/
|
14
|
function panels_requirements_install() {
|
15
|
$requirements = array();
|
16
|
$t = get_t();
|
17
|
// Assume that if the user is running an installation profile that both
|
18
|
// Panels and CTools are the same release.
|
19
|
if (!(defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'install')) {
|
20
|
// apparently the install process doesn't include .module files,
|
21
|
// so we need to force the issue in order for our versioning
|
22
|
// check to work.
|
23
|
if (!defined('PANELS_REQUIRED_CTOOLS_API')) {
|
24
|
include_once drupal_get_path('module', 'panels') . '/panels.module';
|
25
|
}
|
26
|
|
27
|
// In theory we should check module_exists, but Drupal's gating should
|
28
|
// actually prevent us from getting here otherwise.
|
29
|
if (!defined('CTOOLS_API_VERSION')) {
|
30
|
include_once drupal_get_path('module', 'ctools') . '/ctools.module';
|
31
|
}
|
32
|
if (!module_invoke('ctools', 'api_version', PANELS_REQUIRED_CTOOLS_API)) {
|
33
|
$requirements['panels_ctools'] = array(
|
34
|
'title' => $t('CTools API Version'),
|
35
|
'value' => CTOOLS_API_VERSION,
|
36
|
'severity' => REQUIREMENT_ERROR,
|
37
|
'description' => t('The CTools API version is too old for Panels. Panels needs at least %version.', array('%version' => PANELS_REQUIRED_CTOOLS_API))
|
38
|
);
|
39
|
}
|
40
|
}
|
41
|
return $requirements;
|
42
|
}
|
43
|
|
44
|
/**
|
45
|
* Implementation of hook_schema().
|
46
|
*/
|
47
|
function panels_schema() {
|
48
|
// This should always point to our 'current' schema. This makes it relatively easy
|
49
|
// to keep a record of schema as we make changes to it.
|
50
|
return panels_schema_4();
|
51
|
}
|
52
|
|
53
|
function panels_schema_4() {
|
54
|
$schema = panels_schema_3();
|
55
|
|
56
|
$schema['panels_pane']['fields']['locks'] = array(
|
57
|
'type' => 'text',
|
58
|
'size' => 'big',
|
59
|
'serialize' => TRUE,
|
60
|
'object default' => array(),
|
61
|
'initial' => array(),
|
62
|
);
|
63
|
|
64
|
return $schema;
|
65
|
}
|
66
|
|
67
|
/**
|
68
|
* Schema from the D6 version.
|
69
|
*/
|
70
|
function panels_schema_3() {
|
71
|
// Schema 3 is now locked. If you need to make changes, please create
|
72
|
// schema 4 and add them.
|
73
|
$schema = array();
|
74
|
|
75
|
$schema['panels_display'] = array(
|
76
|
'export' => array(
|
77
|
'object' => 'panels_display',
|
78
|
'bulk export' => FALSE,
|
79
|
'export callback' => 'panels_export_display',
|
80
|
'can disable' => FALSE,
|
81
|
'identifier' => 'display',
|
82
|
),
|
83
|
'fields' => array(
|
84
|
'did' => array(
|
85
|
'type' => 'serial',
|
86
|
'not null' => TRUE,
|
87
|
'no export' => TRUE,
|
88
|
),
|
89
|
'layout' => array(
|
90
|
'type' => 'varchar',
|
91
|
'length' => '255',
|
92
|
'default' => '',
|
93
|
),
|
94
|
'layout_settings' => array(
|
95
|
'type' => 'text',
|
96
|
'size' => 'big',
|
97
|
'serialize' => TRUE,
|
98
|
'object default' => array(),
|
99
|
'initial' => array(),
|
100
|
),
|
101
|
'panel_settings' => array(
|
102
|
'type' => 'text',
|
103
|
'size' => 'big',
|
104
|
'serialize' => TRUE,
|
105
|
'object default' => array(),
|
106
|
'initial' => array(),
|
107
|
),
|
108
|
'cache' => array(
|
109
|
'type' => 'text',
|
110
|
'serialize' => TRUE,
|
111
|
'object default' => array(),
|
112
|
'initial' => array(),
|
113
|
),
|
114
|
'title' => array(
|
115
|
'type' => 'varchar',
|
116
|
'length' => '255',
|
117
|
'default' => '',
|
118
|
),
|
119
|
'hide_title' => array(
|
120
|
'type' => 'int',
|
121
|
'size' => 'tiny',
|
122
|
'default' => 0,
|
123
|
'no export' => TRUE,
|
124
|
),
|
125
|
'title_pane' => array(
|
126
|
'type' => 'int',
|
127
|
'default' => 0,
|
128
|
'no export' => TRUE,
|
129
|
),
|
130
|
),
|
131
|
'primary key' => array('did'),
|
132
|
);
|
133
|
|
134
|
$schema['panels_pane'] = array(
|
135
|
'export' => array(
|
136
|
'can disable' => FALSE,
|
137
|
'identifier' => 'pane',
|
138
|
'bulk export' => FALSE,
|
139
|
),
|
140
|
'fields' => array(
|
141
|
'pid' => array(
|
142
|
'type' => 'serial',
|
143
|
'not null' => TRUE,
|
144
|
),
|
145
|
'did' => array(
|
146
|
'type' => 'int',
|
147
|
'not null' => TRUE,
|
148
|
'default' => 0,
|
149
|
'no export' => TRUE,
|
150
|
),
|
151
|
'panel' => array(
|
152
|
'type' => 'varchar',
|
153
|
'length' => '32',
|
154
|
'default' => '',
|
155
|
),
|
156
|
'type' => array(
|
157
|
'type' => 'varchar',
|
158
|
'length' => '32',
|
159
|
'default' => '',
|
160
|
),
|
161
|
'subtype' => array(
|
162
|
'type' => 'varchar',
|
163
|
'length' => '64',
|
164
|
'default' => '',
|
165
|
),
|
166
|
'shown' => array(
|
167
|
'type' => 'int',
|
168
|
'size' => 'tiny',
|
169
|
'default' => 1,
|
170
|
),
|
171
|
'access' => array(
|
172
|
'type' => 'text',
|
173
|
'size' => 'big',
|
174
|
'serialize' => TRUE,
|
175
|
'object default' => array(),
|
176
|
'initial' => array(),
|
177
|
),
|
178
|
'configuration' => array(
|
179
|
'type' => 'text',
|
180
|
'size' => 'big',
|
181
|
'serialize' => TRUE,
|
182
|
'object default' => array(),
|
183
|
'initial' => array(),
|
184
|
),
|
185
|
'cache' => array(
|
186
|
'type' => 'text',
|
187
|
'size' => 'big',
|
188
|
'serialize' => TRUE,
|
189
|
'object default' => array(),
|
190
|
'initial' => array(),
|
191
|
),
|
192
|
'style' => array(
|
193
|
'type' => 'text',
|
194
|
'size' => 'big',
|
195
|
'serialize' => TRUE,
|
196
|
'object default' => array(),
|
197
|
'initial' => array(),
|
198
|
),
|
199
|
'css' => array(
|
200
|
'type' => 'text',
|
201
|
'size' => 'big',
|
202
|
'serialize' => TRUE,
|
203
|
'object default' => array(),
|
204
|
'initial' => array(),
|
205
|
),
|
206
|
'extras' => array(
|
207
|
'type' => 'text',
|
208
|
'size' => 'big',
|
209
|
'serialize' => TRUE,
|
210
|
'object default' => array(),
|
211
|
'initial' => array(),
|
212
|
),
|
213
|
'position' => array(
|
214
|
'type' => 'int',
|
215
|
'size' => 'small',
|
216
|
'default' => 0,
|
217
|
),
|
218
|
),
|
219
|
'primary key' => array('pid'),
|
220
|
'indexes' => array(
|
221
|
'did_idx' => array('did')
|
222
|
),
|
223
|
);
|
224
|
|
225
|
$schema['panels_renderer_pipeline'] = array(
|
226
|
'description' => 'Contains renderer pipelines for Panels. Each pipeline contains one or more renderers and access rules to select which renderer gets used.',
|
227
|
'export' => array(
|
228
|
'identifier' => 'pipeline',
|
229
|
'bulk export' => TRUE,
|
230
|
'primary key' => 'rpid',
|
231
|
'api' => array(
|
232
|
'owner' => 'panels',
|
233
|
'api' => 'pipelines',
|
234
|
'minimum_version' => 1,
|
235
|
'current_version' => 1,
|
236
|
),
|
237
|
),
|
238
|
'fields' => array(
|
239
|
'rpid' => array(
|
240
|
'type' => 'serial',
|
241
|
'description' => 'A database primary key to ensure uniqueness.',
|
242
|
'not null' => TRUE,
|
243
|
'no export' => TRUE,
|
244
|
),
|
245
|
'name' => array(
|
246
|
'type' => 'varchar',
|
247
|
'length' => '255',
|
248
|
'description' => 'Unique ID for this content. Used to identify it programmatically.',
|
249
|
),
|
250
|
'admin_title' => array(
|
251
|
'type' => 'varchar',
|
252
|
'length' => '255',
|
253
|
'description' => 'Administrative title for this pipeline.',
|
254
|
),
|
255
|
'admin_description' => array(
|
256
|
'type' => 'text',
|
257
|
'size' => 'big',
|
258
|
'description' => 'Administrative description for this pipeline.',
|
259
|
'object default' => '',
|
260
|
),
|
261
|
'weight' => array(
|
262
|
'type' => 'int',
|
263
|
'size' => 'small',
|
264
|
'default' => 0,
|
265
|
),
|
266
|
'settings' => array(
|
267
|
'type' => 'text',
|
268
|
'size' => 'big',
|
269
|
'description' => 'Serialized settings for the actual pipeline. The contents of this field are up to the plugin that uses it.',
|
270
|
'serialize' => TRUE,
|
271
|
'object default' => array(),
|
272
|
),
|
273
|
),
|
274
|
'primary key' => array('rpid'),
|
275
|
);
|
276
|
|
277
|
$schema['panels_layout'] = array(
|
278
|
'description' => 'Contains exportable customized layouts for this site.',
|
279
|
'export' => array(
|
280
|
'identifier' => 'layout',
|
281
|
'bulk export' => TRUE,
|
282
|
'primary key' => 'lid',
|
283
|
'api' => array(
|
284
|
'owner' => 'panels',
|
285
|
'api' => 'layouts',
|
286
|
'minimum_version' => 1,
|
287
|
'current_version' => 1,
|
288
|
),
|
289
|
),
|
290
|
'fields' => array(
|
291
|
'lid' => array(
|
292
|
'type' => 'serial',
|
293
|
'description' => 'A database primary key to ensure uniqueness.',
|
294
|
'not null' => TRUE,
|
295
|
'no export' => TRUE,
|
296
|
),
|
297
|
'name' => array(
|
298
|
'type' => 'varchar',
|
299
|
'length' => '255',
|
300
|
'description' => 'Unique ID for this content. Used to identify it programmatically.',
|
301
|
),
|
302
|
'admin_title' => array(
|
303
|
'type' => 'varchar',
|
304
|
'length' => '255',
|
305
|
'description' => 'Administrative title for this layout.',
|
306
|
),
|
307
|
'admin_description' => array(
|
308
|
'type' => 'text',
|
309
|
'size' => 'big',
|
310
|
'description' => 'Administrative description for this layout.',
|
311
|
'object default' => '',
|
312
|
),
|
313
|
'category' => array(
|
314
|
'type' => 'varchar',
|
315
|
'length' => '255',
|
316
|
'description' => 'Administrative category for this layout.',
|
317
|
),
|
318
|
'plugin' => array(
|
319
|
'type' => 'varchar',
|
320
|
'length' => '255',
|
321
|
'description' => 'The layout plugin that owns this layout.',
|
322
|
),
|
323
|
'settings' => array(
|
324
|
'type' => 'text',
|
325
|
'size' => 'big',
|
326
|
'description' => 'Serialized settings for the actual layout. The contents of this field are up to the plugin that uses it.',
|
327
|
'serialize' => TRUE,
|
328
|
'object default' => array(),
|
329
|
),
|
330
|
),
|
331
|
'primary key' => array('lid'),
|
332
|
);
|
333
|
|
334
|
return $schema;
|
335
|
}
|
336
|
|
337
|
/**
|
338
|
* Change panels_display.layout to match the size of panels_layout.name.
|
339
|
*/
|
340
|
function panels_update_7300() {
|
341
|
// Load the schema.
|
342
|
$schema = panels_schema_3();
|
343
|
$table = 'panels_display';
|
344
|
$field = 'layout';
|
345
|
$spec = $schema[$table]['fields'][$field];
|
346
|
|
347
|
// Re-define the column.
|
348
|
db_change_field($table, $field, $field, $spec);
|
349
|
|
350
|
return t('Changed the panels_display.layout field to the correct size.');
|
351
|
}
|
352
|
|
353
|
/**
|
354
|
* Add lock field to panels_pane table.
|
355
|
*/
|
356
|
function panels_update_7301() {
|
357
|
// Load the schema.
|
358
|
|
359
|
// Due to a previous failure, the field may already exist:
|
360
|
|
361
|
$schema = panels_schema_4();
|
362
|
$table = 'panels_pane';
|
363
|
$field = 'locks';
|
364
|
|
365
|
if (!db_field_exists($table, $field)) {
|
366
|
$spec = $schema[$table]['fields'][$field];
|
367
|
|
368
|
// Core does not properly respect 'initial' and 'serialize'.
|
369
|
unset($spec['initial']);
|
370
|
|
371
|
// Re-define the column.
|
372
|
db_add_field($table, $field, $spec);
|
373
|
return t('Added panels_pane.lock field.');
|
374
|
}
|
375
|
|
376
|
return t('panels_pane.lock field already existed, update skipped.');
|
377
|
}
|