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 |
|
|
$schema = array();
|
12 |
|
|
|
13 |
e5e66f93
|
Assos Assos
|
// Fields that are shared between the two tables.
|
14 |
85ad3d82
|
Assos Assos
|
$common_fields = array(
|
15 |
e5e66f93
|
Assos Assos
|
'view_mode' => array(
|
16 |
|
|
'type' => 'varchar',
|
17 |
|
|
'length' => '128',
|
18 |
|
|
'description' => 'Contains the view mode this panelizer is for.',
|
19 |
|
|
'not null' => TRUE,
|
20 |
|
|
),
|
21 |
|
|
'did' => array(
|
22 |
85ad3d82
|
Assos Assos
|
'type' => 'int',
|
23 |
e5e66f93
|
Assos Assos
|
'not null' => TRUE,
|
24 |
|
|
'description' => 'The display ID of the panel.',
|
25 |
|
|
'no export' => TRUE,
|
26 |
|
|
),
|
27 |
|
|
'name' => array(
|
28 |
|
|
'type' => 'varchar',
|
29 |
|
|
'length' => '255',
|
30 |
|
|
'description' => 'The name of the default being used if there is one.',
|
31 |
85ad3d82
|
Assos Assos
|
),
|
32 |
|
|
'css_id' => array(
|
33 |
|
|
'type' => 'varchar',
|
34 |
|
|
'length' => '255',
|
35 |
|
|
'description' => 'The CSS ID this panel should use.',
|
36 |
|
|
'default' => '',
|
37 |
|
|
),
|
38 |
e5e66f93
|
Assos Assos
|
'css_class' => array(
|
39 |
|
|
'type' => 'varchar',
|
40 |
|
|
'length' => '255',
|
41 |
|
|
'description' => 'The CSS class this panel should use.',
|
42 |
|
|
'default' => '',
|
43 |
|
|
),
|
44 |
85ad3d82
|
Assos Assos
|
'css' => array(
|
45 |
|
|
'type' => 'text',
|
46 |
|
|
'size' => 'big',
|
47 |
|
|
'description' => 'Any CSS the author provided for the panel.',
|
48 |
|
|
'object default' => '',
|
49 |
|
|
),
|
50 |
e5e66f93
|
Assos Assos
|
'no_blocks' => array(
|
51 |
|
|
'type' => 'int',
|
52 |
|
|
'size' => 'tiny',
|
53 |
|
|
'description' => 'Whether or not the node disable sidebar blocks.',
|
54 |
|
|
'default' => 0,
|
55 |
|
|
),
|
56 |
|
|
'title_element' => array(
|
57 |
|
|
'type' => 'varchar',
|
58 |
|
|
'length' => '255',
|
59 |
|
|
'description' => 'The HTML element the title should use.',
|
60 |
|
|
'default' => 'H2',
|
61 |
|
|
),
|
62 |
|
|
'link_to_entity' => array(
|
63 |
|
|
'type' => 'int',
|
64 |
|
|
'size' => 'tiny',
|
65 |
|
|
'description' => 'Whether or not the title should link to the entity.',
|
66 |
|
|
'default' => 1,
|
67 |
|
|
),
|
68 |
|
|
'extra' => array(
|
69 |
|
|
'type' => 'text',
|
70 |
|
|
'size' => 'big',
|
71 |
|
|
'description' => 'Contains extra data that can be added by modules.',
|
72 |
|
|
'serialize' => TRUE,
|
73 |
|
|
'object default' => array(),
|
74 |
|
|
),
|
75 |
85ad3d82
|
Assos Assos
|
'pipeline' => array(
|
76 |
|
|
'type' => 'varchar',
|
77 |
|
|
'length' => '255',
|
78 |
|
|
'description' => 'The render pipeline this panel uses.',
|
79 |
|
|
'default' => 'standard',
|
80 |
|
|
),
|
81 |
|
|
'contexts' => array(
|
82 |
|
|
'type' => 'text',
|
83 |
|
|
'size' => 'big',
|
84 |
|
|
'description' => 'The contexts configured by the node author.',
|
85 |
|
|
'serialize' => TRUE,
|
86 |
|
|
'object default' => array(),
|
87 |
|
|
),
|
88 |
|
|
'relationships' => array(
|
89 |
|
|
'type' => 'text',
|
90 |
|
|
'size' => 'big',
|
91 |
|
|
'description' => 'The relationship contexts configured by the node author.',
|
92 |
|
|
'serialize' => TRUE,
|
93 |
|
|
'object default' => array(),
|
94 |
|
|
),
|
95 |
|
|
);
|
96 |
|
|
|
97 |
|
|
$schema['panelizer_entity'] = array(
|
98 |
|
|
'export' => array(
|
99 |
|
|
'bulk export' => FALSE,
|
100 |
|
|
'can disable' => FALSE,
|
101 |
|
|
'identifier' => 'panelizer_node',
|
102 |
|
|
),
|
103 |
|
|
'description' => 'Node panelizer references.',
|
104 |
|
|
'fields' => array(
|
105 |
|
|
'entity_type' => array(
|
106 |
|
|
'description' => 'The type of the entity this panel is attached to.',
|
107 |
|
|
'type' => 'varchar',
|
108 |
|
|
'length' => 128,
|
109 |
|
|
'not null' => TRUE,
|
110 |
|
|
),
|
111 |
|
|
'entity_id' => array(
|
112 |
|
|
'type' => 'int',
|
113 |
|
|
'not null' => TRUE,
|
114 |
|
|
'default' => 0,
|
115 |
|
|
'description' => 'The entity ID this panel is attached to.',
|
116 |
|
|
),
|
117 |
|
|
'revision_id' => array(
|
118 |
|
|
'description' => 'The revision id of the entity.',
|
119 |
|
|
'type' => 'int',
|
120 |
|
|
'unsigned' => TRUE,
|
121 |
|
|
'not null' => TRUE,
|
122 |
|
|
),
|
123 |
|
|
) + $common_fields,
|
124 |
|
|
'primary key' => array('entity_type', 'entity_id', 'revision_id', 'view_mode'),
|
125 |
e5e66f93
|
Assos Assos
|
'indexes' => array(
|
126 |
|
|
'revision_id' => array('revision_id'),
|
127 |
|
|
),
|
128 |
85ad3d82
|
Assos Assos
|
);
|
129 |
|
|
|
130 |
|
|
$schema['panelizer_defaults'] = array(
|
131 |
|
|
'description' => 'Node type panelizer references.',
|
132 |
|
|
'export' => array(
|
133 |
|
|
'primary key' => 'pnid',
|
134 |
|
|
'key' => 'name',
|
135 |
|
|
'key name' => 'Name',
|
136 |
|
|
'admin_title' => 'title',
|
137 |
|
|
'identifier' => 'panelizer',
|
138 |
|
|
'default hook' => 'panelizer_defaults',
|
139 |
|
|
'api' => array(
|
140 |
|
|
'owner' => 'panelizer',
|
141 |
|
|
'api' => 'panelizer',
|
142 |
|
|
'minimum_version' => 1,
|
143 |
|
|
'current_version' => 1,
|
144 |
|
|
),
|
145 |
|
|
// 'create callback' => 'panelizer_export_create_callback',
|
146 |
|
|
'save callback' => 'panelizer_export_save_callback',
|
147 |
|
|
'export callback' => 'panelizer_export_export_callback',
|
148 |
|
|
'delete callback' => 'panelizer_export_delete_callback',
|
149 |
|
|
'subrecords callback' => 'panelizer_export_delete_callback_subrecords',
|
150 |
|
|
),
|
151 |
|
|
'fields' => array(
|
152 |
|
|
'pnid' => array(
|
153 |
|
|
'type' => 'serial',
|
154 |
|
|
'description' => 'The database primary key.',
|
155 |
|
|
'no export' => TRUE,
|
156 |
|
|
'not null' => TRUE,
|
157 |
|
|
),
|
158 |
|
|
'title' => array(
|
159 |
|
|
'type' => 'varchar',
|
160 |
|
|
'length' => '255',
|
161 |
|
|
'description' => 'The human readable title of this default.',
|
162 |
|
|
),
|
163 |
|
|
'panelizer_type' => array(
|
164 |
|
|
'type' => 'varchar',
|
165 |
|
|
'length' => '32',
|
166 |
|
|
'description' => 'The panelizer entity type, such as node or user.',
|
167 |
|
|
),
|
168 |
|
|
'panelizer_key' => array(
|
169 |
|
|
'type' => 'varchar',
|
170 |
|
|
'length' => '128',
|
171 |
|
|
'description' => 'The panelizer entity bundle.',
|
172 |
|
|
),
|
173 |
e5e66f93
|
Assos Assos
|
'access' => array(
|
174 |
|
|
'type' => 'text',
|
175 |
|
|
'size' => 'big',
|
176 |
|
|
'description' => 'Contains the access control for editing this default.',
|
177 |
|
|
'serialize' => TRUE,
|
178 |
|
|
'object default' => array(),
|
179 |
|
|
),
|
180 |
85ad3d82
|
Assos Assos
|
) + $common_fields,
|
181 |
|
|
'primary key' => array('pnid'),
|
182 |
|
|
'indexes' => array(
|
183 |
|
|
'name' => array('name'),
|
184 |
|
|
'type_key' => array('panelizer_type', 'panelizer_key'),
|
185 |
|
|
),
|
186 |
|
|
);
|
187 |
|
|
|
188 |
|
|
return $schema;
|
189 |
|
|
}
|
190 |
|
|
|
191 |
e5e66f93
|
Assos Assos
|
/**
|
192 |
|
|
* Implements hook_install().
|
193 |
|
|
*/
|
194 |
|
|
function panelizer_install() {
|
195 |
|
|
// Set the module weight so it can execute after Panels.
|
196 |
|
|
db_update('system')
|
197 |
|
|
->fields(array(
|
198 |
|
|
'weight' => 21,
|
199 |
|
|
))
|
200 |
|
|
->condition('name', 'panelizer')
|
201 |
|
|
->execute();
|
202 |
|
|
}
|
203 |
85ad3d82
|
Assos Assos
|
|
204 |
e5e66f93
|
Assos Assos
|
/**
|
205 |
|
|
* Implements hook_uninstall().
|
206 |
|
|
*/
|
207 |
|
|
function panelizer_uninstall() {
|
208 |
|
|
foreach (entity_get_info() as $entity_type => $entity_info) {
|
209 |
|
|
if (isset($entity_info['bundles'])) {
|
210 |
|
|
foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) {
|
211 |
|
|
// View mode variables.
|
212 |
|
|
if (!empty($entity_info['view modes'])) {
|
213 |
|
|
foreach ($entity_info['view modes'] as $view_mode => $view_info) {
|
214 |
|
|
variable_del('panelizer_' . $entity_type . ':' . $bundle_name . ':' . $view_mode . '_selection');
|
215 |
|
|
}
|
216 |
|
|
}
|
217 |
|
|
variable_del('panelizer_' . $entity_type . ':' . $bundle_name . ':default_selection');
|
218 |
|
|
variable_del('panelizer_' . $entity_type . ':' . $bundle_name . ':page_manager_selection');
|
219 |
85ad3d82
|
Assos Assos
|
|
220 |
e5e66f93
|
Assos Assos
|
// Other variables.
|
221 |
|
|
variable_del('panelizer_defaults_' . $entity_type . '_' . $bundle_name);
|
222 |
|
|
variable_del('panelizer_' . $entity_type . ':' . $bundle_name . '_allowed_layouts');
|
223 |
|
|
variable_del('panelizer_' . $entity_type . ':' . $bundle_name . '_allowed_layouts_default');
|
224 |
|
|
variable_del('panelizer_' . $entity_type . ':' . $bundle_name . '_allowed_types');
|
225 |
|
|
variable_del('panelizer_' . $entity_type . ':' . $bundle_name . '_default');
|
226 |
|
|
}
|
227 |
|
|
}
|
228 |
|
|
}
|
229 |
|
|
}
|
230 |
85ad3d82
|
Assos Assos
|
|
231 |
e5e66f93
|
Assos Assos
|
/**
|
232 |
|
|
* Implements hook_requirements().
|
233 |
|
|
*/
|
234 |
|
|
function panelizer_requirements($phase) {
|
235 |
|
|
$return = array();
|
236 |
85ad3d82
|
Assos Assos
|
|
237 |
e5e66f93
|
Assos Assos
|
if ($phase === 'runtime') {
|
238 |
|
|
// Check for fields displaying on view modes through core config.
|
239 |
|
|
$view_modes_to_report = array();
|
240 |
85ad3d82
|
Assos Assos
|
|
241 |
e5e66f93
|
Assos Assos
|
foreach (entity_get_info() as $entity_type => $entity_info) {
|
242 |
|
|
if (isset($entity_info['view modes'])) {
|
243 |
|
|
$view_modes = array_keys($entity_info['view modes']);
|
244 |
|
|
// Add default to the list of view modes because that might be panelized
|
245 |
|
|
// too.
|
246 |
|
|
$view_modes[] = 'default';
|
247 |
85ad3d82
|
Assos Assos
|
|
248 |
e5e66f93
|
Assos Assos
|
if (!empty($entity_info['bundles'])) {
|
249 |
|
|
$bundles = $entity_info['bundles'];
|
250 |
|
|
}
|
251 |
|
|
else {
|
252 |
|
|
$bundles = array($entity_type => $entity_type);
|
253 |
|
|
}
|
254 |
85ad3d82
|
Assos Assos
|
|
255 |
e5e66f93
|
Assos Assos
|
foreach ($bundles as $bundle => $bundle_info) {
|
256 |
|
|
foreach ($view_modes as $view_mode) {
|
257 |
|
|
if (panelizer_view_mode_extra_field_displays($entity_type, $bundle, $view_mode)) {
|
258 |
|
|
$view_modes_to_report[] = array(
|
259 |
|
|
'entity_type' => $entity_type,
|
260 |
|
|
'bundle' => $bundle,
|
261 |
|
|
'view_mode' => $view_mode,
|
262 |
|
|
);
|
263 |
|
|
// @todo Should the display be updated to hide the fields?
|
264 |
|
|
// panelizer_hide_fields_on_panelized_view_mode($entity_type, $bundle, $view_mode);
|
265 |
|
|
}
|
266 |
|
|
}
|
267 |
|
|
}
|
268 |
|
|
}
|
269 |
|
|
}
|
270 |
85ad3d82
|
Assos Assos
|
|
271 |
e5e66f93
|
Assos Assos
|
if (!empty($view_modes_to_report)) {
|
272 |
|
|
$count = count($view_modes_to_report);
|
273 |
|
|
$return['double_display'] = array(
|
274 |
|
|
'title' => t('Panelizer'),
|
275 |
|
|
'value' => t('@number view mode / bundle / entity combination(s) use Panelizer but still have field displays configured.', array('@number' => $count)),
|
276 |
|
|
'description' => t('Panelizer replaces the normal entity display. Any view mode that use Panelizer should have all fields hidden through the normal display settings in order to avoid the overhead of generating the output twice.'),
|
277 |
|
|
'severity' => REQUIREMENT_WARNING,
|
278 |
|
|
);
|
279 |
|
|
$description_links = array();
|
280 |
|
|
foreach ($view_modes_to_report as $view_mode_array) {
|
281 |
|
|
extract($view_mode_array);
|
282 |
|
|
$handler = panelizer_entity_plugin_get_handler($entity_type);
|
283 |
|
|
$path = $handler->admin_bundle_display_path($bundle, $view_mode);
|
284 |
|
|
$description_links[] = array(
|
285 |
|
|
'href' => $path,
|
286 |
|
|
'title' => implode(':', $view_mode_array),
|
287 |
|
|
);
|
288 |
|
|
}
|
289 |
85ad3d82
|
Assos Assos
|
|
290 |
e5e66f93
|
Assos Assos
|
$theme_variables = array(
|
291 |
|
|
'links' => $description_links,
|
292 |
|
|
'heading' => array(
|
293 |
|
|
'text' => 'Entity view modes that should have all fields hidden:',
|
294 |
|
|
'level' => 'h6',
|
295 |
|
|
),
|
296 |
|
|
);
|
297 |
|
|
$return['double_display']['description'] .= theme('links', $theme_variables);
|
298 |
|
|
}
|
299 |
|
|
}
|
300 |
|
|
return $return;
|
301 |
85ad3d82
|
Assos Assos
|
}
|
302 |
|
|
|
303 |
|
|
/**
|
304 |
e5e66f93
|
Assos Assos
|
* Check whether a view mode uses core display of fields and panelizer.
|
305 |
|
|
*
|
306 |
|
|
* @return bool
|
307 |
|
|
* Whether or not a bundle/view_mode is panelized and has fields displaying
|
308 |
|
|
* through core settings.
|
309 |
85ad3d82
|
Assos Assos
|
*/
|
310 |
e5e66f93
|
Assos Assos
|
function panelizer_view_mode_extra_field_displays($entity_type, $bundle, $view_mode) {
|
311 |
|
|
$handler = panelizer_entity_plugin_get_handler($entity_type);
|
312 |
|
|
|
313 |
|
|
if (panelizer_is_panelized($handler, $bundle, $view_mode)) {
|
314 |
|
|
$bundle = field_extract_bundle($entity_type, $bundle);
|
315 |
|
|
$instances = field_info_instances($entity_type, $bundle);
|
316 |
|
|
|
317 |
|
|
// @todo, handle extra fields.
|
318 |
|
|
// field_info_extra_fields($entity_type, $bundle, 'display');
|
319 |
|
|
|
320 |
|
|
// Look through all the fields and look for fields that aren't hidden.
|
321 |
|
|
// As soon as one is found, end this function. Finding any non-hidden
|
322 |
|
|
// fields is the point of this function.
|
323 |
|
|
foreach ($instances as $instance) {
|
324 |
|
|
if (!empty($instance['display'][$view_mode]['type']) && $instance['display'][$view_mode]['type'] !== 'hidden') {
|
325 |
|
|
return TRUE;
|
326 |
|
|
}
|
327 |
|
|
}
|
328 |
|
|
}
|
329 |
|
|
|
330 |
|
|
return FALSE;
|
331 |
85ad3d82
|
Assos Assos
|
}
|
332 |
|
|
|
333 |
|
|
/**
|
334 |
e5e66f93
|
Assos Assos
|
* Hide all fields on a view mode.
|
335 |
|
|
*
|
336 |
|
|
* @todo, connect this function to a form and/or ajax callback.
|
337 |
85ad3d82
|
Assos Assos
|
*/
|
338 |
e5e66f93
|
Assos Assos
|
function panelizer_hide_fields_on_panelized_view_mode($entity_type, $bundle, $view_mode) {
|
339 |
|
|
|
340 |
|
|
$bundle = field_extract_bundle($entity_type, $bundle);
|
341 |
|
|
$instances = field_info_instances($entity_type, $bundle);
|
342 |
|
|
|
343 |
|
|
foreach ($instances as $instance) {
|
344 |
|
|
if (!empty($instance['display'][$view_mode]['type'])) {
|
345 |
|
|
$instance['display'][$view_mode]['type'] = 'hidden';
|
346 |
|
|
field_update_instance($instance);
|
347 |
|
|
}
|
348 |
|
|
}
|
349 |
85ad3d82
|
Assos Assos
|
}
|
350 |
|
|
|
351 |
136a805a
|
Assos Assos
|
/**
|
352 |
|
|
* Implements hook_update_dependencies().
|
353 |
|
|
*/
|
354 |
|
|
function panelizer_update_dependencies() {
|
355 |
|
|
// Update 7115 requires UUID support in CTools and Panels.
|
356 |
|
|
$dependencies['panelizer'][7115] = array(
|
357 |
|
|
'panels' => 7302,
|
358 |
|
|
);
|
359 |
|
|
|
360 |
|
|
// These updates requires Panels storage support, which was added in
|
361 |
|
|
// panels_update_7305.
|
362 |
|
|
$dependencies['panelizer'][7302] = array(
|
363 |
|
|
'panels' => 7305,
|
364 |
|
|
);
|
365 |
|
|
$dependencies['panelizer'][7303] = array(
|
366 |
|
|
'panels' => 7305,
|
367 |
|
|
);
|
368 |
|
|
|
369 |
|
|
return $dependencies;
|
370 |
|
|
}
|
371 |
|
|
|
372 |
85ad3d82
|
Assos Assos
|
/**
|
373 |
|
|
* Update the panelizer variable to be more feature module friendly.
|
374 |
|
|
*/
|
375 |
|
|
function panelizer_update_7100() {
|
376 |
|
|
$panelizer_defaults = variable_get('panelizer_defaults', array());
|
377 |
|
|
|
378 |
|
|
if (!empty($panelizer_defaults)) {
|
379 |
|
|
foreach ($panelizer_defaults as $entity => $bundles) {
|
380 |
|
|
foreach ($bundles as $bundle => $values) {
|
381 |
|
|
variable_set('panelizer_defaults_' . $entity . '_' . $bundle, $values);
|
382 |
|
|
}
|
383 |
|
|
}
|
384 |
|
|
}
|
385 |
|
|
|
386 |
|
|
variable_del('panelizer_defaults');
|
387 |
|
|
return t('Updated panelizer variables.');
|
388 |
|
|
}
|
389 |
|
|
|
390 |
|
|
/**
|
391 |
|
|
* Update the panelizer node table to be the panelizer entity table.
|
392 |
|
|
*/
|
393 |
|
|
function panelizer_update_7101() {
|
394 |
|
|
// Rename the table.
|
395 |
|
|
db_rename_table('panelizer_node', 'panelizer_entity');
|
396 |
|
|
|
397 |
|
|
// Remove the primary key.
|
398 |
|
|
db_drop_primary_key('panelizer_entity');
|
399 |
|
|
|
400 |
|
|
// Add the entity type.
|
401 |
e5e66f93
|
Assos Assos
|
$spec = array(
|
402 |
85ad3d82
|
Assos Assos
|
'description' => 'The type of the entity this panel is attached to.',
|
403 |
|
|
'type' => 'varchar',
|
404 |
|
|
'length' => 255,
|
405 |
|
|
);
|
406 |
e5e66f93
|
Assos Assos
|
db_add_field('panelizer_entity', 'entity_type', $spec);
|
407 |
85ad3d82
|
Assos Assos
|
|
408 |
|
|
// Rename nid to entity_id.
|
409 |
e5e66f93
|
Assos Assos
|
$spec = array(
|
410 |
85ad3d82
|
Assos Assos
|
'type' => 'int',
|
411 |
|
|
'not null' => TRUE,
|
412 |
|
|
'default' => 0,
|
413 |
|
|
'description' => 'The entity ID this panel is attached to.',
|
414 |
|
|
);
|
415 |
e5e66f93
|
Assos Assos
|
db_change_field('panelizer_entity', 'nid', 'entity_id', $spec);
|
416 |
85ad3d82
|
Assos Assos
|
|
417 |
|
|
// Update the entity_type field to 'node' since all pre-existing
|
418 |
|
|
// panelizer objects are nodes.
|
419 |
|
|
db_update('panelizer_entity')
|
420 |
|
|
->fields(array('entity_type' => 'node'))
|
421 |
|
|
->execute();
|
422 |
|
|
|
423 |
|
|
// Add the new index
|
424 |
|
|
db_add_primary_key('panelizer_entity', array('entity_type', 'entity_id'));
|
425 |
|
|
}
|
426 |
|
|
|
427 |
|
|
/**
|
428 |
|
|
* Add revision support.
|
429 |
|
|
*/
|
430 |
|
|
function panelizer_update_7102() {
|
431 |
|
|
// Remove the primary key.
|
432 |
|
|
db_drop_primary_key('panelizer_entity');
|
433 |
|
|
|
434 |
e5e66f93
|
Assos Assos
|
// Add the revision ID field.
|
435 |
|
|
$spec = array(
|
436 |
85ad3d82
|
Assos Assos
|
'description' => 'The revision id of the entity.',
|
437 |
|
|
'type' => 'int',
|
438 |
|
|
'unsigned' => TRUE,
|
439 |
|
|
);
|
440 |
e5e66f93
|
Assos Assos
|
db_add_field('panelizer_entity', 'revision_id', $spec);
|
441 |
85ad3d82
|
Assos Assos
|
|
442 |
|
|
db_query("UPDATE {panelizer_entity} pe LEFT JOIN {node} n ON pe.entity_id = n.nid SET pe.revision_id = n.vid");
|
443 |
|
|
|
444 |
e5e66f93
|
Assos Assos
|
// Add the new index.
|
445 |
85ad3d82
|
Assos Assos
|
db_add_primary_key('panelizer_entity', array('entity_type', 'entity_id', 'revision_id'));
|
446 |
|
|
|
447 |
|
|
return t('Added revision support.');
|
448 |
|
|
}
|
449 |
|
|
|
450 |
|
|
/**
|
451 |
|
|
* Set primary keys to NOT NULL.
|
452 |
|
|
*/
|
453 |
|
|
function panelizer_update_7103() {
|
454 |
e5e66f93
|
Assos Assos
|
$spec = array(
|
455 |
|
|
'description' => 'The type of the entity this panel is attached to.',
|
456 |
|
|
'type' => 'varchar',
|
457 |
|
|
'length' => 128,
|
458 |
|
|
'not null' => TRUE,
|
459 |
|
|
);
|
460 |
|
|
db_change_field('panelizer_entity', 'entity_type', 'entity_type', $spec);
|
461 |
85ad3d82
|
Assos Assos
|
|
462 |
e5e66f93
|
Assos Assos
|
$spec = array(
|
463 |
|
|
'description' => 'The revision id of the entity.',
|
464 |
|
|
'type' => 'int',
|
465 |
|
|
'unsigned' => TRUE,
|
466 |
|
|
'not null' => TRUE,
|
467 |
|
|
);
|
468 |
|
|
db_change_field('panelizer_entity', 'revision_id', 'revision_id', $spec);
|
469 |
|
|
|
470 |
|
|
$spec = array(
|
471 |
|
|
'type' => 'serial',
|
472 |
|
|
'description' => 'The database primary key.',
|
473 |
|
|
'no export' => TRUE,
|
474 |
|
|
'not null' => TRUE,
|
475 |
|
|
);
|
476 |
|
|
db_change_field('panelizer_defaults', 'pnid', 'pnid', $spec);
|
477 |
85ad3d82
|
Assos Assos
|
}
|
478 |
|
|
|
479 |
|
|
/**
|
480 |
e5e66f93
|
Assos Assos
|
* Add the {panelizer_defaults}.access field.
|
481 |
85ad3d82
|
Assos Assos
|
*/
|
482 |
|
|
function panelizer_update_7104() {
|
483 |
e5e66f93
|
Assos Assos
|
$spec = array(
|
484 |
|
|
'type' => 'text',
|
485 |
|
|
'size' => 'big',
|
486 |
|
|
'description' => 'Contains the access control for editing this default.',
|
487 |
|
|
'serialize' => TRUE,
|
488 |
|
|
'object default' => array(),
|
489 |
|
|
);
|
490 |
|
|
db_add_field('panelizer_defaults', 'access', $spec);
|
491 |
85ad3d82
|
Assos Assos
|
}
|
492 |
|
|
|
493 |
|
|
/**
|
494 |
|
|
* Add the view mode field.
|
495 |
|
|
*/
|
496 |
|
|
function panelizer_update_7105() {
|
497 |
e5e66f93
|
Assos Assos
|
$spec = array(
|
498 |
|
|
'type' => 'varchar',
|
499 |
|
|
'length' => '128',
|
500 |
|
|
'description' => 'Contains the view mode this panelizer is for.',
|
501 |
|
|
'not null' => TRUE,
|
502 |
|
|
);
|
503 |
|
|
db_add_field('panelizer_defaults', 'view_mode', $spec);
|
504 |
|
|
db_add_field('panelizer_entity', 'view_mode', $spec);
|
505 |
85ad3d82
|
Assos Assos
|
|
506 |
|
|
db_update('panelizer_defaults')
|
507 |
|
|
->fields(array(
|
508 |
|
|
'view_mode' => 'page_manager',
|
509 |
|
|
))
|
510 |
|
|
->execute();
|
511 |
|
|
|
512 |
|
|
db_update('panelizer_entity')
|
513 |
|
|
->fields(array(
|
514 |
|
|
'view_mode' => 'page_manager',
|
515 |
|
|
))
|
516 |
|
|
->execute();
|
517 |
|
|
}
|
518 |
|
|
|
519 |
|
|
/**
|
520 |
e5e66f93
|
Assos Assos
|
* Add the view_mode to the primary key for the {panelizer_entity} table.
|
521 |
85ad3d82
|
Assos Assos
|
*/
|
522 |
|
|
function panelizer_update_7106() {
|
523 |
|
|
db_drop_primary_key('panelizer_entity');
|
524 |
|
|
|
525 |
e5e66f93
|
Assos Assos
|
if (db_index_exists('panelizer_entity', 'PRIMARY')) {
|
526 |
|
|
throw new DrupalUpdateException(t('Could not drop the panelizer_entity primary key in order to recreate it.'));
|
527 |
|
|
}
|
528 |
85ad3d82
|
Assos Assos
|
|
529 |
e5e66f93
|
Assos Assos
|
// Add the new index.
|
530 |
|
|
db_add_primary_key('panelizer_entity', array(
|
531 |
|
|
'entity_type',
|
532 |
|
|
'entity_id',
|
533 |
|
|
'revision_id',
|
534 |
|
|
'view_mode',
|
535 |
|
|
));
|
536 |
|
|
|
537 |
|
|
if (db_index_exists('panelizer_entity', 'PRIMARY')) {
|
538 |
|
|
return t('The Panelizer database scheme has been updated.');
|
539 |
|
|
}
|
540 |
|
|
else {
|
541 |
|
|
throw new DrupalUpdateException(t('There was a problem recreating the panelizer_entity primary key.'));
|
542 |
|
|
}
|
543 |
85ad3d82
|
Assos Assos
|
}
|
544 |
|
|
|
545 |
|
|
/**
|
546 |
|
|
* Add the css class and element title fields.
|
547 |
|
|
*/
|
548 |
|
|
function panelizer_update_7107() {
|
549 |
e5e66f93
|
Assos Assos
|
$spec = array(
|
550 |
|
|
'type' => 'varchar',
|
551 |
|
|
'length' => '255',
|
552 |
|
|
'description' => 'The CSS class this panel should use.',
|
553 |
|
|
'default' => '',
|
554 |
|
|
);
|
555 |
|
|
db_add_field('panelizer_defaults', 'css_class', $spec);
|
556 |
|
|
db_add_field('panelizer_entity', 'css_class', $spec);
|
557 |
|
|
|
558 |
|
|
$spec = array(
|
559 |
|
|
'type' => 'varchar',
|
560 |
|
|
'length' => '255',
|
561 |
|
|
'description' => 'The HTML element the title should use.',
|
562 |
|
|
'default' => 'H2',
|
563 |
|
|
);
|
564 |
|
|
db_add_field('panelizer_defaults', 'title_element', $spec);
|
565 |
|
|
db_add_field('panelizer_entity', 'title_element', $spec);
|
566 |
85ad3d82
|
Assos Assos
|
}
|
567 |
|
|
|
568 |
|
|
/**
|
569 |
|
|
* Add the link_to_entity field
|
570 |
|
|
*/
|
571 |
|
|
function panelizer_update_7108() {
|
572 |
e5e66f93
|
Assos Assos
|
$spec = array(
|
573 |
|
|
'type' => 'int',
|
574 |
|
|
'size' => 'tiny',
|
575 |
|
|
'description' => 'Whether or not the title should link to the entity.',
|
576 |
|
|
'default' => 1,
|
577 |
|
|
);
|
578 |
|
|
db_add_field('panelizer_defaults', 'link_to_entity', $spec);
|
579 |
|
|
db_add_field('panelizer_entity', 'link_to_entity', $spec);
|
580 |
85ad3d82
|
Assos Assos
|
}
|
581 |
|
|
|
582 |
|
|
/**
|
583 |
|
|
* Add the extra field so that modules can extend panelizer more easily.
|
584 |
|
|
*/
|
585 |
|
|
function panelizer_update_7109() {
|
586 |
e5e66f93
|
Assos Assos
|
$spec = array(
|
587 |
|
|
'type' => 'text',
|
588 |
|
|
'size' => 'big',
|
589 |
|
|
'description' => 'Contains extra data that can be added by modules.',
|
590 |
|
|
'serialize' => TRUE,
|
591 |
|
|
'object default' => array(),
|
592 |
|
|
);
|
593 |
|
|
db_add_field('panelizer_defaults', 'extra', $spec);
|
594 |
|
|
db_add_field('panelizer_entity', 'extra', $spec);
|
595 |
85ad3d82
|
Assos Assos
|
}
|
596 |
|
|
|
597 |
|
|
/**
|
598 |
|
|
* Changing the size of the entity_type field of panelizer_entity.
|
599 |
|
|
*/
|
600 |
|
|
function panelizer_update_7110() {
|
601 |
|
|
db_drop_primary_key('panelizer_entity');
|
602 |
e5e66f93
|
Assos Assos
|
$spec = array(
|
603 |
|
|
'description' => 'The type of the entity this panel is attached to.',
|
604 |
|
|
'type' => 'varchar',
|
605 |
|
|
'length' => 128,
|
606 |
|
|
'not null' => TRUE,
|
607 |
85ad3d82
|
Assos Assos
|
);
|
608 |
e5e66f93
|
Assos Assos
|
$keys = array(
|
609 |
|
|
'primary key' => array('entity_type', 'entity_id', 'revision_id', 'view_mode'),
|
610 |
|
|
);
|
611 |
|
|
db_change_field('panelizer_entity', 'entity_type', 'entity_type', $spec, $keys);
|
612 |
|
|
}
|
613 |
|
|
|
614 |
|
|
/**
|
615 |
|
|
* This update script was removed, nothing to see here.
|
616 |
|
|
*/
|
617 |
|
|
function panelizer_update_7111() {
|
618 |
|
|
// Nothing.
|
619 |
|
|
}
|
620 |
|
|
|
621 |
|
|
/**
|
622 |
|
|
* Fix Panelizer settings.
|
623 |
|
|
*/
|
624 |
|
|
function panelizer_update_7112() {
|
625 |
|
|
foreach (entity_get_info() as $entity_type => $entity_info) {
|
626 |
|
|
if (!empty($entity_info) && !empty($entity_info['bundles'])) {
|
627 |
|
|
foreach ($entity_info['bundles'] as $bundle => &$bundle_info) {
|
628 |
|
|
$var_name = 'panelizer_defaults_' . $entity_type . '_' . $bundle;
|
629 |
|
|
$settings = variable_get($var_name);
|
630 |
|
|
if (!empty($settings) && !empty($settings['view modes'])) {
|
631 |
|
|
foreach ($settings['view modes'] as $view_mode => &$config) {
|
632 |
|
|
// If the bundle itself or this view mode are disabled, make sure
|
633 |
|
|
// all settings are disabled.
|
634 |
|
|
if (empty($settings['status']) || empty($config['status'])) {
|
635 |
|
|
foreach ($config as $key => $val) {
|
636 |
|
|
$config[$key] = 0;
|
637 |
|
|
}
|
638 |
|
|
}
|
639 |
|
|
}
|
640 |
|
|
// Update the settings.
|
641 |
|
|
variable_set($var_name, $settings);
|
642 |
|
|
}
|
643 |
|
|
}
|
644 |
|
|
}
|
645 |
|
|
}
|
646 |
|
|
}
|
647 |
|
|
|
648 |
|
|
/**
|
649 |
|
|
* Make {panelizer_entity}.view_mode NOT NULL.
|
650 |
|
|
*/
|
651 |
|
|
function panelizer_update_7113() {
|
652 |
|
|
db_drop_primary_key('panelizer_entity');
|
653 |
|
|
|
654 |
|
|
$spec = array(
|
655 |
|
|
'description' => 'Contains the view mode this panelizer is for.',
|
656 |
|
|
'type' => 'varchar',
|
657 |
|
|
'length' => '128',
|
658 |
|
|
'not null' => TRUE,
|
659 |
|
|
);
|
660 |
|
|
$keys = array('primary key' =>
|
661 |
|
|
array('entity_type', 'entity_id', 'revision_id', 'view_mode'),
|
662 |
|
|
);
|
663 |
|
|
db_change_field('panelizer_entity', 'view_mode', 'view_mode', $spec, $keys);
|
664 |
|
|
}
|
665 |
|
|
|
666 |
|
|
/**
|
667 |
|
|
* Clear the menu cache to fix the display actions page arguments.
|
668 |
|
|
*/
|
669 |
|
|
function panelizer_update_7114() {
|
670 |
|
|
variable_set('menu_rebuild_needed', TRUE);
|
671 |
|
|
}
|
672 |
|
|
|
673 |
|
|
/**
|
674 |
|
|
* Ensure that each Panelizer display is only used once, so that each
|
675 |
|
|
* revision has a separate record.
|
676 |
|
|
*/
|
677 |
|
|
function panelizer_update_7115(&$sandbox) {
|
678 |
|
|
// This loops through all of the records in {panelizer_entity}, looks for any
|
679 |
|
|
// displays that are used more than once and clones any additional copies
|
680 |
|
|
// that are needed. The goal is to have each display only used once.
|
681 |
|
|
|
682 |
|
|
// Process records by groups of 1 (arbitrary value). Doing this one at a time
|
683 |
|
|
// because some sites can have a LOT of revisions.
|
684 |
|
|
$limit = 1;
|
685 |
|
|
|
686 |
|
|
// When ran through Drush it's Ok to process a larger number of objects at a
|
687 |
|
|
// time.
|
688 |
|
|
if (drupal_is_cli()) {
|
689 |
|
|
$limit = 10;
|
690 |
|
|
}
|
691 |
|
|
|
692 |
|
|
// The update hasn't been ran before.
|
693 |
|
|
if (!isset($sandbox['progress'])) {
|
694 |
|
|
// The count of records visited so far.
|
695 |
|
|
$sandbox['progress'] = 0;
|
696 |
|
|
|
697 |
|
|
// Load any 'did' values that are used in more than one revision.
|
698 |
|
|
$records = db_query("SELECT did
|
699 |
|
|
FROM {panelizer_entity}
|
700 |
|
|
WHERE revision_id > 0 AND did <> 0 AND did IS NOT NULL
|
701 |
|
|
GROUP BY did
|
702 |
|
|
HAVING count(revision_id) > 1");
|
703 |
|
|
|
704 |
|
|
// If there are no records, there's nothing to do.
|
705 |
|
|
if ($records->rowCount() == 0) {
|
706 |
|
|
return t('No Panelizer display records need fixing.');
|
707 |
|
|
}
|
708 |
|
|
|
709 |
|
|
// Total records that must be processed.
|
710 |
|
|
$sandbox['max'] = $records->rowCount();
|
711 |
|
|
|
712 |
|
|
watchdog('panelizer', 'Need to fix @count duplicate displays.', array('@count' => $records->rowCount()));
|
713 |
|
|
}
|
714 |
|
|
|
715 |
|
|
// Loop through the records in smaller chunks.
|
716 |
|
|
$dids = db_query_range("SELECT did
|
717 |
|
|
FROM {panelizer_entity}
|
718 |
|
|
WHERE revision_id > 0 AND did <> 0 AND did IS NOT NULL
|
719 |
|
|
GROUP BY did
|
720 |
|
|
HAVING count(revision_id) > 1", 0, $limit)->fetchCol();
|
721 |
|
|
|
722 |
|
|
// Track the entities that need to be reset.
|
723 |
|
|
$cache_clear = array();
|
724 |
|
|
|
725 |
|
|
ctools_include('plugins', 'panels');
|
726 |
|
|
ctools_include('content');
|
727 |
|
|
|
728 |
|
|
// Load all of the requested displays.
|
729 |
|
|
foreach (panels_load_displays($dids) as $original_did => $display) {
|
730 |
|
|
// Load each panelizer_entity record for this display.
|
731 |
|
|
$panelizers = db_query("SELECT * FROM {panelizer_entity} WHERE did=:did", array(':did' => $display->did));
|
732 |
|
|
$ctr = 0;
|
733 |
|
|
foreach ($panelizers as $panelizer) {
|
734 |
|
|
$ctr++;
|
735 |
|
|
// Skip the first record.
|
736 |
|
|
if ($ctr === 1) {
|
737 |
|
|
$ctr++;
|
738 |
|
|
continue;
|
739 |
|
|
}
|
740 |
|
|
|
741 |
|
|
// Reset the 'did' value so that a new record can be created.
|
742 |
|
|
unset($display->did);
|
743 |
|
|
|
744 |
|
|
// Regenerate the UUID.
|
745 |
|
|
$display->uuid = ctools_uuid_generate();
|
746 |
|
|
|
747 |
|
|
// Save the display, thus creating a new 'did' value. Also, using
|
748 |
|
|
// db_insert() as it's safer than using drupal_write_record() directly
|
749 |
|
|
// during an update script. Also, doing each field individually to avoid
|
750 |
|
|
// corrupting data during hook_panels_display_save.
|
751 |
|
|
$display->did = db_insert('panels_display')
|
752 |
|
|
->fields(array(
|
753 |
|
|
'layout' => $display->layout,
|
754 |
|
|
'layout_settings' => serialize($display->layout_settings),
|
755 |
|
|
'panel_settings' => serialize($display->panel_settings),
|
756 |
|
|
'cache' => serialize($display->cache),
|
757 |
|
|
'title' => $display->title,
|
758 |
|
|
'hide_title' => $display->hide_title,
|
759 |
|
|
'title_pane' => $display->title_pane,
|
760 |
|
|
'uuid' => $display->uuid,
|
761 |
|
|
))
|
762 |
|
|
->execute();
|
763 |
|
|
$message = 'Panelizer update 7115: created display %did for %entity_type %entity_id';
|
764 |
|
|
$message_args = array(
|
765 |
|
|
'%did' => $display->did,
|
766 |
|
|
'%entity_type' => $panelizer->entity_type,
|
767 |
|
|
'%entity_id' => $panelizer->entity_id,
|
768 |
|
|
);
|
769 |
|
|
watchdog('panelizer', $message, $message_args, WATCHDOG_NOTICE);
|
770 |
|
|
|
771 |
|
|
// Reset the 'pid' values of each pane, using a new UUID. Because its
|
772 |
|
|
// non-numeric, when the display is saved it'll create a new record for
|
773 |
|
|
// each pane, but still keep all of the internal pointers accurate.
|
774 |
|
|
foreach ($display->panels as $region => $panes) {
|
775 |
|
|
foreach ((array) $panes as $position => $pid) {
|
776 |
|
|
// Pane not found. Shouldn't happen, but you never know.
|
777 |
|
|
if (!isset($display->content[$pid])) {
|
778 |
|
|
watchdog('panelizer', 'Panelizer update 7115: couldn\'t load pane %pid for display %did', array('%pid' => $pid, '%did' => $display->did), WATCHDOG_WARNING);
|
779 |
|
|
continue;
|
780 |
|
|
}
|
781 |
|
|
|
782 |
|
|
// Load the pane.
|
783 |
|
|
$new_pane = clone $display->content[$pid];
|
784 |
|
|
|
785 |
|
|
// This appears to only serve the purpose of ensuring necessary APIs
|
786 |
|
|
// and include files are loaded.
|
787 |
|
|
ctools_get_content_type($new_pane->type);
|
788 |
|
|
|
789 |
|
|
// Remove the pid, it'll be created during the database insertion.
|
790 |
|
|
unset($new_pane->pid);
|
791 |
|
|
|
792 |
|
|
// Generate a new UUID.
|
793 |
|
|
$new_pane->uuid = ctools_uuid_generate();
|
794 |
|
|
|
795 |
|
|
// Update the pane's did.
|
796 |
|
|
$new_pane->did = $display->did;
|
797 |
|
|
|
798 |
|
|
// Create the pane record, save the return ID as the pane pid. Again,
|
799 |
|
|
// using db_insert directly because it's safer than
|
800 |
|
|
// drupal_write_record during an update script. Also, doing the fields
|
801 |
|
|
// individually so that the data isn't corrupted during
|
802 |
|
|
// hook_panels_pane_insert.
|
803 |
|
|
$new_pane->pid = db_insert('panels_pane')
|
804 |
|
|
->fields(array(
|
805 |
|
|
'did' => $new_pane->did,
|
806 |
|
|
'panel' => $new_pane->panel,
|
807 |
|
|
'type' => $new_pane->type,
|
808 |
|
|
'subtype' => $new_pane->subtype,
|
809 |
|
|
'shown' => $new_pane->shown,
|
810 |
|
|
'access' => serialize($new_pane->access),
|
811 |
|
|
'configuration' => serialize($new_pane->configuration),
|
812 |
|
|
'cache' => serialize($new_pane->cache),
|
813 |
|
|
'style' => serialize($new_pane->style),
|
814 |
|
|
'css' => serialize($new_pane->css),
|
815 |
|
|
'extras' => serialize($new_pane->extras),
|
816 |
|
|
'locks' => serialize($new_pane->locks),
|
817 |
|
|
'uuid' => $new_pane->uuid,
|
818 |
|
|
))
|
819 |
|
|
->execute();
|
820 |
|
|
|
821 |
|
|
// Tell the world.
|
822 |
|
|
module_invoke_all('panels_pane_insert', $new_pane);
|
823 |
|
|
watchdog('panelizer', 'Panelizer update 7115: created pane %pid for display %did', array('%pid' => $new_pane->pid, '%did' => $new_pane->did), WATCHDOG_NOTICE);
|
824 |
|
|
|
825 |
|
|
// Update the optional title pane.
|
826 |
|
|
if (isset($display->title_pane) && $display->title_pane == $pid) {
|
827 |
|
|
$display->title_pane = $new_pane->pid;
|
828 |
|
|
// Do a simple update query to write it so we don't have to rewrite
|
829 |
|
|
// the whole record. We can't just save writing the whole record
|
830 |
|
|
// here because it was needed to get the did. Chicken, egg, more
|
831 |
|
|
// chicken.
|
832 |
|
|
db_update('panels_display')
|
833 |
|
|
->fields(array(
|
834 |
|
|
'title_pane' => $new_pane->pid
|
835 |
|
|
))
|
836 |
|
|
->condition('did', $display->did)
|
837 |
|
|
->execute();
|
838 |
|
|
}
|
839 |
|
|
}
|
840 |
|
|
}
|
841 |
|
|
|
842 |
|
|
// Allow other modules to take action when a display is saved.
|
843 |
|
|
module_invoke_all('panels_display_save', $display);
|
844 |
|
|
|
845 |
|
|
// Assign the new display to this Panelizer record.
|
846 |
|
|
$panelizer->did = $display->did;
|
847 |
|
|
|
848 |
|
|
// Update the {panelizer} record.
|
849 |
|
|
db_update('panelizer_entity')
|
850 |
|
|
->fields((array) $panelizer)
|
851 |
|
|
->condition('entity_type', $panelizer->entity_type)
|
852 |
|
|
->condition('entity_id', $panelizer->entity_id)
|
853 |
|
|
->condition('revision_id', $panelizer->revision_id)
|
854 |
|
|
->condition('view_mode', $panelizer->view_mode)
|
855 |
|
|
->execute();
|
856 |
|
|
|
857 |
|
|
// Clear this entity's cache.
|
858 |
|
|
$cache_clear[$panelizer->entity_type][] = $panelizer->entity_id;
|
859 |
|
|
|
860 |
|
|
}
|
861 |
|
|
watchdog('panelizer', 'Panelizer update 7115: finished fixing %did', array('%did' => $original_did), WATCHDOG_NOTICE);
|
862 |
|
|
|
863 |
|
|
$sandbox['progress']++;
|
864 |
|
|
}
|
865 |
|
|
|
866 |
|
|
// Clear the caches for any entities that are updated.
|
867 |
|
|
foreach ($cache_clear as $entity_type => $entity_ids) {
|
868 |
|
|
entity_get_controller($entity_type)->resetCache($entity_ids);
|
869 |
|
|
}
|
870 |
|
|
|
871 |
|
|
$sandbox['#finished'] = ($sandbox['progress'] >= $sandbox['max']) ? TRUE : ($sandbox['progress'] / $sandbox['max']);
|
872 |
|
|
|
873 |
|
|
return t('Fixed @count Panelizer record(s) (out of @total) that were using the same display.', array('@count' => $sandbox['progress'], '@total' => $sandbox['max']));
|
874 |
|
|
}
|
875 |
|
|
|
876 |
|
|
/**
|
877 |
|
|
* Notify the site builder that the "Panelizer" tabs have been renamed.
|
878 |
|
|
*/
|
879 |
|
|
function panelizer_update_7116() {
|
880 |
|
|
drupal_set_message(t('Note: the "Panelizer" tabs on content, user, term pages, etc have been renamed to "Customize display".'));
|
881 |
|
|
}
|
882 |
|
|
|
883 |
|
|
/**
|
884 |
|
|
* Clear the menu cache to pull in the new menu paths.
|
885 |
|
|
*/
|
886 |
|
|
function panelizer_update_7117() {
|
887 |
|
|
variable_set('menu_rebuild_needed', TRUE);
|
888 |
|
|
drupal_set_message(t('Note: the main Panelizer configuration page has moved to the "Structure" menu instead of the "Config" menu.'));
|
889 |
|
|
}
|
890 |
|
|
|
891 |
|
|
/**
|
892 |
|
|
* Reload the menus to fix the 'content' default local tasks.
|
893 |
|
|
*/
|
894 |
|
|
function panelizer_update_7118() {
|
895 |
|
|
variable_set('menu_rebuild_needed', TRUE);
|
896 |
|
|
}
|
897 |
|
|
|
898 |
|
|
/**
|
899 |
|
|
* Fix any {panelizer_entity} records that were broken by update 7115. This may
|
900 |
|
|
* take some time.
|
901 |
|
|
*/
|
902 |
|
|
function panelizer_update_7119(&$sandbox) {
|
903 |
|
|
// Process records by groups of 10 (arbitrary value).
|
904 |
|
|
$limit = 10;
|
905 |
|
|
// When ran through Drush it's Ok to process a larger number of objects at a
|
906 |
|
|
// time.
|
907 |
|
|
if (drupal_is_cli()) {
|
908 |
|
|
$limit = 100;
|
909 |
|
|
}
|
910 |
|
|
|
911 |
|
|
// The update hasn't been ran before.
|
912 |
|
|
if (!isset($sandbox['progress'])) {
|
913 |
|
|
// The count of records visited so far.
|
914 |
|
|
$sandbox['progress'] = 0;
|
915 |
|
|
|
916 |
|
|
// Load any 'panelizer_entity' values that are corrupt.
|
917 |
|
|
$records = db_query("SELECT DISTINCT entity_type, entity_id
|
918 |
|
|
FROM {panelizer_entity}
|
919 |
|
|
WHERE contexts LIKE 's:%'
|
920 |
|
|
OR relationships LIKE 's:%'
|
921 |
|
|
OR extra LIKE 's:%'");
|
922 |
|
|
|
923 |
|
|
// If there are no records, there's nothing to do.
|
924 |
|
|
if ($records->rowCount() == 0) {
|
925 |
|
|
return t('No {panelizer_entity} records were corrupted by update 7115.');
|
926 |
|
|
}
|
927 |
|
|
|
928 |
|
|
// Total records that must be processed.
|
929 |
|
|
$sandbox['max'] = $records->rowCount();
|
930 |
|
|
|
931 |
|
|
watchdog('panelizer', 'Need to fix {panelizer_entity} records for @count entities that were damaged by update 7115.', array('@count' => $records->rowCount()));
|
932 |
|
|
}
|
933 |
|
|
|
934 |
|
|
// Get a small batch of records.
|
935 |
|
|
$records = db_query_range("SELECT DISTINCT entity_type, entity_id
|
936 |
|
|
FROM {panelizer_entity}
|
937 |
|
|
WHERE contexts LIKE 's:%'
|
938 |
|
|
OR relationships LIKE 's:%'
|
939 |
|
|
OR extra LIKE 's:%'", 0, $limit);
|
940 |
|
|
|
941 |
|
|
// Loop over each record.
|
942 |
|
|
foreach ($records as $record) {
|
943 |
|
|
// Track whether this entity needs to be fixed.
|
944 |
|
|
$entity_updated = FALSE;
|
945 |
|
|
|
946 |
|
|
// Get each {panelizer_record} for this entity.
|
947 |
|
|
$entity_records = db_query("SELECT *
|
948 |
|
|
FROM {panelizer_entity}
|
949 |
|
|
WHERE entity_type = :entity_type
|
950 |
|
|
AND entity_id = :entity_id
|
951 |
|
|
ORDER BY revision_id", (array)$record);
|
952 |
|
|
foreach ($entity_records as $panelizer) {
|
953 |
|
|
$last_display = NULL;
|
954 |
|
|
|
955 |
|
|
// Unserialize each of the serialized values.
|
956 |
|
|
foreach (array('contexts', 'relationships', 'extra') as $val) {
|
957 |
|
|
$panelizer->$val = unserialize($panelizer->$val);
|
958 |
|
|
}
|
959 |
|
|
|
960 |
|
|
// Keep track of whether the record needs to be saved.
|
961 |
|
|
$panelizer_updated = FALSE;
|
962 |
|
|
|
963 |
|
|
// Verify each of the items is an array or if it was double-serialized.
|
964 |
|
|
foreach (array('contexts', 'relationships', 'extra') as $val) {
|
965 |
|
|
if (is_string($panelizer->$val)) {
|
966 |
|
|
$panelizer->$val = unserialize($panelizer->$val);
|
967 |
|
|
$panelizer_updated = TRUE;
|
968 |
|
|
$entity_updated = TRUE;
|
969 |
|
|
}
|
970 |
|
|
}
|
971 |
|
|
|
972 |
|
|
// Update the {panelizer_entity} record.
|
973 |
|
|
if ($panelizer_updated) {
|
974 |
|
|
db_update('panelizer_entity')
|
975 |
|
|
->fields(array(
|
976 |
|
|
'contexts' => serialize($panelizer->contexts),
|
977 |
|
|
'relationships' => serialize($panelizer->relationships),
|
978 |
|
|
'extra' => serialize($panelizer->extra),
|
979 |
|
|
))
|
980 |
|
|
->condition('entity_type', $panelizer->entity_type)
|
981 |
|
|
->condition('entity_id', $panelizer->entity_id)
|
982 |
|
|
->condition('revision_id', $panelizer->revision_id)
|
983 |
|
|
->condition('view_mode', $panelizer->view_mode)
|
984 |
|
|
->execute();
|
985 |
|
|
}
|
986 |
|
|
}
|
987 |
|
|
|
988 |
|
|
// The entity was updated so clear its cache.
|
989 |
|
|
if ($entity_updated) {
|
990 |
|
|
entity_get_controller($panelizer->entity_type)->resetCache(array($panelizer->entity_id));
|
991 |
|
|
}
|
992 |
|
|
|
993 |
|
|
$sandbox['progress']++;
|
994 |
|
|
}
|
995 |
|
|
|
996 |
|
|
$sandbox['#finished'] = ($sandbox['progress'] >= $sandbox['max']) ? TRUE : ($sandbox['progress'] / $sandbox['max']);
|
997 |
|
|
|
998 |
|
|
return t('Fixed {panelizer_entity} records for @count entities out of @total total.', array('@count' => $sandbox['progress'], '@total' => $sandbox['max']));
|
999 |
|
|
}
|
1000 |
|
|
|
1001 |
|
|
/**
|
1002 |
|
|
* Update 7115 may have resulted in {panels_pane} records not being created
|
1003 |
|
|
* properly. This will create them, and may take some time.
|
1004 |
|
|
*/
|
1005 |
|
|
function panelizer_update_7120(&$sandbox) {
|
1006 |
|
|
// Process records by groups of 1 (arbitrary value). Doing this one at a time
|
1007 |
|
|
// because some sites can have a LOT of revisions.
|
1008 |
|
|
$limit = 1;
|
1009 |
|
|
|
1010 |
|
|
// When ran through Drush it's Ok to process a larger number of objects at a
|
1011 |
|
|
// time.
|
1012 |
|
|
if (drupal_is_cli()) {
|
1013 |
|
|
$limit = 10;
|
1014 |
|
|
}
|
1015 |
|
|
|
1016 |
|
|
// The update hasn't been ran before.
|
1017 |
|
|
if (!isset($sandbox['progress'])) {
|
1018 |
|
|
// The count of records visited so far.
|
1019 |
|
|
$sandbox['progress'] = 0;
|
1020 |
|
|
|
1021 |
|
|
// Load any 'panelizer_entity' values that are corrupt.
|
1022 |
|
|
$records = db_query("SELECT DISTINCT entity_type, entity_id
|
1023 |
|
|
FROM {panelizer_entity} pe
|
1024 |
|
|
LEFT OUTER JOIN {panels_pane} pp
|
1025 |
|
|
ON pe.did = pp.did
|
1026 |
|
|
WHERE pe.did > 0
|
1027 |
|
|
AND pp.did IS NULL");
|
1028 |
|
|
|
1029 |
|
|
// If there are no records, there's nothing to do.
|
1030 |
|
|
if ($records->rowCount() == 0) {
|
1031 |
|
|
return t('No panes were lost by update 7115.');
|
1032 |
|
|
}
|
1033 |
|
|
|
1034 |
|
|
// Total records that must be processed.
|
1035 |
|
|
$sandbox['max'] = $records->rowCount();
|
1036 |
|
|
|
1037 |
|
|
watchdog('panelizer', 'Need to fix panes for @count entities that were lost by update 7115.', array('@count' => $records->rowCount()));
|
1038 |
|
|
}
|
1039 |
|
|
|
1040 |
|
|
// Get a small batch of records.
|
1041 |
|
|
$records = db_query_range("SELECT DISTINCT entity_type, entity_id
|
1042 |
|
|
FROM {panelizer_entity} pe
|
1043 |
|
|
LEFT OUTER JOIN {panels_pane} pp
|
1044 |
|
|
ON pe.did = pp.did
|
1045 |
|
|
WHERE pe.did > 0
|
1046 |
|
|
AND pp.did IS NULL", 0, $limit);
|
1047 |
|
|
|
1048 |
|
|
watchdog('panelizer', 'Fixing panes for @count entities that were lost by update 7115.', array('@count' => $records->rowCount()));
|
1049 |
|
|
|
1050 |
|
|
// Loop over each record.
|
1051 |
|
|
foreach ($records as $record) {
|
1052 |
|
|
// Track whether this entity was changed.
|
1053 |
|
|
$entity_updated = FALSE;
|
1054 |
|
|
|
1055 |
|
|
// Keep track of the last display for each entity.
|
1056 |
|
|
$last_display = NULL;
|
1057 |
|
|
|
1058 |
|
|
// Get each {panelizer_record} for this entity. Load these in REVERSE order
|
1059 |
|
|
// because the panes were moved to the last revision.
|
1060 |
|
|
$entity_records = db_query("SELECT *
|
1061 |
|
|
FROM {panelizer_entity}
|
1062 |
|
|
WHERE entity_type = :entity_type
|
1063 |
|
|
AND entity_id = :entity_id
|
1064 |
|
|
ORDER BY revision_id DESC", (array)$record);
|
1065 |
|
|
foreach ($entity_records as $panelizer) {
|
1066 |
|
|
// If this is a custom display, load it.
|
1067 |
|
|
if (!empty($panelizer->did)) {
|
1068 |
|
|
$display = panels_load_display($panelizer->did);
|
1069 |
|
|
|
1070 |
|
|
// Check if the display is bereft of panes.
|
1071 |
|
|
if (empty($display->content)) {
|
1072 |
|
|
// Hopefully the "last display" won't be blank.
|
1073 |
|
|
if (empty($last_display)) {
|
1074 |
|
|
watchdog('panelizer', "Unable to load records for display did for entity_type entity_id. Sorry.", (array)$panelizer);
|
1075 |
|
|
}
|
1076 |
|
|
else {
|
1077 |
|
|
foreach ($last_display->content as $pane) {
|
1078 |
|
|
// Clone the pane to avoid accidental damage.
|
1079 |
|
|
$new_pane = clone $pane;
|
1080 |
|
|
|
1081 |
|
|
// Erase the pid so a new record can be saved.
|
1082 |
|
|
$new_pane->pid = NULL;
|
1083 |
|
|
|
1084 |
|
|
// Tie the pane to this display.
|
1085 |
|
|
$new_pane->did = $display->did;
|
1086 |
|
|
|
1087 |
|
|
// Update the pane's UUID.
|
1088 |
|
|
$new_pane->uuid = ctools_uuid_generate();
|
1089 |
|
|
|
1090 |
|
|
// Serialize some of the fields prior to saving.
|
1091 |
|
|
foreach (array('access', 'configuration', 'cache', 'style', 'css', 'extras', 'locks') as $val) {
|
1092 |
|
|
$new_pane->$val = serialize($new_pane->$val);
|
1093 |
|
|
}
|
1094 |
|
|
|
1095 |
|
|
// Create the pane record.
|
1096 |
|
|
db_insert('panels_pane')
|
1097 |
|
|
->fields((array)$new_pane)
|
1098 |
|
|
->execute();
|
1099 |
|
|
|
1100 |
|
|
// Tell the world.
|
1101 |
|
|
module_invoke_all('panels_pane_insert', $new_pane);
|
1102 |
|
|
}
|
1103 |
|
|
}
|
1104 |
|
|
}
|
1105 |
|
|
|
1106 |
|
|
// This display included all of its panes, so skip the fixing and just
|
1107 |
|
|
// use it as the 'last' display for the next loop.
|
1108 |
|
|
else {
|
1109 |
|
|
$last_display = $display;
|
1110 |
|
|
}
|
1111 |
|
|
}
|
1112 |
|
|
}
|
1113 |
|
|
|
1114 |
|
|
// The entity was updated, to clear its cache.
|
1115 |
|
|
if ($entity_updated) {
|
1116 |
|
|
entity_get_controller($panelizer->entity_type)->resetCache(array($panelizer->entity_id));
|
1117 |
|
|
}
|
1118 |
|
|
|
1119 |
|
|
$sandbox['progress']++;
|
1120 |
|
|
}
|
1121 |
|
|
|
1122 |
|
|
$sandbox['#finished'] = ($sandbox['progress'] >= $sandbox['max']) ? TRUE : ($sandbox['progress'] / $sandbox['max']);
|
1123 |
|
|
|
1124 |
|
|
return t('Recovered panes for @count entities out of @total total.', array('@count' => $sandbox['progress'], '@total' => $sandbox['max']));
|
1125 |
|
|
}
|
1126 |
|
|
|
1127 |
|
|
/**
|
1128 |
|
|
* Fix the 'selection' variables.
|
1129 |
|
|
*/
|
1130 |
|
|
function panelizer_update_7121() {
|
1131 |
|
|
foreach (entity_get_info() as $entity_type => $entity_info) {
|
1132 |
|
|
if (isset($entity_info['bundles'])) {
|
1133 |
|
|
foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) {
|
1134 |
|
|
// View mode variables.
|
1135 |
|
|
if (!empty($entity_info['view modes'])) {
|
1136 |
|
|
foreach ($entity_info['view modes'] as $view_mode => $view_info) {
|
1137 |
|
|
$var_name = 'panelizer_' . $entity_type . ':' . $bundle_name . ':' . $view_mode . '_selection';
|
1138 |
|
|
$var = variable_get($var_name);
|
1139 |
|
|
if (empty($var)) {
|
1140 |
|
|
variable_del($var_name);
|
1141 |
|
|
}
|
1142 |
|
|
}
|
1143 |
|
|
}
|
1144 |
|
|
}
|
1145 |
|
|
}
|
1146 |
|
|
}
|
1147 |
|
|
}
|
1148 |
|
|
|
1149 |
|
|
/**
|
1150 |
|
|
* Remove {panelizer_entity} records with only default values.
|
1151 |
|
|
*/
|
1152 |
|
|
function panelizer_update_7300(&$sandbox) {
|
1153 |
|
|
// Initialize sandbox.
|
1154 |
|
|
if (empty($sandbox)) {
|
1155 |
|
|
$sandbox['progress'] = 0;
|
1156 |
|
|
$sandbox['processed_entity_types'] = array();
|
1157 |
|
|
|
1158 |
|
|
// Get a list of all records using a default display.
|
1159 |
|
|
$sandbox['max'] = db_query('SELECT COUNT(DISTINCT entity_type) FROM {panelizer_entity} WHERE did = 0')->fetchField();
|
1160 |
|
|
|
1161 |
136a805a
|
Assos Assos
|
// Bail if no records found.
|
1162 |
|
|
if (empty($sandbox['max'])) {
|
1163 |
|
|
return t('No records need to be fixed.');
|
1164 |
|
|
}
|
1165 |
|
|
|
1166 |
e5e66f93
|
Assos Assos
|
watchdog('panelizer', 'Default panelizer records will be removed for @count entity types.', array('@count' => $sandbox['max']));
|
1167 |
|
|
}
|
1168 |
|
|
|
1169 |
|
|
// Main sandbox query and loop. Processes one entity type at a time.
|
1170 |
|
|
$query = db_select('panelizer_entity', 'pe')
|
1171 |
|
|
->distinct()
|
1172 |
|
|
->fields('pe', array('entity_type'));
|
1173 |
|
|
if (!empty($sandbox['processed_entity_types'])) {
|
1174 |
|
|
$query->condition('entity_type', $sandbox['processed_entity_types'], 'NOT IN');
|
1175 |
|
|
}
|
1176 |
|
|
$entity_types = $query->execute()->fetchCol();
|
1177 |
|
|
foreach ($entity_types as $entity_type) {
|
1178 |
|
|
// Get the default panelizer names for the entity type.
|
1179 |
|
|
$default_names = array();
|
1180 |
|
|
$entity_info = entity_get_info($entity_type);
|
1181 |
|
|
if (!empty($entity_info) && !empty($entity_info['bundles'])) {
|
1182 |
|
|
foreach ($entity_info['bundles'] as $bundle => $bundle_info) {
|
1183 |
|
|
$var_name = 'panelizer_defaults_' . $entity_type . '_' . $bundle;
|
1184 |
|
|
$settings = variable_get($var_name);
|
1185 |
|
|
if (!empty($settings) && !empty($settings['view modes'])) {
|
1186 |
|
|
foreach ($settings['view modes'] as $view_mode => $config) {
|
1187 |
|
|
$default_name = implode(':', array($entity_type, $bundle, 'default'));
|
1188 |
|
|
if ($view_mode != 'page_manager') {
|
1189 |
|
|
$default_name .= ':' . $view_mode;
|
1190 |
|
|
}
|
1191 |
|
|
$default_names[] = $default_name;
|
1192 |
|
|
}
|
1193 |
|
|
}
|
1194 |
|
|
}
|
1195 |
|
|
}
|
1196 |
|
|
|
1197 |
|
|
// Delete panelizer records that have one of the default names.
|
1198 |
|
|
$deleted = db_delete('panelizer_entity')
|
1199 |
|
|
->condition('name', $default_names, 'IN')
|
1200 |
|
|
->condition('entity_type', $entity_type)
|
1201 |
|
|
->execute();
|
1202 |
|
|
if ($deleted > 0) {
|
1203 |
|
|
watchdog('panelizer', '@count default panelizer records were removed for entity type: @entity_type.', array('@count' => $deleted, '@entity_type' => $entity_type));
|
1204 |
|
|
}
|
1205 |
|
|
else {
|
1206 |
|
|
watchdog('panelizer', 'No default panelizer records were found for entity type: @entity_type.', array('@entity_type' => $entity_type));
|
1207 |
|
|
}
|
1208 |
|
|
|
1209 |
|
|
// Update sandbox progress.
|
1210 |
|
|
$sandbox['progress']++;
|
1211 |
|
|
$sandbox['processed_entity_types'][] = $entity_type;
|
1212 |
|
|
}
|
1213 |
|
|
|
1214 |
|
|
if ($sandbox['progress'] != $sandbox['max']) {
|
1215 |
|
|
$sandbox['#finished'] = $sandbox['progress'] / $sandbox['max'];
|
1216 |
|
|
}
|
1217 |
|
|
}
|
1218 |
|
|
|
1219 |
|
|
/**
|
1220 |
|
|
* Add an index to {panelizer_entity} revision IDs.
|
1221 |
|
|
*/
|
1222 |
|
|
function panelizer_update_7301() {
|
1223 |
|
|
if (!db_index_exists('panelizer_entity', 'revision_id')) {
|
1224 |
|
|
db_add_index('panelizer_entity', 'revision_id', array('revision_id'));
|
1225 |
|
|
return t('Added an extra index on the {panelizer_entity} table for the revision_id column.');
|
1226 |
|
|
}
|
1227 |
|
|
else {
|
1228 |
|
|
return t('There was already an index on the {panelizer_entity} table for the revision_id column, so nothing was done.');
|
1229 |
|
|
}
|
1230 |
85ad3d82
|
Assos Assos
|
}
|
1231 |
136a805a
|
Assos Assos
|
|
1232 |
|
|
/**
|
1233 |
|
|
* Set the storage type and ID on existing {panelizer_default} records.
|
1234 |
|
|
*/
|
1235 |
|
|
function panelizer_update_7302(&$sandbox) {
|
1236 |
|
|
if (!isset($sandbox['progress'])) {
|
1237 |
|
|
// Initialize batch update information.
|
1238 |
|
|
$sandbox['progress'] = (float)0;
|
1239 |
|
|
$sandbox['current_did'] = -1;
|
1240 |
|
|
$sandbox['max'] = db_query("SELECT COUNT(pd.did)
|
1241 |
|
|
FROM {panels_display} pd
|
1242 |
|
|
JOIN {panelizer_defaults} p ON p.did = pd.did
|
1243 |
|
|
WHERE pd.storage_type = ''")->fetchField();
|
1244 |
|
|
if (empty($sandbox['max'])) {
|
1245 |
|
|
return t('Nothing to be fixed in Panelizer update 7302.');
|
1246 |
|
|
}
|
1247 |
|
|
}
|
1248 |
|
|
|
1249 |
2545992a
|
Assos Assos
|
// Set a limit of how many rows to process per batch.
|
1250 |
|
|
$limit = 100;
|
1251 |
136a805a
|
Assos Assos
|
|
1252 |
|
|
// Run the query
|
1253 |
|
|
$result = db_query_range("SELECT pd.did, p.name
|
1254 |
|
|
FROM {panels_display} pd
|
1255 |
|
|
JOIN {panelizer_defaults} p ON p.did = pd.did
|
1256 |
2545992a
|
Assos Assos
|
WHERE pd.storage_type = '' AND pd.did > :current_did
|
1257 |
|
|
ORDER BY pd.did ASC", 0, $limit, array(
|
1258 |
|
|
':current_did' => $sandbox['current_did'],
|
1259 |
|
|
));
|
1260 |
|
|
|
1261 |
|
|
// No results means that it's finished.
|
1262 |
|
|
if (empty($result)) {
|
1263 |
|
|
$sandbox['progress'] = $sandbox['max'];
|
1264 |
|
|
}
|
1265 |
|
|
else {
|
1266 |
|
|
foreach ($result as $row) {
|
1267 |
|
|
db_update('panels_display')
|
1268 |
|
|
->fields(array(
|
1269 |
|
|
'storage_type' => 'panelizer_default',
|
1270 |
|
|
'storage_id' => $row->name,
|
1271 |
|
|
))
|
1272 |
|
|
->condition('did', $row->did)
|
1273 |
|
|
->execute();
|
1274 |
136a805a
|
Assos Assos
|
|
1275 |
2545992a
|
Assos Assos
|
// Update our progress information.
|
1276 |
|
|
$sandbox['progress']++;
|
1277 |
|
|
$sandbox['current_did'] = $row->did;
|
1278 |
|
|
}
|
1279 |
136a805a
|
Assos Assos
|
}
|
1280 |
|
|
|
1281 |
|
|
// Set the "finished" status, to tell batch engine whether this function
|
1282 |
|
|
// needs to run again.
|
1283 |
|
|
$sandbox['#finished'] = ($sandbox['progress'] >= $sandbox['max']) ? TRUE : ($sandbox['progress'] / $sandbox['max']);
|
1284 |
|
|
|
1285 |
|
|
if ($sandbox['#finished']) {
|
1286 |
|
|
return t('Added the storage type for panelizer_defaults to relevant panels displays');
|
1287 |
|
|
}
|
1288 |
|
|
}
|
1289 |
|
|
|
1290 |
|
|
/**
|
1291 |
2545992a
|
Assos Assos
|
* Set the storage type and ID on existing {panelizer_entity} records. This may
|
1292 |
|
|
* take some time to complete.
|
1293 |
136a805a
|
Assos Assos
|
*/
|
1294 |
|
|
function panelizer_update_7303(&$sandbox) {
|
1295 |
|
|
if (!isset($sandbox['progress'])) {
|
1296 |
|
|
// Initialize batch update information.
|
1297 |
|
|
$sandbox['progress'] = (float)0;
|
1298 |
|
|
$sandbox['current_did'] = -1;
|
1299 |
|
|
$sandbox['max'] = db_query("SELECT COUNT(pd.did)
|
1300 |
|
|
FROM {panels_display} pd
|
1301 |
|
|
JOIN {panelizer_entity} p ON p.did = pd.did
|
1302 |
|
|
WHERE pd.storage_type = ''")->fetchField();
|
1303 |
|
|
if (empty($sandbox['max'])) {
|
1304 |
|
|
return t('Nothing to be fixed in Panelizer update 7303.');
|
1305 |
|
|
}
|
1306 |
|
|
}
|
1307 |
|
|
|
1308 |
|
|
// Set a limit of how many rows to process per batch.
|
1309 |
2545992a
|
Assos Assos
|
$limit = 100;
|
1310 |
136a805a
|
Assos Assos
|
|
1311 |
|
|
// Look for records to be updated.
|
1312 |
|
|
$result = db_query_range("SELECT pd.did, p.entity_type, p.entity_id, p.view_mode
|
1313 |
|
|
FROM {panels_display} pd
|
1314 |
|
|
JOIN {panelizer_entity} p ON p.did = pd.did
|
1315 |
2545992a
|
Assos Assos
|
WHERE pd.storage_type = '' AND pd.did > :current_did
|
1316 |
|
|
ORDER BY pd.did ASC", 0, $limit, array(
|
1317 |
|
|
':current_did' => $sandbox['current_did'],
|
1318 |
|
|
));
|
1319 |
|
|
|
1320 |
|
|
// No results means that it's finished.
|
1321 |
|
|
if (empty($result)) {
|
1322 |
|
|
$sandbox['progress'] = $sandbox['max'];
|
1323 |
|
|
}
|
1324 |
|
|
else {
|
1325 |
|
|
foreach ($result as $row) {
|
1326 |
|
|
db_update('panels_display')
|
1327 |
|
|
->fields(array(
|
1328 |
|
|
'storage_type' => 'panelizer_entity',
|
1329 |
|
|
'storage_id' => implode(':', array($row->entity_type, $row->entity_id, $row->view_mode)),
|
1330 |
|
|
))
|
1331 |
|
|
->condition('did', $row->did)
|
1332 |
|
|
->execute();
|
1333 |
136a805a
|
Assos Assos
|
|
1334 |
2545992a
|
Assos Assos
|
// Update our progress information.
|
1335 |
|
|
$sandbox['progress']++;
|
1336 |
|
|
$sandbox['current_did'] = $row->did;
|
1337 |
|
|
}
|
1338 |
136a805a
|
Assos Assos
|
}
|
1339 |
|
|
|
1340 |
|
|
// Set the "finished" status, to tell batch engine whether this function
|
1341 |
|
|
// needs to run again.
|
1342 |
|
|
$sandbox['#finished'] = ($sandbox['progress'] >= $sandbox['max']) ? TRUE : ($sandbox['progress'] / $sandbox['max']);
|
1343 |
|
|
|
1344 |
|
|
if ($sandbox['#finished']) {
|
1345 |
|
|
return t('Added the storage type for panelizer_entities to relevant panels displays');
|
1346 |
|
|
}
|
1347 |
|
|
} |