You are here

public function DoubleFieldFormatter::getSummary in Double Field 7.2

Confirm that the formatter summary is being displayed.

File

tests/double_field_formatter.inc, line 165
The file contains a class that assists to test Double field formatter types.

Class

DoubleFieldFormatter
Helper class to test Double field formatters.

Code

public function getSummary() {
  $summary = array();
  switch ($this->type) {
    case 'double_field_fieldset':
      $summary[] = t('Collapsible: %value', array(
        '%value' => $this->settings['collapsible'] ? 'Yes' : 'No',
      ));
      $summary[] = t('Collapsed: %value', array(
        '%value' => $this->settings['collapsed'] ? 'Yes' : 'No',
      ));
      break;
    case 'double_field_unformatted_list':
    case 'double_field_html_list':
      $display_styles = array(
        'inline' => t('Inline'),
        'block' => t('Block'),
        'link' => t('Link'),
        'simple' => t('Simple'),
      );
      $summary[] = t('Display style: %value', array(
        '%value' => $display_styles[$this->settings['style']],
      ));
      if ($this->type == 'double_field_html_list') {
        $summary[] = t('List type: %value', array(
          '%value' => $this->listTypes[$this->settings['list_type']],
        ));
        debug(t('List type: %value', array(
          '%value' => $this->listTypes[$this->settings['list_type']],
        )));
      }
      break;
    case 'double_field_table':
      $summary[] = t('Row number column: %value', array(
        '%value' => $this->settings['table']['number_column'] ? 'Yes' : 'No',
      ));
      if ($this->settings['table']['first']['column_label']) {
        $summary[] = t('First column label: %value', array(
          '%value' => $this->settings['table']['first']['column_label'],
        ));
      }
      if ($this->settings['table']['second']['column_label']) {
        $summary[] = t('Second column label: %value', array(
          '%value' => $this->settings['table']['second']['column_label'],
        ));
      }
      break;
  }

  // Summary of general settings.
  // We test formats later.
  foreach (array(
    'first',
    'second',
  ) as $subfield) {
    $summary[] = '<br/><strong>' . ($subfield == 'first' ? t('First subfield') : t('Second subfield')) . '</strong>';
    $summary[] = t('Hidden: %value', array(
      '%value' => $this->settings[$subfield]['hidden'] ? t('Yes') : t('No'),
    ));
    if ($this->settings[$subfield]['prefix']) {
      $summary[] = t('Prefix: %value', array(
        '%value' => $this->settings[$subfield]['prefix'],
      ));
    }
    if ($this->settings[$subfield]['suffix']) {
      $summary[] = t('Suffix: %value', array(
        '%value' => $this->settings[$subfield]['suffix'],
      ));
    }
  }
  return '<div class="field-formatter-summary">' . implode('<br/>', $summary) . '</div>';
}