1) { $options = array(); $default = array(); foreach ($field['settings']['column_groups'] as $group => $info) { $options[$group] = $info['label']; $default[$group] = !empty($info['translatable']) ? $group : FALSE; } $settings = array('dependent_selectors' => array('instance[settings][translation_sync]' => array('file'))); $element = array( '#type' => 'checkboxes', '#title' => t('Translatable elements'), '#options' => $options, '#default_value' => !empty($instance['settings']['translation_sync']) ? $instance['settings']['translation_sync'] : $default, '#attached' => array( 'library' => array( array('content_translation', 'drupal.content_translation.admin'), ), 'js' => array( array('data' => array('contentTranslationDependentOptions' => $settings), 'type' => 'setting'), ), ), ); } return $element; } /** * (proxied) Implements hook_form_FORM_ID_alter(). */ function _content_translation_form_language_content_settings_form_alter(array &$form, array &$form_state) { // Inject into the content language settings the translation settings if the // user has the required permission. if (!user_access('administer content translation')) { return; } $default = $form['entity_types']['#default_value']; foreach ($default as $entity_type => $enabled) { $default[$entity_type] = $enabled || content_translation_enabled($entity_type) ? $entity_type : FALSE; } $form['entity_types']['#default_value'] = $default; $form['#attached']['library'][] = array('content_translation', 'drupal.content_translation.admin'); $form['#attached']['js'][] = array('data' => drupal_get_path('module', 'content_translation') . '/content_translation.admin.js', 'type' => 'file'); $dependent_options_settings = array(); foreach ($form['#labels'] as $entity_type => $label) { $entity_info = entity_get_info($entity_type); foreach (entity_get_bundles($entity_type) as $bundle => $bundle_info) { // Here we do not want the widget to be altered and hold also the "Enable // translation" checkbox, which would be redundant. Hence we add this key // to be able to skip alterations. $form['settings'][$entity_type][$bundle]['settings']['language']['#content_translation_skip_alter'] = TRUE; // Only show the checkbox to enable translation if the bundles in the // entity might have fields and if there are fields to translate. if (!empty($entity_info['fieldable'])) { $fields = field_info_instances($entity_type, $bundle); if ($fields) { $form['settings'][$entity_type][$bundle]['translatable'] = array( '#type' => 'checkbox', '#default_value' => content_translation_enabled($entity_type, $bundle), ); // @todo Exploit field definitions once all core entities and field // types are migrated to the Entity Field API. foreach ($fields as $field_name => $instance) { $field = field_info_field($field_name); $form['settings'][$entity_type][$bundle]['fields'][$field_name] = array( '#label' => $instance['label'], '#type' => 'checkbox', '#default_value' => $field['translatable'], ); $column_element = content_translation_field_sync_widget($field, $instance); if ($column_element) { $form['settings'][$entity_type][$bundle]['columns'][$field_name] = $column_element; if (isset($column_element['#options']['file'])) { $dependent_options_settings["settings[{$entity_type}][{$bundle}][columns][{$field_name}]"] = array('file'); } } } } } } } $settings = array('dependent_selectors' => $dependent_options_settings); $form['#attached']['js'][] = array('data' => array('contentTranslationDependentOptions' => $settings), 'type' => 'setting'); $form['#validate'][] = 'content_translation_form_language_content_settings_validate'; $form['#submit'][] = 'content_translation_form_language_content_settings_submit'; } /** * (proxied) Implements hook_preprocess_HOOK(); */ function _content_translation_preprocess_language_content_settings_table(&$variables) { // Alter the 'build' variable injecting the translation settings if the user // has the required permission. if (!user_access('administer content translation')) { return; } $element = $variables['element']; $build = &$variables['build']; array_unshift($build['#header'], array('data' => t('Translatable'), 'class' => array('translatable'))); $rows = array(); foreach (element_children($element) as $bundle) { $field_names = !empty($element[$bundle]['fields']) ? element_children($element[$bundle]['fields']) : array(); if (!empty($element[$bundle]['translatable'])) { $checkbox_id = $element[$bundle]['translatable']['#id']; } $rows[$bundle] = $build['#rows'][$bundle]; if (!empty($element[$bundle]['translatable'])) { $translatable = array( 'data' => $element[$bundle]['translatable'], 'class' => array('translatable'), ); array_unshift($rows[$bundle]['data'], $translatable); $rows[$bundle]['data'][1]['data']['#prefix'] = '