diff -ur node_convert/node_convert.info node_convert-6.x/node_convert.info --- node_convert/node_convert.info 2008-04-22 11:00:24.000000000 -0700 +++ node_convert-6.x/node_convert.info 2008-06-27 21:09:48.000000000 -0700 @@ -1,9 +1,10 @@ ; $Id: node_convert.info,v 1.1.2.1 2008/04/17 19:52:27 placinta Exp $ name = Node convert description = "A module that converts a node's type and transfers cck field values" -dependencies = content +dependencies[] = content +core = 6.x ; Information added by drupal.org packaging script on 2008-04-22 -version = "5.x-1.4" +version = "6.x-1.x" project = "node_convert" datestamp = "1208887224" diff -ur node_convert/node_convert.module node_convert-6.x/node_convert.module --- node_convert/node_convert.module 2008-04-22 10:56:32.000000000 -0700 +++ node_convert-6.x/node_convert.module 2008-06-27 21:28:02.000000000 -0700 @@ -6,11 +6,11 @@ * @param section which section of the site we're displaying help * @return help text for section */ -function node_convert_help($section='') { +function node_convert_help($path, $arg) { $output = ''; - switch ($section) { + switch ($path) { case "admin/help#node_convert": $output = '

'. t("Converts a node's type to another type, also transfers cck field values.") .'

'; break; @@ -22,31 +22,25 @@ /** * Implementation of hook_menu(). */ -function node_convert_menu($may_cache) { +function node_convert_menu( { $items = array(); - if ($may_cache) { - } - else { - $items[] = array( - 'path' => 'admin/content/convert_bulk', - 'title' => t('Convert nodes'), - 'description' => t('Convert selected nodes from one node type, to another.'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array("node_convert_bulk"), + $items['admin/content/convert_bulk'] = array( + 'title' => t('Convert nodes'), + 'description' => t('Convert selected nodes from one node type, to another.'), + 'callback' => 'drupal_get_form', + 'callback arguments' => array("node_convert_bulk"), + 'access' => user_access('administer content types'), + 'type' => MENU_NORMAL_ITEM, + ); + if (arg(0) == 'node' && is_numeric(arg(1))) { + $items['node/'. arg(1) .'/convert'] = array( + 'title' => t('Convert'), + 'callback' => 'node_convert_form_page', + 'callback arguments' => array(arg(1)), 'access' => user_access('administer content types'), - 'type' => MENU_NORMAL_ITEM, + 'weight' => 6, + 'type' => MENU_LOCAL_TASK, ); - if (arg(0) == 'node' && is_numeric(arg(1))) { - $items[] = array( - 'path' => 'node/'. arg(1) .'/convert', - 'title' => t('Convert'), - 'callback' => 'node_convert_form_page', - 'callback arguments' => array(arg(1)), - 'access' => user_access('administer content types'), - 'weight' => 6, - 'type' => MENU_LOCAL_TASK, - ); - } } return $items; } @@ -131,7 +125,7 @@ } else $temp_value = $node->{$field['field_name']}[0]['value']; if (empty($temp_value)) $temp_value = "NULL"; - $form['current_field_value_' .$i] = array('#type' => 'markup', '#value' => '
'. t("Current value is:") ." ". $temp_value .'
'); + $form['current_field_value_'. $i] = array('#type' => 'markup', '#value' => '
'. t("Current value is:") ." ". $temp_value .'
'); } } } @@ -143,19 +137,19 @@ return $form; } -function node_convert_conversion_form_submit($form_id, $form_values) { +function node_convert_conversion_form_submit($form, &$form_state) { - if ($form_values['step'] == "choose_destination_fields") { + if ($form_state['values']['step'] == "choose_destination_fields") { // Information needed in the convert process: nid, vid, source type, destination type - $dest_node_type = $form_values['destination_type']; - $nid = $form_values['nid']; + $dest_node_type = $form_state['values']['destination_type']; + $nid = $form_state['values']['nid']; $node = node_load($nid); $vid = $node->vid; $source_node_type = $node->type; - $no_fields_flag = $form_values['no_fields_flag']; + $no_fields_flag = $form_state['values']['no_fields_flag']; - if ($form_values['no_fields_flag'] == false) { // If there are cck fields that can to be converted - foreach ($form_values as $key => $value) { + if ($form_state['values']['no_fields_flag'] == false) { // If there are cck fields that can to be converted + foreach ($form_state['values'] as $key => $value) { if (preg_match("/source_field_[0-9]+?/", $key) == 1) $source_fields[] = $value; // Source fields if (preg_match("/dest_field_[0-9]+?/", $key) == 1) $dest_fields[] = $value; // Destination fields } @@ -259,16 +253,16 @@ return $form; } -function node_convert_bulk_validate($form_id, $form_values) { - if ($form_values['step'] == "choose_source_dest_type") { - if ($form_values['source_type'] == $form_values['dest_type']) { +function node_convert_bulk_validate($form, &$form_state) { + if ($form_state['values']['step'] == "choose_source_dest_type") { + if ($form_state['values']['source_type'] == $form_state['values']['dest_type']) { form_set_error('source_type', t('Please select different node types.')); form_set_error('dest_type', t('Please select different node types.')); } } - elseif ($form_values['step'] == "choose_nodes") { + elseif ($form_state['values']['step'] == "choose_nodes") { $no_nodes = TRUE; - foreach ($form_values['nodes'] as $value) { + foreach ($form_state['values']['nodes'] as $value) { if ($value != 0) { $no_nodes = FALSE; break; @@ -281,11 +275,11 @@ } -function node_convert_bulk_submit($form_id, $form_values) { - if ($form_values['step'] == "choose_fields") { - $info = unserialize($form_values['info']); +function node_convert_bulk_submit($form, $form_state) { + if ($form_state['values']['step'] == "choose_fields") { + $info = unserialize($form_state['values']['info']); if ($info['no_fields'] == false) { // If there are cck fields that can to be converted - foreach ($form_values as $key => $value) { + foreach ($form_state['values'] as $key => $value) { if (preg_match("/dest_field_[0-9]+?/", $key) == 1) $info['fields']['destination'][] = $value; // Destination fields } } @@ -298,6 +292,17 @@ } } +function node_convert_theme() { + return array( + 'theme_node_convert_bulk' => array( + 'arguments' => array('form' => NULL), + ), + 'theme_node_convert_conversion_form' => array( + 'arguments' => array('form' => NULL), + ) + ); +} + function theme_node_convert_bulk($form) { if ($form['step']['#value'] == "choose_source_dest_type") { $output = '
'. t("Choose the source type of the nodes that should be shown, and the destination type to which they will be converted.") .'
'; @@ -436,4 +441,4 @@ $db_message = db_query("UPDATE {". $db_info_dest['table'] ."} SET " . implode(", ", $column_assignments) ." WHERE nid = %d AND vid = %d", $source_values); } } -} \ No newline at end of file +}