function theme_recipe_summary in Recipe 7
Same name and namespace in other branches
- 6 recipe.module \theme_recipe_summary()
- 7.2 recipe.module \theme_recipe_summary()
Returns HTML for displaying the recipe summary box.
1 string reference to 'theme_recipe_summary'
- recipe_theme in ./
recipe.module - Implements hook_theme().
2 theme calls to theme_recipe_summary()
- recipe_block_view in ./
recipe.module - Implements hook_block_view().
- recipe_view in ./
recipe.module - Implements hook_view().
File
- ./
recipe.module, line 970 - Contains functions for Recipe node CRUD and display.
Code
function theme_recipe_summary($variables) {
$node = $variables['node'];
$show_title = isset($variables['show_title']) ? $variables['show_title'] : FALSE;
$show_yield_form = isset($variables['show_yield_form']) ? $variables['show_yield_form'] : TRUE;
// Construct the summary
$output = '<div class="recipe-summary">';
if ($show_title) {
$output .= '<h2 class="title">' . t('Summary') . '</h2>';
}
$output .= '<table>';
// Render the yield form.
$yield_form = drupal_get_form('recipe_yield_form', $node, $show_yield_form);
$output .= '<tr><th class="summary-title">' . t('Yield') . '</th><td class="summary-data">' . drupal_render($yield_form) . '</td></tr>';
if ($node->recipe_source) {
$output .= '<tr><th>' . t('Source') . '</th><td>' . $node->recipe_source . '</td></tr>';
}
if (isset($node->recipe_preptime)) {
$_o_minutes = $node->recipe_preptime;
$_hours = floor($_o_minutes / 60);
$_minutes = $_o_minutes - $_hours * 60;
$_text = '';
if ($_hours > 0) {
$_text = format_plural($_hours, '1 hour', '@count hours');
}
if ($_minutes > 0) {
if (strlen($_text) > 0) {
$_text .= ', ';
}
$_text .= format_plural($_minutes, '1 minute', '@count minutes');
}
// Wrap description in RDFa markup.
if (!empty($node->rdf_mapping['recipe_preptime'])) {
$attributes = rdf_rdfa_attributes($node->rdf_mapping['recipe_preptime']);
$attributes['content'] = array(
recipe_duration_iso8601($_o_minutes),
);
$_text = theme('rdf_template_variable_wrapper', array(
'content' => $_text,
'attributes' => $attributes,
'inline' => FALSE,
));
}
$output .= '<tr><th>' . t('Prep time') . '</th><td>' . $_text . '</td></tr>';
}
if (isset($node->recipe_cooktime)) {
$_o_minutes = $node->recipe_cooktime;
$_hours = floor($_o_minutes / 60);
$_minutes = $_o_minutes - $_hours * 60;
$_text = '';
if ($_hours > 0) {
$_text = format_plural($_hours, '1 hour', '@count hours');
}
if ($_minutes > 0) {
if (strlen($_text) > 0) {
$_text .= ', ';
}
$_text .= format_plural($_minutes, '1 minute', '@count minutes');
}
// Wrap description in RDFa markup.
if (!empty($node->rdf_mapping['recipe_cooktime'])) {
$attributes = rdf_rdfa_attributes($node->rdf_mapping['recipe_cooktime']);
$attributes['content'] = array(
recipe_duration_iso8601($_o_minutes),
);
$_text = theme('rdf_template_variable_wrapper', array(
'content' => $_text,
'attributes' => $attributes,
'inline' => FALSE,
));
}
$output .= '<tr><th>' . t('Cooking time') . '</th><td>' . $_text . '</td></tr>';
}
if (isset($node->recipe_cooktime) && isset($node->recipe_preptime)) {
$_o_minutes = $node->recipe_cooktime + $node->recipe_preptime;
$_hours = floor($_o_minutes / 60);
$_minutes = $_o_minutes - $_hours * 60;
$_text = '';
if ($_hours > 0) {
$_text = format_plural($_hours, '1 hour', '@count hours');
}
if ($_minutes > 0) {
if (strlen($_text) > 0) {
$_text .= ', ';
}
$_text .= format_plural($_minutes, '1 minute', '@count minutes');
}
// Wrap description in RDFa markup.
if (!empty($node->rdf_mapping['recipe_totaltime'])) {
$attributes = rdf_rdfa_attributes($node->rdf_mapping['recipe_totaltime']);
$attributes['content'] = array(
recipe_duration_iso8601($_o_minutes),
);
$_text = theme('rdf_template_variable_wrapper', array(
'content' => $_text,
'attributes' => $attributes,
'inline' => FALSE,
));
}
$output .= '<tr><th>' . t('Total time') . '</th><td>' . $_text . '</td></tr>';
}
$output .= '</table>';
$output .= '</div>';
return $output;
}