function devel_generate_content_add_node in Devel 6
Same name and namespace in other branches
- 7 devel_generate/devel_generate.inc \devel_generate_content_add_node()
Create one node. This is used by both the batch and non-batch branches of the code.
Parameters
$num: array of options obtained from devel_generate_content_form.
2 calls to devel_generate_content_add_node()
- devel_generate_batch_content_add_node in ./
devel_generate_batch.inc - devel_generate_content in ./
devel_generate.inc - The main API function for creating content.
File
- ./
devel_generate.inc, line 459
Code
function devel_generate_content_add_node(&$results) {
// Insert new data:
$node->type = array_rand($results['node_types']);
module_load_include('inc', 'node', 'node.pages');
$type = node_get_types('type', $node->type);
node_object_prepare($node);
$users = $results['users'];
$node->uid = $users[array_rand($users)];
$node->title = devel_create_greeking(mt_rand(1, $results['title_length']), TRUE);
if ($type->has_body) {
$node->body = "node ({$node->type}) - " . devel_create_content();
$node->teaser = node_teaser($node->body);
$node->filter = variable_get('filter_default_format', 1);
$node->format = FILTER_FORMAT_DEFAULT;
}
$node->language = '';
$node->revision = mt_rand(0, 1);
$node->promote = mt_rand(0, 1);
$node->created = time() - mt_rand(0, $results['time_range']);
// A flag to let hook_nodeapi() implementations know that this is a generated node.
$node->devel_generate = $results;
// See devel_generate_nodeapi() for actions that happen before and after this save.
node_save($node);
}