updated entity_translation to last dev version
This commit is contained in:
		@@ -1,7 +1,23 @@
 | 
			
		||||
 | 
			
		||||
Entity Translation 7.x-1.x, xxxx-xx-xx
 | 
			
		||||
--------------------------------------
 | 
			
		||||
 | 
			
		||||
#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
 | 
			
		||||
--------------------------------------------
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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',
 | 
			
		||||
 
 | 
			
		||||
@@ -22,9 +22,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 2015-08-16
 | 
			
		||||
version = "7.x-1.0-beta4+10-dev"
 | 
			
		||||
core = "7.x"
 | 
			
		||||
project = "entity_translation"
 | 
			
		||||
datestamp = "1421971088"
 | 
			
		||||
datestamp = "1439732040"
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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.
 | 
			
		||||
@@ -2019,3 +2019,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);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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 2015-08-16
 | 
			
		||||
version = "7.x-1.0-beta4+10-dev"
 | 
			
		||||
core = "7.x"
 | 
			
		||||
project = "entity_translation"
 | 
			
		||||
datestamp = "1421971088"
 | 
			
		||||
datestamp = "1439732040"
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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, '<>')
 | 
			
		||||
 
 | 
			
		||||
@@ -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 2015-08-16
 | 
			
		||||
version = "7.x-1.0-beta4+10-dev"
 | 
			
		||||
core = "7.x"
 | 
			
		||||
project = "entity_translation"
 | 
			
		||||
datestamp = "1421971088"
 | 
			
		||||
datestamp = "1439732040"
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
 
 | 
			
		||||
@@ -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'];
 | 
			
		||||
      }
 | 
			
		||||
 
 | 
			
		||||
@@ -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()
 | 
			
		||||
   */
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
@@ -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 2015-08-16
 | 
			
		||||
version = "7.x-1.0-beta4+10-dev"
 | 
			
		||||
core = "7.x"
 | 
			
		||||
project = "entity_translation"
 | 
			
		||||
datestamp = "1421971088"
 | 
			
		||||
datestamp = "1439732040"
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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