diff --git a/core/modules/locale/locale.pages.inc b/core/modules/locale/locale.pages.inc index cc1a71b..a6237e5 100644 --- a/core/modules/locale/locale.pages.inc +++ b/core/modules/locale/locale.pages.inc @@ -600,8 +600,14 @@ function locale_translation_status_form($form, &$form_state) { $projects_to_update = array(); foreach ($status as $project_id => $project) { foreach ($project as $langcode => $project_info) { - if (!isset($project_info->type) || $project_info->type != 'current') { - $projects_to_update['all'][$project_info->project] = $projects_to_update[$langcode][] = array( + if (!isset($project_info->type)) { + $projects_to_update[$langcode]['not_found'][] = array( + 'name' => $project_info->name, + 'version' => $project_info->version, + ); + } + elseif ($project_info->type != 'current') { + $projects_to_update[$langcode]['updates'][] = array( 'name' => $project_info->name, 'version' => $project_info->version, ); @@ -633,12 +639,13 @@ function locale_translation_status_form($form, &$form_state) { $options[$langcode] = array( 'title' => $language->name, 'operations' => array( - 'class' => 'update-details', + 'class' => 'operations', 'data' => theme('locale_project_language_update_info', array( 'projects' => array( - 'updates' => $projects_to_update[$langcode], + 'updates' => isset($projects_to_update[$langcode]['updates']) ? $projects_to_update[$langcode]['updates'] : NULL, + 'not_found' => isset($projects_to_update[$langcode]['not_found']) ? $projects_to_update[$langcode]['not_found'] : NULL, ), - 'type' => 'inline_list', + 'langcode' => $langcode, )), ), ); @@ -650,13 +657,6 @@ function locale_translation_status_form($form, &$form_state) { '#options' => $options, '#default_value' => drupal_map_assoc(array_keys($options)), ); - $form['update_info'] = array( - '#markup' => theme('locale_project_language_update_info', array( - 'projects' => array( - 'updates' => $projects_to_update['all'], - ), - )), - ); $form['actions'] = array( '#type' => 'actions', ); @@ -664,6 +664,11 @@ function locale_translation_status_form($form, &$form_state) { '#type' => 'submit', '#value' => t('Update'), ); + $form['#attached']['js'] = array( + drupal_get_path('module', 'locale') . '/locale.toggle-interface-update-details.js' => array( + 'type' => 'file', + ), + ); return $form; } @@ -737,7 +742,7 @@ function theme_locale_translate_edit_form_strings($variables) { } /** - * Returns HTML for language update status. + * Returns HTML for interface translation update status. * * Output contains the list of projects which language updates will be applied * to. A separated list is rendered which contains projects which language @@ -757,40 +762,56 @@ function theme_locale_translate_edit_form_strings($variables) { * the following keys: * - project: Human readable name of the project. * - version: Version of the project. - * - type: Defines how the lists should be rendered ("list" or "inline_list"). * * @ingroup themeable */ function theme_locale_project_language_update_info($variables) { - $output = ''; - $projects = array(); - // Process the project lists, prepare project names for displaying together - // with version. - foreach ($variables['projects'] as $status_type => $project_list) { - foreach ($project_list as $project) { - $projects[$status_type][] = format_string('!name (!version)', array( + $output = array(); + $project_list = array(); + if (isset($variables['projects']['updates'])) { + foreach ($variables['projects']['updates'] as $project) { + $project_list['flat'][] = $project['name']; + $project_list['details'][] = format_string('!name (!version)', array( '!name' => $project['name'], '!version' => $project['version'], )); } + $output['updates_summary'] = array( + '#type' => 'markup', + '#markup' => '
' . t('This applies language updates to %projects.', array( + '%projects' => implode(', ', $project_list['flat']), + )) . "
", + ); + $output['updates_details'] = array( + '#theme' => 'item_list', + '#items' => $project_list['details'], + '#attributes' => array( + 'class' => array('details'), + ), + ); } - if (!empty($variables['projects']['updates'])) { - $output = '' . t('This applies language updates to:') . '
'; - if (!empty($variables['type']) && $variables['type'] == 'inline_list') { - $output .= implode(', ', $projects['updates']); - } - else { - $output .= theme('item_list', array('items' => $projects['updates'])); - } - } - if (!empty($variables['projects']['not_found'])) { - $output .= '' . t('Updates were not found for:') . '
'; - if (!empty($variables['type']) && $variables['type'] == 'inline_list') { - $output .= implode(', ', $projects['not_found']); - } - else { - $output .= theme('item_list', array('items' => $projects['not_found'])); + $project_list = array('count' => 0); + if (isset($variables['projects']['not_found'])) { + foreach ($variables['projects']['not_found'] as $project) { + $project_list['count']++; + $project_list['details'][] = format_string('!name (!version)', array( + '!name' => $project['name'], + '!version' => $project['version'], + )); } + $output['not_found_summary'] = array( + '#type' => 'markup', + '#markup' => '' . t('No updates were found for %count projects.', array( + '%count' => $project_list['count'], + )) . '
', + ); + $output['not_found_details'] = array( + '#theme' => 'item_list', + '#items' => $project_list['details'], + '#attributes' => array( + 'class' => array('details'), + ), + ); } return $output; } diff --git a/core/modules/locale/locale.toggle-interface-update-details.js b/core/modules/locale/locale.toggle-interface-update-details.js index e69de29..cf37891 100644 --- a/core/modules/locale/locale.toggle-interface-update-details.js +++ b/core/modules/locale/locale.toggle-interface-update-details.js @@ -0,0 +1,21 @@ +(function ($) { + +"use strict"; + +/** + * Attaching the toggle behavior to interface translation update details. + */ +Drupal.behaviors.toggleInterfaceUpdateDetails = { + attach: function (context, settings) { + $('' + Drupal.t('Details') + '').insertAfter('td.operations > .summary') + .toggle(function() { + $(this).text(Drupal.t('Hide details')); + $(this).next().show(); + }, function() { + $(this).text(Drupal.t('Details')); + $(this).next().hide(); + }).next().hide() + } +}; + +})(jQuery);