function recipe_import_get_node in Recipe 6
Same name and namespace in other branches
- 7.2 recipe.admin.inc \recipe_import_get_node()
- 7 recipe.module \recipe_import_get_node()
Get a node-like stdClass object suitable for node_save and preview.
3 calls to recipe_import_get_node()
- recipe_import_form_build_preview in ./
recipe.module - Import preview routine that allows that users to see what actually will be imported before doing so.
- recipe_import_form_submit in ./
recipe.module - Submit handler for the single recipe import form.
- recipe_mastercook4_import_form_submit in plugins/
recipe_mastercook4.module
File
- ./
recipe.module, line 1508 - recipe.module - share recipes
Code
function recipe_import_get_node($parsed_recipe_object = FALSE) {
global $user;
if ($parsed_recipe_object) {
//node stuff
$node = new stdClass();
$node->title = $parsed_recipe_object['title'];
$node->body = $parsed_recipe_object['title'] . ' imported from Recipe Import';
$node->type = 'recipe';
$node->uid = $user->uid;
// Promote is usually handled by a moderator.
$node->promote = 0;
// Let's allow comments by default.
$node->comment = 2;
//recipe stuff
$node->source = $parsed_recipe_object['source'] != '' ? $parsed_recipe_object['source'] : $user->name;
$node->yield = 1;
$node->notes = $parsed_recipe_object['notes'];
$node->instructions = $parsed_recipe_object['instructions'];
$node->preptime = 60;
//ingredients, have to change them into node->ingredients format
$ingredient_list = array();
foreach ($parsed_recipe_object['ingredients'] as $i) {
$ingredient = array();
$ingredient['quantity'] = $i['quantity'];
if ($i['unit_obj'] != FALSE) {
$ingredient['unit_id'] = $i['unit_obj']->id;
}
$ingredient['name'] = $i['ingredient_name'];
$ingredient['note'] = $i['ingredient_note'];
$ingredient_list[] = $ingredient;
}
$node->ingredients = $ingredient_list;
return $node;
}
return FALSE;
}