? 484404_migrate_export_content_sets.patch ? migrate_export_lite.patch ? migrate_export_lite2.patch ? migrate_export_lite3.patch Index: migrate.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/migrate/migrate.module,v retrieving revision 1.1.2.63 diff -u -p -r1.1.2.63 migrate.module --- migrate.module 24 Sep 2009 00:47:46 -0000 1.1.2.63 +++ migrate.module 24 Sep 2009 02:38:49 -0000 @@ -1049,6 +1049,14 @@ function migrate_menu() { 'type' => MENU_CALLBACK, 'file' => 'migrate_pages.inc', ); + $items['admin/content/migrate/content_sets/%/export'] = array( + 'title' => 'Content set', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('migrate_export_content_set', 4), + 'access arguments' => array(MIGRATE_ACCESS_ADVANCED), + 'type' => MENU_CALLBACK, + 'file' => 'migrate_pages.inc', + ); $items['migrate/xlat/%'] = array( 'page callback' => 'migrate_xlat', 'access arguments' => array('access content'), Index: migrate_pages.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/migrate/migrate_pages.inc,v retrieving revision 1.1.2.43 diff -u -p -r1.1.2.43 migrate_pages.inc --- migrate_pages.inc 18 Sep 2009 19:13:05 -0000 1.1.2.43 +++ migrate_pages.inc 24 Sep 2009 02:38:50 -0000 @@ -876,3 +876,48 @@ function _migrate_get_view_count($view) $view->execute(); return $view->total_rows; } + +/** + * Menu callback function. + */ +function migrate_export_content_set($form_state, $mcsid) { + $row = db_fetch_array(db_query("SELECT * FROM {migrate_content_sets} + WHERE mcsid=%d", + $mcsid)); + drupal_set_title(check_plain($row['description'])); + // TODO: Examine the view, figure out what tables it uses, for those + // managed by Table Wizard figure out the relationships and generate + // tw API calls + $code = ' // TODO: Table Wizard setup here' . "\n"; + $code .= ' $content_set = new stdClass;' . "\n"; + unset($row['mcsid']); + foreach ($row as $field => $value) { + // Yes, we're quoting integer values - it all works out + $code .= ' $content_set->' . $field . "= '" . $value . "';\n"; + } + $code .= ' migrate_save_content_set($content_set);' . "\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['export'] = array( + '#title' => t('Export data'), + '#type' => 'textarea', + '#value' => $code, + '#rows' => $lines, + '#description' => t('Copy the export text and paste it into another content set using the import function.'), + ); + return $form; +}