function ds_import_data in Display Suite 6.3
Same name and namespace in other branches
- 6 includes/ds.tools.inc \ds_import_data()
- 6.2 includes/ds.tools.inc \ds_import_data()
Import data function.
Parameters
array $data A complete data array with settings.:
boolean $dsm Whether to output drupal messages.:
boolean $override Whether to override existing settings or not.:
string $revert_module The module to revert.:
string $revert_type The object type to revert.:
string $revert_build_mode The build mode to revert.:
2 calls to ds_import_data()
- ds_import_default_data in ./
ds.module - Import default display data from modules.
- ds_import_submit in includes/
ds.tools.inc - Import submit function.
File
- includes/
ds.tools.inc, line 64 - Tools for Display suite like export & import.
Code
function ds_import_data($data, $dsm = TRUE, $override = TRUE, $revert_module = '', $revert_type = '', $revert_build_mode = '') {
foreach ($data as $module => $value) {
foreach ($value as $type => $settings) {
if ($dsm) {
drupal_set_message(t('Saved display settings for @module and @type', array(
'@module' => $module,
'@type' => $type,
)));
}
foreach ($settings as $build_mode => $setting) {
$old_settings = ds_get_settings($module, $type, $build_mode);
// Override no matter what. This comes from the import settings screen.
if ($override) {
$settings[$build_mode]['status'] = DS_SETTINGS_UI;
}
else {
if (isset($old_settings['status']) && $old_settings['status'] == DS_SETTINGS_OVERRIDDEN) {
if ($module == $revert_module && $type == $revert_type && $build_mode == $revert_build_mode) {
$settings[$build_mode]['status'] = DS_SETTINGS_DEFAULT;
}
else {
$settings[$build_mode] = $old_settings;
}
}
else {
$settings[$build_mode]['status'] = DS_SETTINGS_DEFAULT;
}
}
// Remove old settings.
db_query("DELETE FROM {ds_settings} WHERE build_mode = '%s' AND module = '%s' AND type = '%s'", $build_mode, $module, $type);
// Get settings.
$store = $settings[$build_mode];
// Iterate over fields and ditch those which are hidden.
// This is for sites have upgraded but haven't re-exported their settings.
foreach ($store['fields'] as $field_key => $field_value) {
if ($field_value['region'] == 'disabled') {
unset($store['fields'][$field_key]);
}
}
// Save new settings.
$record = new stdClass();
$record->module = $module;
$record->type = $type;
$record->build_mode = $build_mode;
$record->settings = serialize($store);
drupal_write_record('ds_settings', $record);
}
// Act on saving these settings.
module_invoke_all('ds_settings_import', $module, $type, $settings);
}
}
}