You are here

protected function FeedsNodeProcessor::buildNode in Feeds 6

Same name and namespace in other branches
  1. 7 plugins/FeedsNodeProcessor.inc \FeedsNodeProcessor::buildNode()

Creates a new node object in memory and returns it.

1 call to FeedsNodeProcessor::buildNode()
FeedsNodeProcessor::process in plugins/FeedsNodeProcessor.inc
Implementation of FeedsProcessor::process().

File

plugins/FeedsNodeProcessor.inc, line 387
Class definition of FeedsNodeProcessor.

Class

FeedsNodeProcessor
Creates nodes from feed items.

Code

protected function buildNode($nid, $feed_nid) {
  $populate = FALSE;
  if (empty($nid)) {
    $node = new stdClass();
    $node->created = FEEDS_REQUEST_TIME;
    $populate = TRUE;
  }
  else {
    if ($this->config['update_existing'] == FEEDS_UPDATE_EXISTING) {
      $node = node_load($nid, NULL, TRUE);
    }
    else {
      $node = db_fetch_object(db_query("SELECT created, nid, vid, status FROM {node} WHERE nid = %d", $nid));
      $populate = TRUE;
    }
  }
  if ($populate) {
    $node->type = $this->config['content_type'];
    $node->changed = FEEDS_REQUEST_TIME;
    $node->format = $this->config['input_format'];
    $node->feeds_node_item = new stdClass();
    $node->feeds_node_item->id = $this->id;
    $node->feeds_node_item->imported = FEEDS_REQUEST_TIME;
    $node->feeds_node_item->feed_nid = $feed_nid;
    $node->feeds_node_item->url = '';
    $node->feeds_node_item->guid = '';
  }
  static $included;
  if (!$included) {
    module_load_include('inc', 'node', 'node.pages');
    $included = TRUE;
  }
  node_object_prepare($node);

  // Populate properties that are set by node_object_prepare().
  $node->log = 'Created/updated by FeedsNodeProcessor';
  if ($populate) {
    $node->uid = $this->config['author'];
  }
  return $node;
}