You are here

function theme_recipe_html_summary_box in Recipe 7

Default theme implementation for the recipe summary box.

1 string reference to 'theme_recipe_html_summary_box'
recipe_html_theme in includes/recipe_html.module
Implementation of hook_theme().
1 theme call to theme_recipe_html_summary_box()
recipe_html_export_single in includes/recipe_html.module

File

includes/recipe_html.module, line 102
recipe_html.module - Enables a print view for recipes. This supports full 8-1/2" x 11", and 5"x7" and 3"x5" index cards. Some printers may not be able to deal with small page sizes like this. They may have to print on…

Code

function theme_recipe_html_summary_box($variables) {
  $node = $variables['node'];

  // Construct the summary
  $output = '<div class="recipe-summary">';
  $output .= '<table>';
  $cols = 0;
  if ($node->recipe_preptime) {
    $cols++;
  }
  if ($node->recipe_cooktime) {
    $cols++;
  }
  if (!empty($node->recipe_cooktime) && !empty($node->recipe_preptime)) {
    $cols++;
  }
  if (!empty($node->recipe_source)) {
    $output .= '<tr><td colspan="' . $cols . '">';
    $output .= t('Source: @source', array(
      '@source' => $node->recipe_source,
    ));
    $output .= '<td></tr>';
  }
  if ($cols > 0) {
    $output .= '<tr>';
  }
  if ($node->recipe_preptime) {
    $_minutes = $node->recipe_preptime;
    $_text = '';
    if ($node->recipe_preptime < 60) {
      $_text = format_plural($_minutes, '1 minute', '@count minutes');
    }
    elseif ($node->recipe_preptime % 60 == 0) {
      $_text = format_plural($_minutes / 60, '1 hour', '@count hours');
    }
    else {
      $_text = t('!time hours', array(
        '!time' => recipe_ingredient_quantity_from_decimal($_minutes / 60),
      ));
    }
    $output .= '<td>' . t('Prep time: !time', array(
      '!time' => $_text,
    )) . '</td>';
  }
  if ($node->recipe_cooktime) {
    $_minutes = $node->recipe_cooktime;
    $_text = '';
    if ($node->recipe_cooktime < 60) {
      $_text = format_plural($_minutes, '1 minute', '@count minutes');
    }
    elseif ($node->recipe_cooktime % 60 == 0) {
      $_text = format_plural($_minutes / 60, '1 hour', '@count hours');
    }
    else {
      $_text = t('!time hours', array(
        '!time' => recipe_ingredient_quantity_from_decimal($_minutes / 60),
      ));
    }
    $output .= '<td>' . t('Cooking time: !time', array(
      '!time' => $_text,
    )) . '</td>';
  }
  if (!empty($node->recipe_cooktime) && !empty($node->recipe_preptime)) {
    $_minutes = $node->recipe_cooktime + $node->recipe_preptime;
    $_text = '';
    if ($_minutes < 60) {
      $_text = format_plural($_minutes, '1 minute', '@count minutes');
    }
    elseif ($_minutes % 60 == 0) {
      $_text = format_plural($_minutes / 60, '1 hour', '@count hours');
    }
    else {
      $_text = t('!time hours', array(
        '!time' => recipe_ingredient_quantity_from_decimal($_minutes / 60),
      ));
    }
    $output .= '<td>' . t('Total time: !time', array(
      '!time' => $_text,
    )) . '</td>';
  }
  if ($cols > 0) {
    $output .= '</tr>';
  }
  $output .= '</table>';
  $output .= '</div>';
  return $output;
}