You are here

function recipe_node_view in Recipe 7

Same name and namespace in other branches
  1. 8.2 recipe.module \recipe_node_view()
  2. 7.2 recipe.module \recipe_node_view()

Implements hook_node_view().

File

./recipe.module, line 796
Contains functions for Recipe node CRUD and display.

Code

function recipe_node_view($node, $view_mode) {
  if (isset($node->in_preview) && $node->in_preview == 1) {
    return;
  }
  if ($node->type == 'recipe' && $view_mode != 'rss' && $view_mode != 'teaser') {
    $formats = module_invoke_all('recipeio', 'export_single');
    $links = array();
    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}/" . $node->recipe_yield,
          'attributes' => array(
            'title' => $format['format_help'],
          ),
        );
      }
    }
    if (!empty($links)) {
      array_unshift($links, array(
        'title' => '<br/>' . t('Export to') . ':',
        'html' => TRUE,
      ));
      $node->content['links']['recipe'] = array(
        '#theme' => 'links__recipe__node',
        '#links' => $links,
        '#attributes' => array(
          'class' => array(
            'links',
            'inline',
          ),
        ),
      );
    }
  }
}