function recipe_import_parse in Recipe 7
Same name and namespace in other branches
- 6 recipe.module \recipe_import_parse()
- 7.2 recipe.admin.inc \recipe_import_parse()
Returns a parsed imported recipe based on the recipe_format.
All parser instances should return a $recipe object that looks like this:
$recipe = array( 'title' => 'recipe title string', 'ingredients' => array of ingredients items(below); 'instructions' => 'string of instructions' );
ingredients items = array( 'quantity' => 'ingredient_name' => 'unit_name' => 'unit_key' => see recipe_unit_fuzzymatch(). ==FALSE if no-match 'ingre_obj' => comes from database lookup: see recipe_ingredient_match(). ==FALSE if no-match );
2 calls to recipe_import_parse()
- 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().
File
- ./
recipe.module, line 1651 - Contains functions for Recipe node CRUD and display.
Code
function recipe_import_parse($form, &$form_state) {
$import_function = $form_state['values']['recipe_format'];
$text = $form_state['values']['recipe_import_text'];
$recipe = array();
if (function_exists($import_function)) {
$recipe = call_user_func($import_function, $text);
return $recipe;
}
else {
drupal_set_message(t('Recipe import function does not exist(%the_function)', array(
'%the_function' => $import_function,
)), 'error');
return FALSE;
}
}