function node_convert_conversion_form_submit in Node Convert 7
Same name and namespace in other branches
- 5 node_convert.module \node_convert_conversion_form_submit()
- 6 node_convert.module \node_convert_conversion_form_submit()
Submit callback for converting a form.
File
- ./
node_convert.forms.inc, line 164 - Form page callbacks for the node_convert module.
Code
function node_convert_conversion_form_submit($form, &$form_state) {
// Remember the destination type
if ($form_state['values']['step'] == 'choose_destination_type') {
$form_state['rebuild'] = TRUE;
$form_state['storage']['destination_type'] = $form_state['values']['destination_type'];
}
elseif ($form_state['values']['step'] == 'choose_destination_fields') {
// Information needed in the convert process: nid, vid, source type, destination type
$dest_node_type = $form_state['storage']['destination_type'];
$node = $form_state['values']['node'];
$nid = $node->nid;
$no_fields = $form_state['values']['no_fields'];
$number_of_fields = isset($form_state['values']['number_of_fields']) ? $form_state['values']['number_of_fields'] : 0;
// If there are fields that can to be converted.
$source_fields = array();
$dest_fields = array();
if ($no_fields == FALSE) {
for ($i = 1; $i <= $number_of_fields; $i++) {
$source_fields[] = $form_state['values']['source_field_' . $i];
// Source fields
$dest_fields[] = $form_state['values']['dest_field_' . $i];
// Destination fields
}
}
if (!empty($form['hook_options'])) {
$hook_options = $form_state['values']['hook_options'];
}
else {
$hook_options = NULL;
}
$result = node_convert_node_convert($nid, $dest_node_type, $source_fields, $dest_fields, $no_fields, $hook_options);
// We display errors if any, or the default success message.
node_convert_messages($result, array(
'nid' => $nid,
));
// We clear the storage so redirect works
$form_state['storage'] = array();
$form_state['redirect'] = "node/" . $nid;
}
}