View source
<?php
function spaces_features_export($data, &$export, $module_name = '') {
$export['dependencies']['spaces'] = 'spaces';
foreach ($data as $preset) {
$export['features']['spaces'][$preset] = $preset;
}
return array();
}
function spaces_features_export_render($module = 'foo', $data) {
$code = array();
$code[] = ' $presets = array();';
$code[] = '';
$presets = spaces_presets();
foreach ($data as $id) {
$preset = NULL;
$presets = spaces_presets();
foreach (array_keys($presets) as $type) {
if (isset($presets[$type][$id])) {
$preset = $presets[$type][$id];
break;
}
}
if ($preset) {
unset($preset['disabled']);
unset($preset['storage']);
$code[] = ' // Exported preset: ' . $id;
$code[] = ' $presets[\'' . $id . '\'] = ' . features_var_export($preset, ' ') . ';';
$code[] = '';
}
}
$code[] = ' return $presets;';
$code = implode("\n", $code);
return array(
'spaces_presets' => $code,
);
}
function spaces_features_revert($module = NULL) {
if (module_hook($module, 'spaces_presets')) {
module_load_include('inc', 'spaces', 'spaces_admin');
$presets = module_invoke($module, 'spaces_presets');
foreach ($presets as $id => $preset) {
spaces_preset_delete($preset['type'], $id);
}
}
return TRUE;
}