function feedapi_create_node in FeedAPI 5
Same name and namespace in other branches
- 6 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.
2 calls to feedapi_create_node()
- feedapi_simplified_form_submit in ./
feedapi.module - Create the node object and save
- _feedapi_import_opml_process in ./
feedapi.module - Imports from OPML XML file
File
- ./
feedapi.module, line 819 - 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;
}
$node->title = $node->title ? $node->title : $feed->title;
$node->body = $node->body ? $node->body : $feed->description;
$node->feed = $feed;
$node_options = variable_get('node_options_' . $node->type, array(
'status',
'promote',
));
// If this is a new node, fill in the default values.
foreach (array(
'status',
'promote',
'sticky',
) as $key) {
$node->{$key} = in_array($key, $node_options);
}
// 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;
}