Backup of db before drupal security update
[yaffs-website] / web / core / modules / locale / locale.pages.inc
1 <?php
2
3 /**
4  * @file
5  * Interface translation summary, editing and deletion user interfaces.
6  */
7
8 use Drupal\Core\Url;
9 use Symfony\Component\HttpFoundation\RedirectResponse;
10
11 /**
12  * Page callback: Checks for translation updates and displays the status.
13  *
14  * Manually checks the translation status without the use of cron.
15  *
16  * @see locale_menu()
17  */
18 function locale_translation_manual_status() {
19   module_load_include('compare.inc', 'locale');
20
21   // Check the translation status of all translatable projects in all languages.
22   // First we clear the cached list of projects. Although not strictly
23   // necessary, this is helpful in case the project list is out of sync.
24   locale_translation_flush_projects();
25   locale_translation_check_projects();
26
27   // Execute a batch if required. A batch is only used when remote files
28   // are checked.
29   if (batch_get()) {
30     return batch_process('admin/reports/translations');
31   }
32   return new RedirectResponse(\Drupal::url('locale.translate_status', [], ['absolute' => TRUE]));
33 }
34
35 /**
36  * Prepares variables for translation status information templates.
37  *
38  * Translation status information is displayed per language.
39  *
40  * Default template: locale-translate-edit-form-strings.html.twig.
41  *
42  * @param array $variables
43  *   An associative array containing:
44  *   - updates: The projects which have updates.
45  *   - not_found: The projects which updates are not found.
46  *
47  * @see \Drupal\locale\Form\TranslationStatusForm
48  */
49 function template_preprocess_locale_translation_update_info(array &$variables) {
50   foreach ($variables['updates'] as $update) {
51     $variables['modules'][] = $update['name'];
52   }
53 }
54
55 /**
56  * Prepares variables for most recent translation update templates.
57  *
58  * Displays the last time we checked for locale update data. In addition to
59  * properly formatting the given timestamp, this function also provides a "Check
60  * manually" link that refreshes the available update and redirects back to the
61  * same page.
62  *
63  * Default template: locale-translation-last-check.html.twig.
64  *
65  * @param array $variables
66  *   An associative array containing:
67  *   - last: The timestamp when the site last checked for available updates.
68  *
69  * @see \Drupal\locale\Form\TranslationStatusForm
70  */
71 function template_preprocess_locale_translation_last_check(array &$variables) {
72   $last = $variables['last'];
73   $variables['last_checked'] = ($last != NULL);
74   $variables['time'] = \Drupal::service('date.formatter')->formatTimeDiffSince($last);
75   $variables['link'] = \Drupal::l(t('Check manually'), new Url('locale.check_translation', [], ['query' => \Drupal::destination()->getAsArray()]));
76 }