You are here

function recipe_export in Recipe 7.2

Same name and namespace in other branches
  1. 5 recipe.module \recipe_export()
  2. 6 recipe.module \recipe_export()
  3. 7 recipe.module \recipe_export()

Page callback: Outputs recipe nodes in various formats.

Generates various representation of a recipe page with all descendants and prints the requested representation to output.

Parameters

string $type: The type of output requested.

int $nid: The node ID of the node to export.

1 string reference to 'recipe_export'
recipe_menu in ./recipe.module
Implements hook_menu().

File

./recipe.pages.inc, line 19
Contains page callbacks, form validation, and form submission handlers.

Code

function recipe_export($type = 'html', $nid = NULL, $yield = NULL) {

  // normalize typed urls
  $type = drupal_strtolower($type);

  // load supported formats
  $formats = module_invoke_all('recipeio', 'export_single');
  $perm = isset($formats[$type]['access arguments']) ? $formats[$type]['access arguments'] : 'export recipes';
  if (!user_access($perm)) {
    drupal_access_denied();
    return;
  }

  // If callback exists, call it, otherwise error out.
  if (isset($formats[$type]) && function_exists($formats[$type]['callback'])) {
    echo call_user_func($formats[$type]['callback'], $nid, $yield);
  }
  else {
    drupal_set_message(t('Unknown export format(%the_format).', array(
      '%the_format' => $type,
    )), 'error');
    drupal_not_found();
  }
}