You are here

function msnf_msnf_format_summary in Multistep Nodeform 7

Implements hook_msnf_format_summary().

File

./msnf.module, line 503
Main functions for module "Multistep Nodeform".

Code

function msnf_msnf_format_summary($step) {
  $step_form = module_invoke_all('msnf_format_settings', $step);
  $output = '';
  if (isset($step->format_settings['instance_settings'])) {
    $last = end($step->format_settings['instance_settings']);
    foreach ($step->format_settings['instance_settings'] as $key => $value) {
      if (!is_numeric($value) && empty($value)) {
        continue;
      }
      $output .= '<strong>' . $key . '</strong> ';
      if (isset($step_form['instance_settings'], $step_form['instance_settings'][$key]['#options'])) {
        $value = $step_form['instance_settings'][$key]['#options'][$value];
      }
      if (is_array($value)) {
        $output .= '<br />';
        $last_value = end($value);
        foreach ($value as $vkey => $vvalue) {
          $output .= '&nbsp;&nbsp;<strong>' . $vkey . '</strong> ';

          // Shorten the string.
          if (drupal_strlen($vvalue) > 38) {
            $vvalue = truncate_utf8($vvalue, 50, TRUE, TRUE);
          }
          elseif (is_numeric($value)) {
            $vvalue = $vvalue == '1' ? t('yes') : t('no');
          }
          $output .= check_plain($vvalue);
          $output .= $last_value == $vvalue ? ' ' : '<br />';
        }
        continue;
      }

      // Shorten the string.
      if (drupal_strlen($value) > 38) {
        $value = truncate_utf8($value, 50, TRUE, TRUE);
      }
      elseif (is_numeric($value)) {
        $value = $value == '1' ? t('yes') : t('no');
      }
      $output .= check_plain($value);
      $output .= $last == $value ? ' ' : '<br />';
    }
  }
  return $output;
}