You are here

function feedapi_create_node in FeedAPI 6

Same name and namespace in other branches
  1. 5 feedapi.module \feedapi_create_node()

Create a feedapi node programatically.

Parameters

$param: Either a feedapi - enabled node type or a $node object with at least valid $node->type.

$url: URI of feed.

3 calls to feedapi_create_node()
feedapi_drush_create in ./feedapi.drush.inc
Creates a feed
feedapi_simplified_form_submit in ./feedapi.module
Create the node object and save
_feedapi_import_opml in ./feedapi.opml.inc
Imports from OPML XML file.

File

./feedapi.module, line 841
Handle the submodules (for feed and item processing) Provide a basic management of feeds

Code

function feedapi_create_node($param, $url) {
  if (is_object($param)) {
    $node = $param;
  }
  else {
    $node = new stdClass();
    $node->type = $param;
  }
  if (!feedapi_enabled_type($node->type)) {
    return FALSE;
  }
  $feed = _feedapi_build_feed_object($node->type, $url);
  if (!$feed->title && !$node->title) {
    return FALSE;
  }
  module_load_include('inc', 'node', 'node.pages');
  $node->title = $node->title ? $node->title : $feed->title;
  $node->body = $node->body ? $node->body : $feed->description;
  $node->feedapi_object = $feed;

  // Get the content-type settings as default
  $node->feedapi = feedapi_get_settings($node->type);
  node_object_prepare($node);
  global $user;
  $node->uid = $user->uid;
  node_save($node);
  return $node;
}