function recipe_plaintext_export in Recipe 7.2
Same name and namespace in other branches
- 6 plugins/recipe_plaintext.module \recipe_plaintext_export()
- 7 includes/recipe_plaintext.module \recipe_plaintext_export()
1 call to recipe_plaintext_export()
1 string reference to 'recipe_plaintext_export'
- recipe_plaintext_recipeio in modules/
recipe_plaintext.module - Implements hook_recipeio().
File
- modules/
recipe_plaintext.module, line 166
Code
function recipe_plaintext_export($nid = NULL, $yield = NULL) {
if ($nid === NULL) {
drupal_set_message(t('Recipe not found.'));
drupal_not_found();
return;
}
$node = node_load($nid);
// you should not be able to export unpublished recipes
if ($node->status == 0) {
drupal_access_denied();
return;
}
// Set the custom yield so we can scale up/down the recipe quantities.
$node->recipe_custom_yield = $yield;
$output = $node->title . "\n\n";
$output .= t('Ingredients:') . "\n";
$output .= recipe_plaintext_format_ingredients($node) . "\n";
$output .= t('Instructions:') . "\n";
$instructions_items = field_get_items('node', $node, 'recipe_instructions');
$output .= wordwrap(strip_html_and_encode_entities($instructions_items[0]['value']), 75, "\n") . "\n\n";
$output .= t('Description:') . "\n";
$description_items = field_get_items('node', $node, 'recipe_description');
$output .= strip_html_and_encode_entities($description_items[0]['value']) . "\n\n";
$output .= t('Notes:') . "\n";
$notes_items = field_get_items('node', $node, 'recipe_notes');
$output .= strip_html_and_encode_entities($notes_items[0]['value']) . "\n";
drupal_add_http_header('Content-type', 'text/plain; charset=utf-8');
return $output;
}