function migrate_export_content_set in Migrate 6
Menu callback function.
1 string reference to 'migrate_export_content_set'
- migrate_menu in ./
migrate.module - Implementation of hook_menu().
File
- ./
migrate_pages.inc, line 927
Code
function migrate_export_content_set($form_state, $mcsid) {
$row = db_fetch_array(db_query("SELECT * FROM {migrate_content_sets}\n WHERE mcsid=%d", $mcsid));
drupal_set_title(check_plain($row['description']));
// TODO: Generate Table Wizard calls?
$code = ' $content_set = new stdClass;' . "\n";
unset($row['mcsid']);
foreach ($row as $field => $value) {
// Yes, we're potentially quoting integer values - it all works out
$code .= ' $content_set->' . $field . "= '" . $value . "';\n";
}
$code .= ' migrate_save_content_set($content_set);' . "\n";
$code .= "// when used in hook_install(), use this line instead\n";
$code .= "// migrate_save_content_set(\$content_set, array('base_table' => 'table_name'));\n";
$code .= ' $mcsid = $content_set->mcsid;' . "\n\n";
$sql = "SELECT * FROM {migrate_content_mappings} WHERE mcsid=%d";
$result = db_query($sql, $mcsid);
while ($row = db_fetch_array($result)) {
unset($row['mcmid']);
unset($row['mcsid']);
$code .= ' $mapping = new stdClass;' . "\n";
$code .= ' $mapping->mcsid = $mcsid;' . "\n";
foreach ($row as $field => $value) {
$code .= ' $mapping->' . $field . "= '" . $value . "';\n";
}
$code .= ' migrate_save_content_mapping($mapping);' . "\n\n";
}
$lines = substr_count($code, "\n");
$form['description'] = array(
'#prefix' => '<div>',
'#value' => t('Copy this code to the the clipboard and paste it into an
install or update hook. This enables you to maintain content sets
programmatically, and to put their definitions under source control.'),
'#suffix' => '</div>',
);
$form['export'] = array(
'#title' => t('Export data'),
'#type' => 'textarea',
'#value' => $code,
'#rows' => $lines,
);
return $form;
}