You are here

function file_entity_update_7001 in File Entity (fieldable files) 7.2

Same name and namespace in other branches
  1. 7.3 file_entity.install \file_entity_update_7001()
  2. 7 file_entity.install \file_entity_update_7001()

Move file display configurations.

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

File

./file_entity.install, line 307
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');
}