translation.handler.taxonomy_term.inc 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * @file
  4. * Taxonomy term translation handler for the entity translation module.
  5. */
  6. /**
  7. * Taxonomy term translation handler.
  8. */
  9. class EntityTranslationTaxonomyTermHandler extends EntityTranslationDefaultHandler {
  10. public function __construct($entity_type, $entity_info, $entity) {
  11. parent::__construct('taxonomy_term', $entity_info, $entity);
  12. }
  13. /**
  14. * @see EntityTranslationDefaultHandler::getLanguage()
  15. */
  16. public function getLanguage() {
  17. if (isset($this->entity->vid) && module_exists('i18n_taxonomy')) {
  18. $mode = i18n_taxonomy_vocabulary_mode($this->entity->vid);
  19. // We support also terms having no translation enabled, since they can
  20. // just be language-aware.
  21. if ($mode == I18N_MODE_NONE || $mode == I18N_MODE_ENTITY_TRANSLATION) {
  22. $translations = $this->getTranslations();
  23. if (!empty($translations->original)) {
  24. return $translations->original;
  25. }
  26. }
  27. }
  28. return parent::getLanguage();
  29. }
  30. /**
  31. * @see EntityTranslationDefaultHandler::entityForm()
  32. */
  33. public function entityForm(&$form, &$form_state) {
  34. parent::entityForm($form, $form_state);
  35. // Remove the translation fieldset when the deletion confirm form is being
  36. // displayed.
  37. if (isset($form_state['confirm_delete'])) {
  38. unset(
  39. $form[$this->getLanguageKey()],
  40. $form['source_language'],
  41. $form['translation'],
  42. $form['actions']['delete_translation']
  43. );
  44. }
  45. }
  46. }