1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
* @file
|
4 |
|
|
* Install, update and uninstall functions for the panelizer module.
|
5 |
|
|
*/
|
6 |
|
|
|
7 |
|
|
/**
|
8 |
|
|
* Implements hook_schema().
|
9 |
|
|
*/
|
10 |
|
|
function panelizer_schema() {
|
11 |
|
|
// This should always point to our 'current' schema. This makes it
|
12 |
|
|
// relatively easy to keep a record of schema as we make changes to it.
|
13 |
|
|
return panelizer_schema_3();
|
14 |
|
|
}
|
15 |
|
|
|
16 |
|
|
/**
|
17 |
|
|
* Schema version 1 for Panels in D6.
|
18 |
|
|
*/
|
19 |
|
|
function panelizer_schema_1() {
|
20 |
|
|
$schema = array();
|
21 |
|
|
|
22 |
|
|
$common_fields = array(
|
23 |
|
|
'no_blocks' => array(
|
24 |
|
|
'type' => 'int',
|
25 |
|
|
'size' => 'tiny',
|
26 |
|
|
'description' => 'Whether or not the node disable sidebar blocks.',
|
27 |
|
|
'default' => 0,
|
28 |
|
|
),
|
29 |
|
|
'css_id' => array(
|
30 |
|
|
'type' => 'varchar',
|
31 |
|
|
'length' => '255',
|
32 |
|
|
'description' => 'The CSS ID this panel should use.',
|
33 |
|
|
'default' => '',
|
34 |
|
|
),
|
35 |
|
|
'css' => array(
|
36 |
|
|
'type' => 'text',
|
37 |
|
|
'size' => 'big',
|
38 |
|
|
'description' => 'Any CSS the author provided for the panel.',
|
39 |
|
|
'object default' => '',
|
40 |
|
|
),
|
41 |
|
|
'pipeline' => array(
|
42 |
|
|
'type' => 'varchar',
|
43 |
|
|
'length' => '255',
|
44 |
|
|
'description' => 'The render pipeline this panel uses.',
|
45 |
|
|
'default' => 'standard',
|
46 |
|
|
),
|
47 |
|
|
'contexts' => array(
|
48 |
|
|
'type' => 'text',
|
49 |
|
|
'size' => 'big',
|
50 |
|
|
'description' => 'The contexts configured by the node author.',
|
51 |
|
|
'serialize' => TRUE,
|
52 |
|
|
'object default' => array(),
|
53 |
|
|
),
|
54 |
|
|
'relationships' => array(
|
55 |
|
|
'type' => 'text',
|
56 |
|
|
'size' => 'big',
|
57 |
|
|
'description' => 'The relationship contexts configured by the node author.',
|
58 |
|
|
'serialize' => TRUE,
|
59 |
|
|
'object default' => array(),
|
60 |
|
|
),
|
61 |
|
|
'did' => array(
|
62 |
|
|
'type' => 'int',
|
63 |
|
|
'not null' => TRUE,
|
64 |
|
|
'description' => 'The display ID of the panel.',
|
65 |
|
|
'no export' => TRUE,
|
66 |
|
|
),
|
67 |
|
|
);
|
68 |
|
|
|
69 |
|
|
$schema['panelizer_entity'] = array(
|
70 |
|
|
'export' => array(
|
71 |
|
|
'bulk export' => FALSE,
|
72 |
|
|
'can disable' => FALSE,
|
73 |
|
|
'identifier' => 'panelizer_node',
|
74 |
|
|
),
|
75 |
|
|
'description' => 'Node panelizer references.',
|
76 |
|
|
'fields' => array(
|
77 |
|
|
'entity_type' => array(
|
78 |
|
|
'description' => 'The type of the entity this panel is attached to.',
|
79 |
|
|
'type' => 'varchar',
|
80 |
|
|
'length' => 128,
|
81 |
|
|
'not null' => TRUE,
|
82 |
|
|
),
|
83 |
|
|
'entity_id' => array(
|
84 |
|
|
'type' => 'int',
|
85 |
|
|
'not null' => TRUE,
|
86 |
|
|
'default' => 0,
|
87 |
|
|
'description' => 'The entity ID this panel is attached to.',
|
88 |
|
|
),
|
89 |
|
|
'revision_id' => array(
|
90 |
|
|
'description' => 'The revision id of the entity.',
|
91 |
|
|
'type' => 'int',
|
92 |
|
|
'unsigned' => TRUE,
|
93 |
|
|
'not null' => TRUE,
|
94 |
|
|
),
|
95 |
|
|
'name' => array(
|
96 |
|
|
'type' => 'varchar',
|
97 |
|
|
'length' => '255',
|
98 |
|
|
'description' => 'The name of the default being used if there is one.',
|
99 |
|
|
),
|
100 |
|
|
) + $common_fields,
|
101 |
|
|
'primary key' => array('entity_type', 'entity_id', 'revision_id', 'view_mode'),
|
102 |
|
|
);
|
103 |
|
|
|
104 |
|
|
$schema['panelizer_defaults'] = array(
|
105 |
|
|
'description' => 'Node type panelizer references.',
|
106 |
|
|
'export' => array(
|
107 |
|
|
'primary key' => 'pnid',
|
108 |
|
|
'key' => 'name',
|
109 |
|
|
'key name' => 'Name',
|
110 |
|
|
'admin_title' => 'title',
|
111 |
|
|
'identifier' => 'panelizer',
|
112 |
|
|
'default hook' => 'panelizer_defaults',
|
113 |
|
|
'api' => array(
|
114 |
|
|
'owner' => 'panelizer',
|
115 |
|
|
'api' => 'panelizer',
|
116 |
|
|
'minimum_version' => 1,
|
117 |
|
|
'current_version' => 1,
|
118 |
|
|
),
|
119 |
|
|
// 'create callback' => 'panelizer_export_create_callback',
|
120 |
|
|
'save callback' => 'panelizer_export_save_callback',
|
121 |
|
|
'export callback' => 'panelizer_export_export_callback',
|
122 |
|
|
'delete callback' => 'panelizer_export_delete_callback',
|
123 |
|
|
'subrecords callback' => 'panelizer_export_delete_callback_subrecords',
|
124 |
|
|
),
|
125 |
|
|
'fields' => array(
|
126 |
|
|
'pnid' => array(
|
127 |
|
|
'type' => 'serial',
|
128 |
|
|
'description' => 'The database primary key.',
|
129 |
|
|
'no export' => TRUE,
|
130 |
|
|
'not null' => TRUE,
|
131 |
|
|
),
|
132 |
|
|
'name' => array(
|
133 |
|
|
'type' => 'varchar',
|
134 |
|
|
'length' => '255',
|
135 |
|
|
'description' => 'The unique name of this default.',
|
136 |
|
|
),
|
137 |
|
|
'title' => array(
|
138 |
|
|
'type' => 'varchar',
|
139 |
|
|
'length' => '255',
|
140 |
|
|
'description' => 'The human readable title of this default.',
|
141 |
|
|
),
|
142 |
|
|
'panelizer_type' => array(
|
143 |
|
|
'type' => 'varchar',
|
144 |
|
|
'length' => '32',
|
145 |
|
|
'description' => 'The panelizer entity type, such as node or user.',
|
146 |
|
|
),
|
147 |
|
|
'panelizer_key' => array(
|
148 |
|
|
'type' => 'varchar',
|
149 |
|
|
'length' => '128',
|
150 |
|
|
'description' => 'The panelizer entity bundle.',
|
151 |
|
|
),
|
152 |
|
|
) + $common_fields,
|
153 |
|
|
'primary key' => array('pnid'),
|
154 |
|
|
'indexes' => array(
|
155 |
|
|
'name' => array('name'),
|
156 |
|
|
'type_key' => array('panelizer_type', 'panelizer_key'),
|
157 |
|
|
),
|
158 |
|
|
);
|
159 |
|
|
|
160 |
|
|
return $schema;
|
161 |
|
|
}
|
162 |
|
|
|
163 |
|
|
function panelizer_schema_2() {
|
164 |
|
|
$schema = panelizer_schema_1();
|
165 |
|
|
$schema['panelizer_defaults']['fields']['access'] = array(
|
166 |
|
|
'type' => 'text',
|
167 |
|
|
'size' => 'big',
|
168 |
|
|
'description' => 'Contains the access control for editing this default.',
|
169 |
|
|
'serialize' => TRUE,
|
170 |
|
|
'object default' => array(),
|
171 |
|
|
);
|
172 |
|
|
|
173 |
|
|
$schema['panelizer_defaults']['fields']['view_mode'] = array(
|
174 |
|
|
'type' => 'varchar',
|
175 |
|
|
'length' => '128',
|
176 |
|
|
'description' => 'Contains the view mode this panelizer is for.',
|
177 |
|
|
);
|
178 |
|
|
|
179 |
|
|
$schema['panelizer_entity']['fields']['view_mode'] = array(
|
180 |
|
|
'type' => 'varchar',
|
181 |
|
|
'length' => '128',
|
182 |
|
|
'description' => 'Contains the view mode this panelizer is for.',
|
183 |
|
|
);
|
184 |
|
|
|
185 |
|
|
$schema['panelizer_entity']['fields']['css_class'] = array(
|
186 |
|
|
'type' => 'varchar',
|
187 |
|
|
'length' => '255',
|
188 |
|
|
'description' => 'The CSS class this panel should use.',
|
189 |
|
|
'default' => '',
|
190 |
|
|
);
|
191 |
|
|
|
192 |
|
|
$schema['panelizer_defaults']['fields']['css_class'] = array(
|
193 |
|
|
'type' => 'varchar',
|
194 |
|
|
'length' => '255',
|
195 |
|
|
'description' => 'The CSS class this panel should use.',
|
196 |
|
|
'default' => '',
|
197 |
|
|
);
|
198 |
|
|
|
199 |
|
|
$schema['panelizer_entity']['fields']['title_element'] = array(
|
200 |
|
|
'type' => 'varchar',
|
201 |
|
|
'length' => '255',
|
202 |
|
|
'description' => 'The HTML element the title should use.',
|
203 |
|
|
'default' => 'H2',
|
204 |
|
|
);
|
205 |
|
|
|
206 |
|
|
$schema['panelizer_defaults']['fields']['title_element'] = array(
|
207 |
|
|
'type' => 'varchar',
|
208 |
|
|
'length' => '255',
|
209 |
|
|
'description' => 'The HTML element the title should use.',
|
210 |
|
|
'default' => 'H2',
|
211 |
|
|
);
|
212 |
|
|
|
213 |
|
|
$schema['panelizer_entity']['fields']['link_to_entity'] = array(
|
214 |
|
|
'type' => 'int',
|
215 |
|
|
'size' => 'tiny',
|
216 |
|
|
'description' => 'Whether or not the title should link to the entity.',
|
217 |
|
|
'default' => 1,
|
218 |
|
|
);
|
219 |
|
|
|
220 |
|
|
$schema['panelizer_defaults']['fields']['link_to_entity'] = array(
|
221 |
|
|
'type' => 'int',
|
222 |
|
|
'size' => 'tiny',
|
223 |
|
|
'description' => 'Whether or not the title should link to the entity.',
|
224 |
|
|
'default' => 1,
|
225 |
|
|
);
|
226 |
|
|
|
227 |
|
|
return $schema;
|
228 |
|
|
}
|
229 |
|
|
|
230 |
|
|
function panelizer_schema_3() {
|
231 |
|
|
$schema = panelizer_schema_2();
|
232 |
|
|
$schema['panelizer_defaults']['fields']['extra'] = array(
|
233 |
|
|
'type' => 'text',
|
234 |
|
|
'size' => 'big',
|
235 |
|
|
'description' => 'Contains extra data that can be added by modules.',
|
236 |
|
|
'serialize' => TRUE,
|
237 |
|
|
'object default' => array(),
|
238 |
|
|
);
|
239 |
|
|
|
240 |
|
|
$schema['panelizer_entity']['fields']['extra'] = array(
|
241 |
|
|
'type' => 'text',
|
242 |
|
|
'size' => 'big',
|
243 |
|
|
'description' => 'Contains extra data that can be added by modules.',
|
244 |
|
|
'serialize' => TRUE,
|
245 |
|
|
'object default' => array(),
|
246 |
|
|
);
|
247 |
|
|
|
248 |
|
|
return $schema;
|
249 |
|
|
}
|
250 |
|
|
|
251 |
|
|
/**
|
252 |
|
|
* Implements hook_install().
|
253 |
|
|
*/
|
254 |
|
|
function panelizer_install() {
|
255 |
|
|
// Set the module weight so it can execute after Panels.
|
256 |
|
|
db_update('system')
|
257 |
|
|
->fields(array(
|
258 |
|
|
'weight' => 21,
|
259 |
|
|
))
|
260 |
|
|
->condition('name', 'panelizer')
|
261 |
|
|
->execute();
|
262 |
|
|
}
|
263 |
|
|
|
264 |
|
|
/**
|
265 |
|
|
* Implements hook_uninstall().
|
266 |
|
|
*/
|
267 |
|
|
function panelizer_uninstall() {
|
268 |
|
|
db_delete('variable')
|
269 |
|
|
->condition('name', 'panelizer_defaults_%')
|
270 |
|
|
->execute();
|
271 |
|
|
db_delete('variable')
|
272 |
|
|
->condition('name', 'panelizer_node:%')
|
273 |
|
|
->execute();
|
274 |
|
|
}
|
275 |
|
|
|
276 |
|
|
/**
|
277 |
|
|
* Update the panelizer variable to be more feature module friendly.
|
278 |
|
|
*/
|
279 |
|
|
function panelizer_update_7100() {
|
280 |
|
|
$panelizer_defaults = variable_get('panelizer_defaults', array());
|
281 |
|
|
|
282 |
|
|
if (!empty($panelizer_defaults)) {
|
283 |
|
|
foreach ($panelizer_defaults as $entity => $bundles) {
|
284 |
|
|
foreach ($bundles as $bundle => $values) {
|
285 |
|
|
variable_set('panelizer_defaults_' . $entity . '_' . $bundle, $values);
|
286 |
|
|
}
|
287 |
|
|
}
|
288 |
|
|
}
|
289 |
|
|
|
290 |
|
|
variable_del('panelizer_defaults');
|
291 |
|
|
return t('Updated panelizer variables.');
|
292 |
|
|
}
|
293 |
|
|
|
294 |
|
|
/**
|
295 |
|
|
* Update the panelizer node table to be the panelizer entity table.
|
296 |
|
|
*/
|
297 |
|
|
function panelizer_update_7101() {
|
298 |
|
|
// Rename the table.
|
299 |
|
|
db_rename_table('panelizer_node', 'panelizer_entity');
|
300 |
|
|
|
301 |
|
|
// Remove the primary key.
|
302 |
|
|
db_drop_primary_key('panelizer_entity');
|
303 |
|
|
|
304 |
|
|
// Add the entity type.
|
305 |
|
|
$entity_type = array(
|
306 |
|
|
'description' => 'The type of the entity this panel is attached to.',
|
307 |
|
|
'type' => 'varchar',
|
308 |
|
|
'length' => 255,
|
309 |
|
|
);
|
310 |
|
|
|
311 |
|
|
db_add_field('panelizer_entity', 'entity_type', $entity_type);
|
312 |
|
|
|
313 |
|
|
// Rename nid to entity_id.
|
314 |
|
|
$entity_id = array(
|
315 |
|
|
'type' => 'int',
|
316 |
|
|
'not null' => TRUE,
|
317 |
|
|
'default' => 0,
|
318 |
|
|
'description' => 'The entity ID this panel is attached to.',
|
319 |
|
|
);
|
320 |
|
|
|
321 |
|
|
db_change_field('panelizer_entity', 'nid', 'entity_id', $entity_id);
|
322 |
|
|
|
323 |
|
|
// Update the entity_type field to 'node' since all pre-existing
|
324 |
|
|
// panelizer objects are nodes.
|
325 |
|
|
db_update('panelizer_entity')
|
326 |
|
|
->fields(array('entity_type' => 'node'))
|
327 |
|
|
->execute();
|
328 |
|
|
|
329 |
|
|
// Add the new index
|
330 |
|
|
db_add_primary_key('panelizer_entity', array('entity_type', 'entity_id'));
|
331 |
|
|
}
|
332 |
|
|
|
333 |
|
|
/**
|
334 |
|
|
* Add revision support.
|
335 |
|
|
*/
|
336 |
|
|
function panelizer_update_7102() {
|
337 |
|
|
// Remove the primary key.
|
338 |
|
|
db_drop_primary_key('panelizer_entity');
|
339 |
|
|
|
340 |
|
|
// Add the entity type.
|
341 |
|
|
$revision_id = array(
|
342 |
|
|
'description' => 'The revision id of the entity.',
|
343 |
|
|
'type' => 'int',
|
344 |
|
|
'unsigned' => TRUE,
|
345 |
|
|
);
|
346 |
|
|
|
347 |
|
|
db_add_field('panelizer_entity', 'revision_id', $revision_id);
|
348 |
|
|
|
349 |
|
|
db_query("UPDATE {panelizer_entity} pe LEFT JOIN {node} n ON pe.entity_id = n.nid SET pe.revision_id = n.vid");
|
350 |
|
|
|
351 |
|
|
// Add the new index
|
352 |
|
|
db_add_primary_key('panelizer_entity', array('entity_type', 'entity_id', 'revision_id'));
|
353 |
|
|
|
354 |
|
|
return t('Added revision support.');
|
355 |
|
|
}
|
356 |
|
|
|
357 |
|
|
/**
|
358 |
|
|
* Set primary keys to NOT NULL.
|
359 |
|
|
*/
|
360 |
|
|
function panelizer_update_7103() {
|
361 |
|
|
$schema = panelizer_schema_1();
|
362 |
|
|
|
363 |
|
|
db_change_field('panelizer_entity', 'entity_type', 'entity_type', $schema['panelizer_entity']['fields']['entity_type']);
|
364 |
|
|
db_change_field('panelizer_entity', 'revision_id', 'revision_id', $schema['panelizer_entity']['fields']['revision_id']);
|
365 |
|
|
db_change_field('panelizer_defaults', 'pnid', 'pnid', $schema['panelizer_defaults']['fields']['pnid']);
|
366 |
|
|
}
|
367 |
|
|
|
368 |
|
|
/**
|
369 |
|
|
* Add the access field.
|
370 |
|
|
*/
|
371 |
|
|
function panelizer_update_7104() {
|
372 |
|
|
$schema = panelizer_schema_2();
|
373 |
|
|
$access = $schema['panelizer_defaults']['fields']['access'];
|
374 |
|
|
db_add_field('panelizer_defaults', 'access', $access);
|
375 |
|
|
}
|
376 |
|
|
|
377 |
|
|
/**
|
378 |
|
|
* Add the view mode field.
|
379 |
|
|
*/
|
380 |
|
|
function panelizer_update_7105() {
|
381 |
|
|
$schema = panelizer_schema_2();
|
382 |
|
|
$view_mode = $schema['panelizer_defaults']['fields']['view_mode'];
|
383 |
|
|
db_add_field('panelizer_defaults', 'view_mode', $view_mode);
|
384 |
|
|
$view_mode = $schema['panelizer_entity']['fields']['view_mode'];
|
385 |
|
|
db_add_field('panelizer_entity', 'view_mode', $view_mode);
|
386 |
|
|
|
387 |
|
|
db_update('panelizer_defaults')
|
388 |
|
|
->fields(array(
|
389 |
|
|
'view_mode' => 'page_manager',
|
390 |
|
|
))
|
391 |
|
|
->execute();
|
392 |
|
|
|
393 |
|
|
db_update('panelizer_entity')
|
394 |
|
|
->fields(array(
|
395 |
|
|
'view_mode' => 'page_manager',
|
396 |
|
|
))
|
397 |
|
|
->execute();
|
398 |
|
|
}
|
399 |
|
|
|
400 |
|
|
/**
|
401 |
|
|
* Add the view mode to the primary key for the panelizer_entity table.
|
402 |
|
|
*/
|
403 |
|
|
function panelizer_update_7106() {
|
404 |
|
|
// Remove the primary key.
|
405 |
|
|
db_drop_primary_key('panelizer_entity');
|
406 |
|
|
|
407 |
|
|
// Add the new index
|
408 |
|
|
db_add_primary_key('panelizer_entity', array('entity_type', 'entity_id', 'revision_id', 'view_mode'));
|
409 |
|
|
|
410 |
|
|
return t('Added revision support.');
|
411 |
|
|
}
|
412 |
|
|
|
413 |
|
|
/**
|
414 |
|
|
* Add the css class and element title fields.
|
415 |
|
|
*/
|
416 |
|
|
function panelizer_update_7107() {
|
417 |
|
|
$schema = panelizer_schema_2();
|
418 |
|
|
$css_class = $schema['panelizer_defaults']['fields']['css_class'];
|
419 |
|
|
db_add_field('panelizer_defaults', 'css_class', $css_class);
|
420 |
|
|
$css_class = $schema['panelizer_entity']['fields']['css_class'];
|
421 |
|
|
db_add_field('panelizer_entity', 'css_class', $css_class);
|
422 |
|
|
|
423 |
|
|
$title_element = $schema['panelizer_defaults']['fields']['title_element'];
|
424 |
|
|
db_add_field('panelizer_defaults', 'title_element', $title_element);
|
425 |
|
|
$title_element = $schema['panelizer_entity']['fields']['title_element'];
|
426 |
|
|
db_add_field('panelizer_entity', 'title_element', $title_element);
|
427 |
|
|
}
|
428 |
|
|
|
429 |
|
|
/**
|
430 |
|
|
* Add the link_to_entity field
|
431 |
|
|
*/
|
432 |
|
|
function panelizer_update_7108() {
|
433 |
|
|
$schema = panelizer_schema_2();
|
434 |
|
|
$link_to_entity = $schema['panelizer_defaults']['fields']['link_to_entity'];
|
435 |
|
|
db_add_field('panelizer_defaults', 'link_to_entity', $link_to_entity);
|
436 |
|
|
$link_to_entity = $schema['panelizer_entity']['fields']['link_to_entity'];
|
437 |
|
|
db_add_field('panelizer_entity', 'link_to_entity', $link_to_entity);
|
438 |
|
|
}
|
439 |
|
|
|
440 |
|
|
/**
|
441 |
|
|
* Add the extra field so that modules can extend panelizer more easily.
|
442 |
|
|
*/
|
443 |
|
|
function panelizer_update_7109() {
|
444 |
|
|
$schema = panelizer_schema_3();
|
445 |
|
|
$extra = $schema['panelizer_defaults']['fields']['extra'];
|
446 |
|
|
db_add_field('panelizer_defaults', 'extra', $extra);
|
447 |
|
|
$extra = $schema['panelizer_entity']['fields']['extra'];
|
448 |
|
|
db_add_field('panelizer_entity', 'extra', $extra);
|
449 |
|
|
}
|
450 |
|
|
|
451 |
|
|
/**
|
452 |
|
|
* Changing the size of the entity_type field of panelizer_entity.
|
453 |
|
|
*/
|
454 |
|
|
function panelizer_update_7110() {
|
455 |
|
|
db_drop_primary_key('panelizer_entity');
|
456 |
|
|
db_change_field('panelizer_entity', 'entity_type', 'entity_type',
|
457 |
|
|
array(
|
458 |
|
|
'description' => 'The type of the entity this panel is attached to.',
|
459 |
|
|
'type' => 'varchar',
|
460 |
|
|
'length' => 128,
|
461 |
|
|
'not null' => TRUE,
|
462 |
|
|
),
|
463 |
|
|
array('primary key' => array('entity_type', 'entity_id', 'revision_id', 'view_mode'))
|
464 |
|
|
);
|
465 |
|
|
} |