You are here

class TMGMTDefaultTranslatorUIController in Translation Management Tool 7

Default ui controller class for translator plugins.

Hierarchy

Expanded class hierarchy of TMGMTDefaultTranslatorUIController

Related topics

1 string reference to 'TMGMTDefaultTranslatorUIController'
tmgmt_translator_ui_controller in ./tmgmt.module
Get the ui controller class for a given translator plugin.

File

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

View source
class TMGMTDefaultTranslatorUIController extends TMGMTPluginBase implements TMGMTTranslatorUIControllerInterface {

  /**
   * {@inheritdoc}
   */
  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;
  }

  /**
   * {@inheritdoc}
   */
  public function checkoutSettingsForm($form, &$form_state, TMGMTJob $job) {
    if (!element_children($form)) {
      $form['#description'] = t("The @translator translator doesn't provide any checkout settings.", array(
        '@translator' => $job
          ->getTranslator()
          ->label(),
      ));
    }
    return $form;
  }

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

  /**
   * Provides a simple wrapper for the checkout info fieldset.
   *
   * @param TMGMTJob $job
   *   Translation job object.
   * @param $form
   *   Partial form structure to be wrapped in the fieldset.
   *
   * @return
   *   The provided form structure wrapped in a collapsed fieldset.
   */
  public function checkoutInfoWrapper(TMGMTJob $job, $form) {
    $label = $job
      ->getTranslator()
      ->label();
    $form += array(
      '#title' => t('@translator translation job information', array(
        '@translator' => $label,
      )),
      '#type' => 'fieldset',
      '#collapsible' => TRUE,
    );
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function reviewForm($form, &$form_state, TMGMTJobItem $item) {
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function reviewDataItemElement($form, &$form_state, $data_item_key, $parent_key, array $data_item, TMGMTJobItem $item) {
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function reviewFormValidate($form, &$form_state, TMGMTJobItem $item) {

    // Nothing to do here by default.
  }

  /**
   * {@inheritdoc}
   */
  public function reviewFormSubmit($form, &$form_state, TMGMTJobItem $item) {

    // Nothing to do here by default.
  }

}

Members

Namesort descending Modifiers Type Description Overrides
TMGMTDefaultTranslatorUIController::checkoutInfo public function Retrieves information about a translation job. Overrides TMGMTTranslatorUIControllerInterface::checkoutInfo 2
TMGMTDefaultTranslatorUIController::checkoutInfoWrapper public function Provides a simple wrapper for the checkout info fieldset.
TMGMTDefaultTranslatorUIController::checkoutSettingsForm public function Form callback for the checkout settings form. Overrides TMGMTTranslatorUIControllerInterface::checkoutSettingsForm 3
TMGMTDefaultTranslatorUIController::pluginSettingsForm public function Form callback for the plugin settings form. Overrides TMGMTTranslatorUIControllerInterface::pluginSettingsForm 3
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
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