You are here

function commerce_license_field_formatter_view in Commerce License 7

Implements hook_field_formatter_view().

File

./commerce_license.module, line 1158
Provides a framework for selling access to local or remote resources.

Code

function commerce_license_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $element = array();
  if ($display['type'] == 'commerce_license_duration') {
    $units = commerce_license_duration_units();
    foreach ($items as $delta => $item) {
      if ($item['value'] > 0) {
        list($value, $unit) = commerce_license_duration_from_timestamp($item['value']);
        $duration = $value . ' ' . $units[$unit];
      }
      else {
        $duration = t('Unlimited');
      }
      $element[$delta] = array(
        '#markup' => $duration,
      );
    }
  }
  return $element;
}