function recipe_export in Recipe 6
Same name and namespace in other branches
- 5 recipe.module \recipe_export()
- 7.2 recipe.pages.inc \recipe_export()
- 7 recipe.module \recipe_export()
Menu callback; Generates various representation of a recipe page with all descendants and prints the requested representation to output.
Parameters
type:
- a string encoding the type of output requested.
nid:
- an integer representing the node id (nid) of the node to export
1 string reference to 'recipe_export'
- recipe_menu in ./
recipe.module - Implementation of hook_menu().
File
- ./
recipe.module, line 1171 - recipe.module - share recipes
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();
}
}