/** * Overrides TMGMTDefaultTranslatorUIController::pluginSettingsForm(). */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form = parent::buildConfigurationForm($form, $form_state); /** @var \Drupal\tmgmt\TranslatorInterface $translator */ $translator = $form_state->getFormObject()->getEntity(); $form['api_key'] = array('#type' => 'textfield', '#title' => t('Google API key'), '#required' => TRUE, '#default_value' => $translator->getSetting('api_key'), '#description' => t('Please enter your Google API key or visit <a href="@url">Google APIs console</a> to create new one.', array('@url' => 'https://code.google.com/apis/console'))); $form['url'] = array('#type' => 'hidden', '#default_value' => $translator->getSetting('url')); return $form; }
/** * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form = parent::buildConfigurationForm($form, $form_state); /** @var \Drupal\tmgmt\TranslatorInterface $test_translator */ $test_translator = $form_state->getFormObject()->getEntity(); $form['expose_settings'] = array('#type' => 'checkbox', '#title' => t('Display settings'), '#default_value' => $test_translator->getSetting('expose_settings')); $form['action'] = array('#type' => 'select', '#title' => t('Default action'), '#options' => array('translate' => t('Translate'), 'submit' => t('Submit'), 'reject' => t('Reject'), 'fail' => t('Fail'), 'not_available' => t('Not available'), 'not_translatable' => t('Not translatable')), '#default_value' => $test_translator->getSetting('action')); return $form; }
/** * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form = parent::buildConfigurationForm($form, $form_state); /** @var \Drupal\tmgmt\TranslatorInterface $translator */ $translator = $form_state->getFormObject()->getEntity(); $register_app = 'https://datamarket.azure.com/developer/applications/'; $form['client_id'] = array('#type' => 'textfield', '#title' => t('Client ID'), '#required' => TRUE, '#default_value' => $translator->getSetting('client_id'), '#description' => t('Please enter the Client ID, or follow this <a href=":link">link</a> to set it up.', array(':link' => $register_app))); $generate_url = 'https://datamarket.azure.com/developer/applications/edit/' . $translator->getSetting('client_id'); $form['client_secret'] = array('#type' => 'textfield', '#title' => t('Client secret'), '#required' => TRUE, '#default_value' => $translator->getSetting('client_secret'), '#description' => t('Please enter the Client Secret, or follow this <a href=":link">link</a> to generate one.', array(':link' => $generate_url))); $form['url'] = array('#type' => 'hidden', '#default_value' => $translator->getSetting('url')); return $form; }
/** * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form = parent::buildConfigurationForm($form, $form_state); /** @var \Drupal\tmgmt\TranslatorInterface $translator */ $translator = $form_state->getFormObject()->getEntity(); $form['export_format'] = array('#type' => 'radios', '#title' => t('Export to'), '#options' => \Drupal::service('plugin.manager.tmgmt_file.format')->getLabels(), '#default_value' => $translator->getSetting('export_format'), '#description' => t('Please select the format you want to export data.')); $form['xliff_cdata'] = array('#type' => 'checkbox', '#title' => t('XLIFF CDATA'), '#description' => t('Check to use CDATA for import/export.'), '#default_value' => $translator->getSetting('xliff_cdata')); $form['xliff_processing'] = array('#type' => 'checkbox', '#title' => t('Extended XLIFF processing'), '#description' => t('Check to further process content semantics and mask HTML tags instead just escaping it.'), '#default_value' => $translator->getSetting('xliff_processing')); $form['xliff_message'] = array('#type' => 'container', '#markup' => t('By selecting CDATA option, XLIFF processing will be ignored.'), '#attributes' => array('class' => array('messages messages--warning'))); $form['allow_override'] = array('#type' => 'checkbox', '#title' => t('Allow to override the format per job'), '#default_value' => $translator->getSetting('allow_override')); // Any visible, writeable wrapper can potentially be used for the files // directory, including a remote file system that integrates with a CDN. foreach (\Drupal::service('stream_wrapper_manager')->getDescriptions(StreamWrapperInterface::WRITE_VISIBLE) as $scheme => $description) { $options[$scheme] = Html::escape($description); } if (!empty($options)) { $form['scheme'] = array('#type' => 'radios', '#title' => t('Download method'), '#default_value' => $translator->getSetting('scheme'), '#options' => $options, '#description' => t('Choose the location where exported files should be stored. The usage of a protected location (e.g. private://) is recommended to prevent unauthorized access.')); } return $form; }