You are here

class TMGMTFileTranslatorPluginController in Translation Management Tool 7

File translator plugin controller.

Hierarchy

Expanded class hierarchy of TMGMTFileTranslatorPluginController

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

File

translators/file/tmgmt_file.plugin.inc, line 11
Provides the file translator plugin controller.

View source
class TMGMTFileTranslatorPluginController extends TMGMTDefaultTranslatorPluginController {

  /**
   * {@inheritdoc}
   */
  public function canTranslate(TMGMTTranslator $translator, TMGMTJob $job) {

    // Anything can be exported.
    return TRUE;
  }

  /**
   * {@inheritdoc}
   */
  public function requestTranslation(TMGMTJob $job) {
    $name = "JobID" . $job->tjid . '_' . $job->source_language . '_' . $job->target_language;
    $export = tmgmt_file_format_controller($job
      ->getSetting('export_format'));
    $path = $job
      ->getSetting('scheme') . '://tmgmt_file/' . $name . '.' . $job
      ->getSetting('export_format');
    $dirname = dirname($path);
    if (file_prepare_directory($dirname, FILE_CREATE_DIRECTORY)) {
      $file = file_save_data($export
        ->export($job), $path);
      file_usage_add($file, 'tmgmt_file', 'tmgmt_job', $job->tjid);
      $job
        ->submitted('Exported file can be downloaded <a href="!link">here</a>.', array(
        '!link' => file_create_url($file->uri),
      ));
    }
  }

  /**
   * {@inheritdoc}
   */
  public function hasCheckoutSettings(TMGMTJob $job) {
    return $job
      ->getTranslator()
      ->getSetting('allow_override');
  }

  /**
   * {@inheritdoc}
   */
  public function defaultSettings() {
    return array(
      'export_format' => 'xlf',
      'allow_override' => TRUE,
      'scheme' => 'public',
      // Making this setting TRUE by default is more appropriate, however we
      // need to make it FALSE due to backwards compatibility.
      'xliff_processing' => FALSE,
      'xliff_cdata' => FALSE,
    );
  }

}

Members

Namesort descending Modifiers Type Description Overrides
TMGMTDefaultTranslatorPluginController::$escapeEnd protected property Characters that indicate the end of an escaped string. 1
TMGMTDefaultTranslatorPluginController::$escapeStart protected property Characters that indicate the beginning of an escaped string. 1
TMGMTDefaultTranslatorPluginController::$remoteLanguagesMappings protected property
TMGMTDefaultTranslatorPluginController::$supportedRemoteLanguages protected property
TMGMTDefaultTranslatorPluginController::abortTranslation public function Aborts a translation job. Overrides TMGMTTranslatorPluginControllerInterface::abortTranslation
TMGMTDefaultTranslatorPluginController::acceptetDataItem public function Accept a single data item. Overrides TMGMTTranslatorPluginControllerInterface::acceptetDataItem
TMGMTDefaultTranslatorPluginController::escapeText public function Returns the escaped #text of a data item. Overrides TMGMTTranslatorPluginControllerInterface::escapeText
TMGMTDefaultTranslatorPluginController::getDefaultRemoteLanguagesMappings public function Specifies default mappings for local to remote language codes. Overrides TMGMTTranslatorPluginControllerInterface::getDefaultRemoteLanguagesMappings 1
TMGMTDefaultTranslatorPluginController::getEscapedString protected function Returns the escaped string.
TMGMTDefaultTranslatorPluginController::getNotAvailableReason public function Return a reason why the translator is not available. Overrides TMGMTTranslatorPluginControllerInterface::getNotAvailableReason
TMGMTDefaultTranslatorPluginController::getNotCanTranslateReason public function Return a reason why the translator is not able to translate this job. Overrides TMGMTTranslatorPluginControllerInterface::getNotCanTranslateReason
TMGMTDefaultTranslatorPluginController::getRemoteLanguagesMappings public function Gets existing remote languages mappings. Overrides TMGMTTranslatorPluginControllerInterface::getRemoteLanguagesMappings
TMGMTDefaultTranslatorPluginController::getSupportedLanguagePairs public function Default implementation that gets target languages for each remote language. This approach is ineffective and therefore it is advised that a plugin should provide own implementation. Overrides TMGMTTranslatorPluginControllerInterface::getSupportedLanguagePairs 1
TMGMTDefaultTranslatorPluginController::getSupportedRemoteLanguages public function Gets all supported languages of the translator. Overrides TMGMTTranslatorPluginControllerInterface::getSupportedRemoteLanguages
TMGMTDefaultTranslatorPluginController::getSupportedTargetLanguages public function Returns all available target languages that are supported by this service when given a source language. Overrides TMGMTTranslatorPluginControllerInterface::getSupportedTargetLanguages 2
TMGMTDefaultTranslatorPluginController::isAvailable public function Checks whether a translator is available. Overrides TMGMTTranslatorPluginControllerInterface::isAvailable
TMGMTDefaultTranslatorPluginController::mapToLocalLanguage public function Maps remote language to local language. Overrides TMGMTTranslatorPluginControllerInterface::mapToLocalLanguage
TMGMTDefaultTranslatorPluginController::mapToRemoteLanguage public function Maps local language to remote language. Overrides TMGMTTranslatorPluginControllerInterface::mapToRemoteLanguage
TMGMTDefaultTranslatorPluginController::unescapeText public function Removes escape patterns from an escaped text. Overrides TMGMTTranslatorPluginControllerInterface::unescapeText
TMGMTFileTranslatorPluginController::canTranslate public function Check whether this service can handle a particular translation job. Overrides TMGMTDefaultTranslatorPluginController::canTranslate
TMGMTFileTranslatorPluginController::defaultSettings public function Defines default settings. Overrides TMGMTDefaultTranslatorPluginController::defaultSettings
TMGMTFileTranslatorPluginController::hasCheckoutSettings public function Returns if the translator has any settings for the passed job. Overrides TMGMTDefaultTranslatorPluginController::hasCheckoutSettings
TMGMTFileTranslatorPluginController::requestTranslation public function @abstract Overrides TMGMTTranslatorPluginControllerInterface::requestTranslation
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