2011-08-02 00:37:34 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2011-08-07 13:10:57 +00:00
|
|
|
* @file
|
|
|
|
* Interface translation summary, editing and deletion user interfaces.
|
2011-08-02 00:37:34 +00:00
|
|
|
*/
|
|
|
|
|
Issue #1825952 by Fabianx, joelpittet, bdragon, heddn, chx, xjm, pwolanin, mikey_p, ti2m, bfr, dags, cilefen, scor, mgifford: Turn on twig autoescape by default
2014-07-18 09:05:22 +00:00
|
|
|
use Drupal\Component\Utility\SafeMarkup;
|
2014-09-29 13:41:29 +00:00
|
|
|
use Drupal\Core\Url;
|
2014-03-31 17:37:55 +00:00
|
|
|
use Drupal\Core\Render\Element;
|
2012-10-08 18:10:13 +00:00
|
|
|
use Drupal\locale\SourceString;
|
|
|
|
use Drupal\locale\TranslationString;
|
Issue #1668866 by ParisLiakos, aspilicious, tim.plunkett, pdrake, g.oechsler, dawehner, Berdir, corvus_ch, damiankloip, disasm, marcingy, neclimdul: Replace drupal_goto() with RedirectResponse.
2013-06-19 16:07:30 +00:00
|
|
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
2012-06-02 19:41:40 +00:00
|
|
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|
|
|
|
2011-08-02 00:37:34 +00:00
|
|
|
/**
|
2013-09-11 08:14:17 +00:00
|
|
|
* Page callback: Checks for translation updates and displays the status.
|
2012-10-05 15:42:46 +00:00
|
|
|
*
|
2013-09-11 08:14:17 +00:00
|
|
|
* Manually checks the translation status without the use of cron.
|
2012-10-05 15:42:46 +00:00
|
|
|
*
|
|
|
|
* @see locale_menu()
|
2011-08-02 00:37:34 +00:00
|
|
|
*/
|
2013-09-11 08:14:17 +00:00
|
|
|
function locale_translation_manual_status() {
|
|
|
|
module_load_include('compare.inc', 'locale');
|
2011-08-02 00:37:34 +00:00
|
|
|
|
2013-09-11 08:14:17 +00:00
|
|
|
// Check the translation status of all translatable projects in all languages.
|
|
|
|
// First we clear the cached list of projects. Although not strictly
|
|
|
|
// necessary, this is helpful in case the project list is out of sync.
|
|
|
|
locale_translation_flush_projects();
|
|
|
|
locale_translation_check_projects();
|
Issue #1452188 by Schnitzel, droplet, Sutharsan, Bojhan, Kristen Pol, Gábor Hojtsy, ershov.andrey, perusio, nod_, rvilar, andypost: Added New UI for string translation.
2012-06-15 10:01:31 +00:00
|
|
|
|
2013-09-11 08:14:17 +00:00
|
|
|
// Execute a batch if required. A batch is only used when remote files
|
|
|
|
// are checked.
|
|
|
|
if (batch_get()) {
|
|
|
|
return batch_process('admin/reports/translations');
|
Issue #1452188 by Schnitzel, droplet, Sutharsan, Bojhan, Kristen Pol, Gábor Hojtsy, ershov.andrey, perusio, nod_, rvilar, andypost: Added New UI for string translation.
2012-06-15 10:01:31 +00:00
|
|
|
}
|
2014-09-27 07:03:46 +00:00
|
|
|
return new RedirectResponse(\Drupal::url('locale.translate_status', array(), array('absolute' => TRUE)));
|
2011-08-02 00:37:34 +00:00
|
|
|
}
|
|
|
|
|
2012-12-19 22:11:34 +00:00
|
|
|
/**
|
2013-06-16 23:54:01 +00:00
|
|
|
* Prepares variables for translation status information templates.
|
|
|
|
*
|
|
|
|
* Translation status information is displayed per language.
|
|
|
|
*
|
|
|
|
* Default template: locale-translate-edit-form-strings.html.twig.
|
2012-12-19 22:11:34 +00:00
|
|
|
*
|
|
|
|
* @param array $variables
|
|
|
|
* An associative array containing:
|
|
|
|
* - updates: The projects which have updates.
|
|
|
|
* - not_found: The projects which updates are not found.
|
|
|
|
*
|
2014-07-15 11:13:13 +00:00
|
|
|
* @see \Drupal\locale\Form\TranslationStatusForm
|
2012-12-19 22:11:34 +00:00
|
|
|
*/
|
2014-10-22 09:58:00 +00:00
|
|
|
function template_preprocess_locale_translation_update_info(array &$variables) {
|
2012-12-19 22:11:34 +00:00
|
|
|
// Build output for available updates.
|
|
|
|
if (isset($variables['updates'])) {
|
2015-09-19 18:49:40 +00:00
|
|
|
$variables['available_updates'] = [];
|
2012-12-19 22:11:34 +00:00
|
|
|
if ($variables['updates']) {
|
|
|
|
foreach ($variables['updates'] as $update) {
|
2015-09-19 18:49:40 +00:00
|
|
|
$variables['modules'][] = $update['name'];
|
|
|
|
// Format date for Twig template.
|
|
|
|
$release = $update;
|
|
|
|
$release['date'] = \Drupal::service('date.formatter')->format($update['timestamp'], 'html_date');
|
|
|
|
$variables['available_updates'][] = $release;
|
2012-12-19 22:11:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-06-16 23:54:01 +00:00
|
|
|
* Prepares variables for most recent translation update templates.
|
|
|
|
*
|
|
|
|
* Displays the last time we checked for locale update data. In addition to
|
|
|
|
* properly formatting the given timestamp, this function also provides a "Check
|
|
|
|
* manually" link that refreshes the available update and redirects back to the
|
|
|
|
* same page.
|
2012-12-19 22:11:34 +00:00
|
|
|
*
|
2013-06-16 23:54:01 +00:00
|
|
|
* Default template: locale-translation-last-check.html.twig.
|
2012-12-19 22:11:34 +00:00
|
|
|
*
|
2014-10-22 09:58:00 +00:00
|
|
|
* @param array $variables
|
2012-12-19 22:11:34 +00:00
|
|
|
* An associative array containing:
|
|
|
|
* - last: The timestamp when the site last checked for available updates.
|
|
|
|
*
|
2014-07-15 11:13:13 +00:00
|
|
|
* @see \Drupal\locale\Form\TranslationStatusForm
|
2012-12-19 22:11:34 +00:00
|
|
|
*/
|
2014-10-22 09:58:00 +00:00
|
|
|
function template_preprocess_locale_translation_last_check(array &$variables) {
|
2012-12-19 22:11:34 +00:00
|
|
|
$last = $variables['last'];
|
2013-06-16 23:54:01 +00:00
|
|
|
$variables['last_checked'] = ($last != NULL);
|
2015-06-09 14:12:03 +00:00
|
|
|
$variables['time'] = \Drupal::service('date.formatter')->formatTimeDiffSince($last);
|
2015-04-09 14:56:37 +00:00
|
|
|
$variables['link'] = \Drupal::l(t('Check manually'), new Url('locale.check_translation', array(), array('query' => \Drupal::destination()->getAsArray())));
|
2012-12-19 22:11:34 +00:00
|
|
|
}
|