summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--modules/content_migrate/content_migrate.info2
-rw-r--r--modules/content_migrate/includes/content_migrate.admin.inc28
-rw-r--r--modules/content_migrate/includes/content_migrate.drush.inc72
3 files changed, 94 insertions, 8 deletions
diff --git a/modules/content_migrate/content_migrate.info b/modules/content_migrate/content_migrate.info
index fe19746..39d0072 100644
--- a/modules/content_migrate/content_migrate.info
+++ b/modules/content_migrate/content_migrate.info
@@ -4,8 +4,10 @@ description = Migrate fields and field data from CCK D6 format to the D7 field f
core = 7.x
package = CCK
files[] = content_migrate.module
+files[] = content_migrate.api.php
files[] = includes/content_migrate.admin.inc
files[] = includes/content_migrate.values.inc
+files[] = includes/content_migrate.drush.inc
files[] = modules/content_migrate.text.inc
files[] = modules/content_migrate.number.inc
files[] = modules/content_migrate.optionwidgets.inc
diff --git a/modules/content_migrate/includes/content_migrate.admin.inc b/modules/content_migrate/includes/content_migrate.admin.inc
index a172ec5..11c08e0 100644
--- a/modules/content_migrate/includes/content_migrate.admin.inc
+++ b/modules/content_migrate/includes/content_migrate.admin.inc
@@ -6,20 +6,16 @@
*/
/**
- * Form generator for the migration selection form.
- *
- * @todo Make this into a nice table where you have
- * an option to check all available fields to migrate
- * them all at once.
+ * Determine which fields can be migrated, have already been migrated, and are
+ * unable to be migrated due to missing modules.
*/
-function content_migrate_select($form, &$form_state) {
- $form = array();
+function content_migrate_get_options() {
$options = array('available' => array(), 'converted' => array(), 'missing' => array());
$field_values = content_migrate_get_field_values();
if (empty($field_values)) {
drupal_set_message(t('There is no D6 field information in this database.'));
- return $form;
+ return FALSE;
}
$type_names = node_type_get_names();
@@ -63,6 +59,22 @@ function content_migrate_select($form, &$form_state) {
$options['available'][$field_name] = $data;
}
}
+ return $options;
+}
+
+/**
+ * Form generator for the migration selection form.
+ *
+ * @todo Make this into a nice table where you have
+ * an option to check all available fields to migrate
+ * them all at once.
+ */
+function content_migrate_select($form, &$form_state) {
+ $form = array();
+ $options = content_migrate_get_options();
+ if (!$options) {
+ return $form;
+ }
$header = array(t('Field'), t('Field type'), t('Content type(s)'), t('Other information'));
$form['#tree'] = TRUE;
diff --git a/modules/content_migrate/includes/content_migrate.drush.inc b/modules/content_migrate/includes/content_migrate.drush.inc
new file mode 100644
index 0000000..56a4aa2
--- /dev/null
+++ b/modules/content_migrate/includes/content_migrate.drush.inc
@@ -0,0 +1,72 @@
+<?php
+// $Id$
+/**
+ * @file content_migrate.admin.inc
+ * Code to process field data migration, moved into a separate file for efficiency.
+ */
+
+/**
+ * Implementation of hook_drush_help().
+ */
+function content_migrate_drush_help($section) {
+ switch ($section) {
+ case 'content migrate:content-migrate':
+ return dt("Migrate all fields");
+ case 'content migrate:content-migrate-structure':
+ return dt("Migrate a single field structure");
+ case 'content migrate:content-migrate-data':
+ return dt("Migrate a single field data");
+ }
+}
+
+
+/**
+ * Implementation of hook_drush_command().
+ */
+function content_migrate_drush_command() {
+ $items['content-migrate'] = array(
+ 'description' => 'Migrate fields.',
+ );
+ $items['content-migrate-field-structure'] = array(
+ 'description' => 'Migrate a single field structure.',
+ 'arguments' => array(
+ 'name' => 'A field system name.',
+ ),
+ );
+ $items['content-migrate-field-data'] = array(
+ 'description' => 'Migrate a single field data.',
+ );
+
+ return $items;
+}
+
+/**
+ * Command callback.
+ */
+function drush_content_migrate() {
+ module_load_include('inc', 'content_migrate', 'includes/content_migrate.admin');
+ $fields = content_migrate_get_options();
+ $field_names = array_keys($fields['available']);
+
+ foreach ($field_names as $field_name) {
+ drush_invoke_process_args('content-migrate-field-structure', array($field_name));
+ }
+ foreach ($field_names as $field_name) {
+ drush_invoke_process_args('content-migrate-field-data', array($field_name));
+ }
+}
+
+function drush_content_migrate_field_structure($field_name) {
+ drush_log('Migrating structure: ' . $field_name);
+ module_load_include('inc', 'content_migrate', 'includes/content_migrate.admin');
+ _content_migrate_batch_process_create_fields(array($field_name));
+}
+
+function drush_content_migrate_field_data($field_name) {
+ drush_log('Migrating data: ' . $field_name);
+ module_load_include('inc', 'content_migrate', 'includes/content_migrate.admin');
+ $context = array(
+ 'sandbox' => array(),
+ );
+ _content_migrate_batch_process_migrate_data($field_name, $context);
+}