You are here

function theme_recipe_summary in Recipe 6

Same name and namespace in other branches
  1. 7.2 recipe.module \theme_recipe_summary()
  2. 7 recipe.module \theme_recipe_summary()
1 string reference to 'theme_recipe_summary'
recipe_theme in ./recipe.module
Implementation of hook_theme().
2 theme calls to theme_recipe_summary()
recipe_block in ./recipe.module
Implementation of hook_block().
recipe_view in ./recipe.module
Implementation of hook_view().

File

./recipe.module, line 817
recipe.module - share recipes

Code

function theme_recipe_summary($node = NULL, $options = array(
  'show_title' => TRUE,
)) {

  // Construct the summary
  $output = '<table>';

  // Render the yield.
  $output .= '<tr><th class="summary-title">' . t('Yield') . '</th><td class="summary-data">' . drupal_get_form('recipe_yield_form', $node) . '</td></tr>';
  if ($node->source) {
    $output .= '<tr><th>' . t('Source') . '</th><td>' . $node->source . '</td></tr>';
  }
  if ($node->preptime) {
    if ($node->preptime < 60) {
      $node->preptime = format_plural($node->preptime, '1 minute', '@count minutes');
    }
    elseif ($node->preptime % 60 == 0) {
      $node->preptime = format_plural($node->preptime / 60, '1 hour', '@count hours');
    }
    else {
      $node->preptime = t('!time hours', array(
        '!time' => recipe_ingredient_quantity_from_decimal($node->preptime / 60),
      ));
    }
    $output .= '<tr><th>' . t('Prep time') . '</th><td>' . $node->preptime . '</td></tr>';
  }
  $vocabs = taxonomy_get_vocabularies('recipe');
  if (count($vocabs) > 0) {
    foreach ($vocabs as $vocab) {
      $output .= '<tr><th>' . $vocab->name . '</th><td>';
      $terms = taxonomy_node_get_terms_by_vocabulary($node, $vocab->vid);
      foreach ($terms as $term) {
        $term = array_shift($terms);
        $output .= l($term->name, 'taxonomy/term/' . $term->tid) . ' ';
      }
      $output .= '</td></tr>';
    }
  }
  $output .= '</table>';
  if ($options['show_title']) {
    return theme('box', variable_get('recipe_summary_title', t('Summary')), $output);
  }
  else {
    return $output;
  }
}