You are here

public function TMGMTDefaultTranslatorUIController::pluginSettingsForm in Translation Management Tool 7

Form callback for the plugin settings form.

Overrides TMGMTTranslatorUIControllerInterface::pluginSettingsForm

2 calls to TMGMTDefaultTranslatorUIController::pluginSettingsForm()
TMGMTFileTranslatorUIController::pluginSettingsForm in translators/file/tmgmt_file.ui.inc
Form callback for the plugin settings form.
TMGMTTestTranslatorUIController::pluginSettingsForm in tests/tmgmt_test.ui.translator.inc
Form callback for the plugin settings form.
3 methods override TMGMTDefaultTranslatorUIController::pluginSettingsForm()
TMGMTFileTranslatorUIController::pluginSettingsForm in translators/file/tmgmt_file.ui.inc
Form callback for the plugin settings form.
TMGMTLocalTranslatorUIController::pluginSettingsForm in translators/tmgmt_local/includes/tmgmt_local.plugin.ui.inc
Form callback for the plugin settings form.
TMGMTTestTranslatorUIController::pluginSettingsForm in tests/tmgmt_test.ui.translator.inc
Form callback for the plugin settings form.

File

plugin/tmgmt.ui.translator.inc, line 13

Class

TMGMTDefaultTranslatorUIController
Default ui controller class for translator plugins.

Code

public function pluginSettingsForm($form, &$form_state, TMGMTTranslator $translator, $busy = FALSE) {
  if (!empty($translator->plugin)) {
    $controller = tmgmt_translator_plugin_controller($translator->plugin);
  }

  // If current translator is configured to provide remote language mapping
  // provide the form to configure mappings, unless it does not exists yet.
  if (!empty($controller) && tmgmt_provide_remote_languages_mappings($translator)) {
    $form['remote_languages_mappings'] = array(
      '#tree' => TRUE,
      '#type' => 'fieldset',
      '#title' => t('Remote languages mappings'),
      '#description' => t('Here you can specify mappings of your local language codes to the translator language codes.'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $options = array();
    foreach ($controller
      ->getSupportedRemoteLanguages($translator) as $language) {
      $options[$language] = $language;
    }
    ksort($options);
    foreach ($controller
      ->getRemoteLanguagesMappings($translator) as $local_language => $remote_language) {
      $form['remote_languages_mappings'][$local_language] = array(
        '#type' => 'textfield',
        '#title' => tmgmt_language_label($local_language) . ' (' . $local_language . ')',
        '#default_value' => $remote_language,
        '#size' => 6,
      );
      if (!empty($options)) {
        $form['remote_languages_mappings'][$local_language]['#type'] = 'select';
        $form['remote_languages_mappings'][$local_language]['#options'] = $options;
        $form['remote_languages_mappings'][$local_language]['#empty_option'] = ' - ';
        unset($form['remote_languages_mappings'][$local_language]['#size']);
      }
    }
  }
  if (!element_children($form)) {
    $form['#description'] = t("The @plugin plugin doesn't provide any settings.", array(
      '@plugin' => $this->pluginInfo['label'],
    ));
  }
  return $form;
}