Updated to Drupal 8.6.4, which is PHP 7.3 friendly. Also updated HTMLaw library....
[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  * @deprecated in Drupal 8.5.0 and will be removed before 9.0.0. It is unused by
17  *   Drupal core. Duplicate this function in your own extension if you need its
18  *   behavior.
19  *
20  * @see https://www.drupal.org/node/2931188
21  */
22 function locale_translation_manual_status() {
23   @trigger_error('locale_translation_manual_status() is deprecated in Drupal 8.5.0 and will be removed before Drupal 9.0.0. It is unused by Drupal core. Duplicate this function in your own extension if you need its behavior.', E_USER_DEPRECATED);
24   module_load_include('compare.inc', 'locale');
25
26   // Check the translation status of all translatable projects in all languages.
27   // First we clear the cached list of projects. Although not strictly
28   // necessary, this is helpful in case the project list is out of sync.
29   locale_translation_flush_projects();
30   locale_translation_check_projects();
31
32   // Execute a batch if required. A batch is only used when remote files
33   // are checked.
34   if (batch_get()) {
35     return batch_process('admin/reports/translations');
36   }
37   return new RedirectResponse(\Drupal::url('locale.translate_status', [], ['absolute' => TRUE]));
38 }
39
40 /**
41  * Prepares variables for translation status information templates.
42  *
43  * Translation status information is displayed per language.
44  *
45  * Default template: locale-translate-edit-form-strings.html.twig.
46  *
47  * @param array $variables
48  *   An associative array containing:
49  *   - updates: The projects which have updates.
50  *   - not_found: The projects which updates are not found.
51  *
52  * @see \Drupal\locale\Form\TranslationStatusForm
53  */
54 function template_preprocess_locale_translation_update_info(array &$variables) {
55   foreach ($variables['updates'] as $update) {
56     $variables['modules'][] = $update['name'];
57   }
58 }
59
60 /**
61  * Prepares variables for most recent translation update templates.
62  *
63  * Displays the last time we checked for locale update data. In addition to
64  * properly formatting the given timestamp, this function also provides a "Check
65  * manually" link that refreshes the available update and redirects back to the
66  * same page.
67  *
68  * Default template: locale-translation-last-check.html.twig.
69  *
70  * @param array $variables
71  *   An associative array containing:
72  *   - last: The timestamp when the site last checked for available updates.
73  *
74  * @see \Drupal\locale\Form\TranslationStatusForm
75  */
76 function template_preprocess_locale_translation_last_check(array &$variables) {
77   $last = $variables['last'];
78   $variables['last_checked'] = ($last != NULL);
79   $variables['time'] = \Drupal::service('date.formatter')->formatTimeDiffSince($last);
80   $variables['link'] = \Drupal::l(t('Check manually'), new Url('locale.check_translation', [], ['query' => \Drupal::destination()->getAsArray()]));
81 }