| 10 |
} |
} |
| 11 |
|
|
| 12 |
function content_node_import_fields($type) { |
function content_node_import_fields($type) { |
| 13 |
$types = _content_types(); |
$types = (array)_content_types(); |
| 14 |
if (!isset($types[$type])) return; |
if (!isset($types[$type])) return; |
| 15 |
|
|
| 16 |
$content_type = $types[$type]; |
$content_type = $types[$type]; |
| 32 |
$content_type = $types[$node->type]; |
$content_type = $types[$node->type]; |
| 33 |
//add all cck widget fields |
//add all cck widget fields |
| 34 |
foreach ($content_type->fields as $field) { |
foreach ($content_type->fields as $field) { |
| 35 |
$thisval = $node->$field['field_name']; |
if (strpos($field['widget']['type'], 'nodereference') === 0) {//nodereference node: query nid of the referenced node |
| 36 |
$node->$field['field_name'] = array('value' => $thisval); |
$referenced_nodes = array(); |
| 37 |
|
$sql = "select title from {node} where title sounds like '%s'"; |
| 38 |
|
$result = db_query($sql, $node->$field['field_name']); |
| 39 |
|
$record_found = db_fetch_object($result); |
| 40 |
|
|
| 41 |
|
if ($record_found) { |
| 42 |
|
|
| 43 |
|
if ($field['multiple']) { |
| 44 |
|
$node->$field['field_name'] = array('title' => array(0 => $record_found->title)); |
| 45 |
|
} else { |
| 46 |
|
$node->$field['field_name'] = array('title' => $record_found->title); |
| 47 |
|
} |
| 48 |
|
//update the node field with proper info (nid(s) of referenced nodes) |
| 49 |
|
nodereference_widget('submit', $node, $field); |
| 50 |
|
} else { |
| 51 |
|
$node->$field['field_name'] = array(); |
| 52 |
|
} |
| 53 |
|
|
| 54 |
|
} else {//default node types: add value to array w/ key 'value' |
| 55 |
|
$thisval = $node->$field['field_name']; |
| 56 |
|
$node->$field['field_name'] = array('value' => $thisval); |
| 57 |
|
} |
| 58 |
} |
} |
| 59 |
return; |
return; |
| 60 |
} |
} |