You are here

function ds_field_settings_summary in Display Suite 7.2

Same name and namespace in other branches
  1. 8.4 includes/field_ui.inc \ds_field_settings_summary()
  2. 8.2 includes/field_ui.inc \ds_field_settings_summary()
  3. 8.3 includes/field_ui.inc \ds_field_settings_summary()
  4. 7 ds.field_ui.inc \ds_field_settings_summary()

Creates a summary for the field format configuration summary.

Parameters

$field: The configuration of the field.

Return value

$summary An markup array.

1 call to ds_field_settings_summary()
_ds_field_ui_fields in includes/ds.field_ui.inc
Add the fields to the Field UI form.

File

includes/ds.field_ui.inc, line 1071
Field UI functions for Display Suite.

Code

function ds_field_settings_summary($field, $form_state, $form, $view_mode) {
  $summary = '';

  // Not all fields have settings.
  if (isset($field['properties']['settings'])) {
    $summary = module_invoke($field['module'], 'ds_field_format_summary', $field);
  }
  if (module_exists('ds_extras') && variable_get('ds_extras_field_template', FALSE)) {
    module_load_include('inc', 'ds_extras', 'includes/ds_extras.admin');

    // Field template summary
    if (!in_array($field['field_type'], array(
      DS_FIELD_TYPE_IGNORE,
      DS_FIELD_TYPE_PREPROCESS,
    ))) {
      $functions = module_invoke_all('ds_field_theme_functions_info');
      $default_field_function = variable_get('ft-default', 'theme_field');
      $field_function = isset($form_state['formatter_settings'][$field['name']]['ft']['func']) ? $form_state['formatter_settings'][$field['name']]['ft']['func'] : $default_field_function;
      $summary .= 'Field template: ' . check_plain($functions[$field_function]) . '<br />';
    }
  }
  if (!empty($form_state['complete form'])) {
    $formatter_name = $form_state['complete form']['fields'][$field['name']]['format']['type']['#value'];
  }
  else {
    $formatter_name = $form['fields'][$field['name']]['format']['type']['#default_value'];
  }

  // Allow other modules to alter the formatter summary.
  $context = array(
    'formatter' => $formatter_name,
    'field' => $field,
    'instance' => array(
      'display' => array(
        $view_mode => array(
          'label' => '',
          'type' => '',
          'weight' => '',
          'settings' => isset($field['formatter_settings']) ? $field['formatter_settings'] : array(),
          'module' => '',
        ),
      ),
    ),
    'view_mode' => $view_mode,
    'ds' => TRUE,
  );
  drupal_alter('field_formatter_settings_summary', $summary, $context);
  if (empty($summary)) {
    return NULL;

    // no summary return nothing
  }
  return array(
    '#markup' => '<div class="field-formatter-summary">' . $summary . '</div>',
    '#cell_attributes' => array(
      'class' => array(
        'field-formatter-summary-cell',
      ),
    ),
  );
}