function _migrate_ui_dashboard_form in Migrate 6.2
Form for reviewing migrations.
1 string reference to '_migrate_ui_dashboard_form'
- migrate_ui_dashboard in migrate_ui/
migrate_ui.pages.inc - Menu callback
File
- migrate_ui/
migrate_ui.pages.inc, line 17
Code
function _migrate_ui_dashboard_form() {
drupal_add_css(drupal_get_path('module', 'migrate_ui') . '/migrate_ui.css');
$build = array();
$build['overview'] = array(
'#prefix' => '<div>',
'#value' => migrate_overview(),
'#suffix' => '</div>',
);
$header = array(
'status' => array(
'data' => t('Status'),
),
'machinename' => array(
'data' => t('Migration'),
),
'importrows' => array(
'data' => t('Total rows'),
),
'imported' => array(
'data' => t('Imported'),
),
'unimported' => array(
'data' => t('Unimported'),
),
'messages' => array(
'data' => t('Messages'),
),
'lastthroughput' => array(
'data' => t('Throughput'),
),
'lastimported' => array(
'data' => t('Last imported'),
),
);
$migrations = migrate_migrations();
$rows = array();
foreach ($migrations as $migration) {
$row = array();
$has_counts = TRUE;
if (method_exists($migration, 'sourceCount')) {
$total = $migration
->sourceCount();
if ($total < 0) {
$has_counts = FALSE;
$total = t('N/A');
}
}
else {
$has_counts = FALSE;
$total = t('N/A');
}
if (method_exists($migration, 'importedCount')) {
$imported = $migration
->importedCount();
$processed = $migration
->processedCount();
}
else {
$has_counts = FALSE;
$imported = t('N/A');
}
if ($has_counts) {
$unimported = $total - $processed;
}
else {
$unimported = t('N/A');
}
$status = $migration
->getStatus();
switch ($status) {
case MigrationBase::STATUS_IDLE:
$status = t('Idle');
break;
case MigrationBase::STATUS_IMPORTING:
$status = t('Importing');
break;
case MigrationBase::STATUS_ROLLING_BACK:
$status = t('Rolling back');
break;
case MigrationBase::STATUS_STOPPING:
$status = t('Stopping');
break;
case MigrationBase::STATUS_DISABLED:
$status = t('Disabled');
break;
default:
$status = t('Unknown');
break;
}
$row['status'] = $status;
$machine_name = $migration
->getMachineName();
$row['machinename'] = l($machine_name, 'admin/content/migrate/' . $machine_name);
$row['importrows'] = $total;
$row['imported'] = $imported;
$row['unimported'] = $unimported;
if (is_subclass_of($migration, 'Migration')) {
$num_messages = $migration
->messageCount();
$row['messages'] = $num_messages ? l($num_messages, 'admin/content/migrate/messages/' . $machine_name) : 0;
}
else {
$row['messages'] = t('N/A');
}
if (method_exists($migration, 'getLastThroughput')) {
$rate = $migration
->getLastThroughput();
if ($rate == '') {
$row['lastthroughput'] = t('Unknown');
}
elseif ($status == MigrationBase::STATUS_IDLE) {
$row['lastthroughput'] = t('!rate/min', array(
'!rate' => $rate,
));
}
else {
if ($rate > 0) {
$row['lastthroughput'] = t('!rate/min, !time remaining', array(
'!rate' => $rate,
'!time' => format_interval(60 * $unimported / $rate),
));
}
else {
$row['lastthroughput'] = t('!rate/min, unknown time remaining', array(
'!rate' => $rate,
));
}
}
}
else {
$row['lastthroughput'] = t('N/A');
}
$row['lastimported'] = $migration
->getLastImported();
$rows[$machine_name] = $row;
}
$build['dashboard'] = array(
'#type' => 'tableselect',
'#header' => $header,
'#options' => $rows,
'#empty' => t('No migrations'),
);
// Build the 'Update options' form.
$build['operations'] = array(
'#type' => 'fieldset',
'#title' => t('Operations'),
);
$options = array(
'import' => t('Import'),
'rollback' => t('Rollback'),
'rollback_and_import' => t('Rollback and import'),
'stop' => t('Stop'),
'reset' => t('Reset'),
);
$build['operations']['operation'] = array(
'#type' => 'select',
'#title' => t('Operation'),
'#title_display' => 'invisible',
'#options' => $options,
);
$build['operations']['submit'] = array(
'#type' => 'submit',
'#value' => t('Execute'),
'#validate' => array(
'migrate_ui_dashboard_validate',
),
'#submit' => array(
'migrate_ui_dashboard_submit',
),
);
$build['operations']['description'] = array(
'#prefix' => '<p>',
'#value' => t('Choose an operation to run on all migrations selected above:
<ul>
<li>Import - Imports all previously unimported records from the source, plus
any records marked for update, into destination Drupal objects.</li>
<li>Rollback - Deletes all Drupal objects created by the migration.</li>
<li>Rollback and import - Performs the Rollback operation, immediately
followed by the Import operation.</li>
<li>Stop - Cleanly interrupts any import or rollback processes that may
currently be running.</li>
<li>Reset - Sometimes a migration process may fail to stop cleanly, and be
left stuck in an Importing or Rolling Back status. Choose Reset to clear
the status and permit other operations to proceed.</li>
</ul>'),
'#postfix' => '</p>',
);
$build['operations']['options'] = array(
'#type' => 'fieldset',
'#title' => t('Options'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$build['operations']['options']['update'] = array(
'#type' => 'checkbox',
'#title' => t('Update'),
'#description' => t('Check this box to update all previously-migrated content
in addition to importing new content. Leave unchecked to only import
new content'),
);
$build['operations']['options']['force'] = array(
'#type' => 'checkbox',
'#title' => t('Ignore dependencies'),
'#description' => t('Check this box to ignore dependencies when running imports
- all migrations will run whether or not their dependent migrations have
completed.'),
);
$build['operations']['options']['limit'] = array(
'#tree' => TRUE,
'#type' => 'fieldset',
'#attributes' => array(
'class' => 'container-inline',
),
'value' => array(
'#type' => 'textfield',
'#title' => t('Limit to'),
'#size' => 10,
),
'unit' => array(
'#type' => 'select',
'#options' => array(
'items' => t('items'),
'seconds' => t('seconds'),
),
'#description' => t('Set a limit of how many items to process for
each migration, or how long each should run.'),
),
);
return $build;
}