function recipe_import_get_node in Recipe 7.2
Same name and namespace in other branches
- 6 recipe.module \recipe_import_get_node()
- 7 recipe.module \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.admin.inc - Form submission handler for recipe_import_form() 'Preview' button.
- recipe_import_form_submit in ./
recipe.admin.inc - Form submission handler for recipe_import_form().
- recipe_mastercook4_import_form_submit in modules/
recipe_mastercook4.module - recipe_recipeML_import_form_submit in modules/
recipe_recipeML.module
File
- ./
recipe.admin.inc, line 275 - Contains admin page callbacks, form validation, and form submission handlers.
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
$node->recipe_description[LANGUAGE_NONE][0] = array(
'value' => $parsed_recipe_object['title'] . ' imported from Recipe Import',
'format' => 'filtered_html',
);
$node->recipe_instructions[LANGUAGE_NONE][0] = array(
'value' => $parsed_recipe_object['instructions'],
'format' => 'filtered_html',
);
$node->recipe_notes[LANGUAGE_NONE][0] = array(
'value' => isset($parsed_recipe_object['notes']) ? $parsed_recipe_object['notes'] : '',
'format' => 'filtered_html',
);
$node->recipe_source[LANGUAGE_NONE][0] = array(
'value' => $parsed_recipe_object['source'] != '' ? $parsed_recipe_object['source'] : $user->name,
'format' => 'filtered_html',
);
$node->recipe_prep_time[LANGUAGE_NONE][0] = array(
'value' => $parsed_recipe_object['preptime'] != '' ? $parsed_recipe_object['preptime'] : 30,
);
$node->recipe_cook_time[LANGUAGE_NONE][0] = array(
'value' => $parsed_recipe_object['cooktime'] != '' ? $parsed_recipe_object['cooktime'] : 30,
);
$node->recipe_yield = $parsed_recipe_object['yield'];
$node->recipe_yield_unit = $parsed_recipe_object['yield_unit'];
$delta = 0;
$node->recipe_ingredient = array();
foreach ($parsed_recipe_object['ingredients'] as $i) {
$node->recipe_ingredient[LANGUAGE_NONE][$delta] = array(
'iid' => recipe_ingredient_id_from_name($i['ingredient_name']),
'quantity' => $i['quantity'],
'unit_key' => $i['unit_key'],
'note' => isset($i['ingredient_note']) ? $i['ingredient_note'] : '',
);
$delta++;
}
return $node;
}
return FALSE;
}