You are here

function theme_dimension_theme_simple in Dimension 7

Callback to theme a complete dimension field with all values combined into a single line with the labels shortened to the first character.

Parameters

array $variable:

Return value

string

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

File

./dimension.module, line 377

Code

function theme_dimension_theme_simple($variable) {
  $mode = $variable['mode'];
  $item = $variable['item'];
  $settings = $variable['settings'];
  list($has_length, $has_more) = _dimension_get_modes($mode);
  $output = '<div class="dimension dimension-simple">';
  $labels = array();
  $values = array();
  if ($has_length) {
    $labels[] = substr($settings['fields']['length']['label'], 0, 1);
    $values[] = theme('dimension_theme_value', array(
      'value' => $item['length'],
      'settings' => $settings['fields']['length'],
      'label' => FALSE,
    ));
  }
  if ($has_more) {
    $labels[] = substr($settings['fields']['width']['label'], 0, 1);
    $values[] = theme('dimension_theme_value', array(
      'value' => $item['width'],
      'settings' => $settings['fields']['height'],
      'label' => FALSE,
    ));
    $labels[] = substr($settings['fields']['height']['label'], 0, 1);
    $values[] = theme('dimension_theme_value', array(
      'value' => $item['height'],
      'settings' => $settings['fields']['height'],
      'label' => FALSE,
    ));
  }
  $output .= '<span class="label">' . implode('/', $labels) . ':</span>';
  $output .= '<span class="value">' . implode('/', $values) . '</span>';
  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 .= '<span class="dimension ' . $class . '"><span class="label">' . $label . ':</span><span class="value">' . $dimension . $settings['dimension_unit'] . '</span></span>';
  }
  $output .= '</div>';
  drupal_add_css(drupal_get_path('module', 'dimension') . '/dimension.css');
  return $output;
}