protected function WordPressMigrateWizard::contentForm in WordPress Migrate 7.2
Form for mapping source content (node) types to destination types.
2 calls to WordPressMigrateWizard::contentForm()
File
- ./
wordpress_migrate.migrate.inc, line 436
Class
Code
protected function contentForm(&$form_state, $selected_post_type) {
$form = array();
$empty_field = array(
'#type' => 'value',
'#value' => '',
);
$vocabs = $this
->vocabularies($selected_post_type);
if (!empty($vocabs)) {
$options = array(
'' => t('Do not import'),
);
foreach ($vocabs as $machine_name => $name) {
$options[$machine_name] = $name;
}
// If field_tags exists, default to it.
$tags_default = isset($options['field_tags']) ? 'field_tags' : '';
$form['tag_field'] = array(
'#type' => 'select',
'#title' => t('Import WordPress tags to the term reference field'),
'#default_value' => $tags_default,
'#options' => $options,
);
$form['category_field'] = array(
'#type' => 'select',
'#title' => t('Import WordPress categories to the term reference field'),
'#default_value' => '',
'#options' => $options,
);
}
else {
$form['tag_field'] = $form['category_field'] = $empty_field;
}
if (module_exists('comment') && variable_get('comment_' . $selected_post_type, COMMENT_NODE_OPEN) != COMMENT_NODE_CLOSED) {
$form['comments'] = array(
'#type' => 'radios',
'#title' => t('Import comments?'),
'#options' => array(
1 => t('Yes'),
0 => t('No'),
),
'#default_value' => 1,
);
$form['pingbacks'] = array(
'#type' => 'radios',
'#title' => t('Ignore pingbacks?'),
'#options' => array(
1 => t('Yes'),
0 => t('No'),
),
'#default_value' => 1,
);
}
else {
$form['comments'] = array(
'#type' => 'value',
'#value' => 0,
);
$form['pingbacks'] = array(
'#type' => 'value',
'#value' => 0,
);
}
$file_fields = array(
'' => t('Do not import'),
);
$file_fields += $this
->fileFields($selected_post_type, 'file') + $this
->fileFields($selected_post_type, 'media');
$file_image_fields = $file_fields + $this
->fileFields($selected_post_type, 'image');
if (count($file_image_fields) > 1) {
$form['attachment_field'] = array(
'#type' => 'select',
'#title' => t('Field for attachments (including images)'),
'#default_value' => '',
'#options' => $file_image_fields,
'#description' => t(''),
'#states' => array(
'visible' => array(
'input[name="destination_type"]' => array(
'value' => 'blog',
),
),
),
);
}
else {
$form['attachment_field'] = $empty_field;
}
if (count($file_fields) > 1) {
$form['podcast_field'] = array(
'#type' => 'select',
'#title' => t('Field for Blubrry PowerPress podcasts'),
'#default_value' => '',
'#options' => $file_fields,
'#description' => t(''),
);
}
else {
$form['podcast_field'] = $empty_field;
}
$options = array();
foreach (filter_formats() as $format_id => $format) {
$options[$format_id] = $format->name;
}
$form['text_format'] = array(
'#type' => 'select',
'#title' => t('Default format for text fields'),
'#default_value' => 'filtered_html',
'#options' => $options,
'#description' => t(''),
);
$form['text_format_comment'] = array(
'#type' => 'select',
'#title' => t('Default format for comment text fields'),
'#default_value' => 'filtered_html',
'#options' => $options,
'#description' => t(''),
'#states' => array(
'invisible' => array(
'input[name="comments"]' => array(
'value' => 0,
),
),
),
);
if (module_exists('path')) {
$options = array(
0 => t('Do not set path aliases'),
1 => t('Set path aliases to their original WordPress values'),
);
$attributes = array();
$default_value = 1;
if (module_exists('pathauto')) {
$options[2] = t('Have pathauto generate new aliases');
if (!module_exists('migrate_extras')) {
$form['pathauto_message'] = array(
'#prefix' => '<p>',
'#markup' => t('<strong>To be able to change the <em>Path alias handling</em>, ' . 'you must have the <a href="@extras">Migrate Extras module</a> installed and enabled.</strong>', array(
'@extras' => url('http://drupal.org/project/migrate_extras'),
)),
'#suffix' => '</p>',
);
$attributes['disabled'] = TRUE;
$default_value = 2;
}
}
$form['path_action'] = array(
'#type' => 'radios',
'#title' => t('Path alias handling'),
'#description' => t('Select how path aliases for imported nodes will be set.'),
'#options' => $options,
'#default_value' => $default_value,
'#attributes' => $attributes,
);
}
else {
$form['path_action'] = $empty_field;
}
if (module_exists('redirect')) {
if (module_hook('redirect', 'migrate_api')) {
$form['generate_redirects'] = array(
'#type' => 'checkbox',
'#title' => t('Generate redirects'),
'#description' => t('If this box is checked, redirects will be set up from
the former WordPress blog URLs to the new URLs on your Drupal site'),
'#default_value' => FALSE,
);
}
else {
$form['generate_redirects'] = array(
'#type' => 'value',
'#value' => 0,
);
$form['generate_redirects_info'] = array(
'#prefix' => '<p>',
'#markup' => t('You have the Redirect module enabled. To be able to ' . 'generate redirects for your imported WordPress content, you need ' . 'to <a href="@link">patch Redirect</a>.', array(
'@link' => 'http://drupal.org/node/1116408#comment-7603833',
)),
'#suffix' => '</p>',
);
}
}
else {
$form['generate_redirects'] = $empty_field;
}
return $form;
}