You are here

function recipe_plaintext_export in Recipe 7

Same name and namespace in other branches
  1. 6 plugins/recipe_plaintext.module \recipe_plaintext_export()
  2. 7.2 modules/recipe_plaintext.module \recipe_plaintext_export()
1 call to recipe_plaintext_export()
recipe_plaintext_export_multi in includes/recipe_plaintext.module
1 string reference to 'recipe_plaintext_export'
recipe_plaintext_recipeio in includes/recipe_plaintext.module
Implementation of hook_recipeio($type).

File

includes/recipe_plaintext.module, line 169

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 .= format_plaintext_ingredients($node) . "\n";
  $output .= t('Instructions:') . "\n";
  $output .= wordwrap(strip_html_and_encode_entities($node->recipe_instructions), 75, "\n") . "\n\n";
  $output .= t('Description:') . "\n";
  $output .= strip_html_and_encode_entities($node->recipe_description) . "\n\n";
  $output .= t('Notes:') . "\n";
  $output .= strip_html_and_encode_entities($node->recipe_notes) . "\n";
  drupal_add_http_header('Content-type', 'text/plain; charset=utf-8');
  return $output;
}