You are here

translation.handler.taxonomy_term.inc in Entity Translation 7

Taxonomy term translation handler for the entity translation module.

File

includes/translation.handler.taxonomy_term.inc
View source
<?php

/**
 * @file
 * Taxonomy term translation handler for the entity translation module.
 */

/**
 * Taxonomy term translation handler.
 */
class EntityTranslationTaxonomyTermHandler extends EntityTranslationDefaultHandler {
  public function __construct($entity_type, $entity_info, $entity) {
    parent::__construct('taxonomy_term', $entity_info, $entity);
  }

  /**
   * @see EntityTranslationDefaultHandler::getLanguage()
   */
  public function getLanguage() {
    if (isset($this->entity->vid) && module_exists('i18n_taxonomy')) {
      $mode = i18n_taxonomy_vocabulary_mode($this->entity->vid);

      // We support also terms having no translation enabled, since they can
      // just be language-aware.
      if ($mode == I18N_MODE_NONE || $mode == I18N_MODE_ENTITY_TRANSLATION) {
        $translations = $this
          ->getTranslations();
        if (!empty($translations->original)) {
          return $translations->original;
        }
      }
    }
    return parent::getLanguage();
  }

  /**
   * @see EntityTranslationDefaultHandler::entityForm()
   */
  public function entityForm(&$form, &$form_state) {
    parent::entityForm($form, $form_state);

    // Remove the translation fieldset when the deletion confirm form is being
    // displayed.
    if (isset($form_state['confirm_delete'])) {
      unset($form[$this
        ->getLanguageKey()], $form['source_language'], $form['translation'], $form['actions']['delete_translation']);
    }
  }

}

Classes

Namesort descending Description
EntityTranslationTaxonomyTermHandler Taxonomy term translation handler.