You are here

function ds_render_code_field in Display Suite 7.2

Same name and namespace in other branches
  1. 7 ds.module \ds_render_code_field()

Render a code field.

2 calls to ds_render_code_field()
ds_dsc_content_type_render in plugins/content_types/dsc/dsc.inc
Output function for the 'Display Suite' content type.
ds_get_field_value in ./ds.module
Get the value for a Display Suite field.

File

./ds.module, line 822
Display Suite core functions.

Code

function ds_render_code_field($field) {
  if (isset($field['properties']['code'])) {
    $value = $field['properties']['code']['value'];

    // Token support - check on token property so we don't run every single field through token.
    if (isset($field['properties']['use_token']) && $field['properties']['use_token']) {
      $value = token_replace($value, array(
        $field['entity_type'] => $field['entity'],
      ), array(
        'clear' => TRUE,
      ));
    }
    $format = isset($field['properties']['code']['format']) ? $field['properties']['code']['format'] : 'plain_text';
    if ($format == 'ds_code' && module_exists('ds_format')) {
      $value = ds_format_php_eval($value, $field['entity'], isset($field['build']) ? $field['build'] : array());
    }
    else {
      $value = check_markup($value, $format);
    }
    return $value;
  }
}