You are here

function theme_dimension_theme_table in Dimension 7

Callback to theme a complete dimension field with one value per line and a leading label for each of them.

Parameters

array $variable:

Return value

string

1 theme call to theme_dimension_theme_table()
dimension_field_formatter_view in ./dimension.module
Implements hook_field_formatter_view().

File

./dimension.module, line 342

Code

function theme_dimension_theme_table($variable) {
  $mode = $variable['mode'];
  $item = $variable['item'];
  $settings = $variable['settings'];
  list($has_length, $has_more) = _dimension_get_modes($mode);
  $output = '<div class="dimension dimension-table">';
  if ($has_length) {
    $output .= theme('dimension_theme_value', array(
      'value' => $item['length'],
      'settings' => $settings['fields']['length'],
    ));
  }
  if ($has_more) {
    $output .= theme('dimension_theme_value', array(
      'value' => $item['width'],
      'settings' => $settings['fields']['width'],
    ));
    $output .= theme('dimension_theme_value', array(
      'value' => $item['height'],
      'settings' => $settings['fields']['height'],
    ));
  }
  if ($has_more && !empty($settings['dimension_unit'])) {
    $label = $has_length ? t('Volume') : t('Area');
    $class = $has_length ? 'volume' : 'area';
    $dimension = dimension_calculate($item, $settings['fields']);
    $output .= '<div class="dimension ' . $class . '"><span class="label">' . $label . ':</span><span class="value">' . $dimension . $settings['dimension_unit'] . '</span></div>';
  }
  $output .= '</div>';
  drupal_add_css(drupal_get_path('module', 'dimension') . '/dimension.css');
  return $output;
}