You are here

public function LingotekSettingsTabPreferencesForm::buildForm in Lingotek Translation 8

Same name and namespace in other branches
  1. 8.2 src/Form/LingotekSettingsTabPreferencesForm.php \Drupal\lingotek\Form\LingotekSettingsTabPreferencesForm::buildForm()
  2. 4.0.x src/Form/LingotekSettingsTabPreferencesForm.php \Drupal\lingotek\Form\LingotekSettingsTabPreferencesForm::buildForm()
  3. 3.0.x src/Form/LingotekSettingsTabPreferencesForm.php \Drupal\lingotek\Form\LingotekSettingsTabPreferencesForm::buildForm()
  4. 3.1.x src/Form/LingotekSettingsTabPreferencesForm.php \Drupal\lingotek\Form\LingotekSettingsTabPreferencesForm::buildForm()
  5. 3.2.x src/Form/LingotekSettingsTabPreferencesForm.php \Drupal\lingotek\Form\LingotekSettingsTabPreferencesForm::buildForm()
  6. 3.3.x src/Form/LingotekSettingsTabPreferencesForm.php \Drupal\lingotek\Form\LingotekSettingsTabPreferencesForm::buildForm()
  7. 3.4.x src/Form/LingotekSettingsTabPreferencesForm.php \Drupal\lingotek\Form\LingotekSettingsTabPreferencesForm::buildForm()
  8. 3.5.x src/Form/LingotekSettingsTabPreferencesForm.php \Drupal\lingotek\Form\LingotekSettingsTabPreferencesForm::buildForm()
  9. 3.6.x src/Form/LingotekSettingsTabPreferencesForm.php \Drupal\lingotek\Form\LingotekSettingsTabPreferencesForm::buildForm()
  10. 3.7.x src/Form/LingotekSettingsTabPreferencesForm.php \Drupal\lingotek\Form\LingotekSettingsTabPreferencesForm::buildForm()
  11. 3.8.x src/Form/LingotekSettingsTabPreferencesForm.php \Drupal\lingotek\Form\LingotekSettingsTabPreferencesForm::buildForm()

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides ConfigFormBase::buildForm

File

src/Form/LingotekSettingsTabPreferencesForm.php, line 32

Class

LingotekSettingsTabPreferencesForm
Configure Lingotek

Namespace

