uppdated modules
This commit is contained in:
+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,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user