You are here

class EntityTranslationNodeHandler in Entity Translation 7

Node translation handler.

Overrides default behaviours for Node properties.

Hierarchy

Expanded class hierarchy of EntityTranslationNodeHandler

1 string reference to 'EntityTranslationNodeHandler'
entity_translation_entity_info in ./entity_translation.module
Implements hook_entity_info().

File

includes/translation.handler.node.inc, line 14
Node translation handler for the entity translation module.

View source
class EntityTranslationNodeHandler extends EntityTranslationDefaultHandler {
  public function __construct($entity_type, $entity_info, $entity) {
    parent::__construct('node', $entity_info, $entity);
  }

  /**
   * @see EntityTranslationDefaultHandler::isRevision()
   */
  public function isRevision() {
    return !empty($this->entity->revision);
  }

  /**
   * @see EntityTranslationDefaultHandler::getAccess()
   */
  public function getAccess($op) {
    return node_access($op, $this->entity);
  }

  /**
   * @see EntityTranslationDefaultHandler::getTranslationAccess()
   */
  public function getTranslationAccess($langcode) {
    return user_access('bypass node access') || parent::getTranslationAccess($langcode);
  }

  /**
   * Convert the translation update status fieldset into a vartical tab.
   */
  public function entityForm(&$form, &$form_state) {
    parent::entityForm($form, $form_state);

    // Move the translation fieldset to a vertical tab.
    if (isset($form['translation'])) {
      $form['translation'] += array(
        '#group' => 'additional_settings',
        '#weight' => 100,
        '#attached' => array(
          'js' => array(
            drupal_get_path('module', 'entity_translation') . '/entity_translation.node-form.js',
          ),
        ),
      );
      if (!$this
        ->isTranslationForm()) {
        $form['translation']['name']['#access'] = FALSE;
        $form['translation']['created']['#access'] = FALSE;
      }
    }

    // Path aliases natively support multilingual values.
    if (isset($form['path'])) {
      $form['path']['#multilingual'] = TRUE;
    }
  }

  /**
   * @see EntityTranslationDefaultHandler::menuForm()
   */
  protected function menuForm(&$form, &$form_state) {
    entity_translation_i18n_menu_form($form, $form_state);
  }

  /**
   * @see EntityTranslationDefaultHandler::entityFormLanguageWidgetSubmit()
   */
  function entityFormLanguageWidgetSubmit($form, &$form_state) {
    $this
      ->updateFormLanguage($form_state);
  }

  /**
   * @see EntityTranslationDefaultHandler::entityFormSubmit()
   */
  public function entityFormSubmit($form, &$form_state) {
    if (!isset($form_state['values']['translation'])) {

      // Always publish the original values when we have no translations.
      $form_state['values']['translation'] = array(
        'status' => TRUE,
      );
    }
    $values =& $form_state['values']['translation'];
    if (!$this
      ->isTranslationForm()) {

      // Inherit entity authoring information for the original values.
      if (isset($form_state['values']['name'])) {
        $values['name'] = $form_state['values']['name'];
      }
      if (!empty($form_state['values']['date'])) {
        $values['created'] = $form_state['values']['date'];
      }
    }
    parent::entityFormSubmit($form, $form_state);
  }

  /**
   * @see EntityTranslationDefaultHandler::entityFormTitle()
   */
  protected function entityFormTitle() {
    $type_name = node_type_get_name($this->entity);
    return t('<em>Edit @type</em> @title', array(
      '@type' => $type_name,
      '@title' => $this
        ->getLabel(),
    ));
  }

