You are here

function recipe_plaintext_export in Recipe 6

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

File

plugins/recipe_plaintext.module, line 151

Code

function recipe_plaintext_export($nid = NULL) {
  if ($nid === NULL) {
    drupal_set_message(t('Recipe not found.'));
    drupal_not_found();
  }
  $node = node_load(array(
    'nid' => $nid,
    'type' => 'recipe',
  ));

  // you should not be able to export unpublished recipes
  if ($node->status == 0) {
    drupal_access_denied();
    return;
  }
  $output = $node->title . "\n\n";
  $output .= t('Ingredients:') . "\n";
  $output .= format_plaintext_ingredients($node) . "\n";
  $output .= t('Instructions:') . "\n";
  $node->instructions = wordwrap(strip_html_and_encode_entities($node->instructions), 75, "\n");
  $output .= $node->instructions . "\n\n";
  $output .= t('Description:') . "\n";
  $node->body = strip_html_and_encode_entities($node->body);
  $output .= $node->body . "\n\n";
  $output .= t('Notes:') . "\n";
  $node->notes = strip_html_and_encode_entities($node->notes);
  $output .= $node->notes . "\n";
  drupal_set_header('Content-type: text');
  return $output;
}