function l10n_update_status_form in Localization update 7.2
Page callback: Translation status page.
1 string reference to 'l10n_update_status_form'
- l10n_update_menu in ./
l10n_update.module - Implements hook_menu().
File
- ./
l10n_update.admin.inc, line 33 - Admin settings and update page.
Code
function l10n_update_status_form() {
module_load_include('compare.inc', 'l10n_update');
$updates = $options = array();
$languages_update = $languages_not_found = array();
$projects_update = array();
// @todo Calling l10n_update_build_projects() is an expensive way to
// get a module name. In follow-up issue https://www.drupal.org/node/1842362
// the project name will be stored to display use, like here.
$project_data = l10n_update_build_projects();
$languages = l10n_update_translatable_language_list();
$status = l10n_update_get_status();
// Prepare information about projects which have available translation
// updates.
if ($languages && $status) {
foreach ($status as $project) {
foreach ($project as $langcode => $project_info) {
if (isset($project_data[$project_info->name])) {
// No translation file found for this project-language combination.
if (empty($project_info->type)) {
$updates[$langcode]['not_found'][] = array(
'name' => $project_info->name == 'drupal' ? t('Drupal core') : $project_data[$project_info->name]->info['name'],
'version' => $project_info->version,
'info' => _l10n_update_status_debug_info($project_info),
);
$languages_not_found[$langcode] = $langcode;
}
elseif ($project_info->type == L10N_UPDATE_LOCAL || $project_info->type == L10N_UPDATE_REMOTE) {
$local = isset($project_info->files[L10N_UPDATE_LOCAL]) ? $project_info->files[L10N_UPDATE_LOCAL] : NULL;
$remote = isset($project_info->files[L10N_UPDATE_REMOTE]) ? $project_info->files[L10N_UPDATE_REMOTE] : NULL;
$recent = _l10n_update_source_compare($local, $remote) == L10N_UPDATE_SOURCE_COMPARE_LT ? $remote : $local;
$name = isset($project_data[$project_info->name]->info['name']) ? $project_data[$project_info->name]->info['name'] : '';
$updates[$langcode]['updates'][] = array(
'name' => $project_info->name == 'drupal' ? t('Drupal core') : $name,
'version' => $project_info->version,
'timestamp' => $recent->timestamp,
);
$languages_update[$langcode] = $langcode;
$projects_update[$project_info->name] = $project_info->name;
}
}
}
}
$languages_not_found = array_diff($languages_not_found, $languages_update);
// Build data options for the select table.
foreach ($updates as $langcode => $update) {
$title = check_plain($languages[$langcode]);
$l10n_update_update_info = array(
'#theme' => 'l10n_update_update_info',
);
foreach (array(
'updates',
'not_found',
) as $update_status) {
if (isset($update[$update_status])) {
$l10n_update_update_info['#' . $update_status] = $update[$update_status];
}
}
$options[$langcode] = array(
'title' => array(
'class' => array(
'label',
),
'data' => array(
'#title' => $title,
'#markup' => $title,
),
),
'status' => array(
'class' => array(
'description',
'expand',
'priority-low',
),
'data' => drupal_render($l10n_update_update_info),
),
);
}
// Sort the table data on language name.
uasort($options, function ($a, $b) {
return strcasecmp($a['title']['data']['#title'], $b['title']['data']['#title']);
});
}
$last_checked = variable_get('l10n_update_last_check');
$form['last_checked'] = array(
'#theme' => 'l10n_update_last_check',
'#last' => $last_checked,
);
$header = array(
'title' => array(
'data' => t('Language'),
'class' => array(
'title',
),
),
'status' => array(
'data' => t('Status'),
'class' => array(
'status',
'priority-low',
),
),
);
if (!$languages) {
$empty = t('No translatable languages available. <a href="@add_language">Add a language</a> first.', array(
'@add_language' => url('admin/config/regional/language'),
));
}
elseif (empty($options)) {
$empty = t('All translations up to date.');
}
else {
$empty = t('No translation status available. <a href="@check">Check manually</a>.', array(
'@check' => url('admin/config/regional/translate/check'),
));
}
// The projects which require an update. Used by the _submit callback.
$form['projects_update'] = array(
'#type' => 'value',
'#value' => $projects_update,
);
$form['langcodes'] = array(
'#type' => 'tableselect',
'#header' => $header,
'#options' => $options,
'#default_value' => $languages_update,
'#empty' => $empty,
'#js_select' => TRUE,
'#multiple' => TRUE,
'#required' => TRUE,
'#not_found' => $languages_not_found,
'#after_build' => array(
'l10n_update_language_table',
),
'#attributes' => array(),
);
$form['#attached'] = array(
'js' => array(
drupal_get_path('module', 'l10n_update') . '/js/l10n_update.admin.js',
),
'css' => array(
drupal_get_path('module', 'l10n_update') . '/css/l10n_update.admin.css',
),
);
if ($languages_update) {
$form['actions'] = array(
'#type' => 'actions',
'submit' => array(
'#type' => 'submit',
'#value' => t('Update translations'),
),
'#attributes' => array(),
);
}
return $form;
}