You are here

public function EntityTranslationDefaultHandler::entityFormSharedElements in Entity Translation 7

Either remove access or add a translatability clue depending on the current user's "edit translation shared fields" permissions.

Overrides EntityTranslationHandlerInterface::entityFormSharedElements

See also

EntityTranslationHandlerInterface::entityFormSharedElements()

File

includes/translation.handler.inc, line 1424
Default translation handler for the translation module.

Class

EntityTranslationDefaultHandler
Class implementing the default entity translation behaviours.

Code

public function entityFormSharedElements(&$element, $access = NULL) {
  static $ignored_types, $shared_labels;
  if (!isset($ignored_types)) {
    $ignored_types = array_flip(array(
      'actions',
      'value',
      'hidden',
      'vertical_tabs',
      'token',
    ));
  }
  if (!isset($shared_labels)) {
    $shared_labels = variable_get('entity_translation_shared_labels', TRUE);
  }
  if (!isset($access)) {
    $access = $this
      ->getSharedFieldsAccess();
  }
  foreach (element_children($element) as $key) {
    if (!isset($element[$key]['#type'])) {
      $this
        ->entityFormSharedElements($element[$key], $access);
    }
    else {

      // Ignore non-widget form elements.
      if (isset($ignored_types[$element[$key]['#type']])) {
        continue;
      }

      // Elements are considered to be non multilingual by default.
      // Update #access only if it has not been set already or if we have
      // explicit mlutilingual support.
      if (!isset($element[$key]['#access']) || isset($element[$key]['#multilingual'])) {
        $element[$key]['#access'] = (!isset($element[$key]['#access']) || $element[$key]['#access']) && ($access || !empty($element[$key]['#multilingual']));
      }

      // Add translatability clue for visible elements.
      if ($access && $shared_labels) {
        _entity_translation_element_add_callback($element[$key], '#process', 'entity_translation_element_translatability_clue');
      }
    }
  }
}