diff --git a/entity_token.tokens.inc b/entity_token.tokens.inc index f9ec7f7..e1a246a 100644 --- a/entity_token.tokens.inc +++ b/entity_token.tokens.inc @@ -293,6 +293,7 @@ function _entity_token_wrap_data($token_type, $type, $data, $options) { * Gets the token replacement by correctly obeying the options. */ function _entity_token_get_token($wrapper, $options) { + $options += array('format' => TRUE); if ($wrapper->value() === NULL) { // Do not provide a replacement if there is no value. @@ -300,7 +301,7 @@ function _entity_token_get_token($wrapper, $options) { } if (empty($options['sanitize'])) { - // When we don't need sanitized tokens decode already sanitizied texts. + // When we don't need sanitized tokens decode already sanitized texts. $options['decode'] = TRUE; } $langcode = isset($options['language']) ? $options['language']->language : NULL; @@ -314,20 +315,25 @@ function _entity_token_get_token($wrapper, $options) { switch ($wrapper->type()) { case 'integer': return $wrapper->value(); + case 'decimal': - return number_format($wrapper->value(), 2); + return $options['format'] ? number_format($wrapper->value(), 2) : $wrapper->value(); + case 'date': - return format_date($wrapper->value(), 'medium', '', NULL, $langcode); + return $options['format'] ? format_date($wrapper->value(), 'medium', '', NULL, $langcode) : $wrapper->value(); + case 'duration': - return format_interval($wrapper->value(), 2, $langcode); + return $options['format'] ? format_interval($wrapper->value(), 2, $langcode) : $wrapper->value(); + case 'boolean': return $wrapper->value() ? t('true') : t('false'); + case 'uri': case 'text': return $wrapper->value($options); } - // Care for outputing list values. + // Care for outputting list values. if ($wrapper instanceof EntityListWrapper) { $output = array(); foreach ($wrapper as $item) {