function fe_block_settings_features_export_render in Features Extra 6
Same name and namespace in other branches
- 7 fe_block/fe_block.module \fe_block_settings_features_export_render()
Implementation of hook_features_export_render().
File
- ./
fe_block.module, line 83
Code
function fe_block_settings_features_export_render($module_name = '', $data) {
global $custom_theme, $theme_key;
init_theme();
$backup = array(
$custom_theme,
$theme_key,
);
$component = 'fe_block_settings';
$default_hook = 'default_' . $component;
$theme_default = variable_get('theme_default', 'garland');
$themes = list_themes();
$code = array();
$code[] = ' $export = array();';
$code[] = '';
foreach ($themes as $_theme_key => $theme) {
if ($_theme_key == $theme_default || !empty($theme->status)) {
$code[] = ' // ' . $_theme_key;
$code[] = ' $theme = array();';
$code[] = '';
$custom_theme = $theme_key = $_theme_key;
$blocks = _block_rehash();
usort($blocks, '_fe_block_compare');
foreach ($blocks as $block) {
unset($block['bid'], $block['info']);
$block_id = _fe_block_build_id($block);
if (empty($block_id)) {
continue;
}
if (in_array($block_id, $data)) {
// Use machine name with boxes.
if ($block['module'] == 'block') {
$block['machine_name'] = _fe_block_get_machine_name($block['delta']);
unset($block['delta']);
}
// Region.
if ($block['region'] == BLOCK_REGION_NONE) {
$block['status'] = 0;
$block['region'] = '';
}
$code[] = ' $theme[\'' . $block_id . '\'] = ' . features_var_export($block, ' ') . ';';
$code[] = '';
}
}
$code[] = ' $export[\'' . $_theme_key . '\'] = $theme;';
$code[] = '';
}
}
// Only reture for enabled themes and the default theme.
$code[] = ' $theme_default = variable_get(\'theme_default\', \'garland\');';
$code[] = ' $themes = list_themes();';
$code[] = ' foreach ($export as $theme_key => $settings) {';
$code[] = ' if ($theme_key != $theme_default && empty($themes[$theme_key]->status)) {';
$code[] = ' unset($export[$theme_key]);';
$code[] = ' }';
$code[] = ' }';
$code[] = ' return $export;';
$code = implode("\n", $code);
list($custom_theme, $theme_key) = $backup;
return array(
$default_hook => $code,
);
}