You are here

function media_oembed_update_7007 in oEmbed 7

Same name and namespace in other branches
  1. 7.0 deprecated/media_oembed/media_oembed.install \media_oembed_update_7007()

Rename file displays.

File

modules/media_oembed/media_oembed.install, line 62
Install, update and uninstall functions for the Media: oEmbed module.

Code

function media_oembed_update_7007() {
  ctools_include('export');
  $displays = ctools_export_load_object('file_display');
  foreach ($displays as $name => $display) {
    list($file_type, $view_mode, $formatter_name) = explode('__', $name);
    if (strpos($formatter_name, 'media_oembed') === 0) {
      $formatter_name = str_replace('media_oembed', 'oembed', $formatter_name);
      $new_display = array(
        'api_version' => 1,
        'name' => implode('__', array(
          $file_type,
          $view_mode,
          $formatter_name,
        )),
        'status' => $display->status,
        'weight' => $display->weight,
        'settings' => $display->settings,
        'export_type' => NULL,
      );
      file_display_save((object) $new_display);
      if ($display->export_type & EXPORT_IN_DATABASE) {
        ctools_export_crud_delete('file_display', $name);
      }
      if ($display->export_type & EXPORT_IN_CODE) {
        ctools_export_crud_disable('file_display', $name);
      }
    }
  }
}