function l10n_client_settings_form_validate in Localization client 6
Same name and namespace in other branches
- 6.2 l10n_client.admin.inc \l10n_client_settings_form_validate()
- 7 l10n_client.admin.inc \l10n_client_settings_form_validate()
Validation to make sure the provided server can handle our submissions.
Make sure it supports the exact version of the API we will try to use.
File
- ./
l10n_client.module, line 552 - Localization client. Provides on-page translation editing.
Code
function l10n_client_settings_form_validate($form, &$form_state) {
if ($form_state['values']['l10n_client_use_server']) {
if (!empty($form_state['values']['l10n_client_server'])) {
// Try to invoke the remote string submission with a test request.
$response = xmlrpc($form_state['values']['l10n_client_server'] . '/xmlrpc.php', 'l10n.server.test', '2.0');
if ($response && !empty($response['name']) && !empty($response['version'])) {
if (empty($response['supported']) || !$response['supported']) {
form_set_error('l10n_client_server', t('The given server could not handle the v2.0 remote submission API.'));
}
else {
drupal_set_message(t('Verified that the specified server can handle remote string submissions. Supported languages: %languages.', array(
'%languages' => $response['languages'],
)));
}
}
else {
form_set_error('l10n_client_server', t('Invalid localization server address specified. Make sure you specified the right server address.'));
}
}
else {
form_set_error('l10n_client_server', t('You should provide a server address, such as http://localize.drupal.org'));
}
}
}