You are here

class TMGMTFileTranslatorUIController in Translation Management Tool 7

File translator plugin controller.

Hierarchy

Expanded class hierarchy of TMGMTFileTranslatorUIController

1 string reference to 'TMGMTFileTranslatorUIController'
tmgmt_file_tmgmt_translator_plugin_info in translators/file/tmgmt_file.module
Implements hook_tmgmt_translator_plugin_info().

File

translators/file/tmgmt_file.ui.inc, line 11
Please supply a file description.

View source
class TMGMTFileTranslatorUIController extends TMGMTDefaultTranslatorUIController {

  /**
   * {@inheritdoc}
   */
  public function pluginSettingsForm($form, &$form_state, TMGMTTranslator $translator, $busy = FALSE) {
    $form['export_format'] = array(
      '#type' => 'radios',
      '#title' => t('Export to'),
      '#options' => tmgmt_file_format_plugin_labels(),
      '#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' => 'item',
      '#markup' => t('By selecting CDATA option, XLIFF processing will be ignored.'),
      '#prefix' => '<div class="messages warning">',
      '#suffix' => '</div>',
    );
    $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 (file_get_stream_wrappers(STREAM_WRAPPERS_WRITE_VISIBLE) as $scheme => $info) {
      $options[$scheme] = check_plain($info['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 parent::pluginSettingsForm($form, $form_state, $translator);
  }

  /**
   * {@inheritdoc}
   */
  public function checkoutSettingsForm($form, &$form_state, TMGMTJob $job) {
    if ($job
      ->getTranslator()
      ->getSetting('allow_override')) {
      $form['export_format'] = array(
        '#type' => 'radios',
        '#title' => t('Export to'),
        '#options' => tmgmt_file_format_plugin_labels(),
        '#default_value' => $job
          ->getTranslator()
          ->getSetting('export_format'),
        '#description' => t('Please select the format you want to export data.'),
      );
    }
    return parent::checkoutSettingsForm($form, $form_state, $job);
  }

  /**
   * {@inheritdoc}
   */
  public function checkoutInfo(TMGMTJob $job) {

    // If the job is finished, it's not possible to import translations anymore.
    if ($job
      ->isFinished()) {
      return parent::checkoutInfo($job);
    }
    $form = array(
      '#type' => 'fieldset',
      '#title' => t('Import translated file'),
    );
    $supported_formats = array_keys(tmgmt_file_format_plugin_info());
    $form['file'] = array(
      '#type' => 'file',
      '#title' => t('File file'),
      '#size' => 50,
      '#description' => t('Supported formats: @formats.', array(
        '@formats' => implode(', ', $supported_formats),
      )),
    );
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Import'),
      '#submit' => array(
        'tmgmt_file_import_form_submit',
      ),
    );
    return $this
      ->checkoutInfoWrapper($job, $form);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
TMGMTDefaultTranslatorUIController::checkoutInfoWrapper public function Provides a simple wrapper for the checkout info fieldset.
TMGMTDefaultTranslatorUIController::reviewDataItemElement public function Form callback for the data item element form. Overrides TMGMTTranslatorUIControllerInterface::reviewDataItemElement 1
TMGMTDefaultTranslatorUIController::reviewForm public function Form callback for the job item review form. Overrides TMGMTTranslatorUIControllerInterface::reviewForm
TMGMTDefaultTranslatorUIController::reviewFormSubmit public function Submit callback for the job item review form. Overrides TMGMTTranslatorUIControllerInterface::reviewFormSubmit
TMGMTDefaultTranslatorUIController::reviewFormValidate public function Validation callback for the job item review form. Overrides TMGMTTranslatorUIControllerInterface::reviewFormValidate
TMGMTFileTranslatorUIController::checkoutInfo public function Retrieves information about a translation job. Overrides TMGMTDefaultTranslatorUIController::checkoutInfo
TMGMTFileTranslatorUIController::checkoutSettingsForm public function Form callback for the checkout settings form. Overrides TMGMTDefaultTranslatorUIController::checkoutSettingsForm
TMGMTFileTranslatorUIController::pluginSettingsForm public function Form callback for the plugin settings form. Overrides TMGMTDefaultTranslatorUIController::pluginSettingsForm
TMGMTPluginBase::$pluginInfo protected property
TMGMTPluginBase::$pluginType protected property
TMGMTPluginBase::pluginInfo public function Returns the info of the type of the plugin. Overrides TMGMTPluginBaseInterface::pluginInfo
TMGMTPluginBase::pluginType public function Returns the type of the plugin. Overrides TMGMTPluginBaseInterface::pluginType
TMGMTPluginBase::__construct public function Constructor. Overrides TMGMTPluginBaseInterface::__construct