/[drupal]/contributions/modules/node_import/import_cck.inc
ViewVC logotype

Diff of /contributions/modules/node_import/import_cck.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1, Thu Mar 30 12:12:30 2006 UTC revision 1.2, Wed Apr 5 10:36:23 2006 UTC
# Line 10  function content_node_import_types() { Line 10  function content_node_import_types() {
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];
# Line 32  function content_node_import_prepare(&$n Line 32  function content_node_import_prepare(&$n
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  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.2