function recipe_link in Recipe 6
Same name and namespace in other branches
- 5 recipe.module \recipe_link()
- 7 recipe.module \recipe_link()
Implementation of hook_link().
File
- ./
recipe.module, line 105 - recipe.module - share recipes
Code
function recipe_link($type, $node = NULL, $teaser = FALSE) {
$links = array();
if ($type == 'node' && $node->type == 'recipe') {
if (!$teaser) {
$formats = module_invoke_all('recipeio', 'export_single');
foreach ($formats as $key => $format) {
$perm = isset($format['access arguments']) ? $format['access arguments'] : 'export recipes';
if (user_access($perm)) {
$links[$key] = array(
'title' => $format['format_name'],
'href' => "recipe/export/{$key}/{$node->nid}/__yield__",
'attributes' => array(
'title' => $format['format_help'],
),
);
}
}
}
if (count($links) > 0) {
array_unshift($links, array(
'title' => '<br/>' . t('Export to') . ':',
'html' => TRUE,
));
}
}
elseif ($type == 'node' && $node->type == 'ingredient') {
$ing = recipe_ingredient_match(trim(strtolower($node->title)));
if ($ing) {
$links['where_used'] = array(
'title' => t('Recipes where used'),
'href' => "recipe/bying/" . $ing['id'],
);
}
}
return $links;
}