function entity_metadata_field_get_language

cis7 callbacks.inc entity_metadata_field_get_language($entity_type, $entity, $field, $langcode = LANGUAGE_NONE, $fallback = FALSE)
cle7 callbacks.inc entity_metadata_field_get_language($entity_type, $entity, $field, $langcode = LANGUAGE_NONE, $fallback = FALSE)
elmsmedia7 callbacks.inc entity_metadata_field_get_language($entity_type, $entity, $field, $langcode = LANGUAGE_NONE, $fallback = FALSE)
icor7 callbacks.inc entity_metadata_field_get_language($entity_type, $entity, $field, $langcode = LANGUAGE_NONE, $fallback = FALSE)
meedjum_blog7 callbacks.inc entity_metadata_field_get_language($entity_type, $entity, $field, $langcode = LANGUAGE_NONE, $fallback = FALSE)
mooc7 callbacks.inc entity_metadata_field_get_language($entity_type, $entity, $field, $langcode = LANGUAGE_NONE, $fallback = FALSE)

Helper for determining the field language to be used.

Note that we cannot use field_language() as we are not about to display values, but generally read/write values.

Parameters

$fallback: (optional) Whether to fall back to the entity default language, if no value is available for the given language code yet.

Return value

The language code to use.

4 calls to entity_metadata_field_get_language()
entity_metadata_field_property_get in sites/all/modules/ulmus/entity/modules/callbacks.inc
Callback for getting field property values.
entity_metadata_field_property_set in sites/all/modules/ulmus/entity/modules/callbacks.inc
Callback for setting field property values.
entity_metadata_field_verbatim_get in sites/all/modules/ulmus/entity/modules/callbacks.inc
Callback to verbatim get the data structure of a field. Useful for fields that add metadata for their own data structure.
entity_metadata_field_verbatim_set in sites/all/modules/ulmus/entity/modules/callbacks.inc
Writes the passed field items in the object. Useful as field level setter to set the whole data structure at once.

File

sites/all/modules/ulmus/entity/modules/callbacks.inc, line 552
Provides various callbacks for the whole core module integration.

Code

function entity_metadata_field_get_language($entity_type, $entity, $field, $langcode = LANGUAGE_NONE, $fallback = FALSE) {
  // Try to figure out the default language used by the entity.
  // With Drupal >= 7.15 we can use entity_language().
  if (function_exists('entity_language')) {
    $default_langcode = entity_language($entity_type, $entity);
  }
  else {
    $default_langcode = !empty($entity->language) ? $entity->language : LANGUAGE_NONE;
  }

  // Determine the right language to use.
  if ($default_langcode != LANGUAGE_NONE && field_is_translatable($entity_type, $field)) {
    $langcode = ($langcode != LANGUAGE_NONE) ? field_valid_language($langcode, $default_langcode) : $default_langcode;
    if (!isset($entity->{$field['field_name']}[$langcode]) && $fallback) {
      $langcode = $default_langcode;
    }
    return $langcode;
  }
  else {
    return LANGUAGE_NONE;
  }
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.