function recipe_import_get_node in Recipe 7
Same name and namespace in other branches
- 6 recipe.module \recipe_import_get_node()
- 7.2 recipe.admin.inc \recipe_import_get_node()
Returns a node-like stdClass object suitable for node_save and preview.
4 calls to recipe_import_get_node()
- recipe_import_form_build_preview in ./
recipe.module - Form submission handler for recipe_import_form() 'Preview' button.
- recipe_import_form_submit in ./
recipe.module - Form submission handler for recipe_import_form().
- recipe_mastercook4_import_form_submit in includes/
recipe_mastercook4.module - recipe_recipeML_import_form_submit in includes/
recipe_recipeML.module
File
- ./
recipe.module, line 1589 - Contains functions for Recipe node CRUD and display.
Code
function recipe_import_get_node($parsed_recipe_object = FALSE) {
global $user;
if ($parsed_recipe_object) {
//node stuff
$node = new stdClass();
$node->type = 'recipe';
$node->nid = NULL;
node_object_prepare($node);
$node->title = $parsed_recipe_object['title'];
$node->language = LANGUAGE_NONE;
//recipe stuff
//WYSIWYG fields need an array with a 'value' key.
$node->recipe_description = array(
'value' => $parsed_recipe_object['title'] . ' imported from Recipe Import',
);
$node->recipe_instructions = array(
'value' => $parsed_recipe_object['instructions'],
);
$node->recipe_notes = array(
'value' => isset($parsed_recipe_object['notes']) ? $parsed_recipe_object['notes'] : '',
);
$node->recipe_source = $parsed_recipe_object['source'] != '' ? $parsed_recipe_object['source'] : $user->name;
$node->recipe_yield = $parsed_recipe_object['yield'];
$node->recipe_yield_unit = $parsed_recipe_object['yield_unit'];
$node->recipe_preptime = $parsed_recipe_object['preptime'] != '' ? $parsed_recipe_object['preptime'] : 30;
$node->recipe_cooktime = $parsed_recipe_object['cooktime'] != '' ? $parsed_recipe_object['cooktime'] : 30;
//ingredients, have to change them into node->ingredients format
$ingredient_list = array();
$weight = 0;
foreach ($parsed_recipe_object['ingredients'] as $i) {
$ingredient = array();
$ingredient['quantity'] = $i['quantity'];
$ingredient['unit_key'] = $i['unit_key'];
$ingredient['name'] = isset($i['ingredient_name']) ? $i['ingredient_name'] : '';
$ingredient['note'] = isset($i['ingredient_note']) ? $i['ingredient_note'] : '';
$ingredient['weight'] = $weight++;
$ingredient_list[] = $ingredient;
}
$node->recipe_ingredients['ing'] = $ingredient_list;
return $node;
}
return FALSE;
}