'Export distribution', 'access arguments' => array('export distribution'), 'page callback' => 'distrib_export', 'type' => MENU_CALLBACK, ); return $items; } function distrib_export() { distrib_export_vocabs(); distrib_export_content_types(); return t('Your distribution has been exported and saved in !path.', array('!path' => file_directory_path() . '/distrib_export')); } function distrib_export_vocabs() { $code = ''; $vocabs = taxonomy_get_vocabularies(); foreach ($vocabs as $vocab) { $properties = get_object_vars($vocab); unset($properties['name']); unset($properties['nodes']); unset($properties['vid']); $nodes = var_export($vocab->nodes, true); $properties = var_export($properties, true); $code .= "install_taxonomy_add_vocabulary('$vocab->name', $nodes, $properties);\n"; } $res = fopen(file_directory_path() . '/distrib_export/vocabs.inc', "w"); fwrite($res, '<' . '?php' . "\n$code"); fclose($res); return $code; } function distrib_export_content_types() { $dir = file_directory_path() . '/distrib_export/content_types'; $types = node_get_types(); foreach ($types as $type => $info) { if ($info->module != 'node') { continue; } // let modules like webform, blog, etc. define their own content types if (in_array($type, array('page', 'story'))) { continue; } // ignore the automatically generated types $cck_info = content_types($type); $file = "$type.def"; $res = fopen($dir . '/' . $file, "w"); $def = content_copy_export(array('type_name' => $type, 'fields' => array_keys($cck_info['fields']))); fwrite($res, '<' . '?php' . "\n$def"); fclose ($res); } }