  /**
   * @see EntityTranslationDefaultHandler::getStatus()
   */
  protected function getStatus() {
    return (bool) $this->entity->status;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityTranslationDefaultHandler::$activeLanguage protected property
EntityTranslationDefaultHandler::$basePath protected property
EntityTranslationDefaultHandler::$bundle protected property
EntityTranslationDefaultHandler::$children protected property The translation handler hierarchy storage.
EntityTranslationDefaultHandler::$editPath protected property
EntityTranslationDefaultHandler::$entity protected property
EntityTranslationDefaultHandler::$entityForm protected property 4
EntityTranslationDefaultHandler::$entityId protected property
EntityTranslationDefaultHandler::$entityInfo protected property
EntityTranslationDefaultHandler::$entityType protected property
EntityTranslationDefaultHandler::$factory protected property The translation handler factory.
EntityTranslationDefaultHandler::$outdated protected property
EntityTranslationDefaultHandler::$pathScheme protected property
EntityTranslationDefaultHandler::$pathWildcard protected property
EntityTranslationDefaultHandler::$revisionable protected property
EntityTranslationDefaultHandler::$routerMap protected property
EntityTranslationDefaultHandler::$sourceLanguage protected property
EntityTranslationDefaultHandler::$translatePath protected property
EntityTranslationDefaultHandler::$translating protected property
EntityTranslationDefaultHandler::$viewPath protected property
EntityTranslationDefaultHandler::addChild public function Overrides EntityTranslationHandlerInterface::addChild
EntityTranslationDefaultHandler::doSaveTranslations protected function Saves entity translation records to the storage.
EntityTranslationDefaultHandler::emptyTranslations protected static function Returns an empty translations data structure.
EntityTranslationDefaultHandler::entityFormLanguageWidget public function Overrides EntityTranslationHandlerInterface::entityFormLanguageWidget
EntityTranslationDefaultHandler::entityFormSharedElements public function Either remove access or add a translatability clue depending on the current user's "edit translation shared fields" permissions. Overrides EntityTranslationHandlerInterface::entityFormSharedElements
EntityTranslationDefaultHandler::entityFormValidate public function Overrides EntityTranslationHandlerInterface::entityFormValidate
EntityTranslationDefaultHandler::findMatchingPathScheme protected function Find a path scheme matching the given path.
EntityTranslationDefaultHandler::getActiveLanguage public function Returns the active language. Overrides EntityTranslationHandlerInterface::getActiveLanguage
EntityTranslationDefaultHandler::getBasePath public function Overrides EntityTranslationHandlerInterface::getBasePath
EntityTranslationDefaultHandler::getDefaultLanguage public function Overrides EntityTranslationHandlerInterface::getDefaultLanguage
EntityTranslationDefaultHandler::getEditPath public function Overrides EntityTranslationHandlerInterface::getEditPath
EntityTranslationDefaultHandler::getEntity public function Overrides EntityTranslationHandlerInterface::getEntity
EntityTranslationDefaultHandler::getEntityId protected function Returns the entity identifier.
EntityTranslationDefaultHandler::getEntityType public function Overrides EntityTranslationHandlerInterface::getEntityType
EntityTranslationDefaultHandler::getFormLanguage public function Retrieves the active form language. Overrides EntityTranslationHandlerInterface::getFormLanguage
EntityTranslationDefaultHandler::getLabel public function Overrides EntityTranslationHandlerInterface::getLabel
EntityTranslationDefaultHandler::getLanguage public function Overrides EntityTranslationHandlerInterface::getLanguage 1
EntityTranslationDefaultHandler::getLanguageKey public function Overrides EntityTranslationHandlerInterface::getLanguageKey 1
EntityTranslationDefaultHandler::getPathInstance protected function Returns an instance of the given path.
EntityTranslationDefaultHandler::getPathScheme public function Overrides EntityTranslationHandlerInterface::getPathScheme
EntityTranslationDefaultHandler::getSharedFieldsAccess public function Overrides EntityTranslationHandlerInterface::getSharedFieldsAccess
EntityTranslationDefaultHandler::getSourceLanguage public function Overrides EntityTranslationHandlerInterface::getSourceLanguage
EntityTranslationDefaultHandler::getTranslatePath public function Overrides EntityTranslationHandlerInterface::getTranslatePath
EntityTranslationDefaultHandler::getTranslations public function Overrides EntityTranslationHandlerInterface::getTranslations
EntityTranslationDefaultHandler::getTranslationsKey protected function Returns the translation object key for the wrapped entity type.
EntityTranslationDefaultHandler::getViewPath public function Overrides EntityTranslationHandlerInterface::getViewPath
EntityTranslationDefaultHandler::initOriginalTranslation public function Overrides EntityTranslationHandlerInterface::initOriginalTranslation
EntityTranslationDefaultHandler::initPathScheme public function Overrides EntityTranslationHandlerInterface::initPathScheme
EntityTranslationDefaultHandler::initPathVariables protected function Initializes handler path variables based on the active path scheme.
EntityTranslationDefaultHandler::initTranslations public function Overrides EntityTranslationHandlerInterface::initTranslations
EntityTranslationDefaultHandler::isAliasEnabled public function Overrides EntityTranslationHandlerInterface::isAliasEnabled
EntityTranslationDefaultHandler::isEntityForm public function Overrides EntityTranslationHandlerInterface::isEntityForm
EntityTranslationDefaultHandler::isEntityTypeRevisionable public static function Returns whether the entity type is revisionable.
EntityTranslationDefaultHandler::isNewEntity public function Overrides EntityTranslationHandlerInterface::isNewEntity
EntityTranslationDefaultHandler::isRevisionable public function Overrides EntityTranslationHandlerInterface::isRevisionable
EntityTranslationDefaultHandler::isTranslating public function Overrides EntityTranslationHandlerInterface::isTranslating
EntityTranslationDefaultHandler::isTranslationForm protected function Returns TRUE if an entity translation is being edited.
EntityTranslationDefaultHandler::isWrappedEntity public function Overrides EntityTranslationHandlerInterface::isWrappedEntity
EntityTranslationDefaultHandler::languageSwitchLinks public static function Returns the localized links for the given path.
EntityTranslationDefaultHandler::loadMultiple public static function Read the translation data from the storage.
EntityTranslationDefaultHandler::loadTranslations public function Overrides EntityTranslationHandlerInterface::loadTranslations
EntityTranslationDefaultHandler::localTasksAlter public function Overrides EntityTranslationHandlerInterface::localTasksAlter
EntityTranslationDefaultHandler::notifyChildren protected function Proxies the specified method invocation to a child translation handler.
EntityTranslationDefaultHandler::removeChild public function Overrides EntityTranslationHandlerInterface::removeChild
EntityTranslationDefaultHandler::removeRevisionTranslations public function Overrides EntityTranslationHandlerInterface::removeRevisionTranslations
EntityTranslationDefaultHandler::removeTranslation public function Overrides EntityTranslationHandlerInterface::removeTranslation
EntityTranslationDefaultHandler::removeTranslations public function Overrides EntityTranslationHandlerInterface::removeTranslations
EntityTranslationDefaultHandler::saveTranslations public function Overrides EntityTranslationHandlerInterface::saveTranslations
EntityTranslationDefaultHandler::setActiveLanguage public function Sets the active language. Overrides EntityTranslationHandlerInterface::setActiveLanguage
EntityTranslationDefaultHandler::setEntity public function Overrides EntityTranslationHandlerInterface::setEntity
EntityTranslationDefaultHandler::setFactory public function Overrides EntityTranslationHandlerInterface::setFactory
EntityTranslationDefaultHandler::setFormLanguage public function Sets the active form language. Overrides EntityTranslationHandlerInterface::setFormLanguage
EntityTranslationDefaultHandler::setOriginalLanguage public function Overrides EntityTranslationHandlerInterface::setOriginalLanguage
EntityTranslationDefaultHandler::setOutdated public function Overrides EntityTranslationHandlerInterface::setOutdated
EntityTranslationDefaultHandler::setPathScheme public function Overrides EntityTranslationHandlerInterface::setPathScheme
EntityTranslationDefaultHandler::setSourceLanguage public function Overrides EntityTranslationHandlerInterface::setSourceLanguage
EntityTranslationDefaultHandler::setTranslating public function Overrides EntityTranslationHandlerInterface::setTranslating
EntityTranslationDefaultHandler::setTranslation public function Overrides EntityTranslationHandlerInterface::setTranslation
EntityTranslationDefaultHandler::translationTabSort protected function Helper callback. Sorts language tabs by weight.
EntityTranslationDefaultHandler::updateFormLanguage protected function Update the current form language based on the submitted value.
EntityTranslationDefaultHandler::updateTranslations public function Overrides EntityTranslationHandlerInterface::updateTranslations
EntityTranslationNodeHandler::entityForm public function Convert the translation update status fieldset into a vartical tab. Overrides EntityTranslationDefaultHandler::entityForm
EntityTranslationNodeHandler::entityFormLanguageWidgetSubmit function Overrides EntityTranslationDefaultHandler::entityFormLanguageWidgetSubmit
EntityTranslationNodeHandler::entityFormSubmit public function Overrides EntityTranslationDefaultHandler::entityFormSubmit
EntityTranslationNodeHandler::entityFormTitle protected function Overrides EntityTranslationDefaultHandler::entityFormTitle
EntityTranslationNodeHandler::getAccess public function Overrides EntityTranslationDefaultHandler::getAccess
EntityTranslationNodeHandler::getStatus protected function Overrides EntityTranslationDefaultHandler::getStatus
EntityTranslationNodeHandler::getTranslationAccess public function Overrides EntityTranslationDefaultHandler::getTranslationAccess
EntityTranslationNodeHandler::isRevision public function Overrides EntityTranslationDefaultHandler::isRevision
EntityTranslationNodeHandler::menuForm protected function Overrides EntityTranslationDefaultHandler::menuForm
EntityTranslationNodeHandler::__construct public function Initializes an instance of the translation handler. Overrides EntityTranslationDefaultHandler::__construct