You are here

function msnf_formatter_settings_update in Multistep Nodeform 7

Update handler for step configuration settings.

Parameters

object $step: The step object.

array $settings: Configuration settings for the formatter.

2 calls to msnf_formatter_settings_update()
msnf_field_ui_overview_form_alter in includes/msnf.field_ui.inc
Function to alter the fields overview screen.
msnf_formatter_row_update in includes/msnf.field_ui.inc
Update the row so that the step variables are updated.

File

includes/msnf.field_ui.inc, line 411
msnf.field_ui.inc is a file that contains most functions needed on the Fields UI Manage forms (display and fields).

Code

function msnf_formatter_settings_update(&$step, $settings) {

  // Fetch the step formatter defaults.
  $step_types = msnf_formatter_info();
  $formatter = $step_types[$step->format_type];

  // For format changes we load the defaults.
  if (empty($settings['format_settings']['settings'])) {
    $step->format_settings = array(
      'instance_settings' => $formatter['instance_settings'],
    );
  }
  else {
    $step->format_type = $settings['format']['type'];
    $step->label = $settings['format_settings']['settings']['label'];
    $step->format_settings = $settings['format_settings']['settings'];
  }
  if (module_exists('i18n_string')) {

    // Update label for translation.
    if (drupal_strlen($step->label) > 0) {
      i18n_string_update(array(
        'msnf_step',
        $step->step_name,
        $step->bundle,
        'label',
      ), $step->label);
    }
    else {
      i18n_string_remove(array(
        'msnf_step',
        $step->step_name,
        $step->bundle,
        'label',
      ));
    }

    // Update step description for translation.
    if (drupal_strlen($step->format_settings['instance_settings']['description']) > 0) {
      i18n_string_update(array(
        'msnf_step',
        $step->step_name,
        $step->bundle,
        'description',
      ), $step->format_settings['instance_settings']['description']);
    }
    else {
      i18n_string_remove(array(
        'msnf_step',
        $step->step_name,
        $step->bundle,
        'description',
      ));
    }

    // Update step buttons for translation.
    foreach (array(
      'previous',
      'next',
      'skip',
    ) as $button) {
      if (drupal_strlen($step->format_settings['instance_settings']['buttons'][$button]) > 0) {
        i18n_string_update(array(
          'msnf_step',
          $step->step_name,
          $step->bundle,
          "button_{$button}",
        ), $step->format_settings['instance_settings']['buttons'][$button]);
      }
      else {
        i18n_string_remove(array(
          'msnf_step',
          $step->step_name,
          $step->bundle,
          "button_{$button}",
        ));
      }
    }
  }
}