You are here

function _slick_views_update_style_options in Slick Views 7.3

Utility function to update formatter and style options within Views displays.

@todo use batch for potential large sets of slicks.

1 call to _slick_views_update_style_options()
slick_views_update_7301 in ./slick_views.install
Update the deprecated Slick Views options to migrate from Slick 2.x to 3.x.

File

./slick_views.install, line 29
Installation actions for Slick Views.

Code

function _slick_views_update_style_options(&$display_options) {
  if (!function_exists('_slick_update_formatter_settings')) {
    module_load_include('inc', 'slick', 'includes/slick.update');
  }
  $updated = FALSE;

  // 1. Update style options.
  if (isset($display_options['style_plugin']) && $display_options['style_plugin'] == 'slick' && isset($display_options['style_options'])) {
    $updated = TRUE;
    _slick_update_formatter_settings($display_options['style_options']);
  }

  // 2. Also update formatters within views.
  if (isset($display_options['fields'])) {
    foreach ($display_options['fields'] as $field_name => $field_display) {
      if (isset($field_display['type']) && $field_display['type'] == 'slick' && isset($field_display['settings'])) {
        $updated = TRUE;
        $field = field_info_field($field_name);

        // Update deprecated settings, and formatter to the new ones.
        _slick_update_formatter_settings($display_options['fields'][$field_name]['settings']);
        $display_options['fields'][$field_name]['type'] = 'slick_' . $field['type'];
      }
    }
  }
  return $updated;
}