uppdated modules

This commit is contained in:
Bachir Soussi Chiadmi
2017-01-22 16:19:36 +01:00
parent 03be8f82aa
commit 8416e3eea1
748 changed files with 32317 additions and 20900 deletions
@@ -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.
@@ -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',
@@ -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"
@@ -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;
}
@@ -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;
}
@@ -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"
@@ -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 2016-05-07
version = "7.x-1.0-beta5"
core = "7.x"
project = "entity_translation"
datestamp = "1421971088"
datestamp = "1462661041"
@@ -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());
}
/**
@@ -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;
}
@@ -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,
));
}
}
}
}
}
@@ -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"
@@ -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',
),
@@ -8,9 +8,9 @@ files[] = i18n_object.inc
files[] = i18n.test
configure = admin/config/regional/i18n
; Information added by Drupal.org packaging script on 2015-01-26
version = "7.x-1.12"
; Information added by Drupal.org packaging script on 2016-10-22
version = "7.x-1.14"
core = "7.x"
project = "i18n"
datestamp = "1422286982"
datestamp = "1477154943"
@@ -11,7 +11,7 @@ class Drupali18nTestCase extends DrupalWebTestCase {
function setUpLanguages($admin_permissions = array()) {
// Setup admin user.
$this->admin_user = $this->drupalCreateUser(array_merge(array('bypass node access', 'administer nodes', 'administer languages', 'administer content types', 'administer blocks', 'access administration pages', 'translate interface'), $admin_permissions));
$this->admin_user = $this->drupalCreateUser(array_merge(array('bypass node access', 'administer nodes', 'administer languages', 'administer content types', 'administer fields', 'administer blocks', 'access administration pages', 'translate interface'), $admin_permissions));
$this->drupalLogin($this->admin_user);
@@ -362,6 +362,7 @@ class Drupali18nTestCase extends DrupalWebTestCase {
function resetCaches() {
drupal_static_reset('locale_url_outbound_alter');
drupal_static_reset('language_list');
drupal_language_initialize();
}
/**
@@ -8,9 +8,9 @@ files[] = i18n_block.inc
files[] = i18n_block.test
; Information added by Drupal.org packaging script on 2015-01-26
version = "7.x-1.12"
; Information added by Drupal.org packaging script on 2016-10-22
version = "7.x-1.14"
core = "7.x"
project = "i18n"
datestamp = "1422286982"
datestamp = "1477154943"
@@ -5,9 +5,9 @@ dependencies[] = i18n_string
package = Multilingual - Internationalization
core = 7.x
; Information added by Drupal.org packaging script on 2015-01-26
version = "7.x-1.12"
; Information added by Drupal.org packaging script on 2016-10-22
version = "7.x-1.14"
core = "7.x"
project = "i18n"
datestamp = "1422286982"
datestamp = "1477154943"
@@ -6,9 +6,9 @@ package = Multilingual - Internationalization
core = 7.x
files[] = i18n_field.inc
files[] = i18n_field.test
; Information added by Drupal.org packaging script on 2015-01-26
version = "7.x-1.12"
; Information added by Drupal.org packaging script on 2016-10-22
version = "7.x-1.14"
core = "7.x"
project = "i18n"
datestamp = "1422286982"
datestamp = "1477154943"
@@ -7,9 +7,9 @@ package = Multilingual - Internationalization
core = 7.x
files[] = i18n_forum.test
; Information added by Drupal.org packaging script on 2015-01-26
version = "7.x-1.12"
; Information added by Drupal.org packaging script on 2016-10-22
version = "7.x-1.14"
core = "7.x"
project = "i18n"
datestamp = "1422286982"
datestamp = "1477154943"
@@ -10,9 +10,9 @@ core = 7.x
files[] = i18n_menu.inc
files[] = i18n_menu.test
; Information added by Drupal.org packaging script on 2015-01-26
version = "7.x-1.12"
; Information added by Drupal.org packaging script on 2016-10-22
version = "7.x-1.14"
core = "7.x"
project = "i18n"
datestamp = "1422286982"
datestamp = "1477154943"
@@ -180,6 +180,7 @@ function i18n_menu_menu_link_alter(&$item) {
// We just make sure every link has a valid language property.
if (!i18n_object_langcode($item)) {
$item['language'] = LANGUAGE_NONE;
$item['i18n_tsid'] = 0;
}
}
@@ -515,9 +516,11 @@ function _i18n_menu_link_description($link, $langcode = NULL) {
* Check whether this link is to be processed by i18n_menu and start processing.
*/
function _i18n_menu_link_process(&$link) {
// Only visible links that have a language property and haven't been processed
// before. We also check that they belong to a menu with language options.
if (empty($link['i18n_menu']) && !empty($link['language']) && !empty($link['access']) && empty($link['hidden']) && i18n_menu_mode($link['menu_name'])) {
// Only links that have a language property and haven't been processed before.
// We also translate links marked as hidden because core breadcrumbs ignore
// that flag and excluding them would basically interfere with core behaviour.
// We also check that they belong to a menu with language options.
if (empty($link['i18n_menu']) && !empty($link['language']) && !empty($link['access']) && i18n_menu_mode($link['menu_name'])) {
// Mark so it won't be processed twice.
$link['i18n_menu'] = TRUE;
// Skip if administering this menu or this menu item.
@@ -588,7 +591,7 @@ function _i18n_menu_link_localizable_properties($link) {
// If the title callback is 't' and the link title matches the router title
// it will be localized by core, not by i18n_menu.
if (!$router ||
(empty($router['title_callback']) || $router['title_callback'] != 't') ||
(empty($router['title_callback']) || ($router['title_callback'] != 't' || !empty($link['customized']))) ||
(empty($router['title']) || $router['title'] != $link['link_title'])
) {
$props[] = 'title';
@@ -597,7 +600,7 @@ function _i18n_menu_link_localizable_properties($link) {
if (!empty($link['options']['attributes']['title'])) {
// If the description matches the router description, it will be localized
// by core.
if (!$router || empty($router['description']) || $router['description'] != $link['options']['attributes']['title']) {
if (!$router || empty($router['description']) || ($router['description'] != $link['options']['attributes']['title']) || !empty($link['customized'])) {
$props[] = 'description';
}
}
@@ -9,9 +9,9 @@ configure = admin/config/regional/i18n/node
files[]=i18n_node.test
files[]=i18n_node.variable.inc
; Information added by Drupal.org packaging script on 2015-01-26
version = "7.x-1.12"
; Information added by Drupal.org packaging script on 2016-10-22
version = "7.x-1.14"
core = "7.x"
project = "i18n"
datestamp = "1422286982"
datestamp = "1477154943"
@@ -6,9 +6,9 @@ core = 7.x
files[] = i18n_path.inc
files[] = i18n_path.test
; Information added by Drupal.org packaging script on 2015-01-26
version = "7.x-1.12"
; Information added by Drupal.org packaging script on 2016-10-22
version = "7.x-1.14"
core = "7.x"
project = "i18n"
datestamp = "1422286982"
datestamp = "1477154943"
@@ -4,9 +4,9 @@ dependencies[] = i18n
package = Multilingual - Internationalization
core = 7.x
; Information added by Drupal.org packaging script on 2015-01-26
version = "7.x-1.12"
; Information added by Drupal.org packaging script on 2016-10-22
version = "7.x-1.14"
core = "7.x"
project = "i18n"
datestamp = "1422286982"
datestamp = "1477154943"
@@ -6,9 +6,9 @@ core = 7.x
configure = admin/config/regional/i18n/select
files[] = i18n_select.test
; Information added by Drupal.org packaging script on 2015-01-26
version = "7.x-1.12"
; Information added by Drupal.org packaging script on 2016-10-22
version = "7.x-1.14"
core = "7.x"
project = "i18n"
datestamp = "1422286982"
datestamp = "1477154943"
@@ -82,11 +82,11 @@ function i18n_select_mode($type = NULL) {
}
/**
* Check current path to enable selection
* Check current path to enable selection.
*
* This works pretty much like block visibility
* This works pretty much like block visibility.
*
* @return boolean
* @return bool
* TRUE if content selection should be enabled for this page.
*/
function i18n_select_page() {
@@ -100,8 +100,11 @@ function i18n_select_page() {
// with different case. Ex: /Page, /page, /PAGE.
$pages = drupal_strtolower($pages);
if ($visibility < I18N_SELECT_PAGE_PHP) {
// Convert the Drupal path to lowercase
$path = drupal_strtolower(drupal_get_path_alias($_GET['q']));
// @see views_ajax()
// @see I18NSelectAdminViewsAjax::testViewsAjaxWithoutSkippingTags()
$path = isset($_REQUEST['view_path']) ? $_REQUEST['view_path'] : $_GET['q'];
// Convert the Drupal path to lowercase.
$path = drupal_strtolower(drupal_get_path_alias($path));
// Compare the lowercase internal and lowercase path alias (if any).
$page_match = drupal_match_path($path, $pages);
if ($path != $_GET['q']) {
@@ -109,8 +112,8 @@ function i18n_select_page() {
}
// When $visibility has a value of 0 (I18N_SELECT_PAGE_NOTLISTED),
// the block is displayed on all pages except those listed in $pages.
// When set to 1 (I18N_SELECT_PAGE_LISTED), it is displayed only on those
// pages listed in $pages.
// When set to 1 (I18N_SELECT_PAGE_LISTED), it is displayed only on
// those pages listed in $pages.
$mode = !($visibility xor $page_match);
}
elseif (module_exists('php')) {
@@ -121,7 +124,7 @@ function i18n_select_page() {
}
}
else {
// No pages defined, still respect the setting (unlike blocks)
// No pages defined, still respect the setting (unlike blocks).
$mode = $visibility == I18N_SELECT_PAGE_NOTLISTED;
}
}
@@ -84,3 +84,87 @@ class i18nSelectTestCase extends Drupali18nTestCase {
}
}
}
/**
* Test case for AJAX queries on "views/ajax" when view on admin page.
*/
class I18NSelectAdminViewsAjax extends Drupali18nTestCase {
/**
* {@inheritdoc}
*/
public static function getInfo() {
return array(
'name' => t('I18N select Admin Views (AJAX)'),
'group' => 'Internationalization',
'description' => t('Test AJAX requests to the "views/ajax" when view located on "admin/*" and list of skipping tags is empty.'),
// Skip this test when "admin_views" module does not exists.
'dependencies' => array('admin_views'),
);
}
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp('translation', 'i18n_variable', 'i18n_select', 'admin_views');
parent::setUpLanguages(array('access content overview'));
parent::setUpContentTranslation();
}
/**
* Test AJAX of a view without skipping tags for selection.
*
* @see i18n_select_page()
*/
public function testViewsAjaxWithoutSkippingTags() {
// If this variable will have the "views" value then this test will not
// have sense. For instance, we want apply language selection filter
// for views and remove "views" from "i18n_select_skip_tags" variable.
// In this case all AJAX for views, on administration part of the site,
// will be broken because the "i18n_select_page()" function will work
// with "views/ajax" path instead of, for example, "admin/content".
variable_set('i18n_select_skip_tags', '');
// Create one hundred of nodes.
for ($i = 1; $i <= 100; $i++) {
// Create every second node on Spanish language and
// every first - on English.
$node = $this->createNode('page', "Node $i", '', $i % 2 ? $this->default_language : $this->secondary_language);
// Update "changed" in order to sort the content by updating date. In
// other case all nodes will be with the same date and not arranged in
// order.
db_update('node')
->fields(array('changed' => strtotime("+ $i minute")))
->condition('nid', $node->nid)
->execute();
}
$this->drupalGet('admin/content');
// Check that latest node exists at the top.
$this->assertText('Node 100');
// Check that our page contains fifty nodes (the latest must be 51).
$this->assertNoText('Node 50');
// Test $_REQUEST['view_path']. There's no form to submit to, so
// drupalPost() won't work here. This just tests a direct $_POST
// request instead.
$this->curlExec(array(
CURLOPT_URL => $this->getAbsoluteUrl('views/ajax'),
CURLOPT_POST => TRUE,
CURLOPT_POSTFIELDS => http_build_query(array(
'page' => 1,
'view_path' => 'admin/content',
'view_name' => 'admin_views_node',
'view_display_id' => 'system_1',
)),
));
// Check that we are successfully switched to a new page of content.
$this->assertText('Node 50');
$this->assertNoText('Node 100');
}
}
@@ -10,9 +10,9 @@ files[] = i18n_string.inc
files[] = i18n_string.test
configure = admin/config/regional/i18n/strings
; Information added by Drupal.org packaging script on 2015-01-26
version = "7.x-1.12"
; Information added by Drupal.org packaging script on 2016-10-22
version = "7.x-1.14"
core = "7.x"
project = "i18n"
datestamp = "1422286982"
datestamp = "1477154943"
@@ -29,7 +29,9 @@ function i18n_string_install() {
i18n_string_update_7001();
}
// Create new index in {locales_source}, performance improvement in sites with i18n.
db_add_index('locales_source', 'textgroup_context', array('textgroup', 'context'));
if (!db_index_exists('locales_source', 'textgroup_context')) {
db_add_index('locales_source', 'textgroup_context', array('textgroup', array('context', 50)));
}
}
/**
@@ -106,7 +108,7 @@ function i18n_string_schema() {
),
'primary key' => array('lid'),
'indexes' => array(
'group_context' => array('textgroup', 'context'),
'group_context' => array('textgroup', array('context', 50)),
),
);
return $schema;
@@ -238,7 +240,9 @@ function i18n_string_update_7001() {
* Create new index in {locales_source}, performance improvement in sites with i18n.
*/
function i18n_string_update_7002() {
db_add_index('locales_source', 'textgroup_context', array('textgroup', 'context'));
if (!db_index_exists('locales_source', 'textgroup_context')) {
db_add_index('locales_source', 'textgroup_context', array('textgroup', array('context', 50)));
}
}
@@ -269,4 +273,4 @@ function i18n_string_update_7002() {
* Node type
* nodetype:type:[type]:[property] -> node:type:[type]:[property]
* Property names: title -> title_label
*/
*/
@@ -53,6 +53,28 @@ class i18nStringTestCase extends Drupali18nTestCase {
$this->assertEqual($translation, $translations[$key][$language->language], "The right $language->name ($language->language) translation has been retrieved for $name, $translation");
}
}
// Test that regular strings can be translated. Use 'Built-in interface' as
// filter, and translate first one.
$search = array(
'language' => 'all',
'translation' => 'all',
'group' => 'default',
'string' => '',
);
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
$this->clickLink(t('edit'));
// Just add a random translation.
$translation = $this->randomString();
$edit = array();
foreach ($this->getOtherLanguages() as $language) {
$langcode = $language->language;
$edit["translations[$langcode]"] = $translation;
}
$this->drupalPost(NULL, $edit, t('Save translations'));
$this->assertText(t('The string has been saved.'), t('The string has been saved.'));
$this->assertEqual($this->getUrl(), url('admin/config/regional/translate/translate', array('absolute' => TRUE)), t('Correct page redirection.'));
}
/**
@@ -10,9 +10,9 @@ files[] = i18n_sync.install
files[] = i18n_sync.module.inc
files[] = i18n_sync.node.inc
files[] = i18n_sync.test
; Information added by Drupal.org packaging script on 2015-01-26
version = "7.x-1.12"
; Information added by Drupal.org packaging script on 2016-10-22
version = "7.x-1.14"
core = "7.x"
project = "i18n"
datestamp = "1422286982"
datestamp = "1477154943"
@@ -11,9 +11,9 @@ files[] = i18n_taxonomy.pages.inc
files[] = i18n_taxonomy.admin.inc
files[] = i18n_taxonomy.test
; Information added by Drupal.org packaging script on 2015-01-26
version = "7.x-1.12"
; Information added by Drupal.org packaging script on 2016-10-22
version = "7.x-1.14"
core = "7.x"
project = "i18n"
datestamp = "1422286982"
datestamp = "1477154943"
@@ -213,7 +213,12 @@ function i18n_taxonomy_field_formatter_view($entity_type, $entity, $field, $inst
);
}
else {
$term = $item['taxonomy_term'];
if (isset($item['taxonomy_term'])) {
$term = $item['taxonomy_term'];
}
else {
$term = taxonomy_term_load($item['tid']);
}
$uri = entity_uri('taxonomy_term', $term);
$element[$delta] = array(
'#type' => 'link',
@@ -1020,6 +1025,10 @@ function i18n_taxonomy_localize_terms($terms) {
if (!i18n_string_translate_langcode()) {
return $terms;
}
// $terms is not a valid array or term.
if (empty($terms)) {
return $terms;
}
$object_info = i18n_object_info('taxonomy_term');
$list = is_array($terms) ? $terms : array($terms);
foreach ($list as $index => $term) {
@@ -6,9 +6,9 @@ core = 7.x
files[] = i18n_translation.inc
; Information added by Drupal.org packaging script on 2015-01-26
version = "7.x-1.12"
; Information added by Drupal.org packaging script on 2016-10-22
version = "7.x-1.14"
core = "7.x"
project = "i18n"
datestamp = "1422286982"
datestamp = "1477154943"
@@ -4,9 +4,9 @@ core = 7.x
package = Multilingual - Internationalization
dependencies[] = i18n_variable
; Information added by Drupal.org packaging script on 2015-01-26
version = "7.x-1.12"
; Information added by Drupal.org packaging script on 2016-10-22
version = "7.x-1.14"
core = "7.x"
project = "i18n"
datestamp = "1422286982"
datestamp = "1477154943"
@@ -54,7 +54,7 @@ function i18n_user_user_mail_tokens(&$replacements, $data, $options) {
*/
function i18n_user_user_pass_reset_url($account) {
$timestamp = REQUEST_TIME;
return url("user/reset/$account->uid/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login), array('absolute' => TRUE, 'language' => i18n_language($account->language)));
return url("user/reset/$account->uid/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login, $account->uid), array('absolute' => TRUE, 'language' => i18n_language($account->language)));
}
/**
@@ -65,5 +65,5 @@ function i18n_user_user_pass_reset_url($account) {
*/
function i18n_user_user_cancel_url($account) {
$timestamp = REQUEST_TIME;
return url("user/$account->uid/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login), array('absolute' => TRUE, 'language' => i18n_language($account->language)));
return url("user/$account->uid/cancel/confirm/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login, $account->uid), array('absolute' => TRUE, 'language' => i18n_language($account->language)));
}
@@ -10,9 +10,9 @@ configure = admin/config/regional/i18n/variable
files[] = i18n_variable.class.inc
files[] = i18n_variable.test
; Information added by Drupal.org packaging script on 2015-01-26
version = "7.x-1.12"
; Information added by Drupal.org packaging script on 2016-10-22
version = "7.x-1.14"
core = "7.x"
project = "i18n"
datestamp = "1422286982"
datestamp = "1477154943"
@@ -7,9 +7,9 @@ package = Testing
core = 6.x
hidden = TRUE
; Information added by Drupal.org packaging script on 2015-01-26
version = "7.x-1.12"
; Information added by Drupal.org packaging script on 2016-10-22
version = "7.x-1.14"
core = "7.x"
project = "i18n"
datestamp = "1422286982"
datestamp = "1477154943"