You are here

function webform_structured_text_format_value in Webform Structured Text 6

Same name and namespace in other branches
  1. 7 structured_text.inc \webform_structured_text_format_value()

Helper function to format a value per a mask.

Parameters

mixed $mask Either the string mask, or the mask array.:

string $value The value to be formatted.:

array $component The component array itself.:

string $format What format (HTML or text) should be returned.: Specifying 'html' forces a pass of the output through check_plain.

Return value

string The formatted value.

5 calls to webform_structured_text_format_value()
webform_validate_structured_text in ./structured_text.inc
Validation function for structured text. Ensure that user input conforms to the mask, and that no portions are left empty.
_webform_analysis_structured_text in ./structured_text.inc
Implements _webform_analysis_component.
_webform_csv_data_structured_text in ./structured_text.inc
Implements _webform_cvs_data_component().
_webform_display_structured_text in ./structured_text.inc
Implements _webform_display_component().
_webform_table_structured_text in ./structured_text.inc
Implements _webform_table_component().

File

./structured_text.inc, line 882

Code

function webform_structured_text_format_value($mask, $value, $component, $format = 'html') {
  $mask_array = is_array($mask) ? $mask : webform_structured_text_parse_mask($mask);
  $value = webform_structured_text_parse_value($mask_array, $value);
  if (($empty_test = implode('', $value)) && empty($empty_test)) {
    return '';
  }
  $output = '';
  foreach ($mask_array as $part => $details) {
    if ($details['type'] != 'markup') {
      $output .= $value[$part];
    }
    else {
      $output .= _webform_structured_text_t("{$component['nid']}:{$component['cid']}:mask:{$part}", $details['value']);
    }
  }
  return $format == 'html' ? str_replace(' ', ' ', check_plain($output)) : $output;
}