You are here

function file_entity_update_7001 in D7 Media 7

Move file display configurations from the 'file_displays' variable to the {file_display} database table.

1 call to file_entity_update_7001()
media_update_7017 in ./media.install
Move file display configurations from the 'file_displays' variable to the {file_display} table.

File

file_entity/file_entity.install, line 199
Install, update and uninstall functions for the file_entity module.

Code

function file_entity_update_7001() {
  $file_displays = variable_get('file_displays');
  if (!empty($file_displays)) {
    foreach ($file_displays as $file_type => $file_type_displays) {
      if (!empty($file_type_displays)) {
        foreach ($file_type_displays as $view_mode => $view_mode_displays) {
          if (!empty($view_mode_displays)) {
            foreach ($view_mode_displays as $formatter_name => $display) {
              if (!empty($display)) {
                db_merge('file_display')
                  ->key(array(
                  'name' => implode('__', array(
                    $file_type,
                    $view_mode,
                    $formatter_name,
                  )),
                ))
                  ->fields(array(
                  'status' => isset($display['status']) ? $display['status'] : 0,
                  'weight' => isset($display['weight']) ? $display['weight'] : 0,
                  'settings' => isset($display['settings']) ? serialize($display['settings']) : NULL,
                ))
                  ->execute();
              }
            }
          }
        }
      }
    }
  }
  variable_del('file_displays');
}