function taxonomy_xml_source_features_export_render in Taxonomy import/export via XML 7
Same name and namespace in other branches
- 6.2 taxonomy_xml.features.inc \taxonomy_xml_source_features_export_render()
Implements hook_features_export_render()
Return the PHP code that represents a dump of the settings listed as $data
This string is compared to the current site status to determine if the feature is 'overridden'. This will not work, as we insert once into the database, but cannot retrieve what was inserted, so our feature will always allegedly be overridden. TODO find a way to tidy this. Count the terms?
File
- ./
taxonomy_xml.features.inc, line 69
Code
function taxonomy_xml_source_features_export_render($module, $data) {
$code = array();
$code[] = ' $settings = array();';
$code[] = '';
$all_nodes = array_map('check_plain', node_type_get_name());
// To avoid an imprt being flagged as overridden each time,
// return a cached copy of the settings that we imported,
// to tell the system there is no change.
// This is cheating the method that detects overrides.
// TODO - do this properly instead.
$taxonomy_xml_imports = variable_get('taxonomy_xml_imports', array());
$translatables = array();
foreach ($data as $item_id) {
if (isset($taxonomy_xml_imports[$item_id])) {
$item = $taxonomy_xml_imports[$item_id];
if (empty($item['nodes'])) {
$item['nodes'] = array();
}
// Check if the node associations are 'wildcard'.
$diff = array_diff((array) $all_nodes, (array) $item['nodes']);
if (empty($diff)) {
$item['nodes'] = '*';
}
unset($item['module']);
$code[] = " // Exported {$item_id}";
$export = features_var_export($item, ' ');
$code[] = " \$settings['{$item_id}'] = {$export};";
}
}
$code[] = '';
$code[] = ' return $settings;';
$code = implode("\n", $code);
return array(
'taxonomy_xml_source_default_items' => $code,
);
}