function slick_views_update_7301 in Slick Views 7.3
Update the deprecated Slick Views options to migrate from Slick 2.x to 3.x.
Tasks:<br>
- Updated deprecated settings for both Slick Views style and formatters.<br>
- Updated deprecated Slick formatter to the new one based on field type.<br>
File
- ./
slick_views.install, line 118 - Installation actions for Slick Views.
Code
function slick_views_update_7301() {
if (!db_table_exists('views_display')) {
return;
}
module_load_include('inc', 'ctools', 'includes/export');
module_load_include('inc', 'slick', 'includes/slick.update');
// Update Slick Views deprecated settings to use more generic settings.
$names = _slick_views_get_view_names();
if (empty($names)) {
return;
}
$success = FALSE;
foreach ($names as $name) {
$view = ctools_export_crud_load('views_view', $name);
// Code has been saved into database previously, the view which was stored
// in codebase has now an ID to work with. Here is just in case.
if (empty($view->vid)) {
continue;
}
foreach ($view->display as &$display) {
if (!empty($display->display_options) && _slick_views_update_style_options($display->display_options)) {
db_update('views_display')
->fields([
'display_options' => serialize($display->display_options),
])
->condition('id', $view->vid)
->execute();
$success = TRUE;
}
}
// Without re-saving the entire view, the above views_display is ignored.
if ($success) {
ctools_export_crud_save('views_view', $view);
}
}
// Clear caches that might contain stale Views displays.
// Rebuild CTools cache for the views_view.
if ($success) {
ctools_export_load_object_reset('views_view');
cache_clear_all('*', 'cache_views', TRUE);
cache_clear_all('*', 'cache_views_data', TRUE);
cache_clear_all('*', 'cache_block', TRUE);
cache_clear_all('*', 'cache_page', TRUE);
}
return $success ? t('Slick Views style plugin updated.') : t('Doh! Slick Views failed updating.');
}