Drupal\lingotek\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {

  /** @var \Drupal\lingotek\LingotekConfigurationServiceInterface $lingotek_config */
  $lingotek_config = \Drupal::service('lingotek.configuration');
  $this
    ->retrieveImportSetting();
  $this
    ->retrieveLanguageSwitcher();
  $this
    ->retrieveAdminMenu();
  $form['prefs'] = array(
    '#type' => 'details',
    '#title' => t('Preferences'),
  );
  $form['prefs']['lang_switcher'] = array(
    '#type' => 'checkbox',
    '#title' => 'Enable the default language switcher',
    '#default_value' => $this->lang_switcher_value,
  );
  $form['prefs']['lang_switcher_select'] = array(
    '#type' => 'select',
    '#description' => $this
      ->t('The region where the switcher will be displayed') . '<br>' . $this
      ->t('Note: The default language switcher block is only shown if at least two languages are enabled and language negotiation is set to <em>URL</em> or <em>Session</em>. Go to <a href=":url">%language_detection</a> to change this.', [
      '%language_detection' => $this
        ->t('Language detection and selection'),
      ':url' => Url::fromRoute('language.negotiation')
        ->toString(),
    ]),
    '#options' => $this->lang_regions,
    '#default_value' => $this->lang_region_selected == 'none' ? $this->default_region : $this->lang_region_selected,
    '#states' => array(
      'visible' => array(
        ':input[name="lang_switcher"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $form['prefs']['advanced_taxonomy_terms'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable advanced handling of taxonomy terms'),
    '#description' => t('This option is used to handle translation of custom fields assigned to taxonomy terms.'),
    '#default_value' => $this->lingotek
      ->get('preference.advanced_taxonomy_terms'),
  );
  $form['prefs']['hide_top_level'] = array(
    '#type' => 'checkbox',
    '#title' => t('Hide top-level menu item'),
    '#description' => t('When hidden, the module can still be accessed under <i>Configuration > Regional and language</i>. <p> Note: It will take a few seconds to save if this setting is changed.'),
    '#default_value' => $this->top_level_value,
  );
  $form['prefs']['show_language_labels'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show language label on node pages'),
    '#description' => t('If checked, language labels will be displayed for nodes that have the \'language selection\' field set to be visible.'),
    '#default_value' => $this->lingotek
      ->get('preference.show_language_labels'),
  );
  $form['prefs']['always_show_translate_tabs'] = array(
    '#type' => 'checkbox',
    '#title' => t('Always show non-Lingotek translate tabs'),
    '#description' => t('If checked, edit-form tabs for both Content Translation and Entity Translation will not be hidden, even if the entity is managed by Lingotek.'),
    '#default_value' => $this->lingotek
      ->get('preference.always_show_translate_tabs'),
  );
  $form['prefs']['allow_local_editing'] = array(
    '#prefix' => '<div style="margin-left: 20px;">',
    '#suffix' => '</div>',
    '#type' => 'checkbox',
    '#title' => t('Allow local editing of Lingotek translations'),
    '#description' => t('If checked, local editing of translations managed by Lingotek will be allowed. (Note: any changes made may be overwritten if the translation is downloaded from Lingotek again.)'),
    '#default_value' => $this->lingotek
      ->get('preference.allow_local_editing'),
    '#states' => array(
      'visible' => array(
        ':input[name="always_show_translate_tabs"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $form['prefs']['language_specific_profiles'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable language-specific profiles'),
    '#description' => t('If checked, languages enabled for Lingotek translation will not automatically be queued for all content. Instead, languages enabled for Lingotek will be added to the available languages for profiles but will be disabled by default on profiles that have existing content. (Note: this cannot be unchecked if language-specific settings are in use.)'),
    '#default_value' => $this->lingotek
      ->get('preference.language_specific_profiles'),
  );
  $form['prefs']['delete_tms_documents_upon_disassociation'] = array(
    '#type' => 'checkbox',
    '#title' => t('Delete documents from Lingotek TMS when disassociating'),
    '#description' => t('Your documents will remain in your Drupal site but will be deleted from the Lingotek TMS if this option is checked.'),
    '#default_value' => $lingotek_config
      ->mustDeleteRemoteAfterDisassociation(),
  );
  $form['prefs']['advanced_parsing'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable advanced features'),
    '#description' => t('Some features may not be available without an <a href=":url">Enterprise License</a> for the Lingotek TMS. Call <a href=":phone_link">%phone</a> for details.', [
      ':url' => 'http://www.lingotek.com',
      ':phone_link' => 'tel:1-801-331-7777',
      '%phone' => '+1 (801) 331-7777',
    ]),
    '#default_value' => $this->lingotek
      ->get('preference.advanced_parsing'),
  );
  $states = array(
    'published' => t('Published'),
    'unpublished' => t('Unpublished'),
    'same-as-source' => t('Same as source content'),
  );
  $form['prefs']['target_download_status'] = array(
    '#type' => 'select',
    '#title' => t('Translations download publication status'),
    '#description' => t('Translations download publication status: specify which published status the translations downloads must be saved with.'),
    '#options' => $states,
    '#default_value' => $lingotek_config
      ->getPreference('target_download_status') ?: 'same-as-source',
  );
  $form['prefs']['enable_content_cloud'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable importing from Lingotek Content Cloud (beta)'),
    '#description' => t('Allows the importing of documents that are in your TMS. An \'Import\' tab will appear next to the \'Settings\' tab. <br> Note: The settings could take longer to save if this setting is changed.'),
    '#default_value' => $this->lingotek
      ->get('preference.enable_content_cloud', FALSE),
  );
  $form['prefs']['actions']['#type'] = 'actions';
  $form['prefs']['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
    '#button_type' => 'primary',
  );
  return $form;
}