diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSettingsTest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSettingsTest.php index 182eb64..6a15c20 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSettingsTest.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSettingsTest.php @@ -114,7 +114,7 @@ function testSettingsUI() { * TRUE if the assertion succeeded, FALSE otherwise. */ protected function assertSettings($entity_type, $bundle, $enabled, $edit) { - $this->drupalPost('admin/config/regional/content-language', $edit, t('Save')); + $this->drupalPost('admin/config/regional/content-language', $edit, t('Save configuration')); $args = array('@entity_type' => $entity_type, '@bundle' => $bundle, '@enabled' => $enabled ? 'enabled' : 'disabled'); $message = format_string('Translation for entity @entity_type (@bundle) is @enabled.', $args); field_info_cache_clear(); diff --git a/core/modules/language/language.module b/core/modules/language/language.module index 6b45fa1..66ad904 100644 --- a/core/modules/language/language.module +++ b/core/modules/language/language.module @@ -149,9 +149,7 @@ function language_menu() { $items['admin/config/regional/content-language'] = array( 'title' => 'Content language settings', 'description' => 'Configure content language support for any multilingual element.', - 'page callback' => 'language_content_settings_page', - 'access arguments' => array('administer languages'), - 'file' => 'language.admin.inc', + 'route_name' => 'language_content_settings', ); return $items; @@ -195,22 +193,6 @@ function language_theme() { } /** - * Returns a list of supported entity types. - * - * @return array - * An array of entity type names. - */ -function language_entity_supported() { - $supported = array(); - foreach (entity_get_info() as $entity_type => $info) { - if (!empty($info['translatable'])) { - $supported[$entity_type] = $entity_type; - } - } - return $supported; -} - -/** * Implements hook_element_info_alter(). */ function language_element_info_alter(&$type) { @@ -848,3 +830,26 @@ function language_system_regional_settings_form_submit($form, &$form_state) { $language->default = TRUE; language_save($language); } + +/** + * Implements hook_library_info(). + * + * @return array + * Library definitions. + */ +function language_library_info() { + $libraries = array(); + + $libraries['drupal.language.admin'] = array( + 'title' => 'Language configuration css.', + 'version' => VERSION, + 'css' => array( + drupal_get_path('module', 'language') . '/css/language.admin.css' => array( + 'type' => 'file', + 'media' => 'all', + ), + ), + ); + + return $libraries; +} diff --git a/core/modules/language/language.routing.yml b/core/modules/language/language.routing.yml index 4a2fc8c..a5a1b70 100644 --- a/core/modules/language/language.routing.yml +++ b/core/modules/language/language.routing.yml @@ -18,3 +18,10 @@ language_negotiation_selected: _form: 'Drupal\language\Form\NegotiationSelectedForm' requirements: _permission: 'administer languages' + +language_content_settings: + pattern: '/admin/config/regional/content-language' + defaults: + _form: 'Drupal\language\Form\ContentLanguageSettingsForm' + requirements: + _permission: 'administer languages' diff --git a/core/modules/language/lib/Drupal/language/Form/ContentLanguageSettingsForm.php b/core/modules/language/lib/Drupal/language/Form/ContentLanguageSettingsForm.php new file mode 100644 index 0000000..5b7d165 --- /dev/null +++ b/core/modules/language/lib/Drupal/language/Form/ContentLanguageSettingsForm.php @@ -0,0 +1,136 @@ + $info) { + if (!empty($info['translatable'])) { + $supported[$entity_type] = $entity_type; + } + } + return $supported; + } + + /** + * {@inheritdoc} + */ + public function getFormID() { + return 'language_content_settings_form'; + } + + /** + * {@inheritdoc} + */ + public function buildForm(array $form, array &$form_state) { + $entity_info = entity_get_info(); + $labels = array(); + $default = array(); + + foreach ($this->entitySupported() as $entity_type) { + $labels[$entity_type] = isset($entity_info[$entity_type]['label']) ? $entity_info[$entity_type]['label'] : $entity_type; + $default[$entity_type] = FALSE; + + // Check whether we have any custom setting. + foreach (entity_get_bundles($entity_type) as $bundle => $bundle_info) { + $conf = language_get_default_configuration($entity_type, $bundle); + if (!empty($conf['language_show']) || $conf['langcode'] != 'site_default') { + $default[$entity_type] = $entity_type; + } + $language_configuration[$entity_type][$bundle] = $conf; + } + } + + asort($labels); + + $form = array( + '#labels' => $labels, + '#attached' => array( + 'library' => array( + array('language', 'drupal.language.admin') + ), + ), + ); + + $form['entity_types'] = array( + '#title' => t('Custom language settings'), + '#type' => 'checkboxes', + '#options' => $labels, + '#default_value' => $default, + ); + + $form['settings'] = array('#tree' => TRUE); + + foreach ($labels as $entity_type => $label) { + $info = $entity_info[$entity_type]; + + $form['settings'][$entity_type] = array( + '#title' => $label, + '#type' => 'container', + '#entity_type' => $entity_type, + '#theme' => 'language_content_settings_table', + '#bundle_label' => isset($info['bundle_label']) ? $info['bundle_label'] : $label, + '#states' => array( + 'visible' => array( + ':input[name="entity_types[' . $entity_type . ']"]' => array('checked' => TRUE), + ), + ), + ); + + foreach (entity_get_bundles($entity_type) as $bundle => $bundle_info) { + $form['settings'][$entity_type][$bundle]['settings'] = array( + '#type' => 'item', + '#label' => $bundle_info['label'], + 'language' => array( + '#type' => 'language_configuration', + '#entity_information' => array( + 'entity_type' => $entity_type, + 'bundle' => $bundle, + ), + '#default_value' => $language_configuration[$entity_type][$bundle], + ), + ); + } + } + + $form['actions'] = array('#type' => 'actions'); + $form['actions']['submit'] = array( + '#type' => 'submit', + '#value' => t('Save'), + ); + + return parent::buildForm($form, $form_state); + } + + /** + * {@inheritdoc} + */ + public function submitForm(array &$form, array &$form_state) { + $entity_types = $form_state['values']['entity_types']; + $settings = &$form_state['values']['settings']; + foreach ($settings as $entity_type => $entity_settings) { + foreach ($entity_settings as $bundle => $bundle_settings) { + language_save_default_configuration($entity_type, $bundle, $bundle_settings['settings']['language']); + } + } + parent::submitForm($form, $form_state); + } + +} diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php index 0a457a6..a858813 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php @@ -542,8 +542,8 @@ function testGetLibrary() { $libraries = drupal_get_library('common_test'); $this->assertTrue(isset($libraries['jquery.farbtastic']), 'Retrieved all module libraries.'); // Retrieve all libraries for a module not implementing hook_library_info(). - // Note: This test installs language module. - $libraries = drupal_get_library('language'); + // Note: This test installs action module. + $libraries = drupal_get_library('action'); $this->assertEqual($libraries, array(), 'Retrieving libraries from a module not implementing hook_library_info() returns an emtpy array.'); // Retrieve a specific library by module and name.