uppdated modules
This commit is contained in:
@@ -3,6 +3,36 @@ Entity Translation 7.x-1.x, xxxx-xx-xx
|
||||
--------------------------------------
|
||||
|
||||
|
||||
Entity Translation 7.x-1.0-beta5, 2016-05-08
|
||||
--------------------------------------------
|
||||
#929402 by das-peter, bastnic, kristiaanvandeneynde, brockfanning, greenjuls,
|
||||
make77, steinmb: Added support for migrate module.
|
||||
#1291388 by Jax, poiu, plach: Added support for multilingual core search.
|
||||
#2339315 by loopduplicate, gnucifer, plopesc, james.williams: Fixed Source
|
||||
language prepopulated values should be also included in $form_state['field'].
|
||||
#2648062 by brunoric, cebasqueira, lucasr, mmchristoph: Fixed Fatal error: Call
|
||||
to a member function getFormLanguage() on a non-object.
|
||||
#S156840 by HelenaEksler, plach: Fixed XSS vulnerability in the translation
|
||||
form page title.
|
||||
#2444203 by Leksat, badrange, attiks: Show fallback information on the translation
|
||||
overview.
|
||||
#2458393 by catch, plach, douggreen: Fixed unindexed query in
|
||||
EntityTranslationDefaultHandler::loadMultiple().
|
||||
#2462909 by GeduR: Misspelling translation exists help in views handler
|
||||
definition.
|
||||
#2166157 by rsmylski, ciss: entity translation handler id for new entities not
|
||||
unique enough - can cause infinite/circular child reference.
|
||||
#2452279 by GeduR: Duplicated variable $language in
|
||||
entity_translation_edit_access().
|
||||
#2423661 by marcoscano: Module api documentation has wrong example ("path sets"
|
||||
instead of "path schemes").
|
||||
#2305547 by das-peter: Fixed undefined index name.
|
||||
#1989084 by jsacksick, candelas: Fixed <nolink> and validation.
|
||||
#2203801 by idflood: Impossible to update taxonomy term after enabling
|
||||
i18n_taxonomy.
|
||||
#2415189 by catch: Translation deletion bypasses entity saving.
|
||||
|
||||
|
||||
Entity Translation 7.x-1.0-beta4, 2015-01-23
|
||||
--------------------------------------------
|
||||
#2396103 by plach: Fixed [DATA LOSS] Translations deleted.
|
||||
|
||||
+62
-6
@@ -18,6 +18,18 @@ function entity_translation_admin_form($form, $form_state) {
|
||||
'#default_value' => variable_get('locale_field_language_fallback', TRUE),
|
||||
);
|
||||
|
||||
$form['entity_translation_show_fallback_on_overview_pages'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Show fallback statuses on overview pages'),
|
||||
'#description' => t('Enable to the show fallback information on the entity overview pages.'),
|
||||
'#default_value' => variable_get('entity_translation_show_fallback_on_overview_pages', FALSE),
|
||||
'#states' => array(
|
||||
'visible' => array(
|
||||
':input[name="locale_field_language_fallback"]' => array('checked' => TRUE),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$form['entity_translation_shared_labels'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display shared labels'),
|
||||
@@ -219,8 +231,7 @@ function entity_translation_overview($entity_type, $entity, $callback = NULL) {
|
||||
// languages.
|
||||
if ($handler->initOriginalTranslation()) {
|
||||
// FIXME!
|
||||
field_attach_presave($entity_type, $entity);
|
||||
field_attach_update($entity_type, $entity);
|
||||
entity_translation_entity_save($entity_type, $entity);
|
||||
}
|
||||
|
||||
$header = array(t('Language'), t('Source language'), t('Translation'), t('Status'), t('Operations'));
|
||||
@@ -236,6 +247,8 @@ function entity_translation_overview($entity_type, $entity, $callback = NULL) {
|
||||
$links = EntityTranslationDefaultHandler::languageSwitchLinks($path);
|
||||
}
|
||||
|
||||
$show_fallback = variable_get('locale_field_language_fallback', TRUE) && variable_get('entity_translation_show_fallback_on_overview_pages', FALSE);
|
||||
|
||||
foreach ($languages as $language) {
|
||||
$classes = array();
|
||||
$options = array();
|
||||
@@ -305,6 +318,18 @@ function entity_translation_overview($entity_type, $entity, $callback = NULL) {
|
||||
$classes[] = $translatable ? '' : 'non-traslatable';
|
||||
}
|
||||
$status = t('Not translated');
|
||||
// Show fallback information if required.
|
||||
if ($show_fallback) {
|
||||
$language_fallback_candidates = _entity_translation_language_fallback_get_candidates($language);
|
||||
$fallback_candidates = array_intersect_key(drupal_map_assoc($language_fallback_candidates), $translations->data);
|
||||
$fallback_langcode = reset($fallback_candidates);
|
||||
if ($fallback_langcode !== FALSE) {
|
||||
$status = t('Fallback from @language', array('@language' => $languages[$fallback_langcode]->name));
|
||||
$label = _entity_translation_label($entity_type, $entity, $fallback_langcode);
|
||||
$link = isset($links->links[$langcode]['href']) ? $links->links[$langcode] : array('href' => $path, 'language' => $langcode);
|
||||
$row_title = l($label, $link['href'], $link);
|
||||
}
|
||||
}
|
||||
}
|
||||
$rows[] = array(
|
||||
'data' => array($language_name, $source_name, $row_title, $status, implode(" | ", $options)),
|
||||
@@ -420,8 +445,7 @@ function entity_translation_delete_confirm_submit($form, &$form_state) {
|
||||
|
||||
// Remove the translation entry and the related fields.
|
||||
$handler->removeTranslation($langcode);
|
||||
field_attach_presave($entity_type, $entity);
|
||||
field_attach_update($entity_type, $entity);
|
||||
entity_translation_entity_save($entity_type, $entity);
|
||||
|
||||
$form_state['redirect'] = $handler->getTranslatePath();
|
||||
}
|
||||
@@ -654,8 +678,7 @@ function _entity_translation_update_field($entity_type, $entity, $field_name) {
|
||||
// otherwise any stored empty field value would be deleted. If this happens
|
||||
// the range queries would be messed up.
|
||||
if ($empty < count($entity->{$field_name})) {
|
||||
field_attach_presave($entity_type, $entity);
|
||||
field_attach_update($entity_type, $entity);
|
||||
entity_translation_entity_save($entity_type, $entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -671,3 +694,36 @@ function entity_translation_translatable_batch_done($success, $results, $operati
|
||||
drupal_set_message(t("Something went wrong while processing data. Some nodes may appear to have lost fields."));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns language fallback candidates for a certain language.
|
||||
*
|
||||
* @param object $language
|
||||
* Drupal language object.
|
||||
*
|
||||
* @return array
|
||||
* An array of language codes in the fallback order.
|
||||
*/
|
||||
function _entity_translation_language_fallback_get_candidates($language) {
|
||||
// Save original fallback candidates.
|
||||
$language_fallback_original = drupal_static('language_fallback_get_candidates');
|
||||
// Replace all global languages with the given one. We need this because the
|
||||
// language_fallback_get_candidates() does not take the $language parameter,
|
||||
// however other modules (like language_fallback) may use current language(s)
|
||||
// when they alter the language fallback candidates.
|
||||
$languages_original = array();
|
||||
foreach (language_types() as $language_type) {
|
||||
$languages_original[$language_type] = $GLOBALS[$language_type];
|
||||
$GLOBALS[$language_type] = $language;
|
||||
}
|
||||
// Clear static cache, so that fallback candidates are recalculated.
|
||||
drupal_static_reset('language_fallback_get_candidates');
|
||||
$language_fallback_candidates = language_fallback_get_candidates();
|
||||
// Restore original data.
|
||||
$language_fallback =& drupal_static('language_fallback_get_candidates');
|
||||
$language_fallback = $language_fallback_original;
|
||||
foreach ($languages_original as $language_type => $_language) {
|
||||
$GLOBALS[$language_type] = $_language;
|
||||
}
|
||||
return $language_fallback_candidates;
|
||||
}
|
||||
|
||||
+1
-1
@@ -91,7 +91,7 @@ function hook_entity_info() {
|
||||
'translation' => array(
|
||||
'entity_translation' => array(
|
||||
'class' => 'EntityTranslationCustomEntityHandler',
|
||||
'path sets' => array(
|
||||
'path schemes' => array(
|
||||
'default' => array(
|
||||
'base path' => 'custom_entity_2/%custom_entity',
|
||||
'path wildcard' => '%custom_entity',
|
||||
|
||||
@@ -11,6 +11,7 @@ files[] = includes/translation.handler.comment.inc
|
||||
files[] = includes/translation.handler.node.inc
|
||||
files[] = includes/translation.handler.taxonomy_term.inc
|
||||
files[] = includes/translation.handler.user.inc
|
||||
files[] = includes/translation.migrate.inc
|
||||
|
||||
files[] = tests/entity_translation.test
|
||||
|
||||
@@ -22,9 +23,9 @@ files[] = views/entity_translation_handler_filter_language.inc
|
||||
files[] = views/entity_translation_handler_filter_translation_exists.inc
|
||||
files[] = views/entity_translation_handler_field_field.inc
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-01-22
|
||||
version = "7.x-1.0-beta4"
|
||||
; Information added by Drupal.org packaging script on 2016-05-07
|
||||
version = "7.x-1.0-beta5"
|
||||
core = "7.x"
|
||||
project = "entity_translation"
|
||||
datestamp = "1421971088"
|
||||
datestamp = "1462661041"
|
||||
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Implements a Migrate destination handler to automatically add translations
|
||||
* to entities with translatable fields.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_migrate_api().
|
||||
*/
|
||||
function entity_translation_migrate_api() {
|
||||
$api = array(
|
||||
'api' => 2,
|
||||
'destination handlers' => array('MigrateTranslationEntityHandler'),
|
||||
);
|
||||
return $api;
|
||||
}
|
||||
+61
-2
@@ -567,7 +567,7 @@ function entity_translation_edit_access() {
|
||||
}
|
||||
|
||||
$translations = $handler->getTranslations();
|
||||
$langcode = $langcode = entity_translation_get_existing_language($entity_type, $entity, $langcode);
|
||||
$langcode = entity_translation_get_existing_language($entity_type, $entity, $langcode);
|
||||
|
||||
// The user must be explicitly allowed to access the original values if
|
||||
// workflow permissions are enabled.
|
||||
@@ -1274,10 +1274,14 @@ function entity_translation_field_attach_form($entity_type, $entity, &$form, &$f
|
||||
function entity_translation_prepare_element($element, &$form_state) {
|
||||
static $drupal_static_fast;
|
||||
if (!isset($drupal_static_fast)) {
|
||||
$drupal_static_fast['source_forms'] = &drupal_static(__FUNCTION__, array());
|
||||
$drupal_static_fast = &drupal_static(__FUNCTION__, array(
|
||||
'source_forms' => array(),
|
||||
'source_form_states' => array(),
|
||||
));
|
||||
}
|
||||
|
||||
$source_forms = &$drupal_static_fast['source_forms'];
|
||||
$source_form_states = &$drupal_static_fast['source_form_states'];
|
||||
$form = $form_state['complete form'];
|
||||
$build_id = $form['#build_id'];
|
||||
$source = $element['#source'];
|
||||
@@ -1294,9 +1298,11 @@ function entity_translation_prepare_element($element, &$form_state) {
|
||||
$source_form_state = $form_state;
|
||||
field_attach_form($entity_type, $element['#entity'], $source_form, $source_form_state, $source);
|
||||
$source_forms[$build_id][$source][$entity_type][$id] = &$source_form;
|
||||
$source_form_states[$build_id][$source][$entity_type][$id] = &$source_form_state;
|
||||
}
|
||||
|
||||
$source_form = &$source_forms[$build_id][$source][$entity_type][$id];
|
||||
$source_form_state = $source_form_states[$build_id][$source][$entity_type][$id];
|
||||
$langcode = $element['#language'];
|
||||
$field_name = $element['#field_name'];
|
||||
|
||||
@@ -1307,12 +1313,42 @@ function entity_translation_prepare_element($element, &$form_state) {
|
||||
if (isset($source_form[$field_name][$source])) {
|
||||
$element[$langcode] = $source_form[$field_name][$source];
|
||||
entity_translation_form_element_language_replace($element, $source, $langcode);
|
||||
entity_translation_form_element_state_replace($element, $source_form[$field_name], $field_name, $source_form_state, $form_state);
|
||||
unset($element[$element['#previous']]);
|
||||
}
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function. Sets the right values in $form_state['field'] when using
|
||||
* source language values as defaults.
|
||||
*/
|
||||
function entity_translation_form_element_state_replace($element, $source_element, $field_name, $source_form_state, &$form_state) {
|
||||
if (isset($source_element['#language'])) {
|
||||
$source = $source_element['#language'];
|
||||
|
||||
// Iterate through the form structure recursively.
|
||||
foreach (element_children($element) as $key) {
|
||||
if (isset($source_element[$key])) {
|
||||
entity_translation_form_element_state_replace($element[$key], $source_element[$key], $key, $source_form_state, $form_state);
|
||||
}
|
||||
elseif (isset($source_element[$source])) {
|
||||
entity_translation_form_element_state_replace($element[$key], $source_element[$source], $key, $source_form_state, $form_state);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($source_element[$source]['#field_parents'])) {
|
||||
$source_parents = $source_element[$source]['#field_parents'];
|
||||
$langcode = $element['#language'];
|
||||
$parents = $element[$langcode]['#field_parents'];
|
||||
$source_state = field_form_get_state($source_parents, $field_name, $source, $source_form_state);
|
||||
drupal_alter('entity_translation_source_field_state', $source_state);
|
||||
field_form_set_state($parents, $field_name, $langcode, $form_state, $source_state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function. Recursively replaces the source language with the given one.
|
||||
*/
|
||||
@@ -1799,6 +1835,9 @@ function entity_translation_settings($entity_type, $bundle) {
|
||||
*/
|
||||
function entity_translation_language($entity_type, $entity) {
|
||||
$handler = entity_translation_get_handler($entity_type, $entity);
|
||||
if (empty($handler)) {
|
||||
return LANGUAGE_NONE;
|
||||
}
|
||||
$langcode = $handler->getFormLanguage();
|
||||
return !empty($langcode) ? $langcode : $handler->getLanguage();
|
||||
}
|
||||
@@ -2019,3 +2058,23 @@ function path_entity_translation_delete($entity_type, $entity, $langcode) {
|
||||
$handler = entity_translation_get_handler($entity_type, $entity);
|
||||
path_delete(array('source' => $handler->getViewPath(), 'language' => $langcode));
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper for entity_save().
|
||||
*
|
||||
* @param $entity_type
|
||||
* The entity type.
|
||||
* @param $entity
|
||||
* The entity object.
|
||||
*/
|
||||
function entity_translation_entity_save($entity_type, $entity) {
|
||||
// Entity module isn't required, but use it if it's available.
|
||||
if (module_exists('entity')) {
|
||||
entity_save($entity_type, $entity);
|
||||
}
|
||||
// Fall back to field_attach_* functions otherwise.
|
||||
else {
|
||||
field_attach_presave($entity_type, $entity);
|
||||
field_attach_update($entity_type, $entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,3 +249,24 @@ function entity_translation_query_comment_filter_alter(QueryAlterableInterface $
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_node_update_index().
|
||||
*
|
||||
* Add translated node content to search index.
|
||||
*/
|
||||
function entity_translation_node_update_index($node) {
|
||||
$text = '';
|
||||
$langcodes = array_keys(language_list());
|
||||
$translations = entity_translation_get_handler('node', $node)->getTranslations();
|
||||
foreach ($langcodes as $langcode) {
|
||||
// Skip the default language (already indexed by search.module).
|
||||
if ($GLOBALS[LANGUAGE_TYPE_CONTENT]->language != $langcode && isset($translations->data[$langcode])) {
|
||||
// Render the node in each language.
|
||||
node_build_content($node, 'search_index', $langcode);
|
||||
$rendered = drupal_render($node->content);
|
||||
$text .= '<h1>' . check_plain($node->title) . '</h1>' . $rendered;
|
||||
}
|
||||
}
|
||||
return $text;
|
||||
}
|
||||
|
||||
+3
-3
@@ -7,9 +7,9 @@ dependencies[] = i18n
|
||||
dependencies[] = i18n_menu
|
||||
files[] = entity_translation_i18n_menu.test
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-01-22
|
||||
version = "7.x-1.0-beta4"
|
||||
; Information added by Drupal.org packaging script on 2016-05-07
|
||||
version = "7.x-1.0-beta5"
|
||||
core = "7.x"
|
||||
project = "entity_translation"
|
||||
datestamp = "1421971088"
|
||||
datestamp = "1462661041"
|
||||
|
||||
|
||||
+2
-2
@@ -196,8 +196,8 @@ function entity_translation_i18n_menu_form_menu_edit_item_validate($form, &$form
|
||||
$item = $form_state['values'];
|
||||
|
||||
// Localizable menu items should not be created when a translation set for the
|
||||
// same path already exists.
|
||||
if ($item['language'] == LANGUAGE_NONE) {
|
||||
// same path already exists (exluding special paths starting by <).
|
||||
if ($item['language'] == LANGUAGE_NONE && strpos($item['link_path'], '<') !== 0) {
|
||||
$count = db_select('menu_links', 'ml')
|
||||
->condition('ml.link_path', $item['link_path'])
|
||||
->condition('ml.i18n_tsid', 0, '<>')
|
||||
|
||||
+3
-3
@@ -4,9 +4,9 @@ package = Multilingual - Entity Translation
|
||||
core = 7.x
|
||||
dependencies[] = entity_translation
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-01-22
|
||||
version = "7.x-1.0-beta4"
|
||||
; Information added by Drupal.org packaging script on 2016-05-07
|
||||
version = "7.x-1.0-beta5"
|
||||
core = "7.x"
|
||||
project = "entity_translation"
|
||||
datestamp = "1421971088"
|
||||
datestamp = "1462661041"
|
||||
|
||||
|
||||
+5
-5
@@ -441,10 +441,7 @@ class EntityTranslationDefaultHandler implements EntityTranslationHandlerInterfa
|
||||
$query->condition('revision_id', $revisions_ids, 'IN');
|
||||
}
|
||||
|
||||
$results = $query
|
||||
->orderBy('entity_id')
|
||||
->orderBy('created')
|
||||
->execute();
|
||||
$results = $query->execute();
|
||||
|
||||
foreach ($results as $row) {
|
||||
$id = $row->entity_id;
|
||||
@@ -1615,9 +1612,12 @@ class EntityTranslationDefaultHandler implements EntityTranslationHandlerInterfa
|
||||
|
||||
/**
|
||||
* Returns the title to be used for the entity form page.
|
||||
*
|
||||
* This may contain HTML markup and thus needs to be sanitized, since it will
|
||||
* be used as page title as-is.
|
||||
*/
|
||||
protected function entityFormTitle() {
|
||||
return $this->getLabel();
|
||||
return check_plain($this->getLabel());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+3
-1
@@ -92,7 +92,9 @@ class EntityTranslationNodeHandler extends EntityTranslationDefaultHandler {
|
||||
|
||||
if (!$this->isTranslationForm()) {
|
||||
// Inherit entity authoring information for the original values.
|
||||
$values['name'] = $form_state['values']['name'];
|
||||
if (isset($form_state['values']['name'])) {
|
||||
$values['name'] = $form_state['values']['name'];
|
||||
}
|
||||
if (!empty($form_state['values']['date'])) {
|
||||
$values['created'] = $form_state['values']['date'];
|
||||
}
|
||||
|
||||
+16
@@ -15,6 +15,22 @@ class EntityTranslationTaxonomyTermHandler extends EntityTranslationDefaultHandl
|
||||
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);
|
||||
if ($mode == I18N_MODE_NONE) {
|
||||
$translations = $this->getTranslations();
|
||||
if (!empty($translations->original)) {
|
||||
return $translations->original;
|
||||
}
|
||||
}
|
||||
}
|
||||
return parent::getLanguage();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see EntityTranslationDefaultHandler::entityForm()
|
||||
*/
|
||||
|
||||
+3
-2
@@ -112,9 +112,10 @@ class EntityTranslationHandlerFactory {
|
||||
*/
|
||||
public function getHandlerId($entity_type, $entity) {
|
||||
if (!isset($entity->entity_translation_handler_id)) {
|
||||
list($id, $revision_id) = entity_extract_ids($entity_type, $entity);
|
||||
list($id, $revision_id, $bundle) = entity_extract_ids($entity_type, $entity);
|
||||
$revision_id = isset($revision_id) ? $revision_id : 0;
|
||||
$entity->entity_translation_handler_id = $entity_type . '-' . (!empty($id) ? 'eid-' . $id . '-' . $revision_id : 'new-' . self::$newId++);
|
||||
$bundle = isset($bundle) ? $bundle : $entity_type;
|
||||
$entity->entity_translation_handler_id = $entity_type . '-' . $bundle . '-' . (!empty($id) ? 'eid-' . $id . '-' . $revision_id : 'new-' . self::$newId++);
|
||||
}
|
||||
return $entity->entity_translation_handler_id;
|
||||
}
|
||||
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* MigrateTranslationEntityHandler class for entity_translation.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Destination handler implementing translatable fields.
|
||||
*/
|
||||
class MigrateTranslationEntityHandler extends MigrateDestinationHandler {
|
||||
/**
|
||||
* Registers all entites as handled by this class.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->registerTypes(array('entity'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles Entity Translations.
|
||||
*
|
||||
* @param stdClass $entity
|
||||
* @param stdClass $sourceRow
|
||||
*/
|
||||
public function prepare($entity, stdClass $row) {
|
||||
$migration = Migration::currentMigration();
|
||||
$entity_type = $migration->getDestination()->getEntityType();
|
||||
|
||||
// Only continue if the entity type + bundle combination is enabled for
|
||||
// entity_translation.
|
||||
if (entity_translation_enabled($entity_type, $entity)) {
|
||||
// Get the entity_translation handler and load any existing translations.
|
||||
$handler = entity_translation_get_handler($entity_type, $entity);
|
||||
$handler->loadTranslations();
|
||||
$original_language = $handler->getLanguage();
|
||||
|
||||
// Get the bundle of the entity.
|
||||
list(, , $bundle) = entity_extract_ids($entity_type, $entity);
|
||||
|
||||
// We need to get all of the possible translations to create. So we look
|
||||
// for any translatable fields.
|
||||
$translatable_fields = array();
|
||||
foreach (field_info_instances($entity_type, $bundle) as $instance) {
|
||||
$field_name = $instance['field_name'];
|
||||
$field = field_info_field($field_name);
|
||||
|
||||
if ($field['translatable']) {
|
||||
$translatable_fields[] = $field_name;
|
||||
}
|
||||
}
|
||||
|
||||
// In those fields we look for translated values to build out an array
|
||||
// of languages we need to set translations for.
|
||||
$translate_languages = array();
|
||||
foreach ($translatable_fields as $translatable_field) {
|
||||
if (!empty($entity->{$translatable_field})) {
|
||||
$field_languages = array_keys($entity->{$translatable_field});
|
||||
foreach ($field_languages as $field_language) {
|
||||
$translate_languages[$field_language] = $field_language;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the LANGUAGE_NONE results.
|
||||
unset($translate_languages[LANGUAGE_NONE]);
|
||||
|
||||
// Remove the original language.
|
||||
unset($translate_languages[$original_language]);
|
||||
|
||||
// Anything we're left with is a translation that should be set.
|
||||
foreach ($translate_languages as $translate_language) {
|
||||
if (!isset($entity->translations->data[$translate_language])) {
|
||||
// Add the new translation and store it.
|
||||
$handler->setTranslation(array(
|
||||
'translate' => 0,
|
||||
'status' => 1,
|
||||
'language' => $translate_language,
|
||||
'source' => $original_language,
|
||||
'uid' => (empty($entity->uid)) ? 0 : $entity->uid,
|
||||
'changed' => (empty($entity->changed)) ? REQUEST_TIME : $entity->changed,
|
||||
'created' => (empty($entity->created)) ? REQUEST_TIME : $entity->created,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -6,9 +6,9 @@ hidden = TRUE
|
||||
dependencies[] = entity_translation
|
||||
files[] = entity_translation_test.module
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-01-22
|
||||
version = "7.x-1.0-beta4"
|
||||
; Information added by Drupal.org packaging script on 2016-05-07
|
||||
version = "7.x-1.0-beta5"
|
||||
core = "7.x"
|
||||
project = "entity_translation"
|
||||
datestamp = "1421971088"
|
||||
datestamp = "1462661041"
|
||||
|
||||
|
||||
+1
-1
@@ -182,7 +182,7 @@ function entity_translation_views_data() {
|
||||
);
|
||||
$data['entity_translation']['translation_exists'] = array(
|
||||
'title' => t('Translation exists'),
|
||||
'help' => t('Link to translation overview page.'),
|
||||
'help' => t('Determines if a translation exists for a particular translation.'),
|
||||
'filter' => array(
|
||||
'handler' => 'entity_translation_handler_filter_translation_exists',
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user