| 1 |
<?php |
<?php |
| 2 |
/* $Id: import_flexinode.inc,v 1.5 2005/07/01 23:37:02 drumm Exp $ */ |
/* $Id$ */ |
| 3 |
|
|
| 4 |
|
/** |
| 5 |
|
* Implementation of hook_node_import_types(). |
| 6 |
|
*/ |
| 7 |
function content_node_import_types() { |
function content_node_import_types() { |
| 8 |
$types = array(); |
$types = array(); |
| 9 |
foreach (_content_types() as $id => $type) { |
foreach (_content_types() as $id => $type) { |
| 12 |
return $types; |
return $types; |
| 13 |
} |
} |
| 14 |
|
|
| 15 |
|
/** |
| 16 |
|
* Implementation of hook_node_import_fields(). |
| 17 |
|
*/ |
| 18 |
function content_node_import_fields($type) { |
function content_node_import_fields($type) { |
| 19 |
$types = (array)_content_types(); |
$types = (array)_content_types(); |
| 20 |
if (!isset($types[$type])) return; |
if (!isset($types[$type])) return; |
| 32 |
return $fields; |
return $fields; |
| 33 |
} |
} |
| 34 |
|
|
| 35 |
|
/** |
| 36 |
|
* Implementation of hook_node_import_prepare(). |
| 37 |
|
*/ |
| 38 |
function content_node_import_prepare(&$node, $preview = FALSE) { |
function content_node_import_prepare(&$node, $preview = FALSE) { |
| 39 |
$types = _content_types(); |
$types = _content_types(); |
| 40 |
if (!isset($types[$node->type])) return; |
if (!isset($types[$node->type])) return; |
| 41 |
$content_type = $types[$node->type]; |
$content_type = $types[$node->type]; |
| 42 |
|
|
| 43 |
//add all cck widget fields |
//add all cck widget fields |
| 44 |
foreach ($content_type->fields as $field) { |
foreach ($content_type->fields as $field) { |
| 45 |
if (strpos($field['widget']['type'], 'nodereference') === 0) {//nodereference node: query nid of the referenced node |
if (strpos($field['widget']['type'], 'nodereference') === 0) {//nodereference node: query nid of the referenced node |
| 46 |
$referenced_nodes = array(); |
$referenced_nodes = array(); |
| 47 |
$sql = "select nid, title from {node} where title sounds like '%s'"; |
$sql = "SELECT nid, title FROM {node} WHERE title SOUNDS LIKE '%s'"; |
| 48 |
$result = db_query($sql, $node->$field['field_name']); |
$result = db_query($sql, $node->$field['field_name']); |
| 49 |
$record_found = db_fetch_object($result); |
$record_found = db_fetch_object($result); |
| 50 |
if ($record_found) { |
if ($record_found) { |
| 64 |
} |
} |
| 65 |
return; |
return; |
| 66 |
} |
} |
|
?> |
|